abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 10:42 am

hello!
i am using raspberry pi to send a signal to ULN2803 (input) and on the output side i want to control 24VDC valve(on off with 10sec delay)
i want to know the connection and if there is anything else which is needed to control the valve.
thank you

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 11:35 am

The first question you need to ask is what current does the 24vDC solenoid valve draw ?

The ULN has a maximum current of 500 mA per channel, so how you connect it will depend on how many channels you need to sink the current of the solenoid valve.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 11:40 am

hello!
thanks for the response.
Valve draws 333mA at 24VDC.

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 12:04 pm

So you only need a single channel per valve.

Not at home on my pc at the moment , will draw you up a diagram latter today when I return home.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 12:06 pm

thank you so much i will be waiting for it

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 1:35 pm

i am following this circuit diagram but i am getting no results.
https://www.robotics.org.za/image/catal ... yout02.jpg

danjperron
Posts: 3404
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 1:41 pm

Use a multi-meter and check if the input toggle and then check if the output toggle also.


GPIO for IN 0 at = 0 What is the ULN2803 Voltage at the In and Out pin?
GPIO for IN 0 at = 1 What is the ULN2803 Voltage at the In and Out pin?

Are you using Python? did you set your GPIO to be output ?

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 1:56 pm

hello
yes i have checked GPIO pin is sending a perfect signal.
i am using physical pin 29 (GPIO 5). here is the code:

Code: Select all

import RPi.GPIO.as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(29,GPIO.OUT)
while True:
	GPIO.output(29, True)
	time.sleep(10)
	GPIO.output(29,False)
	time.sleep(10)
[code/]
i have connected wire as:
GPIO physical pin 29 of RPi to in1 of ULN2803A
GND of RPi to pin 9 of the ULN2803A
+24Vdc to pin 10 of ULN 2803A
+24Vdc to pin 18 of the ULN 2803A
one wire of valve to pin 10 and other wire of the valve to pin 18 of ULN 2803A
if i have done something wrong in wiring in point me that mistake.
thanks

ddahms
Posts: 67
Joined: Tue Mar 18, 2014 3:38 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 5:08 pm

The "+24Vdc to pin 18 of the ULN 2803A" connection should be removed. Additionally you must attach the other wire from the +24V supply to the "GND of RPi to pin 9 of the ULN2803A" connection that you already made.

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 6:08 pm

so i should not provide any any +24V to COM pin 10?

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 7:13 pm

So this is how you should connect your valve to the ULN2803A

Image


you program is set for board mode so shown connected to correct gpio pi, you also need to have the 24V DC connected to the ULN2803A to allow the in built back emf diode to work, which will protect the chip from the back EMF generated by the valve coil when power is removed.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 7:29 pm

Thank you so much.
i have tried this scheme also but valve is not reacting and also when i check the voltage output with multi meter from pin 18 of ULN2803A its always 0.

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue Apr 10, 2018 7:38 pm

The ULN2803A provides a ground to what ever device you are trying to control.

so you need to supply 24V DC to your valve then connect the - or ground terminal on the valve to the O1 pin on the ULN2803A.
then when you apply a high to I1 the O1 will be connected to ground so activating your valve.


This is how my diagram show you should have thins connected.

Image

you can prove the ULN2803 is working be connect a meter between 24V DC + and O1 on the chip it should read zero until you set I1 to high then you should read 24v

Is you chip a ULN2803A the A is important as it signifies you can drive the chip with 3.3v
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Wed Apr 11, 2018 8:02 am

yes, i am using ULN2803A.
and i tried the same circuit but there is no output. GPIO 5 pin is connected to input 1. and multimeter is showing 3.3V and 0V simultaneously as it it is programmed. but output is zero.
there is one strange thing when i am connecting COM pin with 24V my DC power is going into C.C mode from C.V mode.

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Wed Apr 11, 2018 9:47 am

Are you sure you have this connected correctly ?

May be you could post some pictures so we can check just in case you have made a silly mistake.

EDIT......

so just tested this myself using 12v DC as I don't have a 24V supply.

