Output pin P12 on Parallax Bs2p40 OEM are oscillating for unknown reason

Dear Parallax team,
I recently found a very unusual behaviour which i am trying to root cause and would appreciate any advice. I was trying to activate a simple relay using output pin P12 (pin 24) to turn on a relay. This part of my circuit is quite stable in the past - see picture (Pump to CPU Schematic). What i found is that when i activate P12 (active high) the relay turns on as expected, but then the output signal coming from P12 begin to show a step function - see attached (periodic power cycle of P12) with a time of about 2 seconds. The step function drops from the expected 5VDC to near zero and last about 16ms - see attached picture (P12 pump activation). I checked the four +5VDC inputs and the +5VDC does have a small A/C spike of about 150mV @ 15MHz - see attached picture (Pin 4 Vdd BS2P40 OEM).

Things I have done so far:
1. I do have an external brownout circuit and have disconnected the external reset. which connects to Pin1 of the Bs2P40 OEM
2. I did hardwire the relay with +5VDC and it is stable (no power cycling) which suggests the relay circuitry and hardware is ok.
3. I placed the activation on signal for P12 at the very beginning of the software and then ended the program and the relay cycling continues - hoping other code was interfering.


I would like to figure out where this periodic pulses are originating from and why they seem to be affecting what is supposed to be a stable high signal (P12 should remain at +5VDC).

I am guessing that a clock or A/C harmonic is getting into the CPU and causing some unusual behaviour. All 4 Vdd do have decoupling caps in place.

Thanks very much,
Chris.[img][/img]
«1

