Announcement

Collapse
No announcement yet.

Remote pump control ideas.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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...

    Comment


      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, 06:45 AM.
      Wattevah...

      Comment


        Re: Remote pump control ideas.

        check the schematics to see where it goes - i think it's linked to the stlink mcu

        Comment


          Re: Remote pump control ideas.

          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...
          Wattevah...

          Comment


            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

            Comment


              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 Files
              Last edited by Dannyx; 10-28-2020, 10:44 AM.
              Wattevah...

              Comment


                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!

                Comment


                  Re: Remote pump control ideas.

                  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 ?
                  Wattevah...

                  Comment


                    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 Files

                    Comment


                      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 Files
                      Last edited by Dannyx; 10-29-2020, 02:35 AM.
                      Wattevah...

                      Comment


                        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.

                        Comment


                          Re: Remote pump control ideas.

                          Great pointers as usual. Cheers !
                          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 ?


                          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.

                          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 Files
                          Wattevah...

                          Comment


                            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....
                            Wattevah...

                            Comment


                              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! )

                              Comment


                                Re: Remote pump control ideas.

                                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...
                                Wattevah...

                                Comment


                                  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

                                  Comment


                                    Re: Remote pump control ideas.

                                    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...
                                    Wattevah...

                                    Comment


                                      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!

                                      Comment


                                        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
                                        Wattevah...

                                        Comment


                                          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 Files
                                          Wattevah...

                                          Comment

                                          Working...
                                          X