my correctly connected setup. yellow cable is 12v supply connected to + rail on the right ground being on the left.

Image

did find a couple of errors in your code so corrected them and added a couple of print statements

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(29,GPIO.OUT)
while True:
    GPIO.output(29, True)
    print "on"
    time.sleep(10)
    GPIO.output(29, False)
    print "off"
    time.sleep(10)

you can see my set up running here https://youtu.be/DfdH5Sv4VP4
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Wed Apr 11, 2018 12:46 pm

this is how i have connected the circuit.
check the attached image
Optimized-Optimized-unnamed (1).jpg
Optimized-Optimized-unnamed (1).jpg (142 KiB) Viewed 3022 times

abusaeedmirza
Posts: 66
Joined: Tue Mar 06, 2018 3:02 pm

Re: how to control 24VDC valve with ULN2803A?

Wed Apr 11, 2018 1:02 pm

thanks its working now.
:D cheers

RaspNew01
Posts: 5
Joined: Tue May 28, 2019 10:49 am

Re: how to control 24VDC valve with ULN2803A?

Tue May 28, 2019 11:00 am

Hello everyone,

first of all thank you for sharing your project and giving some hints how to realize it. I have to some extend a very similiar setup, but it won't work. To figure where my mistake is, I would very appreciate if someone can take a look my work (pictures attached).

What did i do wrong?

The aim here is to control 8 relays with 24VDC and an ULN2803A. I am new to this and happy for any comments.

Thanks in advance.

Best
Dennis
Attachments
photo5433801450066127520.jpg
photo5433801450066127520.jpg (132.47 KiB) Viewed 1991 times
photo5433654420450683577.jpg
photo5433654420450683577.jpg (106.25 KiB) Viewed 1991 times
photo5433654420450683575.jpg
photo5433654420450683575.jpg (155.62 KiB) Viewed 1991 times

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue May 28, 2019 12:31 pm

Well apart from the soldering not look particularly good , nothing jumps out as being wrong with what you have shown in your images, except you have not connected the 24V+ to the ULN2803A to enable the protection diodes to work and protect the chip from the reverse voltage spikes from the relays.

Image

You may find your chip has been damage due to not connecting the 24v+ to it.

May be the problem is with the pi end or even your software, have you tried checking that you are actually driving the inputs high using a meter set to volts and connected between ground and each input on the chip,
then you can do the same on the outputs connecting your meter between 24V + and each output pin on the chip.

You might also post some pictures on the wiring at the pi end and your program that's driving the gpio pins.

When trying to solve problems like this I always like to write a simple test program that will drive each of the gpio pins in question high for
30 seconds so you have time to do your testing.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

RaspNew01
Posts: 5
Joined: Tue May 28, 2019 10:49 am

Re: how to control 24VDC valve with ULN2803A?

Tue May 28, 2019 1:49 pm

Hello pcmanbob,

thank you very much for your fast reply. i didn't programm anything yet so far, I just wanted it to work first, hence I am using Python to controll the gpio's directly. The board is connected to the GND PIN 9; GPIO 5, 6, 13, 19, 26, 16, 20 and 21.
have you tried checking that you are actually driving the inputs high using a meter set to volts and connected between ground and each input on the chip,
then you can do the same on the outputs connecting your meter between 24V + and each output pin on the chip.
What I did is checking with the Benning Duspol expert, if everything is correctly connected, but that's not what you suggest, isn't it? So I would have to use a multimeter? Or could i use the Duspol, turn on the whole system and check, whether the flow is correct? (as you can see, I have a lot to learn)

I thought I did connect the common on the ULN2803A (-> attached picture)

Could it be that my resistor network is broken? Can it be broken?

Thank you very much in advance.
Attachments
photo5433654420450683575.jpg
photo5433654420450683575.jpg (189.84 KiB) Viewed 1964 times

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue May 28, 2019 2:49 pm

OK so I missed that you had the 24v connected not easy when you are trying to match up pictures.

I have no idea what a Benning Duspol expert is ;)

You could test the ULN2803A which is eight NPN darlington pairs and not a resistor network if that is what you were thinking.

