CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

interfacing PIC18F with solenoid valve

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alimary1988



Joined: 04 Sep 2012
Posts: 5
Location: Rome

View user's profile Send private message

interfacing PIC18F with solenoid valve
PostPosted: Tue Sep 04, 2012 2:52 am     Reply with quote

Good morning,
I am trying to use a PIC18f46j50 to control a solenoid valve. You can find details of the valve here. Its a Solenoid Valve with 5 V control signal.

http://www.theleeco.com/EFSWEB2.NSF/51afc74e7f2112c9852563a9005db170/90ec02848de7db99852574350067cbdf!OpenDocument

In my project I have a pressure sensor that measures the depression inside a chamber. The analogic signal from the sensor its converted with a MAX128 and sent with I2C to the PIC that will send datas serially to the computer.

When a certain depression is monitored from the PIC, I want the valve to open.

My questions are:

1) How should I interface the solenoid valve with the PIC?

I have found this schematic
[img]
http://farm6.static.flickr.com/5143/5659349985_fe4cc2f631_m.jpg
[/img]

In the picture the solenoid is at +12V, but in my case would connect it to 5V. Can this work?

2)
In particular the PIC18F46J50 has some special pins that will allow voltage to reach 5V. So, if using this schematic, can i Open/Close the solenoid with a simple output_high() command to that pin, once the ADC reads a certain value of pressure??


Thank you so much.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Sep 04, 2012 5:16 am     Reply with quote

1) The link you supplied shows me a 'latching' style solenoid valve, that requires you to send a pulse of current to open and a reverse current to close. As such the schematic you've also linked to will not operate the valve correctly.It'll only work once.

You require an 'H-bridge' style interface which can be made from either 3 relays,4 transistors or an IC.

What is NOT specifically stated in the spec sheet is the current demands for the valve(unless I missed reading it ...)

If this is a one-off-project, transistors will be the cheapest though an IC may be easier to use depending on required speed of use.
Remember that the valve only requires a 'pulse' to work, so the bridge needs to be left in the hi-impedance mode after the command is sent otherwise you risk destroying the valve. Similar circuits are used for model train switches,overhead highway signage,etc.

hth
jay
alimary1988



Joined: 04 Sep 2012
Posts: 5
Location: Rome

View user's profile Send private message

Thank you
PostPosted: Tue Sep 04, 2012 5:35 am     Reply with quote

Thank you for your reply Actually the datasheet doesnt say the current required but it gives the pover consumption that is (5.5 mW-sec/Switch)
.
Can you tell me more on how using a H-Bridge and then interfacing with the PIC?

What IC do you refer to? I need the valve to open not just ones but several times. I am not good at these things so please can you give me more indications?

thank you

I have found this IC :
http://www.allegromicro.com/Products/Motor-Driver-And-Interface-ICs/Bipolar-Stepper-Motor-Drivers/A3966.aspx#Q8

will this be ok?? but how the to use it with pic? thank you
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Sep 04, 2012 7:55 am     Reply with quote

Hi,

temtronic has given you some good information. It looks to me like that
solenoid has two electrical connections. It appears that if you connect
+5V in one direction momentarily, the solenoid will assume a given state,
and then latch that state. Likewise, if you connect +5V in the other
direction momentarily, the solenoid will assume the opposite state, and
then latch that opposite state.

You can easily perform this function with a PIC using a single DPDT relay
to control the polarity of the 5V being applied to the solenoid, and a
single MOSFET acting as a low side switch to control when GND is applied
to the solenoid (in either polarity). You would use two I/O pins on your
PIC - one to control the polarity switching relay, and one to switch the
MOSFET. If that's enough, great, otherwise send me a PM with your email
address, and I'll make a simple schematic to illustrate this technique.


John
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Sep 04, 2012 8:05 am     Reply with quote

OK.
First, the 46J50, has pins that will accept 5v _inputs_, not drive 5v outputs.
However even if it was a 5v PIC, you would not want to connect a coil like this to the chip directly.

The key point here is that the coil need s pulse of current in one direction to move it one way, and a pulse in the other direction to move it the other. Exactly like a motor, except the pulse only needs to be 'on' for a moment.
Look at the MPC17511A H bridge driver. This is a complete driver IC, which accepts a 'logic' supply down to 2.7v (ideal for your PIC), and a main switching supply up to 6.8v (5v is what your valve wants). It contains the complete H-Bridge circuit.

All you need do, is effectively set the motor 'forwards', for a few mSec (10mSec) - since this is the maximum needed, then switch to the 'tri-state' mode (turns off the bridge). To move the valve the other way, you select 'reverse', again wait 10mSec, and again select the tri-state mode.

