A logic gate chip with 1 ea XOR and 2 ea AND gates?


Closed Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default A logic gate chip with 1 ea XOR and 2 ea AND gates?

    I am using a PIC16F690 in an application which will control a valve solenoid. The solenoid requires reversing the polarity of the signal to latch open or latch closed the valve. I am using two output pins in the MCU to turn on or off two DPDT relays so that I can switch the polaritiy from a 9 v battery output to the solenoid: 1) MCU Pin1 turning on one relay that is Normally Open (NO) connects the +9 v to the redwire and GND to black wire of the solenoid...turning on the other relay that is NO connects the GND to the redwire and +9 v to the black wire.
    The problem I need to solve is how to make sure as a fail safe that both relays are never activated at once by the MCU when it may be going thru powerup or register settings, which means I need a logic circuit connected to the two PIC output pins with the following logic outputs to the relays so that only one of the relays can ever be turned on:
    Pin 1 Pin2 RL Output1 RL Output 2
    0 0 0 0
    1 0 1 0
    0 1 0 1
    1 1 0 0 'This state is the fail safe!
    I have determined the logic circuit to do this is a 2-input XOR gate with its output wired to one of the inputs on each of 2 AND gates, and the individual inputs to the XOR gate also connected to the other input of each of the AND gates. My question is, where can I find a single DIP IC chip that contains at least one, 2-input XOR gate and two, 2-input AND gates, which I can then wire up per above on my MCU circuit board?? I tried to find a CMOS chip that combined these different types of logic gates with no success. Anyone know where I can find one and the part number?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    jellis00, it is not clear how you have connected the two relays to the solenoid, but if you use the schematic attached you will have no fail safe problem.

    Al.
    Attached Images Attached Images  
    All progress began with an idea

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Most PICs power-up with the I/O's in Analog or Input Mode.

    If your first commands set the Relay I/O's to whichever the Failsafe state is, followed by the TRIS for those I/O's, you should not experience any problems.

    There is a gotcha here... that IF your I/O's are driving something like a ULN2004 or similar High-Current Driver, and you are using a Port with internal Global Pull-Up's (like PORTB on a 16F628), then the act of switching-ON the internal Pull-ups BEFORE you've set any I/O's to OUTPUT would be enough to flip them into an undesired state.

    So the rule is... immediately on Power-Up...

    1. Set your OUTPUTS to the desired High/Low state
    2. Disable any ANALOG
    3. Set appropriate TRIS for that PORT.

    Worst case scenario, is that Relays take a few mS to react, and if you mess up you might pulse the Relays with a few uS in the wrong state... theoretically, it shouldn't affect things... anyone with a Pacemaker please step forward for an experiment...

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default This is a scheamatic for PIC/RELAY/SOLENOID connection

    it is not clear how you have connected the two relays to the solenoid
    Attached is a schematic as to how I am connecting the PIC outputs to the RELAYS to control the SOLENOID via its RED and BLACK wires. This shoulld permit switching of the polarity to the RED BLACK wires depending on which control pin is active??
    I guess if I follow the steps from Melanie's email I can do this without inserting the 2XOR and Dual 2AND gates in between the two PIC control pins and the two relay coils??????
    Attached Images Attached Images  

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    This picture should be more clear.

    Al.

    Edit: picture is too small to see details, I attach a zipped one
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by aratti; - 26th June 2009 at 07:13.
    All progress began with an idea

  6. #6
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Have you ever tested or used your circuit with a latching

    aratti,
    Thanks for the schematic. Yours is a better approach than mine because it only requires two SPDT relays instead of two DPDT relays...cheaper! However I am a little concerned about whether "nothing happens" in your circuit for the state where both Relay 1 and 2 coils are turned on and both the Red and Black wires are connected to +9vdc. I am not certain what the latching solenoid does that I am looking at when both wires are high.
    Have your ever tested or used your circuit with an actual latching solenoid? If so what was your experience and can you refer me to the Part No. for the one you used??

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Latching solenoid are just a normal solenoid with the addition of a permanent magnet. When you connect the coil (Red to + and Black to 0) the magnetic field attract the iron core and when the core is in contact with the permanet magnet it will be hold without the need of the magnetic field generated by the coil. So to activate it you just keep the coil connected for a very short while.

    If you need to de-activate the solenoid, you will need to generate in the core a reverse magnectic field so that the core will be pushed away from the permanet magnet holding it. To obtain such a result you simply reverse the current flow into the coil, connecting the Red to 0 and the Black to + and hoops the solenoid has released the core.

    If you connect both wire to zero volts or both wire to +9 volts nothing will happen, and when I say nothing I mean it (no current will circulate at all), and the solenoid will keep is position. This is the max I can say to assure you.

    Have a nice day.

    Al.
    Last edited by aratti; - 26th June 2009 at 08:32.
    All progress began with an idea

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Instead of putting the battery terminals on the common of the relay, put the solenoid terminals on the common pins, and use a DPDT relay. Wire the N.O. pins with power and ground and wire the N.C. terminals opposite of the N.O. ones. With a DPDT relay you only need one control pin also.
    Tim Barr

  9. #9
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Question Will this schematic work like yours?

    Quote Originally Posted by aratti View Post
    This picture should be more clear.

    Al.

    Edit: picture is too small to see details, I attach a zipped one
    Anrati, I have designed the Relay Circuit for use with my 16F690 MCU as shown in the attached partial schematic. As you can see, pin RC2 controls one of the two SPDT relays and pin RC3 controls the other. I have purposely wired the ground from the battery rather than the positive terminal to the normally closed contacts on the two relays so that in case there is any leakage in the Solenoid_RED or Solenoid_BLACK wire circuits it won't drain the battery when the relays aren't actuated.

    Do you think this circuit will work? One of my concerns is finding a SPDT relay that can be operated within the 25 mA limit of the MCU output pin. Any suggestions where I can get one?Name:  MCU_Relay_Circuit.jpg