So to test the ULN2803A

1. remove all the wires that go to the pi at the pcb end.
2 connect a cable to the 24v+ screw terminal on the pcb, with the other end having just a few mm stripped.

Image

now with the 24v supply on connect the stripped cable end to one of the input pins were you had the pi connected
( do not connect it to the earth pin ) you should have the corresponding relay turn on if the chip is ok and your relay is connected correctly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
ptimlin
Posts: 88
Joined: Tue Jan 08, 2019 7:44 pm

Re: how to control 24VDC valve with ULN2803A?

Tue May 28, 2019 8:47 pm

Just a design note that I think is important to know when working with the ULN2803A and others driver ICs of the same types (ULN2003, etc.) which I don't think was mentioned in this thread the first time around and worth mentioning since the new poster is wanting to drive 8 relays with a single IC.

These types of driver ICs sink current to the GND pin of the device. So when, for example, you apply +V to Pin 1, Pin 18 goes low and whatever it is connected to that pin allows current into pin 18 and sinks to the GND pin 9. Now say you have two things you are driving. You apply +V on pins 1 and 2 which drives pins 18 and 17 low. Current enters pins 17 & 18 but the combined current sinks to the single pin 9 GND pin. While there might be 7 or 8 channels per IC there is only one GND pin per IC.

So what does that mean? Well you look at the data sheet and it states "500-mA-Rated Collector Current (Single Output)" and yes you could sink 500mA into pin 17 or pin 18. However the problem is the single GND pin 9 has a limit of how much current you can sink through it for the whole device. If you read the absolute maximum ratings of the IC it states "Total substrate-terminal current –2.5 A" which means, max current out of the GND pin is ~2.5A. And to be safe you probably want to keep it at no more than about 80% of that value, which is a 2A limit. Averaged over the 8 channels, this gives you roughly ~250mA per channel. So you need to keep this in mind when driving 8 loads on that IC and if there is any chance than you might have all 8 sinking current at the same time. You could wire up 8x 500mA loads, but only if you know that no more than about 3 or 4 of them will be sinking current at the same time. If all 8 come on at the same time you could very well wreck your drive IC, so add up your loads (relay coils, solenoids, etc.) and make sure they don't exceed the GND pin rating. If they do you may want to use 2 or 3 ICs even if you have 8 or less loads.

RaspNew01
Posts: 5
Joined: Tue May 28, 2019 10:49 am

Re: how to control 24VDC valve with ULN2803A?

Tue Jun 18, 2019 7:51 pm

Thank you guys so much for the fast replies. I will first have to figure out what all those information mean, but I will try to test my setup.

Actually all the components I am using are new, so I should not have a problem with the Chip isn't it? Propably you never know till you test it :D

Also I am using the A102G resistor network?? -> https://ae01.alicdn.com/kf/HTB19JoTXznu ... uzFXa7.jpg

Do I actually need it? Or is that obsolete?

Thank you again very much in advance.

pcmanbob
Posts: 7069
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: how to control 24VDC valve with ULN2803A?

Tue Jun 18, 2019 8:40 pm

I don't see what you think you need the resistor for.

The pi gpio drives the input pins on the chip directly, and the output pins on the chip provide the ground to what ever device you are trying to control.

In the diagram I posted on this thread there are no resistors what so ever.

Edit.

Looking at you pictures again you appear to have the resistor array connected across the gpio inputs to the chip this will short all the gpio outputs together so any pin trying to send a high to the chip will be shorted to every other gpio pi , any that are set low will prevent the high from reaching the chip.

So nothing will work.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

RaspNew01
Posts: 5
Joined: Tue May 28, 2019 10:49 am

Re: how to control 24VDC valve with ULN2803A?

Wed Jun 19, 2019 8:20 pm

Hello pcmanbob,

thank you for your fast reply. This is great info. So basically all the problems stem from the resistor.

Ok I will do It again, this time leaving the resistor array away.

Thank you a lot, I will come back with the results.

Thanks again!

Return to “Automation, sensing and robotics”