Connect with us

Detecting solenoid ON and OFF state

Discussion in 'General Electronics Discussion' started by Prakash123, Jun 23, 2016.

Scroll to continue with content
  1. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    I want to detect solenoid ON and OFF state.
    If solenoid ON, with respect to HIGH signal no problem.
    If solenoid not working means with respect to HIGH signal, solenoid remains OFF state. In that situation I have to generate HIGH or LOW signal.
    So I designed a circuit with XOX gate attached here.
    I have to detect 128 solenoid ON/OFF state.
    My question is, this circuit is will withstand for 128 solenoid?
    If not means any other solution?
     

    Attached Files:

  2. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    Your "contact point switch" already provides an "active low" signal indicative of the solenoid state. The exclusive-OR gate does nothing except invert the switch signal, which an inverter would do with less complexity. What are you trying to DO with the other 127 solenoids? Do you want to determine when any of the 128 solenoids fails to actuate? Is there a logic signal available to signal when a solenoid is supposed to be actuated? Do you want to logically combine the two signals, one from the contact point switch and one that indicates the solenoid is supposed to actuate, to create an output that indicates the solenoid failed to actuate? Do you want to do this independently for all 128 solenoids, or is it sufficient to indicate when any of the 128 solenoids fails to actuate without concern for which one failed? Are each of the 128 solenoids independently actuated, or does one signal command all of them actuate? More information, please. Tell us what you are trying to DO.
     
    Prakash123 likes this.
  3. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Hi,
    Thanks for your questions. You just simplified my all doubts. I have to improve my question asking skills because I'm new to online forum.

    Yes, I want to determine when any of the 128 solenoids fails to actuate.
    Yes, there is a logic signal available, when a solenoid is supposed to be actuated.
    Yes, I want to create an output that indicates the solenoid failed to actuate.
    Not independently for all 128 solenoids, any of the solenoid failed means I want a single signal.
    Each 128 solenoids has to be actuated independently.

    See my second circuit and give your suggestion. Why I checking solenoid state means, any how it may not work in some instances. At that time I have to stop this process.
     

    Attached Files:

  4. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    You need to replace the exclusive-OR gate (XOR) with an open-collector NAND gate. If the solenoid command from the microprocessor is high, indicating the solenoid should operate, and the switch subsequently fails to close, then the NAND gate output will be low, indicating an error condition.

    All 128 NAND gate outputs should be connected together in a wired-OR configuration, so if any NAND gate output goes low, then the wired-OR connection goes low. A single pull-up resistor is sufficient for all 128 wired-or connections.

    You should examine the wired-OR output from the 128 open-collector NAND gates with a microprocessor and generate a software timed delay when it goes low. If it is still low after the time delay then you can signal an alarm event. This delay is absolutely necessary because a finite time interval exists between when the microprocessor output controlling the solenoid goes high to command the solenoid to actuate and the associated switch actually closes. During this time interval both inputs to the NAND gate will be high and its output will be low, which is a false alarm if the switch eventually closes a few milliseconds later.

    So, look for the wired-OR NAND gates output going low, but wait a sufficient interval of time to allow the switch to actuate before declaring an error has occurred. You could do this time delay with external hardware by using a re-triggerable one-shot and more logic, which would prevent the microprocessor from having to respond to the "false alarms" that will occur each time any of the solenoids is actuated. Problem with that is what happens when a lot of solenoids are going on and off more or less at the same time? A lot depends on how fast you want to cycle power to the solenoids as to what circuit you would use to prevent false alarms.
     
    Prakash123 likes this.
  5. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Very very thank you.
    For this I lost so many days and thought lot of complexity technique including multiplexing, flip-flop so and so. And this one is very very simple one you gave.
    I learned new one "Open-collector NAND".
    Genius ahead of all.
    Again and again very very thanks.
     
  6. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Hi,
    Can we use open-drain NAND gate?
    If not means why?
     
  7. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    Sure. Same principle applies. Are you considering using CMOS logic? It should work the same way as TTL with somewhat better noise immunity. The important thing you need to remember is that time delay from when you actuate the coil of a solenoid to when the switch closes. During this short interval (a few milliseconds) the NAND gate will generate a "false positive" until the switch closes. You need to ignore that "false positive" each time you actuate one of the solenoids, using either circuitry or software... your choice.

    Personally, I would opt for circuitry to offload the work on the microprocessor, but it is easy enough to incorporate the time delay in the routine that actuates each solenoid. You could poll the wired-OR NAND gate output in software, say every hundred milliseconds or so, and maybe require two or more polls returning the same result before declaring an error condition. Depends on how critical and timely the recognition of failure must be. Also, since you are looking for failure in any one (or more) of 128 solenoids, you could duplicate and parallel the inputs of a second NAND gate for each solenoid, but use an LED in the output of the second NAND gate to visually indicate where failure occurred.

    That's a lot of wiring for 128 devices, but you could build a small circuit board that contained quad NAND gates (two of which are unused... be sure to ground inputs if CMOS) and an LED, plus the solenoid driver for each solenoid and mount that board near or on the solenoids. Then you would have four wires to connect from the microprocessor to each solenoid: power, ground, command, and wired-OR output. Might be able to get away with unshielded cable for this, but make sure the microprocessor can drive the distributed capacitance in the cable for the command signal. How far are the solenoids located away from the microprocessor?
     
    Prakash123 likes this.
  8. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Yes, I'm using all CMOS IC's.
    OK I'm beware of giving time delay using trial and error method to find find out time delay.
    In-between the solenoid and PIC18F87K22 there will be 3 meters distance.

    To control I use D-f/f connected to solenoid via transistor buffer or IC buffer. Still confuse to selecting this.
    From controller to D-f/f, 74HC541(Buffer) is used. Output of buffer is connected parallel to 16 D-f/f(See fig). To control or giving clock pulses to 16 D-f/f, Decoder-74HC154 is used.
    From fig it is necessary to use pullup resistors in all or not. If yes or no give suggestion where to place. Because I have to implement it in real time.
     

    Attached Files:

  9. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    This appears to be very conservative design. I can't tell you whether all those pull-up resistors are necessary or not, but probably not. All the devices (including the PIC) have active totem-pole output capable of sinking or sourcing at least 4 mA of current with a 5 V supply, which means pull-up resistors are not required. However, if you lay out your circuit board as if all of them are required, you can then populate the circuit board with whatever is found to be necessary. Ten thousand ohm pull-up resistors to +Vcc will usually be sufficient for CMOS.

    How you drive each solenoid depends on the current and voltage requirements of each solenoid. Can you provide us with that information?

    Your decoder operation may be suspect because of setup time considerations for the four address bits. The decoder outputs are active-low, so it is guaranteed that one output will be low for any address combination. When the address bits are simultaneously changed by the PIC to address a different block of sixteen solenoids, there may be decoder outputs that briefly go low and then high again before the address is fully stable and decoded. The result will be that other (incorrect) D-flops will be clocked in addition to the correct D-flop. Not a good idea if the intent is to change the state of just one set of flip-flops.

    If I were designing this, I would use two octal inverters to make the decoder outputs active-high instead of active-low and then use one of the two active-low enable inputs to toggle the selected output off and then on again. So, initially, all the outputs are high while the active-low enable input is high, and after the inverters the clock inputs to all the D-flops are low. The PIC presents a new address to the decoder and waits one instruction cycle for the address bits to stabilize. Then the PIC make the active-low enable input low, which will cause the output for the selected address to go low and the clock input (after the inverter) for that flip-flop to go high, clocking the flip-flop on the rising edge. Then on the next instruction, the PIC sets the active-low enable input high again, which will cause all the decoded outputs to go high and the inverter outputs to go low. The non-selected outputs are already low, so no artifacts are introduced. Each time you change the address you get a single low-high-low pulse on the decoded output. However, if you have already built and tested your circuit and the artifacts that I described do not occur... never mind!
     
    Prakash123 likes this.
  10. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Thanks a lot lot lot again. I just taken the logic as it is. It would not fail in simulation. But in practical there would many chance to fail. I testing under only in simulation. I didn't focus deeply on your last post about clocking in simulation and now only I realize the problem.

    OK, I'm populating where I've to use pull-up resistors.

    Coming to solenoid I've to make new design in small size. Which want to pull with low force like normal 6V or 12V relay.

    Again thanks for decoder design.

    Any problem in 3 meters distance?
     
  11. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    The problem with simulation is accuracy. The real world exhibits skew when two or more digital variables, like PIC outputs, change "simultaneously". Even on your best day there can be enough propagation delay in logic elements and wiring to create "glitches" or momentary states that lead to undesirable results when bits that are supposed to change simultaneously and instantaneously instead behave like the real components they are.

    These can be extremely difficult problems to troubleshoot and find, and even more trouble to eliminate. It is best to anticipate what could happen if the timing of edge transitions are skewed and clocks are skewed, displaced in time from each other. The conventional way to do this is a two step process: make whatever changes in state are required, such as presenting a new address where more than one bit changes state, and then after a short delay act upon (clock) the new state. For your decoder this could be accomplished, for consecutive addresses, by ensuring only one bit in the address changes, a gray code implementation. However, this probably won't work for you since your PIC program will probably want to access each solenoid arbitrarily, and more than one bit will change from one address to the next address.

    You need to better define what you mean by "pull with low force" and there is no such thing as a "normal 6V or 12V relay". Relays with 6V and 12V coils come in all sorts of shapes and sizes from tiny reed relays drawing a few milliamperes of current to large multi-pole contactors capable of switching hundreds of amperes of current and requiring several amps of coil current to actuate. It is the same with solenoid actuators. All sorts of shapes and sizes are available. You need to specify what you intend to use and specify the coil current and voltage the solenoid requires. It would be nice to know the solenoid inductance too, and how fast and how often you intend to actuate and de-actuate the solenoid coil. All of these factors will help determine the solid-state switching circuit you need, and what you need to protect that circuitry from back emf created when the solenoid is de-energized.

    I don't think you will have any problems with 3 meters of cable if the coil driver electronics and the open-drain NAND gates are located at the solenoid. Just make sure the power wiring for the 128 solenoids has a large enough conductor (or conductors) to carry the current of all the solenoids being actuated at the same time. You should have a separate power supply and return for the solenoids that is separate from the command and logic return signals. It is okay to power the open-drain NAND gates from the same power as the solenoids, but provide a separate "digital logic" ground return from the gates back to the PIC outputs, and by-pass the NAND gate package at Vcc pin with a capacitor, size to depend on what kind of "glitch" the solenoid produces when it actuates.

    If you haven't picked a transistor for the solenoid driver yet, I would suggest using a 2N7000 MOSFET. The source connects to solenoid common (or return), the gate is driven directly with a CMOS output of your octal D-flop latches, the drain connects to one side of the solenoid coil (the other side connects to +V solenoid power), and you should place a diode across the coil to dampen back emf that occurs when the solenoid is de-energized.

    I strongly recommend that you breadboard at least part of your circuit: the decoder, one octal D-flop, and one solenoid driver. If you have a wide-bandwidth oscilloscope or a fast logic analyzer, attach probes to all eight D-flop outputs and look for glitches as you set an output pattern just once and then cycle through all of the remaining fifteen address combinations while changing the data sent to the nonexistent octal D-flops. You should write a test routine for the PIC that performs this test. If the outputs for the one octal D-flop on your breadboard remain stable while you vary the addresses and "data" sent to the fifteen non-existent D-flops you are probably good to go. But repeat the test using a different decoder output to clock the octal D-flop. If it continues to maintain its original data pattern while you address other decoder outputs, you are probably glitch-free and can add the other fifteen D-flops to the circuit.

    Good luck with your project! And could you tell us what you are trying to DO? That's a lot of solenoids, enough to create a simulated pin-ball game, probably! But I bet you have something else in mind.
     
    Prakash123 likes this.
  12. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Again and again I learning a new thing from you "two step process".

    Coming to solenoid, "pull with low force" and "normal 6V or 12V relay" see relay fig. I just want attached relay pull force, because I need to pull or push the contact rod to at least 0.5cm. Also want to decide solenoid voltage and current to fill above requirements. The shape may be any but the size would limit 1x1x1cm. And also space between solenoids as low as considerable.

    OK I'm separating power supply. But I can't understand "return for the solenoids that is separate from the command and logic return signals" and "provide a separate "digital logic" ground" these two sentences. What should I have to separate solenoids from command and logic return signals. If we couldn't interconnect grounds of two power supply, how to identify reference voltages OR I wrongly understand from your sentences!

    For solenoid driver I will take 2N7000 MOSFET.

    And at last I don't have any logic analyzer to see out puts. Normal visible outputs only I can take for my verification:(.

    This project is to implement in power loom to replace mechanical dobby. We changing common dobby mechanism to a little. For this I took solenoids to control. In our mechanism I'm controlling solenoid to pull or push.

    Thanks again.
     

    Attached Files:

  13. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    I have been fascinated with weaving for a long time, but have never tried to build even a hand-loom. So, I Googled some information on dobby looms and their advanced enhancement, the Jacquard loom. A computer-controlled dobby loom is a common thing, but usually only a maximum of 24 harnesses or dobbies with their attached heddles are implemented. Are you going to have 128 harnesses? That's a lot of dobbies! I am suspecting you really want to control 128 heddles independently like Jacquard did with his paper-tape programmed loom. The image below (copied from this Wikipedia web page) of Jacquard gives some idea of the complexity of weaving patterns you can produce if you can control each weft thread (or groups of weft threads) with each pass of the shuttle. Very few of these silk self-portraits were made, but it is said that Charles Babbage owned one, inspiring him to use punched cards to "program" his analytical engine. Said cards were the precursor to 80-column by 12-row Hollerith cards popularized by International Business Machines (IBM) at the beginning of the 20th Century.

    [​IMG]

    The solenoid power supply and the logic power supply have separate commons, but they are connected together at just one point, generally by means of a small-gauge wire connecting the solenoid common to the logic common. Ideally, the solenoid return wire does not also serve as the logic return wire because any voltage drop in this wire caused by solenoid current will appear in series with the logic signal with respect to the logic power supply common. Hopefully, for the short distances and small solenoid currents you anticipate, this will not be a problem. If it were a problem, optically-coupled isolators could be used to separate the logic returns from the solenoid power returns. I would normally do this anyway since I don't like having the "real world" interact directly with digital electronics without the protection of optical or transformer isolation of input as well as output signals. But that's just my design philosophy. It's not cast in stone, so sometimes I will not use isolation to interface with the real world. It all depends on the specific application.

    I would imagine you are planning to drill a hole through the plastic case and weld or cement an actuator rod to the armature, said rod to somehow mechanically determine whether a dobby is raised or lowered. I would be interested in seeing a close-up picture of such a mechanism. Be aware that the armature moves through a short arc on a pivot, so your rod will move up and down as well as swing to and fro. Or did you plan to disassemble these relays and modify them?

    Years ago I had an idea to use solenoids to control when an overhead valve (OHV) cam in an internal combustion engine (ICE) opened and closed the intake and exhaust valves. The cam would provide the energy to "cock" the mechanism that opened the valves, but the solenoid would "trigger" the valve action. Thus the valve timing could be computer controlled according to the load demands placed on the ICE. Might be useful for high-performance engines used in racing, but operating the valves directly from the cams is so much simpler. Got the idea in the 1960s when I learned that "hot rod" builders replaced stock cams with special profiles to eek out more high-end performance. The idea never went anywhere, and AFAIK cars still use cam-operated intake and exhaust valves, relegating computer control to spark timing and fuel injector timing.

    Could you provide some photos of the dobby loom you will be modifying? Is this just a school project, or do you have a product in mind? There are plenty of computer controlled dobby looms on the world wide web to look at for inspiration. Apparently weaving is a world wide hobby right now. Maybe I will look into how American Natives do it. You can buy plenty of Navajo and Mexican tapestry if you visit the American West, but I wonder if upon close inspection I would find that many are made in India!:eek:

    Well, a 'scope is nice but if you add the second open-drain NAND gate in parallel with the wired-OR NAND gate, and use it to illuminate an LED when an error occurs, that might be all the troubleshooting assistance you need. Since the relay has some unused contacts, maybe you could use a pair of those to light up a second LED to see when a solenoid is actuated. Depends on how fast the loom operates as to whether or not you will be able to use these visual indications. At the very least the LEDs will make for an interesting visual display, especially if the loom is motor-driven with a flying shuttle.
     
    Prakash123 likes this.
  14. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Hi,
    I had to use the word "Jacquard" instead of "Dobby". I don't know, you know about jacquard,so only I used the common word dobby. Sorry about this:D.

    Coming to jacquard we normally use jacquard card. In market there is readily available electronic jacquard. That are expensive, so I decided to design a new one.

    Yes, I'm planning to drill a hole through the plastic molding. OK I'm well concentrating on this design.

    I know just only about car. In depth noooooo.... But you are a genius you know all.

    This project has to be implement in real time, so only I'm asking more doubts.:). Here for a street there may be 10 to 100's of power looms and hand looms are present.

    For a scope I thought of your idea of using LED.
     

    Attached Files:

  15. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    Thank you for the compliment, but I do not know all. I barely understand how a loom works, and have never actually seen or touched one, so my practical experience is non-existent with regard to looms. You are far more qualified to talk about this than I am.

    There is a 2008 movie, "Wanted" starring (among others) James McAvoy, Angelina Jolie and Morgan Freeman that I watched again recently, because of this conversation with you. It features a "Loom of Fate" whose "accidentally" misplaced threads in the weave pattern binary encode names of people. Yeah, riiight. A 1000 year-old fraternity of assassins is supposed to kill people whose names appear in the weave, "for the good of mankind". Not a believable plot, but the movie does show some close-up shots of a powered loom with a flying shuttle zipping across the warp threads about two hundred times per minute while "our hero" attempts to snatch the shuttle out with his bare hand. This exercise was all part of his "training" to become an assassin and avenge his father's death at the hands of a "rogue" assassin. Like I said, not a very plausible plot, but plenty of CGI and over-the-top cinematic violence.
     
    Prakash123 likes this.
  16. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Yeah, me too watched "Wanted" movie but not "Loom of Fate". There maybe like those facts in real world in some other life.
    Once I completed this project I will show you a visual demo of this machine.:)
     
    hevans1944 likes this.
  17. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    Nah, it's all just "comic book" fiction... or graphic novels as they are called today for an illiterate generation of "readers". The "Loom of Fate" is not a movie, it was a loom featured in the movie. Movie and the loom have no resemblance to the real world. It's just escapist entertainment. Harmless if no one takes it seriously.

    I got started in digital electronics using a 'scope, and even tried using a logic analyzer, but gave that up because it was more trouble than it was worth (to me). So an LED with a 330 ohm current-limiting resistor was my "first" digital logic probe.

    Later, someone in my lab at work purchased a Hewlett-Packard digital logic probe that measured both TTL and CMOS input levels.
    [​IMG]
    It displayed both high and low states as well as open-circuit, which was useful for probing tri-state outputs. IIRC, this thing would also generate narrow pulses at the push of a button, overriding whatever state was already there. That feature was very handy for toggling flip-flops.

    When I left that employer after graduating from college, the logic probe stayed behind of course. I could not, at that time, afford to purchase an identical model for home/hobby use, but I found several cheaper ones with fewer features and not as "pretty" as the Hewlett-Packard probe. Used them for many years, occasionally buying a new one whenever I misplaced an older one. They were pretty cheap. But my old stand-by, the LED+330Ω resistor, is what I still use if my logic probe isn't handy. Still, if you need to do some serious troubleshooting, and the digital signals are rapidly changing, a logic probe with so-called "pulse-stretching" capability, and perhaps a "memory" function, is a big help. You can make these yourself or purchase an inexpensive one online.
     
    Last edited: Jun 28, 2016
    Prakash123 likes this.
  18. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Ya you correct that's all become imaginary one.

    OK I'm trying to buy a Digital Logic Probe as soon. Already I started LED Probe.:D

    After this I'm trying to design a backup circuit to my circuit for 1 or 2 second to save current data in EEPROM. Presently I'm using 1000μF capacitor. It is sufficient now. This have to work for more days even a year but days passed means will the same capacitor give 1 or 2 seconds backup time. Or any other means give your suggestion.
     
  19. hevans1944

    hevans1944 Hop - AC8NS

    4,562
    2,135
    Jun 21, 2012
    I suppose you could write current data (whatever that is) to the EEPROM as often as the current data changes. An EEPROM is non-volatile, so when power is restored the last "current data" that you wrote to the EEPROM would still be there. Problem with that is if the "current data" changes a lot and rapidly, you will soon exceed the maximum number of write cycles allowed for the EEPROM. So a better way might be some external power management circuitry that detects when power is failing, triggers an interrupt to a routine that allows you to save "current data" to the EEPROM, and then gracefully shuts down the machine. How long all this takes depends on how much "current data" you need to save and how fast that data can be written to the EEPROM. You could, with the proper power management hardware and software, use a rechargeable lithium-ion back-up battery (instead of a capacitor) to keep the electronics running until the current data is saved in EEPROM and the microprocessor and the loom is shut down. You would also have to write some sort of recovery software to start everything up again without misplacing any weaving threads. Good luck with that, It boggles my mind how you would get the shuttle re-syncronized with the weave-in-progress if a power-fail shut-down of the loom occurs.
     
    Prakash123 likes this.
  20. Prakash123

    Prakash123

    25
    1
    Jun 23, 2016
    Yes, I want to restore the last data when power failure occur. I will use power failure interrupt to save current data to EEPROM. 3 Bytes would be stored and time taken is maximum 20mS.

    The thing you telling is correct but certain condition problem may appear. Please rectify me from below condition

    At certain situation for a long time loom will not ON and the battery become over discharge and battery go below low voltage, it will take time to recharge to get nominal voltage. Now loom will started running after a long time at below low voltage of battery. Within couple of minutes power will shut down without any notification. In that situation there is no enough voltage to save current data to EEPROM. The above power failure condition will arise normally here. But we use normal electrolytic capacitor means charging will occur quickly. For this reason only I mentioned 1000μF capacitor in last post.

    Is there any solution to overcome the above condition?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-