I need to read some switch closures with PICs in a ship. The cables
running to the switches will run several hundred feet and will be run
alongside AC power lines and possibly some lines to big motors. There
will be three PIC circuits in three different locations reading the
switches. They will be daisy chained. There won't be any serial coms
between the pics, just 11 switch lines and common. There won't be any
fast switching, just going to alarm contacts on doors.
Any suggestions for protecting the pics and keeping noise on the lines
from looking like switch closures?
Also, should I use 5V going to the closures or bump it up to 12 or 24
and step it down with a zeener at the pic end for better noise immunity?
Brian Kraut wrote:
>
> I need to read some switch closures with PICs in a ship. The cables
> running to the switches will run several hundred feet and will be run
> alongside AC power lines and possibly some lines to big motors. There
> will be three PIC circuits in three different locations reading the
> switches. They will be daisy chained. There won't be any serial coms
> between the pics, just 11 switch lines and common. There won't be any
> fast switching, just going to alarm contacts on doors.
>
> Any suggestions for protecting the pics and keeping noise on the lines
> from looking like switch closures?
>
> Also, should I use 5V going to the closures or bump it up to 12 or 24
> and step it down with a zeener at the pic end for better noise immunity?
Opto couplers are cheap and simple. It's highly unlikely that the LEDs
will light except when driven by the switch closures. The PIC connects
to the transistor collectors to detect the swicth change.
I use them all the time for serial coms for the same reasons that make them a
good choice for this app. I must have had a serious brain fart. This will
also make it easy to run 12V to the switches to compensate for loss in the
cable. Thanks for helping me see the obvious. Amazing how easy it is to
forget the simple things when you spend too much time working on things that
are more complicated.
> Brian Kraut wrote:
> >
> > I need to read some switch closures with PICs in a ship. The cables
> > running to the switches will run several hundred feet and will be run
> > alongside AC power lines and possibly some lines to big motors. There
> > will be three PIC circuits in three different locations reading the
> > switches. They will be daisy chained. There won't be any serial coms
> > between the pics, just 11 switch lines and common. There won't be any
> > fast switching, just going to alarm contacts on doors.
> >
> > Any suggestions for protecting the pics and keeping noise on the lines
> > from looking like switch closures?
> >
> > Also, should I use 5V going to the closures or bump it up to 12 or 24
> > and step it down with a zeener at the pic end for better noise immunity?
>
> Opto couplers are cheap and simple. It's highly unlikely that the LEDs
> will light except when driven by the switch closures. The PIC connects
> to the transistor collectors to detect the swicth change.
>
> --
> Best regards
>
> Tony
>
> http://www.picnpoke.com
> Email .....salesKILLspam@spam@picnpoke.com
switch common 0V
switch contact intp the base of a NPN transistor pulled high via 1k and a
series reisitor into the base of 10K.
Use schotkey diode clamps on the input lines.
Use current limit potection resistors on both lines say 100R
USe the tansistor as an active low switch.
This method is used in vehicle environments, agreed that there will be no
110VAC around, but lots of other stuff.
>I use them all the time for serial coms for the same reasons that make them a
>good choice for this app. I must have had a serious brain fart. This will
>also make it easy to run 12V to the switches to compensate for loss in the
>cable. Thanks for helping me see the obvious. Amazing how easy it is to
>forget the simple things when you spend too much time working on things that
>are more complicated.
>
>Tony Nixon wrote:
>
>> Brian Kraut wrote:
>> >
>> > I need to read some switch closures with PICs in a ship. The cables
>> > running to the switches will run several hundred feet and will be run
>> > alongside AC power lines and possibly some lines to big motors. There
>> > will be three PIC circuits in three different locations reading the
>> > switches. They will be daisy chained. There won't be any serial coms
>> > between the pics, just 11 switch lines and common. There won't be any
>> > fast switching, just going to alarm contacts on doors.
>> >
>> > Any suggestions for protecting the pics and keeping noise on the lines
>> > from looking like switch closures?
>> >
>> > Also, should I use 5V going to the closures or bump it up to 12 or 24
>> > and step it down with a zeener at the pic end for better noise immunity?
>>
>> Opto couplers are cheap and simple. It's highly unlikely that the LEDs
>> will light except when driven by the switch closures. The PIC connects
>> to the transistor collectors to detect the swicth change.
>>
>> --
>> Best regards
>>
>> Tony
>>
>> http://www.picnpoke.com
>> Email salesKILLspampicnpoke.com
>
>
> Opto couplers are cheap and simple. It's highly unlikely that the LEDs
> will light except when driven by the switch closures.
Oh yeah? I have heard of just this happening in an Automotive
environment (big long truck actually). The trick is to put zeners in
series with the optocouplers so they need a signifcant current AND
a significant voltage before they light up. Have seen this in other
commercial equipment too where a certain amount of induced EMF
is practically unavoidable. Hope this helps.
Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile: 025 334 069
eMail: .....brent.brownKILLspam.....clear.net.nz
Could also use some software filtering. For example, maintain a counter
that increments each time a polling routine sees an apparent switch closure.
Reset the counter when the closure goes away. Only consider it a real
closure if the count reaches some appropriate value. This way short
duration noise is ignored, but the DC of a real switch closure is not. This
also effectively debounces the switches.
> Oh yeah? I have heard of just this happening in an Automotive
> environment (big long truck actually). The trick is to put zeners in
> series with the optocouplers so they need a signifcant current AND
> a significant voltage before they light up. Have seen this in other
> commercial equipment too where a certain amount of induced EMF
> is practically unavoidable. Hope this helps.
> > Opto couplers are cheap and simple. It's highly unlikely that the LEDs
> > will light except when driven by the switch closures.
>
> Oh yeah? I have heard of just this happening in an Automotive
> environment (big long truck actually). The trick is to put zeners in
> series with the optocouplers so they need a signifcant current AND
> a significant voltage before they light up. Have seen this in other
> commercial equipment too where a certain amount of induced EMF
> is practically unavoidable. Hope this helps.
>
> Brent Brown
With some serious bypass caps, 10nF are useless, even 100n dont cut
the grade in this sort of environment, I prefer 470nF.Beware
electrolytic caps above this value that are not low ESR.
I have seen LEDs actually flashing from induced noise with motorized
gates limit switch contacts running next to the power wires. That
problem was fixed with the afore mentioned caps AND a 470 ohm
resistor across incoming pair .... brutal but effective.
Power Distribution and Radio Comms are youre biggest problems in this
environment as far as noise goes.
_____________________________
Lance Allen
Technical Officer
Uni of Auckland
Psych Dept
New Zealand
I have a problem with the generic recommendation of optocouplers.
They are appropriate where the two circuits are isolated. If however,
you are using them with one common line to both input and output as I
have seen in some suggestions, as a glorified transistor, then you have
misunderstood the problem and are bound to be disappointed.
There are other, more effective ways to slow down the response of a
circuit!
--
Cheers,
Paul B.
> > Opto couplers are cheap and simple. It's highly unlikely that the LEDs
> > will light except when driven by the switch closures.
>
> Oh yeah? I have heard of just this happening in an Automotive
> environment (big long truck actually).
Uhm, most of this type of signalling is done with the receiving end holding
the line hi through a local, high value pull-up and the switching end
pulling the line lo when required - all noise and cross talk helps to hold
the line hi. When the switch pulls the line lo the receiver gets the message
loud and clear.
If the receiver is opto coupled to the sending switch then the scheme is
modified a bit, the pull-up is a much lower value to allow about 15-20mA
through an LED (in the opto coupler) and contact losses can be significant.
My suggestion is to set up the switches as a 24V, 20mA current loop through
all 3 opto couplers with the switch pulling the signal lo (allow for a 2
volt drop across each LED). On the photo transistor side of each opto
coupler hold the collector hi with a high value resistor (say 10K) and
connect the resistor/collector joint to a PIC I/O pin (emitter connects
directly to 0V). Don't forget a very high value resistor (100K) from the
photo transistor's base to 0V to bleed off any accumulated static to avoid
false triggering.
This set up inverts the signal - when the line is hi (switch open) the PIC
will get a lo while the photo transistor is on (diverting the pull-up to
0V). When the line goes lo the LED goes out, the photo transistor turns off
and the pull-up signals a hi to the PIC.
> I have a problem with the generic recommendation of optocouplers.
>
> They are appropriate where the two circuits are isolated. If however,
>you are using them with one common line to both input and output as I
>have seen in some suggestions, as a glorified transistor, then you have
>misunderstood the problem and are bound to be disappointed.
>
> There are other, more effective ways to slow down the response of a
>circuit!
Paul -
can you explain your answer for the non EE's amongst us?
Anne Ogborn wrote:
>
> > I have a problem with the generic recommendation of optocouplers.
> >
> > They are appropriate where the two circuits are isolated. If however,
> >you are using them with one common line to both input and output as I
> >have seen in some suggestions, as a glorified transistor, then you have
> >misunderstood the problem and are bound to be disappointed.
> >
> > There are other, more effective ways to slow down the response of a
> >circuit!
>
> Paul -
> can you explain your answer for the non EE's amongst us?
>
> Annie
I guess you never saw two opto-couplers sharing the same line, back to
back, input and ouput, as a two way line opto-isolated, in a bridge
configuration or not...