Comments

  • Hey Chris - what's "B-" on the schematic?
    Well-written documentation requires no explanation.
  • Hi Dave,
    It is labels for transistor (B=Base, C=collector, E=emitter). It was just the way the library pulled up the part.

    Regards,
    Chris.
  • Hi chrisdlove

    IMHO, davejames was referring to one of the top left connections at the schematic, the one labeled "B-".

    Relay_Coil_01.jpg
    743 x 339 - 29K
  • My first guess is a coding issue. Write a simple code and just turn on that pin and see if it stays on without a glitch. Secondly when driving any kind of relay its a good idea to opto isolate them. And lastly you could have pin that's almost blown out. I have a BS2 module that has a blown pin and it just stays on.
  • I was just wondering is this board you've been working on some type of hot tub or spa temp. controller
  • Take out the 1k resistor going to the transistor base. Then wire the pin to a separate led and resistor and see what happens.
  • There's an error in your schematic: -12V should be connected to the transistor's emitter (i.e. ground), not its collector.
    And you need to make that connection right at the transistor, not somewhere else in the logic ground's current path.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Seems like if power where applied to the A/B -/+ pins in red. The relay would turn on and just stay on. And when the transistor turned on it would just ground. Don't know if he has a dual supply or single supply system.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,442
    edited 2019-05-23 - 01:47:54
    Oh, maybe the red thing is for an external switching signal?

    In any event, my caveat about the 12V ground return still holds true. If he's routing that return through his logic ground traces, he might well be seeing the behavior he notes, as the Stamp keeps resetting.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Hi Phil, Bob, Yanomani and Dave,
    Thanks for all the feedback.

    I'm sorry Dave, I did misunderstand your inquiry - the B-/B+ are for a Blue LED to activate when the relay is on. Bob, I did wire the input of R42 directly to +5VDC and the relay activated but did not cycle on and off so having a stable +5VDC input at R42 provides the expected output, i.e, relay stayed on permanently until the +5VDC wire is removed. P12 clears shows a 16 msec width step function (+5VDC, 0VDC, +5VDC) every 2 seconds as shown in the attached files.....this is clearly coming out of P12. Bob, I did do as you suggested, which is to place P12 into a high mode at the very beginning of the code, line 1, and then use the "END" command directly afterwards. Again, it shows this same behaviour.

    I use a "medical grade" +12V AC/DC supply and manage it down using a +5VDC regulator to bring the voltage down to the rest of the board. I will check the quality of the +12VDC supply to see if it is showing this same 2 second spikes which are carrying through to the +5VDC supply. I could also add some additional capacitors to see if i can minimize the 150mV spikes on the +5VDC supply....I also want to see if these spikes are also 2 seconds apart....so basically work upstream to see where these are starting...or identify where/why they are being introduced? I believe it is a power quality issue that is impacting the circuit resulting in this odd behavior of the outputs. I may try to wire the relay through a different output pin - maybe that particular pin is defective?

    I have one f those STAMP education boards from a long time ago and will try and provide the +5VDC onto my board to see if the issue is related to the +12V AC/DC supply...

    Aslo, in a stable state (when i am not driving P12), it is not showing this behaviour - basically idle (GND) - which is expected - basically I'm saying its not some random output behaviour.

    I have a 4-channel digital oscilloscope with me so i can do some deeper analysis if you have some thoughts.

    Thanks so much for your input as always,
    Chris.

    PS. Yes Bob - same board :( this defect came as a real surprise!
  • YanomaniYanomani Posts: 882
    edited 2019-05-23 - 00:20:41
    Hi chrisdlove

    Only a thought...

    Did you ever checked for a partly burned component at D2 or BJTx positions?

    I never trusted 1N914s to be used as relay coil flyback returns, even with the most sensitive +5V relays, where the coils tend to have a high series resistance. For this application (flyback supression), I use to rely on 1 A or 2 A Schottkys and ever oversize the BJTs, based on relay coil max. operating current and voltage specs.

    I have used them (1N914) in thousands, but in series with the driver BJT's base, to ensure that a failed transistor would not harm my (CMOS/TTL) driving logic. Sure there was also ~10 kOhm pull-down resistors, connected between BJT's Base and GND.

    Henrique
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,442
    edited 2019-05-23 - 01:47:31
    Chris,

    Can you post a photo of your setup, please? I really need to see where the 12V ground return is attached to your circuit.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Chris is there a spare pin that you can try the code on and see if it glitches. I assume your wrote whole new short code with a different name than the main one your are using to run your board.
    Sounds like the glitch is on some program loop or clock cycle. Or another component on the board is doing this.
  • Hi Phil,
    attached is the power circuit providing the 12 VDC and 5 VDC - see attached.

    Hi Yanomani,
    I will check the function of the transistors tomorrow and see if this is a possibility of damage.
    thx,
    Chris.
    1425 x 305 - 87K
  • You said you have a spare stamp education board. Load your code on that one put an led on pin 12 and see if it glitches.
  • Hi Bob,
    i will try and program the output onto another pin as well tomorrow - a little tricky given it is SMT, but i will try. I agree that it may even be a defective processor. I may order a new one and have the manufacturing company replace it if this proves to be a likely scenario.

    I used the same main code, but put the relay HIGH command on line 1, after defining constants and so on...it was the first line of "active" code, but i can try to produce a entirely new program with only that line in it....

    I'll let you know what i find.

    Have a good evening,
    Chris.
  • Hi,
    i just read your new message about the education board- the education board is a BS2P24, but the pins i am using are P12 so it is included here so theoretically the same processor and same pin... i will try that but will have to use PTH transistors as all components other than relay is SMT, and the relay operates off off +12VDC...i may have to pull that voltage level off of my proto board to get that DC level..a little tricky but do-able.

    Thanks all - will report back tomorrow.
    Have a good evening,
    Chris.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,442
    edited 2019-05-23 - 04:12:58
    chrisdlove wrote:
    attached is the power circuit providing the 12 VDC and 5 VDC - see attached.
    Yes, but how physically is the 12V ground return routed? Do ground currents from the relay run through the Stamp's logic ground traces or wiring? That's why I wanted a photo, not just a schematic.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Hi Phil,
    The DC ground plane is connected at one point to the analog ground plane near the power supply through C2-Y1. I will need to look at the board layers, but i believe that the DC ground plane is shared between both the +5VDC and +12VDC voltages. The AC and DC ground planes do not overlap, in fact the A/C board segment is adjacent to the DC one so as to minimize any EMI interference. I hope I have answered your question. If you need a physical photo of the board, I can share that.

    After some further thinking, I am leaning towards some earlier comments about EMI back flash of the relay into the DC voltages....i seen some weird waveforms on the 20 MHZ clock and other signals when the pulses were showing up....and i think the relay response time aligns closely with the pulse duration 16 ms....I think the decoupling capacitors on the CPU are saving the CPU from resetting itself, but the +5VDC is getting corrupted enough that it is causing the CPU to act strangely, maybe because of the 20 MHz clock getting impacted and other signals as well. I may try to add a MOV across the pump relay and closely examine if any of the transistors have become damaged, etc. tonight.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,442
    edited 2019-05-23 - 18:25:28
    Where, physically, in the ground plane, relative to the transistor and the other components, is the DC ground return lead attached? IOW, does the lead come in on one side of the board with the transistor on the other side -- or what?

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Hi Phil,
    my board is two layers and the top layer has most of the traces. The 2nd layer has the ground planes. I would say that the digital ground plane connection point is connected through the C2-Y1. This is the single point where the analog ground coming from the cord connects to the digital ground. This safety capacitor is physically located very close to the AC/DC power supply. The capacitors foot print overlaps the boundary between the analog ground plane and the digital ground plane. This ties the references together at a single point to prevent ground loop noise.

    I hope this answers your question. If it doesn't maybe let me know what your potential concern is and that may help me to better address the potential issue.

    thanks for your time,
    Chris.
  • Hi Bob,
    I have created completely independent program and simply place the active high for the pump relay switch. All of the following test use this simplified program. It continues a cycling behaviour. I also added a MOV directly across the line/neutral of the pump A/C output connections and the main power input.
    1. Using the simplified program, the pump relay shows the cycling behaviour.
    2. I wired the pump relay through P10 (a different pin) currently wired to P12 and it shows the cycling behaviour
    3. I wired the pump relay (input of R42) directly to 5V and it showed stable behaviour - suggests interference with the processor via the relay operate time - some kind of feedback loop - maybe what Phil is suggesting.
    4. I checked the output of the Pin 10 prior to connecting it to the relay input and it is a stable +5VDC, however as soon as it is connected it begin to show a drop to 0V lasting 16ms.
    5. I removed the connection between B+/B- (Blue LED) so this has no pathway into the circuit.

    FYI, the operate time of the relay is 15 msc - my scope shows about 16.3 msec so this seems to be directly related
  • chrisdlove wrote:
    I hope this answers your question.
    No, it doesn't, I'm afraid. My concern is where in the ground plane the switching transistor is. If it's remote from where the power returns to the 12V supply, there could be enough relay-coil current through the ground plane and past the logic components to cause a disruption.

    You've done well, it seems, to handle analog/digital ground loops, but the relay current could also be a problem if not routed properly.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • YanomaniYanomani Posts: 882
    edited 2019-05-23 - 22:49:21
    The more I look at those power integrated converters (AC/DC and DC/DC), the more I miss the classic, old-scholl, transformer + diode bridge + capacitor bank setup, feeding a plethora of voltage regulators, integrated or not, linear or (recently) switching.

    If you download and read, to the fine-print level, the datasheets of Mean Well IRM-10-12 and NCP1117DT50RKG, you'll note that the AC/DC converter has no means of reducing its output voltage, back-sensed and internally processed, other than lowering its PWM activity, in the hope it'll lower a increasingly high sensed output.

    Well, it works if the DC output voltage is raising due to an increase at the AC (mains) input, but it's kind of a nonsense, IF the output voltage is raising due to external (to the converter control loop) reasons, i. e., a non-completelly-bleeded flyback pulse, caused by the deactivation of a relay coil, powered by the AC/DC converter.

    The first poor victim could be the NCP1117, whose MAXIMUM input voltage is speccd at 20 V, sure convenient for a 12 V input, as designed, but totally insufficient, if the kickback pulse, generated when the relay coil is de-energized, could top 150 V, and even more, if not conveniently bleeded.

    Studying a bit more about freewheeling diodes (aka clamp, flyback, kickback, etc.. (ad nauseam)) I've stumbled upon that article at embedded dot com:

    Back EMF and snubber, by Aubrey Kagan

    (https://www.embedded.com/electronics-blogs/without-a-paddle/4443026/Back-EMF-and-snubber)

    Reading thru it, I was introduced to the outstanding work of Rudy Severns (Call Sign N6LF):

    Snubbers for Electronic Circuits, freely available in two versions, at his site:

    (https://www.antennasbyn6lf.com/mosfets/)

    During the past months (years???) we've been seeying a lot of threads/posts about (motor) actuator-related circuit failures, due to arcing, back EMF, EMI and God knows what's more.

    I'm posting this at chrisdlove's thread because we've been discussing something closelly related to it, just now.

    I'm also asking chrisdlove permission (indulgence???; perhaps too late...), in the hope more experienced forumistas could jump in and contribute with their knowledge on that subject.

    In the hope it helps a bit

    Henrique
  • Hi All,
    I've had a chance to remodel the relay onto a proto board from Parallax (Board of Education). I used two different manufacturers: OMRON and SCHRACK (TE). I used the same setup as my prototype and wired the BS2P24 to Pin 12 as was the case in my prototype. Both relays showed the same behaviour so it is not my board, it is a my poor design. I will have to carefully review why the relays are cycling like this and figure it out. Interestingly, the relay never closes long enough for the LED to flicker - i guess 16 ms is too short. I'm attaching what the relay waveform looks like - which is explainable: the first two spikes, upwards, followed by a downwards is about 16 ms apart activation of the relay, followed immediately by the release which is about 5 msec apart. It is the immediate release that is undesirable.

    If anyone can explain it, it would of course be appreciated :)

    Thanks to all,
    Chris.

    PS. My previous design used only +5 V coil relays, ie everything on the board operated at 5VDC. I moved to 12VDC to separate the relay power from the more sensitive 5V components...it seems this did not work as planned :(
    800 x 480 - 81K
  • Hi Phil,
    this issue persists even on the BoE, is your inquiry around current routing still valid....these are pretty short pathways back to ground and not really underneath anything?

    For all, I am going to try returning to a 5VDC coil relay onto the BoE...same manufacturer, but different coil voltage - no mixing of +5/+12 onto same ground plane....maybe that is the issue- just as i have tied the analog to the digital at one point, maybe too, the +5VDC and +12VDC ground planes also need to be separated and connected at that same single point?

    regards,
    Chris.
    2448 x 3264 - 2M
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,442
    edited 2019-05-24 - 00:01:57
    Your wiring could be an issue. Instead of connecting the transistor's emitter to the Vss socket, use a jumper to the middle pin of the LM2940.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Hi Phil,
    that was an easy test...as expected - same behaviour - connected Emitter to LM2940 centre pin (GND) rather than Vss line.

    Regards,
    Chris.
  • Chris you removed the R42 and hot wired the relay and it was solid. Now leave that in place and wire a spare led and current limiting resistor to P12 and ground. See if the glitch persist. If the glitch goes away replace R42 and wire in an opto coupler. Opto isolate any relay that's wired to the microcontroller.
    I'm guessing if all relays are disconnected and replaced with test led's everything is good
    I was looking at that power supply too but couldn't read the number looked like FM-10-12. Yanomani has a good point that could just add problems to the design. You might want to hot wire board power from a linear bench top supply. But I don't think that's the cause of the glitch.
    Maybe your board just lacks juice and your traces are too small to carry the current.
  • I first encountered this relay problem with switching 120vac solenoids with the Prop1. I used a prop1 with an ADC to read to signals through the USB using labview. On the same Prop1 I tried switching some A/C solenoids. What a nightmare every time the solenoid switched off it would disrupt the serial link and stop my labview VI. Finally I fixed it by putting 600V 1uf caps across the contacts of the relay (not the coil) That stopped the spikes and it worked.
    On my next project I'm going to use a separate prop and USB just to switch the I/O (relays, probably will use Opto's from grayhill)
Sign In or Register to comment.