??? 07/24/04 12:52 Read: times |
#74792 - RE: Reed Relay *INPUTS* Responding to: ???'s previous message |
There's a couple of mistakes in the circuit - firstly the port pin should go to pin 5 of the opto NOT pin 4 (as pin 4 is set to 0v). Also, the value of R1 at 470R seems a tad low, try something like 4700R. Try these changes and the circuit has a fair chance of working. What you have described is the usual input in an industrial PLC. The addition they make is a zener diode for some protection on the input of the opto for reverse and over voltage. Onto the 'chattering' relays - I gather you mean contact bounce - as mentioned earlier do a search on 'debounce'. My usual technique is to sample the inputs at a constant rate (say 10mS) and shift each bit into a byte. If the input is bouncing you will get a sequence of 0 and 1 bits. When the input sequence is all 0's (your opto circuit places a 0 on the input when active) for 8 samples (80mS total) then you can assume the input is actually active. Depending on the application, you may want this to be longer to give you more immunity to noise. |