User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

0V to 10V output from the RPi

Wed Aug 27, 2014 2:38 pm

Hello guys,
Is somehow possible to output and adjust, from the RPi's GPIO pins, a voltage that can range between 0V and 10V?
I mean, is the I2C, SPI or any other connection able to do this?
My intention is to control a dimmable ballast for T8 lamps and a RAM fan array.
If I understand, should be possible to use a digital potentiometer via SPI or 1-wire or the Gertboard, but I really don't know where to start.

I would appreciate any input in this direction.
Thanks.
Last edited by dentex on Tue Oct 28, 2014 10:53 am, edited 2 times in total.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 2:45 pm

Hi,
dentex wrote:My intention is to control a dimmable ballast for T8 lamps and a RAM fan array.
PWM should be the first option if the attached devices can live with this control... what are the lamps and fans types (links to specifications always help) ?


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 3:20 pm

Hello.
Lamps are 2x15W T8 lamps by Sylvania, nothing special, apart the °K temp.
The ballast would be following one (looks like I can also connect 2x15W lamps, but I'm not 100% sure, because their p.numbers don't match):
http://assets.sylvania.com/assets/Docum ... 9c635e.pdf

The RAM fans are the Dominator Airflow back from 2007 or 2009, so I don't have any datasheet.
http://tapatalk.imageshack.com/v2/14/08 ... e15965.jpg
http://tapatalk.imageshack.com/v2/14/08 ... 05dbf0.jpg
They are currently powered on, as I write, with a 3V/4.5V/6V/7.5V/9V/12V Adjustable Adapter and they change the rotation speed according to the provided V.

What I was thinking is that if I find the way to provide this adjustable current from the Pi's GPIOs, I would be able to control both the devices.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 3:45 pm

http://raspi.tv/2013/how-to-use-soft-pw ... ed-control shows one way of doing it, but you'd obviously have to check the darlington array supports the voltage you require.

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 3:47 pm

Hi,
dentex wrote:What I was thinking is that if I find the way to provide this adjustable current from the Pi's GPIOs
Adjustable current or voltage ?

I'd use one circuit for lamps control and at least one circuit for fans - measure their consumption first.

For lamps: a circuit based on LM317 and digital potentiometer is simple and robust solution. The digital pot is controlled by RasPi and this pot changes reference voltage of the LM317, causing its output voltage to change.
Google: "variable voltage LM317" and replace manual potentiometer with digital one.

For fans: it seems that PWM is ok, so you could use plain 12V motor driver circuit. If the fans consumption is higher, then you could use one driver circuit for each fan. This motor driver circuit can be bought in most hobby-robots stores, for example. Just make sure that they can handle 12V voltage and sufficient current for either all three or one fan... do not forget to calculate at least 50% safe margin... data on sites listing cheap crap (like eBay) should be verified twice, from datasheets of the elements present on a board (I vote for datasheets lookup instead of blindly believing to the sellers !).
Google: "12V motor driver board"


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12991
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 4:15 pm

Not to be a nuisance, but
a current that can range between 0V and 10V?
is nonsense!

It is either:

a current that can range between 0A and 10A?

OR
a Voltage that can range between 0V and 10V?


You can use a PWM signal to create a variable voltage, using a resistor/capacitor (RC) filter, but to control a (large) current you will need some kind of voltage to current converter, like an emitter follower with a tiny emitter resistance to GND, however that is true for a DC current, not for a mains AC current, as used by a TL lamp.

A TL dimmer is much more complex! something like this:
http://www.turbokeu.com/myprojects/tl-dimmer/ecg.pdf

but note that the dim input (and the COM return ground) is still connected to mains, and thus deadly! Do not connect either of the directly to a PI!

You could send a PWM signal to the dimmer unit using an opto isolator, and then convert the PWM signal locally to the analog control voltage.

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 4:25 pm

The data sheet linked in the OP says 0 - 10V dc control input 0.5mA into a fluorescent lamp (T8 tubes) dimmable electronic ballast.

