Badcaps.net Forum
Go Back   Badcaps Forums > Troubleshooting Hardware & Devices and Electronics Theory > General Electronics Technical Discussion
Register FAQ Calendar Search Today's Posts Mark Forums Read

 
Thread Tools Display Modes
Old 10-27-2020, 12:04 PM   #141
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Ok, there were two posts there, but I sorted out the first one - the one about the pin numbers (no delete option here unfortunately, since I would've removed that one).

I sort-of worked out the second issue too: again, I checked all my connections and wiggled them around (I'm currently on breadboards) and it now works better - the LED no longer dims in sync with the buzzer, though I'm STILL a bit surprised that a "HIGH" pin only reads 3.3v. Having used Arduino so far, I was expecting 5v...
__________________
Wattevah...
Dannyx is offline   Reply With Quote
Old 10-28-2020, 05:48 AM   #142
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Just managed to kill one of the boards - the NRST pin is pulled low all the time so the board doesn't initialize....no idea how it happened...

Last edited by Dannyx; 10-28-2020 at 06:45 AM..
Dannyx is offline   Reply With Quote
Old 10-28-2020, 08:11 AM   #143
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

check the schematics to see where it goes - i think it's linked to the stlink mcu
stj is offline   Reply With Quote
Old 10-28-2020, 08:52 AM   #144
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Quote:
Originally Posted by stj View Post
check the schematics to see where it goes - i think it's linked to the stlink mcu
I did some measurements in the meantime and I think it really IS the STM32 that quit.

I removed SB111 and SB177 to separate the STLink and LAN IC's own RST pins from the rest to see if either of them drags down the NRST line, but no change: it still reads 192ohms and never goes past 0.1v. I thought there might still be hope and something got busted at a more "logic" level (bootloader or stuff which I'm not familiar with), but that doesn't explain why the pin reads such a low value compared to the good board physically ! Ironically, the Aruino IDE seems to upload its sketches just fine and the board is detected as a mass storage device just like before (so flash is working ?), but nothing happens after that. In a more technical way (I THINK), it doesn't enter the "main loop". I even checked with the simplest sketch possible (blink the LED) and it didn't work, so it looks like the STM packed it...

Scenario 1: I was worried about the 3.3v thing I mentioned, since my Schmitt trigger outputs 5v as "HIGH", but having a look at the datasheet for the STM32F767 IC itself, reveals the maximum input on its pins is VCC + 4v, so 3.3v+4 = 7ish, which puts me well into the safe zone I'd say. To drive the point home even further, this board didn't' even have any "inputs" The phenomenon occurred just as I was trying to add an input pin through a schmitt trigger. I tried loading the sketch with my new changes and noticed the board was just sitting there doing nothing. This led me to believe that the newly added input damaged something, but I doubt it. Meanwhile, the other board (which reads the float sensor and actually HAS two inputs) is happily sitting there with 5v on its pins no problem, so this couldn't have been it...

Scenario 2: it may have been ESD or something dodgy related to the ethernet jack/my own body/soldering iron...

Scenario 3: operator error. With so many exposed wires hanging around the bench, maybe one brushed against the board enough to kill it when I moved it around...
Dannyx is offline   Reply With Quote
Old 10-28-2020, 10:18 AM   #145
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

i dont know about your desk, but you need to be carefull with these type of large explosed boards - put them on/in a case or something
you may want to run your inputs through opto islolators on the final design too - to stop long wires conducting esd into the board if there is a storm
stj is offline   Reply With Quote
Old 10-28-2020, 10:27 AM   #146
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Thumbs up Re: Remote pump control ideas.

Yes, the board will have its own case.

Good idea about the optoisolators. I'd drop them between the schmitt trigger's output and the Nucleo's pin like this. The Nucleo's pin would then require pulling up, so I guess this is a good place to use internal pull-ups.

Should I also be concerned about the 2n2222 trannies spitting back voltage into the micro's pins ? I tested the outputs pretty hard the other days and it didn't seem to complain. There's currently a 1k resistor between the base and the micro's pin, for the record...
Attached Images
File Type: png Test2.png (20.1 KB, 6 views)

Last edited by Dannyx; 10-28-2020 at 10:44 AM..
Dannyx is offline   Reply With Quote
Old 10-28-2020, 12:36 PM   #147
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

what the hell is that diagram?
why are you using a schmit trigger anyway?

i think later i'll have to do a diagram myself!
stj is offline   Reply With Quote
Old 10-28-2020, 12:42 PM   #148
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Quote:
Originally Posted by stj View Post
what the hell is that diagram?
why are you using a schmit trigger anyway?

i think later i'll have to do a diagram myself!
It's a snippet of the KiKad schematic - I cut to only the part of interest which monitors the contact status of the 3 phase contactor. I could upload the whole thing if people really wanted to see it, though it could confuse the heck out of you and it'd have to write a wall of text to explain what's what

I heard it's common practice to use a schmitt trigger between mechanical contacts and MCUs...it can't "hurt", now can it ?
Dannyx is offline   Reply With Quote
Old 10-28-2020, 07:50 PM   #149
redwire
Badcaps Veteran
 
Join Date: Dec 2010
City & State: Alberta
My Country: Canada
Posts: 1,860
Default Re: Remote pump control ideas.

It can hurt because it's another part that can get zapped if not done right. The MCU will have Schmitt trigger inputs as well.

The contactor switch is not a nice signal because it's close to mains wiring and an arcing contact. So you need good noise rejection and protection against spikes, and also need many mA of current to flow through it.
I would use this (a typical PLC digital input) that makes the DI good (activate) for say anything above ~6V, and the slow opto does filter some noise.
It's easier to standardize your digital inputs as say 12V switch to ground. But this would waste current for the tank switches...

You don't care about debouncing or a Schmitt trigger because you turn on the contactor and then read the switch a good while later say 1 second, to confirm the motor overload relay has not tripped.
Attached Images
File Type: jpg DI_PLC.JPG (88.4 KB, 6 views)
redwire is offline   Reply With Quote
Old 10-29-2020, 02:15 AM   #150
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Thumbs up Re: Remote pump control ideas.

Nice. Thanks. I was actually thinking of the same setup at some point. So we should scrap the Schmitt triggers entirely ???

Recap: So SW1 is the auxiliary NO contact of the contactor and LP1 is the 12v LED indicator lamp for "motor RUN" ? Ok, got that

The 1.5K resistor is for current limit through the LED of U1 - makes sense. I went with 2k last time I had 12v on PC817 in this setup (in my car window project). Now that I think about it, I think I can even go LOWER. The Vf of a PC817 is given as 1.4v max. So 12v-1.4 = 10.6v. Divide that by 1500ohms and we get approximately 8mA of current to the LED....did I get this right ?

Can't I use 5/3.3v to drive the LED of U1 so that resistor can be smaller ? I'd only switch the GNDs of both the lamp and the cathode of the LED at once. Let me answer my own question with a schematic: no, because when GND is cut and the LED inside the lamp becomes forward-biased, 12v would flow through it and feed back into the 5v supply via the 1n4148 diode like in the schematic which I drew to illustrate this setup I had in mind...hence why named it "ProbablyBadIdea"

The 10k on the far right pulls up the MCU pin when the opto is off - makes sense as well. Pulling up to 3.3v instead of 5v is probably a good idea in the case of the STM

The 1n4148 is to clamp reverse voltage - I have this in that other project too. I've seen it as a 5v zener in some examples instead of a regular diode.

Now that 470 resistor is the only thing left - what does it do ?

The tank side does not have any lamps (energy conservation), so I could go straight to the input of U1 via the switch - either by pulling the anode side UP to 12/5/3.3v or the cathode to GND. It's a SPDT switch, so the COM (pole) goes to GND/V+ and the NO/NC (throws) go to either optocoupler anode/cathode, which each get a pin on the MCU. The resistor would indeed waste some power to keep the LED on, hence why I'd go with lower input voltage. The wire run from the tank switch to the control box is pretty long there, though it is shielded, if it matters at all, since we're talking small control signals, susceptible to noise...
Attached Images
File Type: png ProbablyBadIDea.png (7.9 KB, 5 views)

Last edited by Dannyx; 10-29-2020 at 02:35 AM..
Dannyx is offline   Reply With Quote
Old 10-29-2020, 01:21 PM   #151
redwire
Badcaps Veteran
 
Join Date: Dec 2010
City & State: Alberta
My Country: Canada
Posts: 1,860
Default Re: Remote pump control ideas.

You want the opto to turn on around 1/2 input voltage for noise immunity, not at say 2V but 6V up. The 470R resistor across the opto LED wastes a few mA, so the 1k5 current is not entirely going through the LED. It just ends up increasing the activation voltage to work better with 12V signals. If you had a 24VDC input that activated at 2V it can get easily fooled and is not what a PLC uses.
It's best to have a few mA flow through the switch so humidity/dirt leakage current is not enough to activate anything. But not ideal for battery/solar systems.

That circuit - the LED lamp sees ~7V when the switch is open, and 12V when closed, so the old/bright dim thing. 1N4148 only good for 100V spike. Why do you want to run the opto from 5V, you're using three rails already 12V, 5V, 3.3V it's too complicated. I would just make the opto input for 12V. Or add a series diode good for 1kV. Or use a simple voltage divider.

If you need a low power-wasting digital input, I use small MOSFETs that have the built-in gate protection diode like 2N7002K or BSS138K, or go directly into an MCU input after protection diode/resistors. Again, set to trip at several volts. Remember 3.3V MCU will think >1.8V is a logic 1 which is very low in an industrial environment.
redwire is offline   Reply With Quote
Old 10-29-2020, 01:38 PM   #152
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Thumbs up Re: Remote pump control ideas.

Great pointers as usual. Cheers !
Quote:
Originally Posted by redwire View Post
You want the opto to turn on around 1/2 input voltage for noise immunity, not at say 2V but 6V up. The 470R resistor across the opto LED wastes a few mA, so the 1k5 current is not entirely going through the LED. It just ends up increasing the activation voltage to work better with 12V signals.
I see now. What is the math behind this ?


Quote:
Originally Posted by redwire View Post
That circuit - the LED lamp sees ~7V when the switch is open, and 12V when closed, so the old/bright dim thing.
Yes - I axed that idea anyway.

Quote:
Originally Posted by redwire View Post
Why do you want to run the opto from 5V, you're using three rails already 12V, 5V, 3.3V it's too complicated. I would just make the opto input for 12V.
Yes, it was getting too complicated indeed, so up on the hill, which is battery powered, and there are no lamps to drive at the same time as a MCU pin, I'll be using the 3.3v output for the tank toggle switch. I bench-tested the setup shown in the schematic and it works: I used a single 100ohm resistor in series with the anode of the optocoupler. It might be too sensitive though, as you described, so it could false-trigger (though I do have a pretty long countdown delay time in code before the MCU actually acts and does anything with that input). I talk about battery power and energy conservation here, though probably even 12v across 1.5k resistors in series with the opto's anode would not draw THAT much extra power compared to my 3.3v idea, so it may not be that much more efficient...

For the pump panel which is utility-powered and there are 12v lamps to power as well, I HAVE to use 12v with the 1.5k resistors in series, otherwise I'd run into that issue of not being able to properly turn off the lamps, so I'll do it like in your first schematic.
Attached Images
File Type: png Test2.png (6.3 KB, 2 views)
Dannyx is offline   Reply With Quote
Old 10-30-2020, 03:24 PM   #153
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Turning back to the "dead" Nucleo: I'm tempted to get a chip off Ali to fix it....I doubt it's a drop-in replacement though since it's essentially a computer and requires some programming to work the way it did out of the box. Trouble is I have no idea how to do that, what I need or IF it can be done AT ALL with no external tools and pieces of software...the more astute in this field could probably provide an answer....
Dannyx is offline   Reply With Quote
Old 10-31-2020, 04:01 AM   #154
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

there is no programming for the main chip, only the stlink mcu has code on it.
(and i have that! )
stj is offline   Reply With Quote
Old 10-31-2020, 04:03 AM   #155
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Quote:
Originally Posted by stj View Post
there is no programming for the main chip, only the stlink mcu has code on it.
(and i have that! )
So I can just drop a new chip in, provided the STlink is good ? The board's still detected and even goes as far as to upload sketches to it, but doesn't run anything after that, the NRST pin being asserted low all the time...
Dannyx is offline   Reply With Quote
Old 10-31-2020, 08:49 AM   #156
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

well if you are sure it's the chip holding it's own reset line down.

btw, a bit of a bodge, but try adding a pullup resistor to 3v3
stj is offline   Reply With Quote
Old 10-31-2020, 09:55 AM   #157
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

Quote:
Originally Posted by stj View Post
well if you are sure it's the chip holding it's own reset line down.

btw, a bit of a bodge, but try adding a pullup resistor to 3v3
I thought of that too, but given the resistance to GND on the RST pin is around 192ohms on the "dead" board and around 7Meg-ohms on the good one, I think something went pop inside the chip.

I removed two 0-ohm resistors which connect together the RST lines of the ethernet chip and the STLink to try and narrow down where the low resistance is and unfortunately it seems to be facing the MCU. There's no solder bridge I can further remove to isolate the RST pin of the MCU entirely, so I doubt there's anything left on that line that can cause this...the only way to find out would be to pop off the chip and see if the reset pin restores to 3.3v...
Dannyx is offline   Reply With Quote
Old 10-31-2020, 12:40 PM   #158
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 23,518
Default Re: Remote pump control ideas.

hardwire it to 3v3 at the regulator (for max current) and see if you can blow out the shorted gate.
nothing to lose trying!
stj is offline   Reply With Quote
Old 10-31-2020, 03:11 PM   #159
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Default Re: Remote pump control ideas.

I don't think the regulator can provide the necessary current to do that, plus I risk damaging it more...tempting, but I don't think I'd do it after all
Dannyx is offline   Reply With Quote
Old 11-02-2020, 03:08 AM   #160
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,983
Lightbulb Re: Remote pump control ideas.

Back to protecting my sh!t: can I also use optocouplers the other way around to protect "output" pins too, like so ? I saw this setup somewhere on the web, I tested it for around half and hour and it seems to work reliably enough, at least on the bench under normal temperature conditions. It's for powering the 12v relay which in turn provides 230v to the main contactor, since that's its rating...I originally had the MCU pin straight on the base of that 2n2222 but I thought the MCU may not like the arcing that goes on in the 12v relay close to the wire which leads back to the 2n2222. Don't worry about not having a flyback diode across the relay in the schematic - I have a 1n4007 there in reality.
Attached Images
File Type: png OutputProtection.png (10.4 KB, 5 views)
Dannyx is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Badcaps.net Technical Forums 2003 - 2020
Powered by vBulletin ®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
All times are GMT -6. The time now is 07:53 AM.
Did you find this forum helpful?