The 'point' about the H-bridge, is that it is effectively four switches. You turn on the 'high' switch on one side of the device you want to drive, and the low switch on the other, to give current flow in one direction. Turn on the opposite high/low pair, and current flows the other way. Hence the ideal combination to give forward/reverse on things like motors, or to move valves like this. Obviously you need to ensure that the high and low on the same side are never on together.

You could do it fairly easily with four FETs, protection diodes, and a couple of level shifters, but the complete IC is a lot simpler/cheaper....

Best Wishes
alimary1988



Joined: 04 Sep 2012
Posts: 5
Location: Rome

View user's profile Send private message

another option......
PostPosted: Tue Sep 04, 2012 8:33 am     Reply with quote

I have also found this other valve

http://ph.parker.com/webapp/wcs/stores/servlet/Product2_10151_12051_12169_-1_14107_14107_14097_ProductDisplayErrorView

It is a NO 2 Ways valve that can be operating at 3 V. It simply needs the application of 3 V to be closed and 0 V to be opened.

will i be able to interface this directly with the PIC18 instead?

thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Sep 04, 2012 9:44 am     Reply with quote

No.
Same comment as above (even if it was a 5v PIC, you would not want to connect a coil like this to the chip directly).

Doing so, is a pretty sure way to kill a PIC output.

However with this one, you could just use a single FET, and a trap diode. Difference is though _power_. The original valves need a small pulse of power to move. This one needs a continuous feed. 0.5W, implies 166mA at 3v (PIC pin can deliver typically 25mA max), and this power needs to come from your supply. Do you want to/can you deliver this?. If so, this is much easier to drive.

Best Wishes
alimary1988



Joined: 04 Sep 2012
Posts: 5
Location: Rome

View user's profile Send private message

Ok...
PostPosted: Tue Sep 04, 2012 12:46 pm     Reply with quote

Yes i wish to deliver this supply since driving this valve will be really easier and i can actually drive it with this kinda of circuit
[img]
http://farm6.static.flickr.com/5143/5659349985_fe4cc2f631_m.jpg
[/img]

Any suggestion on supply?

Im really a newbie so any suggestion is open...Can i power everything with some batteries? or what are ur suggestions?

I am sorry i make very stupid and simple questions but im learning how to do all this and i really do not know where to start so I seek your wises advice in order to understand how to start moving in the projecting and designing
alimary1988



Joined: 04 Sep 2012
Posts: 5
Location: Rome

View user's profile Send private message

Ok dont laugh at me if i say something stupid
PostPosted: Tue Sep 04, 2012 1:01 pm     Reply with quote

Sorry maybe this can be a very stupid question...



If using this circuit when instead of 12 V i put the 3V supply of my valve
[img]
http://farm6.static.flickr.com/5143/5659349985_fe4cc2f631_m.jpg
[/img]

can't I use two different supplies for the PIC and the solenoid?
Like jsut for powering the solenoid couldn't i use a battery like this one: https://www.sparkfun.com/products/341

and then power the PIC separately lets say with another battery or with some wires?

or this thing its impossible to do?

Sorry for stupid questions and thanks for help
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Sep 04, 2012 5:01 pm     Reply with quote

your circuit:

R1=100 ohm
R2=10k

Q1 better be a damned nice sensitive gate , LOGIC LEVEL mosfet rated at LEAST 30V or better @ rated I (++)

regulate 3V down from solenoid supply or use appropriate HV family PIC

as 4 some other reason you cant use 5V PIC ??
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Wed Sep 05, 2012 11:34 am     Reply with quote

One thing you need to be very careful of - the data sheet for the valve does not show any protection across the coil. When you remove the drive from a coil (like in the valve) with a fast switch, you can get an inductive "kick" from the coil that may be in the 50 volt range as the field collapses. If you don't have some form of protection, that spike can easily fry whatever device is driving the coil. There are a number of ways to limit that spike - clamp diodes across the coil, limiting the rise/fall time of the switch (a small cap across the gate of the switch transistor will slow it down - not good for lots of fast switching, but for what you are doing, it could do the job) etc. If you are not careful with making sure the grounds are solid, you can also get a pulse back in the ground circuit causing all sorts of odd things to happen (inductive pulses and microprocessors are noted for strange resets and other odd "things" happening at apparently random times).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Sep 05, 2012 1:44 pm     Reply with quote

Quote:

protection across the coil.


rest easy - D1 in your circuit - PLUS the internal BP zener diode in a power mosfet are all the protection you need. your circuit will work fine w/o the modification issue Mikey alludes to.

of MORE value, for your circuit, would be adding a .1uF ceramic cap from
D1 cathode to GROUND .

' been doing this sort of thing for 40 + years, and have a drawer full of hardware t shirts'
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group