Views: 1818
Size:  31.5 KB

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi John,
    Why not just use an H Bridge to control your solenoid ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Do you think this circuit will work?
    Yes.

    One of my concerns is finding a SPDT relay that can be operated within the 25 mA limit of the MCU output pin. Any suggestions where I can get one
    See at this link they have reed relay @ 5V 10 mA.

    http://www.americanrelays.com/dip.pdf

    Al.
    All progress began with an idea

  12. #12
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    When I need a strange combination of logic gates that doesn't have to be exceedingly fast, I usually use a small PIC (12F series for example). Small, cheap and can be programmed to any function I need. The best part is that if I want to change something later, I can do it with programming instead of X-acto knives and little blue wires.
    Charles Linquist

  13. #13
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default h-bridge

    L293d

    tle 5205-2

  14. #14
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Question Right drive current...wrong drive voltage..any others?

    Quote Originally Posted by aratti View Post
    Yes.



    See at this link they have reed relay @ 5V 10 mA.

    http://www.americanrelays.com/dip.pdf

    Al.
    My 16F690 MCU is operating at 3.3 vdc. Therefore I need a relay (SPST or SPDT) whose coil voltage is 3.3 vdc with a coil resistance of 132 ohms or more, and a contact rating for 1 Amp when switching and 0.5 Amps when closed:
    3.3 vdc/.025 ma = 132 ohms
    Do you know of any sources? I have looked high and low with no success...most have coil resistances that require drive of 50 mA or more which is above 1-pin drive capabilty of the 16F690 and I didn't want to have to use more than one pin to trigger the relay.

    I have read that many of the 5V reed relays will still operate at 3.3vdc. What do you know about this?

    I appreciate your help. I am going to investigate the suggestion to use an "H-Bridge", but I know nothing about them. Can you point me to any good tutorials on H-Bridges for controlling solenoids that require more current than a PIC will provide?

  15. #15
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default solenoid valve model #

    what is the model # of your solenoid valve ?

  16. #16
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    I appreciate your help. I am going to investigate the suggestion to use an "H-Bridge", but I know nothing about them. Can you point me to any good tutorials on H-Bridges for controlling solenoids that require more current than a PIC will provide?
    http://www.mcmanis.com/chuck/robotic...t-circuit.html
    http://www.cadvision.com/blanchas/hexfet/np-s.htm
    http://www.4qdtec.com/h.html
    The simplest 4 transistor h bridge:
    http://library.solarbotics.net/circu...arHbridge.html
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  17. #17
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Answer: Model of solenoid valve in our design

    Quote Originally Posted by bogdan View Post
    what is the model # of your solenoid valve ?
    bogdan,
    Our PIC microcontroller must control a latching valve solenoid, Model L 1/180 1/4"x1/4" as described at http://www.giplindia.com/pdf/water-valve-catalogue.pdf . Here is a description from this document and why we think it is the right choice for use with a microcontroller and battery operation. BTW, why do you ask?
    "Brief Design Guide:
    􀀹 Life of battery (1.5 V DC X 4 Nos. alkaline) is about 250 000 cycles (only valve
    operations).
    􀀹 Latching valve operates upto 5 V DC, 60 mS pulse. Hence cicuit should have cut off
    voltage or battery low / replace battery indication sutabley.
    􀀹 It is prefered to mount latching valve in coil up right position.
    􀀹 As supply voltage goes higher pulse width decreases.
    􀀹 40 mS pulse is optimum pulse width for valve operation from CLOSE to OPEN
    position. For OPEN to CLOSE pisition, pulse width of 20 mS may be kept. This will
    maximize battery life.
    􀀹 Circuit employed in operation of valve should be of high quality and should have
    minimum current consumption in stand by mode to maximise battery life.
    􀀹 Test figures mentioned in this document is based on 6 V DC obtained using 1.5 V X 4
    Nos. alkaline batteries."

  18. #18
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default My current approach using H-Bridge solenoid control??

    Joe: I studied the H-Bridge circuit and I can see now why it is probably the preferred choice for microcontroller use with motor control, and I presume it can be applied in same manner for controller of latching solenoids. Therefore, I have redone our design as shown in the attached schematic, in which we propose to use a ROHM H-Bridge IC model BD6211 or BD6221, depending on what battery voltage we select for solenoid control (see http://www.rohm.com/products/databoo...x_series-e.pdf for data sheet). This IC can be purchased for $1.50 USD at Mouser and greatly reduces the cost and simplifies the circuit layout as compared to using relays. What is your opinion of this schematic?....will it work to control the latching solenoid without fear of "shoot through" during startup of the MCU while it is being initialized and the MCU pin logics are not yet stabilized? At this point that is my only concern about using the H-bridge for latching solenoid control.
    Thanks so much for this tip!
    Attached Images Attached Images  

  19. #19
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default clamp diodes

    ..the clamp diodes are missing...

    I think is easy with L293D (internal clamp diodes)...if you combine the channels you have Peak Output Current=1.2A (check the specs of the solenoid)

    If you need more current use TLE 5205-2 (peak=6A)

    Both of the items should be at mouser.com

    ...please check also this tutorial to understand better the h-bridge circuit http://www.robotroom.com/HBridge.html

  20. #20
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Question Comparison of L293D and DB6221

    Quote Originally Posted by bogdan View Post
    ..the clamp diodes are missing...

    I think is easy with L293D (internal clamp diodes)...if you combine the channels you have Peak Output Current=1.2A (check the specs of the solenoid)
    ]
    Granted I forgot the external clamp diodes, but I can't see why you think using the L293D is an advantage over the Rohm BD62x1. Here are compairsons that appear to favor the BD62x1:

    Operating range: BD62x1 will run with Vss 3 to 36 v; L293D is 4.5 to 36. This is important to me since my board supply is 3.95 vdc (3 ea AA NiMH batteries);

    Quantity 1 price at Mouser: BD62x1 = $1.50; L293D = $5.12....even adding the 4 ea clamp diiodes (1N4001??) BD62x1 approach is a lot cheaper;

    Low Stanby current: BD62x1 has standby mode = 10 microAmps; L293D has quiescent current total (Vss + Vx) of at least 18 milliAmps dey pending on logic setting.....this is too high for battery operation.

    Based on above comparison I wouldl really appreciate your opinon as to why the L293D is preferable. ???

  21. #21
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Looks like BD622x chip also has internal clamp diodes

    Quote Originally Posted by jellis00 View Post
    Granted I forgot the external clamp diodes, but I can't see why you think using the L293D is an advantage over the Rohm BD62x1. Here are compairsons that appear to favor the BD62x1:

    ???
    Taking a closer look at the Rohm data sheets for their BD622x chips, it appears they also have internal clamp diodes, making it a further advantage for the BD622x1 over the L293D. The chip diagram from data sheet is in the attached image. Am I mis-interpreting this image??
    Attached Images Attached Images  

  22. #22
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Sorry for the delay, my ISP is sooooo lame!
    Lots of HBridge chips out there, allegro makes a bunch of them, It trumps relays due to cost, reliability, size and they look better too even discrete transistors are still cheaper, smaller, and more reliable, though mosfets might be better than junction types.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts