LPT anomalies "help"

Discussion in 'The Projects Forum' started by Bluebirdiran, Feb 16, 2010.

  1. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    I am getting these unexpected results from the LPT port. I hope you will bear with me while I give a full explanation.

    I use the circuit shown below to verify that I get the correct TTL signals from my LPT port pins. When I use a little software called LPTinterface.exe I get logical results, ie when I make say pin 2 high I get the LED in the circuit go off and when I make pin 2 low I get the LED lit up. The same happens on other pins up to 7 that I have tried. I have measured the current and the LPT can apparently supply as much as 35mA to the optocoupler at about 3.5Volts. I am in fact using a 4 pin opto instead of the 6 pin shown in the sketch. But that makes no difference as far as my problem is concerned.

    The problem starts when I use the Mach3 software. All configurations are done correctly but when I try to jog in the x or y or z direction using the arrow keys, the LED toggles the first time I push the appropriate arrow key but the LED stays in the same condition indefinitely regardles of which arrow key I push next. I expect the LED to toggle when other arrow keys are pressed but this does not happen. Can anyone tell me what is happening and how to overcome this problem. I need to add that when the pins are connected to a step motor driver it won't drive the motors unless I use a buffer circuit as an interface. Is there any reason why the LPT should be able to drive the below circiut using the LPTinterface.exe but not so when using Mach3?
    I will be grateful for any help.
    Cheers Bluebirdiran
    [​IMG]
     
  2. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    If your LPT port works under the LPTinterface.exe test then it works without problems. The LED turns OFF when you issue a HIGH to the port pin is due to the way the LED & optocoupler are connected, which leaves a lot to be said.

    No current limiting resistors on the input side(risks LPT port damages) and shunting LED current instead of switching LED current. :(

    Therefore your problem must be in the mach3 software or how one configures the software to control the parallel port.

    I'm afraid only those members who have actually used the mach3 software can offer any solution to you.
     
  3. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Hi eblc1388

    Thanks for your reply.
    I have been doing some more tests on this and it seems that dealing with direction pulses coming from pin 3, 5 and 7 there is no problem turning the LED on & off every time I change direction but the step signals which are much more frequent and last only for a very smal amount of time mearured in microseconds, I get no visual response. I have increased the step pulse duration to its max. of 25mS, no better. The only thing is, that when I tick the "low active" option for the signals, I get the LED very very dimly lit in boith +ve and -ve direction (jogging). What are your thoughts pls.

    Thanks
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You need to correct your circuit right away before you burn out your printer port.

    Re-wire it like this:

    [​IMG]
     
  5. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Do you think the 360 is really needed, because as it is, the LPT cannot supply enough current. That resistor will certainly present some drop in voltage and block the current making the situatuion even worse. Isn't this the case.
    The open circuit voltage is only 3.5 volts or there abouts. But I will definitely rewire the rest to your recommendations. Although I was originally trying to set up a circuit where I could get more of a switching action (either On or Off )rather than a proportional response which the new wiring presents.

    Thanks
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You really should limit the current through the emitter side of the optocoupler (I'm talking about the IR LED, not the emitter connection of the output side). If you don't, you risk burning out your LPT port.

    IR LEDs typically have a very low forward voltage; perhaps 1.2-1.3v at 10mA current.

    So, if your open-circuit output is 3.5v, then:
    Rlimit >= (3.5v-1.2v)/10mA = 2.3/0.01 = 230 Ohms. You could get by with 220 Ohms.
    Since I=E/R, 2.3v/220 Ohms = 10.454...mA.

    The concern here is burning up your printer port. It's probably built-in to your motherboard.

    You would be better off to use an add-on multi-IO card for your experiments; they're readily available for under $20. If you burn it up, you won't have to buy a new motherboard.

    The new wiring represents "ON" or "OFF" - it isn't proportional; it's digital.
     
  7. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    During my experiments I realized that if I used different resistors to limit the current to the IR side, the output side diode's brightness changed proportionally when using your type of wiring (This was before your reply though). It seems the brighter the IR LED glows the more current is generated on the recieving side and thus a bigger current flows into the base of the transistor inside the opto and hence what I called a proportional response.
    I do have a second parallel port card which I use at times but this one that I use normally, has really made me surprised as to how robust it is. I use a PC in my work room and another in the basement where I have connected it to the CNC. But you are right, I must make an effort to take that one out and install it on this one in my workroom.
    Thanks
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Plain optocouplers generally have pretty low-current output, and it is somewhat proportional to the IR emitter drive current. However, don't expect your printer port to last very long if you're asking it to source 30mA or more.

    You'd be better off to do something like use a ULN2803 driven by the LPT port to drive the optoisolators; they can sink 100mA per channel without breaking too much of a sweat, and have built-in 2.3k or 2.7k (can't remember which offhand) base current limiting resistors that would be a very light load for your port. Then you could source current from the 3.3v or 5v computer supply for your opto's IR emitter.

    You could also use Darlington optocouplers.
     
  9. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Hi SgtWookie
    Thanks for your help. Me, being a Mechanical Engineer, do get more than my fare share of troubles whenever I enter the world of electronics:confused:. I am using a very simple circiut to drive a relay so that I can switch on and off my electric valve controling the cutting oxygen on my CNC. It works a couple of times but goes bust after that. I thought the transistor had fried but it was ok. Then I checked the diode it was ok. In the end one comes to the conclusion that it must be the optocoupler that is getting fried (or maybe not!!). To be frank with you I don't know how to test an opto! After the first several on's and off's, then when I switch the 5.3v supply on, the relay latches without any signal at the input of the opto but sometimes I hear several clicking noises instead of just one. So can you tell me why this is happening and how to put things right. Do I need to add other components to protect the opto or what.

    Thanks a million

    Bluebirdiran
     
  10. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Hi again SgtWookie
    Well I have just learnt how to test the opto and surprisingly enough it is ok. This makes things more confusing as far as I am concerned. All the components are ok but the relay latches without an input to the opto. Figure out this one for me pls.!!
    Bluebird
     
  11. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    The problem is the slight leakage current from the opto-coupler.

    The following will cure the problem.

    [​IMG]
     
  12. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Hello Mr. Chung

    Thanks for your reply. Can you pls. tell me how you would add a pull-up or a pull-down resistor to the attached circuit to stabilize it. The supply voltage is a bit higher than 12v in this circuit and the relay is 12v.

    Thanks again

    Bluebird
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Add R3:

    [​IMG]

    [eta]
    Pay attention to the optocoupler's collector current rating. Right now, you're trying to sink around 24mA from the PNP's base through the opto output transistor, which seems a bit much. You may need to go to a Darlington transistor configuration to reduce the current required of the optocoupler.
     
  14. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Thanks SgtWookie

    Cann't I just increase R2 to limit the current?
    Bluebird
     
  15. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    Yes you can.

    Increase R2 to 1KΩ and R1 to 10KΩ. This would bring the collector current down to about ~12mA.

    The Ic of P521 opto is rated at 50mA max. so it will survive but I agree with recommendation by Sgt. Using large Ic is not necessary in this case.
     
  16. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, whether you can reduce the base current of Q1 (thus the optocoupler's output current) really depends on the current required by the relay's coil.

    To get transistor Q1 properly saturated, you''ll need Ib=Ic/10.

    So, calculate R2 = (Vcc-Vbe)/(Ic/10)
    where Vbe will be around 0.8v (higher for high base current), and Vcc=12, and Ic is the current required by the relay coil. In any event, you don't want to push the ratings of the optocoupler too hard, or use more current through the base/opto output transistor than you really need to.

    Don't forget to calculate the power dissipation for R2, and double the result to get the resistor wattage rating requirement.
     
  17. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Well the resistance of the relay is about 396ohm, so it will need about 30mA to operate properly at 12v. The reason why it is operating properly as it is, is probably because the source voltage is slightly higher than 12v. So which way do I go? Increase R2 or go for the darlington. If the latter is recommended, give me a part number for such a transistor.

    Thanks again,
    Bluebird
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    So, calculate R2 = (Vcc-Vbe)/(Ic/10)
    R2 = (12v-0.8v)/(30mA/10)
    R2 = 11.2v/3mA
    R2 = 3733 Ohms.
    That is not a standard value of resistance.
    A table of standard resistance values is here: http://www.logwell.com/tech/components/resistor_values.html
    Bookmark that page.
    You could use a 3.6k Ohm resistor - that would be close enough.
    For R3, use a resistor that is roughly 5 to 10 times as large as R2, so somewhere in the range of 18k to 39k Ohms.

    You do not need to change your transistor.
     
  19. Bluebirdiran

    Thread Starter Member

    Feb 5, 2010
    62
    0
    Thanks Sgt. I have modified the circuit and it works.
    Bluebird :D
     
  20. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Do the following test: Use your test software to set a Port pin High. Use your DMM in the DC current (~10mA scale), pos probe to the port pin, neg probe to the DB25 shell or one of the ground pins, and measure the current that your port pin can source. Without moving the Probes, put the meter in DC Volts mode, and measure the voltage, too. Post the results.
     
Loading...