PLC - realys or MOSFETS?
This was originally posted to the "PLC frequently rebooting" thread, but since I prematurely decreed that the problem appeared to be solved, nobody has responded to my latest newbie question. For more background, see the "PLC frequently rebooting" thread.
As it turns out, a problem of the the Stamp PLC frequently rebooting was not "solved", just reduced. In fact, the reboots have continued after insuring that the ATN pin was grounded when programming of the PLC was not in progress.
I decided to see if I could find other ways in which a transient might cause a reset of the PLC. My PLC controls two relays via Dout1 and Dout2, and measures two analog voltages via Ain1 and Ain2. I figured that anything external causing a reboot likely had to travel one of these paths.
I first made a software change to simple prevent Dout1 from activating the attached relay (commented out the LOW instruction). This seemed to solve the problem - about 99% of the reboots have gone away. At this point I have not tested the second relay circuit.
The Dout1 relay trigger circuit is an exact duplicate of Figure 8 in the PLC instruction sheets "BASIC Stamp Programmable Logic Controller Package" 12/29/03. The relay coil is powered by 24VDC, but unlike Figure 8, there is a zener diode across the coil with the cathode at the +24 VDC end of the coil. With the relay disabled in software, the reboot problem largely went away. Since this relay controls the power to a sensor which in turn provides a voltage between 0 and 10VDC (measured by Ain1) that is proportional to distance, perhaps a transient was getting into the system via the signal line, not the relay circuit. So to test for this definitively, I disconnected the signal line and reconnected the relay circuit by removing the comment characters preventing the subroutine from toggling the pin. Reboots abound. Conclusion: The relay circuit (Dout1) seems to be the cause of the problem since the associated sensor input line could not be causing the problem (disconnected).
I should also mention that there is a voltage divider circuit ( a 22k and a 0-100k variable resistor) to drop the +/- 24VDC to the 0-5 volt range so that the Maxim 1270 ADC can translate. This is driven by the 24VDC line switched on and off by the sensor power relay (Dout1).
The Dout2 circuit is probably not the source of the problem since it is turned on and off many times per program loop, and when Dout1 was disconnected (but Dout2 was NOT disconnected), only 1 reboot happened in 24 hours.
Thus my conclusion is that the relay controlled by Dout1 supplying 24 volt DC power to a sensor seems to be the main culprit. The second relay controlled by Dout2 supplying 12 volt power to a radio modem may also be somewhat to blame, bit that's less obvious. Given that both relays sport zener diodes, perhaps I can find a less noisy way of controlling the power switches. If so, how do I fix it? I was thinking of scrapping the relays and using MOSFETs in their place. The sensor is a SensComp Mini-AE 24VDC that requires 30mA of current (2.0 Amperes during the .5 ms transmit pulse).
Perhaps someone can tell me if the relays can be further conditioned to reduce noise, or if MOSFETS or some other alternative would be less noisy.
I do not know which MOSFETS might be suitable. I assume I could use the +5 volt supply from the PLC to activate the gate on a MOSFET of sufficient size to turn power to the radio modem (300 ma @ 12 volts when transmitting) or the sensor on and off.
Since I am only bright enough to follow simple instructions, any diagrams showing how components would relate to each other, and recommendations for parts by number would be appreciated.
Thanks, Pieter
As it turns out, a problem of the the Stamp PLC frequently rebooting was not "solved", just reduced. In fact, the reboots have continued after insuring that the ATN pin was grounded when programming of the PLC was not in progress.
I decided to see if I could find other ways in which a transient might cause a reset of the PLC. My PLC controls two relays via Dout1 and Dout2, and measures two analog voltages via Ain1 and Ain2. I figured that anything external causing a reboot likely had to travel one of these paths.
I first made a software change to simple prevent Dout1 from activating the attached relay (commented out the LOW instruction). This seemed to solve the problem - about 99% of the reboots have gone away. At this point I have not tested the second relay circuit.
The Dout1 relay trigger circuit is an exact duplicate of Figure 8 in the PLC instruction sheets "BASIC Stamp Programmable Logic Controller Package" 12/29/03. The relay coil is powered by 24VDC, but unlike Figure 8, there is a zener diode across the coil with the cathode at the +24 VDC end of the coil. With the relay disabled in software, the reboot problem largely went away. Since this relay controls the power to a sensor which in turn provides a voltage between 0 and 10VDC (measured by Ain1) that is proportional to distance, perhaps a transient was getting into the system via the signal line, not the relay circuit. So to test for this definitively, I disconnected the signal line and reconnected the relay circuit by removing the comment characters preventing the subroutine from toggling the pin. Reboots abound. Conclusion: The relay circuit (Dout1) seems to be the cause of the problem since the associated sensor input line could not be causing the problem (disconnected).
I should also mention that there is a voltage divider circuit ( a 22k and a 0-100k variable resistor) to drop the +/- 24VDC to the 0-5 volt range so that the Maxim 1270 ADC can translate. This is driven by the 24VDC line switched on and off by the sensor power relay (Dout1).
The Dout2 circuit is probably not the source of the problem since it is turned on and off many times per program loop, and when Dout1 was disconnected (but Dout2 was NOT disconnected), only 1 reboot happened in 24 hours.
Thus my conclusion is that the relay controlled by Dout1 supplying 24 volt DC power to a sensor seems to be the main culprit. The second relay controlled by Dout2 supplying 12 volt power to a radio modem may also be somewhat to blame, bit that's less obvious. Given that both relays sport zener diodes, perhaps I can find a less noisy way of controlling the power switches. If so, how do I fix it? I was thinking of scrapping the relays and using MOSFETs in their place. The sensor is a SensComp Mini-AE 24VDC that requires 30mA of current (2.0 Amperes during the .5 ms transmit pulse).
Perhaps someone can tell me if the relays can be further conditioned to reduce noise, or if MOSFETS or some other alternative would be less noisy.
I do not know which MOSFETS might be suitable. I assume I could use the +5 volt supply from the PLC to activate the gate on a MOSFET of sufficient size to turn power to the radio modem (300 ma @ 12 volts when transmitting) or the sensor on and off.
Since I am only bright enough to follow simple instructions, any diagrams showing how components would relate to each other, and recommendations for parts by number would be appreciated.
Thanks, Pieter
Comments
Update: I finally had the time to try another relay (didn't get any mosfet advice so I gave up on the idea of a solid state relay), and I discovered that the relay was the entire cause of the problem. After installing the new relay, no more reboots. Ever!! So electrically we're doing better. I still have an ultrasonic sensor issue, but I believe the sensor itself is defective.
QUESTION: I am using the stamp PLC with the MAX1270 A/D converter installed. I am reading analog voltages on channels 1 and 2. I amusing the subroutine shown on page 10 of the "Stamp PLC (#30064) version 1.8 document on the Parallax web site.
What I found is that when cycling through the subroutine and printing the value on those two channels, the first time through (of each iteration of 10 readings), there was some non-zero value present even if there was no input present at all. Completely disconnected, Channels 1 and 2 showed some positive values, but only on the first of several trips through the subroutine to get a value.
While fooling around with the idea that it might be a software problem, I commented out the first "LOW CsAdc" in the routine, and the subroutine works right - it produces a zero reading for all iterations of the subroutine when there is no input voltage present.
I'm happy its working, but why the strange behavior?
Here's some snippets of the code:
'
[noparse][[/noparse] I/O Definitions ]
'
AinAdc PIN 5 ' A/D Data in
AoutAdc PIN 4 ' A/D Data out
ClkAdc PIN 0 ' A/D clock
CsAdc PIN 3 ' Chip Select for ADC
Dat PIN 2
Load PIN 1
modem PIN 15 ' modem power relay is on Dout 2
sensor PIN 14 ' sensor power relay is on Dout 1
....
GOSUB ReadVolts
.......
ReadVolts:
'
VoltResult = 0
LOW CsAdc <<
IF I COmMENT THIS LINE OUT IT WORKS CORRECTLY
PAUSE briefly 'select chip
SHIFTOUT AoutAdc, ClkAdc, MSBFIRST, [noparse][[/noparse]%11100000] 'Ch2 0-5 VDC
PAUSE briefly
HIGH CsAdc
PAUSE briefly 'trigger
LOW CsAdc
PAUSE briefly
SHIFTIN AinAdc, ClkAdc, MSBPRE, [noparse][[/noparse]VoltResult\12] ' get result
PAUSE briefly
HIGH CsAdc
'.................
'