A digital pot that handles >10V would probably do the job on it's own, no need for LM317 or whatever.
PWM to a motor driver is not advisable, because control input is spec'd as DC.
You could use such a motor driver with a low pass filter, or drive a transistor from GPIO PWM signal to switch >10V into a low pass filter to produce a DC voltage. Google pwm as analog

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 4:44 pm

Thanks to everyone for the highly valuable inputs! (and thanks mod for the revision)
Not that I can't use google (actually I'm a duckduckgo fun), but it was that I didn't know what to search for.
Now I need some time to dig into this whole new stuff, although it seems that the "pwm as analog" approach could do the job for both the pieces of this project.
I'll report back any other doubt.
Thanks again! :D
Last edited by dentex on Wed Aug 27, 2014 4:46 pm, edited 1 time in total.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 4:46 pm

Hi,
PiGraham wrote:A digital pot that handles >10V would probably do the job on it's own, no need for LM317 or whatever.
LM317 is (also) a cheap protection for RasPi.
PiGraham wrote:PWM to a motor driver is not advisable, because control input is spec'd as DC.
It is not advisable for lamps, but should be ok for fans. (Dimmable ballast is for lamps only, isn't it ?).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: 0V to 10V output from the RPi

Wed Aug 27, 2014 4:52 pm

FLYFISH TECHNOLOGIES wrote:
PiGraham wrote:PWM to a motor driver is not advisable, because control input is spec'd as DC.
It is not advisable for lamps, but should be ok for fans. (Dimmable ballast is for lamps only, isn't it ?).


Best wishes, Ivan Zilic.
Yes, not for the lamps/ballast, but good for fans. Actually, fans don't need an H-bridge since they aren't made to reverse, so just a transistor on PWM will do.

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 10:05 am

Hello again.
I would like to put aside for a moment the "T8s and ballast" thing and focus on the fans.
Searching for "pwm as analog" I found several pieces of information about the ULN2003.
I.e., is the last picture at http://electroniccomponentknowledge.wor ... l-uln2003/ a good example? I may try to wire the things up like this and look at some code snippets, as this one: http://raspi.tv/2013/how-to-use-soft-pw ... ed-control

(edit: in regards to the linked wiring scheme, can I leave the power supply locked on 12V? it can output 2A)

What do you think?
Thanks.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 10:39 am

Hi,
dentex wrote:is the last picture a good example?
Yes... but check the fans current consumption not to overload the chip.
You can also connect each fan on one ULN2003's output (and short related three inputs together and drive them with single GPIO pin).
dentex wrote:can I leave the power supply locked on 12V?
Yes.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 10:44 am

Wow!!! thanks!!!
FLYFISH TECHNOLOGIES wrote:...check the fans current consumption not to overload the chip...
Here it comes the noobness... how?
With a meter?
Image
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 10:49 am

Hi,
dentex wrote:
FLYFISH TECHNOLOGIES wrote:...check the fans current consumption not to overload the chip...
Here it comes the noobness... how?
With a meter?
Yes, with ampermeter (alias ammeter, alias multimeter set to measure current).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 10:51 am

You're the man.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 11:10 am

dentex wrote:Wow!!! thanks!!!
FLYFISH TECHNOLOGIES wrote:...check the fans current consumption not to overload the chip...
Here it comes the noobness... how?
With a meter?
Image
Or you could read the label (if there is one).

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Thu Aug 28, 2014 11:15 am

ame wrote: Or you could read the label (if there is one).
Ohh, so true. I'm not at home right now. I'll do it tonight. Thanks!!!

A digression: I cannot stop myself from thanking you, guys! I'm starting to figure out that maybe all this "aquarium project" may become a reality, bit by bit.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Sat Aug 30, 2014 4:01 pm

Hello.
No labels or datasheets for the fans, so I measured the current with a meter.

With the power supply at 12V and the resolution set on 200m, it's stable at 2.5 after a spike at ~3.8
With resolution on 20m it's 0.25 after a spike at ~0.35

So, is it safe for the ULN2003A to handle? I have the problem I don't know where to look on its datasheet.
1.png
1.png (29.17 KiB) Viewed 13108 times
2.png
2.png (29.04 KiB) Viewed 13108 times
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: 0V to 10V output from the RPi

Sat Aug 30, 2014 9:44 pm

Hi,
dentex wrote:With the power supply at 12V and the resolution set on 200m, it's stable at 2.5 after a spike at ~3.8
In the tables you attached there is always a column containing unit... for reason, because a number without unit can cause wrong assumption... and you don't want this to happen.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Sat Aug 30, 2014 10:23 pm

Sorry I've been not precise.
I measured the current using the two scale below, inserting the meter in series into the circuit.
With the scale 200mA set on the meter, 2.5 was the value I read. While with a scale of 20mA I read 0.25.
Image1259316229.jpg
Image1259316229.jpg (35.15 KiB) Viewed 13063 times
The measured current for these fans should be 25mA. But I'm not sure it's correct.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Sun Aug 31, 2014 8:31 am

I tried anyway and the fans are nicely going up and down using this script:

Code: Select all

#!/usr/bin/env python2.7

# script by Alex Eames http://RasPi.tv
# http://RasPi.tv/2013/how-to-use-soft-pwm-in-rpi-gpio-pt-2-led-dimming-and-motor-speed-control
# Using PWM with RPi.GPIO pt 2 - requires RPi.GPIO 0.5.2a or higher

import RPi.GPIO as GPIO # always needed with RPi.GPIO
from time import sleep  # pull in the sleep function from time module

GPIO.setmode(GPIO.BCM)  # choose BCM or BOARD numbering schemes. I use BCM

GPIO.setup(25, GPIO.OUT)# set GPIO 25 as output for fans
#GPIO.setup(24, GPIO.OUT)

fans = GPIO.PWM(25, 100)    # create object fans for PWM on port 25 at 100 Hertz
#unused = GPIO.PWM(24, 100) 

fans.start(0)              # start fans on 0 percent duty cycle (off)
#unused.start(100)           

pause_time = 0.02           # you can change this to slow down/speed up

try:
    while True:
        for i in range(0,101):      # 101 because it stops when it finishes 100
            fans.ChangeDutyCycle(i)
            #unused.ChangeDutyCycle(100 - i)
            sleep(pause_time)
        for i in range(100,-1,-1):      # from 100 to zero in steps of -1
            fans.ChangeDutyCycle(i)
            #unused.ChangeDutyCycle(100 - i)
            sleep(pause_time)

except KeyboardInterrupt:
    fans.stop()            # stop the fans PWM output
    #unused.stop()           
    GPIO.cleanup()          # clean up GPIO on CTRL+C exit
It's so funny, but my intention is to use a temp probe to regulate the fan speed. Less funny, but more useful. :mrgreen:

Thanks to everyone for the help!
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: 0V to 10V output from the RPi

Mon Sep 01, 2014 11:54 pm

dentex wrote:It's so funny, but my intention is to use a temp probe to regulate the fan speed. Less funny, but more useful. :mrgreen:
Here's something similar http://raspi.tv/2014/temperature-contro ... your-pipes
(except he's obviously heating things up, whereas you'll be cooling things down ;) )

http://raspi.tv/2013/raspberry-pi-in-th ... -switching

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Tue Sep 02, 2014 9:22 am

Thanks for the links!
I'm taking a look right now (although he's using an "hybrid" arduino/RPi solution).

Hey guys, in regards to the table from the ULN2003A datasheet above, what's the right current the fans have to not overcome: Ic or Ib (they are 500mA and 25mA)?
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12991
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: 0V to 10V output from the RPi

Tue Sep 02, 2014 9:32 am

Ic = collector current, the output current (to the fan). <= this is the one you are interested in

Ib = base current, the input current (from the PI, into the base of the transistor, limited by input voltage)

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: 0V to 10V output from the RPi

Tue Sep 02, 2014 9:38 am

mahjongg wrote:Ic = collector current, the output current (to the fan). <= this is the one you are interested in

Ib = base current, the input current (from the PI, into the base of the transistor, limited by input voltage)
Thanks mahjongg.
In this case I'm OK. I'm far away from 500mA. I measured 25mA (with a spike up to ~35mA), if I've done the things right.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

Return to “Automation, sensing and robotics”