Arduino Forum

Using Arduino => General Electronics => Topic started by: Jonnym on Nov 15, 2012, 04:54 am

Title: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 15, 2012, 04:54 am
Hello everyone,

I'm trying to build a device to test a proportional valve. This valve requires a 24v input and a control signal that ranges from -10v to +10v. I've read up getting an analog voltage from a pmw signal, and read up on charge pumps to get a negative voltage. But all of this is sort theory, and I don't really understand it fully..... So what attached components would I need to do something like this? Or maybe just a research topic pointer...

Any info would be great and most appreciated.

Thanks
Jon
Title: Re: -10v to 10v analog output
Post by: Grumpy_Mike on Nov 15, 2012, 05:08 am
Is this +/- 10V signal an input or an output. The body of the post and the title seem to contradict each other.
What sort of resolution do you want?
Basically you need some form of power supply, an op amp or some transistors and some filtering.
Title: Re: -10v to 10v analog output
Post by: Jonnym on Nov 15, 2012, 05:57 am
Hi Grumpy Mike,

The +/-10v would be an output, it is the control signal going to the valve, originating from the Arduino 

resolution, i would like it to be analog, or fine enough to appear analog. the valve operates full open / full close over a 20v range. 1000 steps seems reasonable  20mv/step?.

would i be stuck to 255 steps since it is going to be tied to the PWM? 

power supply - 2x12v batteries...

this 'tester' i am building would also have an lcd output, theres a bit of math to give me a valve percentage, etc. - this is software stuff.

thanks
jon

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: jackrae on Nov 15, 2012, 09:56 am
Filter PWM output to produce a smooth 0-5volt analogue signal.  The centre point of your 24 volt battery configuration to be connected to arduino ground.  All OpAmps to be powered by +/- 12 volts.  Feed the 0-5volt analogue to a unity gain OpAmp/comparator with +2.5 volt fixed offset.  This will produce -2.5 to +2.5 volt output.  Now feed this to OpAmp with gain of 4 to produce the required -10 to +10 volt drive signal.    Probably could be done with a single Opamp/comparator but using two makes it simpler to calibrate.

If your PWM filter reduces the 100% signal to less than 5 volts, let's say 4.5, then the 50% PWM value should be 2.25 so you need to alter the 1st stage bias voltage to +2.25 and the output will be -2.25 to +2.25.  By altering the gain of the second stage to 4.44 you get back to the -10 to +10 output.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dc42 on Nov 15, 2012, 11:01 am
Can you point us to a datasheet for the valve? Whether or not you can use a charge pump to derive the negative voltage depends on its input resistance.

You can get more than 255 steps by using 2 PWM pins, if the valve is capable of distinguishing more than 255 steps..
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: MarkT on Nov 15, 2012, 12:39 pm
I'm sceptical that a device with a single +24V rail would take a negative voltage on a control input...  Plenty of 0..10V proportional valves out there, but Google doesn't find anything for -10V
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 15, 2012, 12:45 pm
It is quite unusual, but not impossible, for a valve to have a control signal below its ground.

So before wasting your time thinking about generating a -10 to +10v signal, make sure that your valve does need such a signal. Chances are that it doesn't but read the datasheet to be sure.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 15, 2012, 05:43 pm
Hi Everyone,

Thanks for all the good info. here is a link to the data sheet of the valve.

http://goo.gl/4Xlh8 (http://goo.gl/4Xlh8)

we have the version that is voltage controlled not amperage controlled.

thanks
jon

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dc42 on Nov 15, 2012, 06:02 pm
The datasheet says that the input is a differential amplifier. Therefore, one way of controlling the valve is to use two PWM pins, generate a 0 -> 10V signal from each one, and feed them to the inputs. Set one of the outputs to zero (depending on which way you want to move the valve) and the other to 0 to 10V. This requires 2 PWM pins to control the valve, but does not need a negative supply. The attached schematic is one way of generating one 0-10V signal.

Alternatively, only use a PWM pin to generate one of the inputs, and switch the other to 0V or +10V from a digital output pin.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: MarkT on Nov 15, 2012, 08:07 pm

Hi Everyone,

Thanks for all the good info. here is a link to the data sheet of the valve.

http://goo.gl/4Xlh8 (http://goo.gl/4Xlh8)

we have the version that is voltage controlled not amperage controlled.

thanks
jon




That's not the datasheet, that's a catalog entry.  This is the datasheet (auf Deutsch!) http://www.moog.com/literature/ICD/Moog-Valves-D633K-D634K-D635K-Manual-multi-en.pdf (http://www.moog.com/literature/ICD/Moog-Valves-D633K-D634K-D635K-Manual-multi-en.pdf)

If my german is good enough its a 0..10V control signal.  But it is _differential_ so you can connect either Ue or Ud to ground and get either sense as (Ud-Ue) is the control voltage (section 3.3.1.3 of the pdf) - anyone got a better grasp of technical german??
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 15, 2012, 10:35 pm
Quote
anyone got a better grasp of technical german??

No but if you scroll down the data sheet the bottom half is repeated in English!  ;)

So yes it is a differential input. That means the two signals both go from 0 to 10V, it is just that when one is up and the other is down that is a 10V signal but when this is reversed it is a -10V input. But there is not a -10V with respect to ground it is just with respect to the other signal.
Therefore you need two 0 to 10V analogue signals. I would put the PWM first through a transistor to get it in the 0 to 10V range, and then filter it to remove the PWM switching noise. This is simpler than smoothing it and then having to get a linear amplifier to boost it up to 10V.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 15, 2012, 10:45 pm
Quote
The attached schematic is one way of generating one 0-10V signal.


That wouldn't work.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dc42 on Nov 15, 2012, 11:41 pm
Ignore dhenry, he likes saying things won't work but doesn't provide any justification for his opinion, because he hasn't any.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: be80be on Nov 16, 2012, 12:20 am
It will work may have to play with it a  little but that's the fun part. low pass and a op-amp and 2 volts above 10 should go 10 to 0 volts
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 16, 2012, 12:29 am
Quote
doesn't provide any justification for his opinion


That's called the art of engineering: if you had built your circuit, you would know why it doesn't work.

Something like that is great on paper only.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 16, 2012, 03:27 am
hi everyone,

thanks for all the pointers and ideas- it seems that the catalog page was missing a bit of info that the data sheet filled in. who would have thought it :) 

to move this thing in direction "A", apply a voltage to pin D, this voltage is ranging from 0-10v. 
to move this thing in direction "B", apply  0-10v to pin E.

pin D and pin E are to remain connected to their respective branches of the circuit. i would imagine i could break something it 10v was on pin D and pin E at the same time?

the data sheet says that if only one signal pin is available, then the other needs to be grounded. since i will be using both signal pins - there is no need to ground the pin, when traveling in the opposite direction, correct?

i'll keep reading a bit and post a circuit sketch in a bit -- again thanks for the help

_Jon



Title: Re: generating a -10v...+10v control signal from an arduino
Post by: oric_dan on Nov 16, 2012, 03:42 am
I agree with dc42 that his ckt should work, and all the way from 0V to 10V output, as the LM358
opAmp has input common-mode range down to ground.

The one thing that may be an issue is that 1st-order filtering of the PWM signal will leave a little
ripple on the DC-level, so the valve may jitter some. You can deal with that by using a PWM
frequency much much greater than the R*C time constant of his filter, but this will also reduce
the frequency response of the valve, if that's an issue.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 16, 2012, 04:20 am
hi oric_dan,

thanks for the reply ---  although it is bit above my knowledge level.

...filtering of the PWM
so if i look at it on a scope i'll see some stepped lines, and not super smooth, the faster the pwm frequency, the less noticeably this becomes?

...PWM frequency much much greater than the R*C time constant of his filter
??? the math of circuits has got me confused. i used to have respectable math skills, but haven't used them in many years. could you clarify a bit.

...response time of valve.
--slow is fine. :)

i'm putting together a parts order now... any suggestions?

_J
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: oric_dan on Nov 16, 2012, 04:27 am
This should help explain it,

http://www.google.com/search?hl=en&safe=off&q=PWM+ripple&bav=on.2,or.r_gc.r_pw.r_qf.&bpcl=38625945&biw=1153&bih=827&um=1&ie=UTF-8&tbm=isch&source=og

You can see dc42's same ckt here,

http://www.hoelscher-hi.de/hendrik/english/demux.htm

For a 1st-order RC low-pass filter, the 3dB or 'cutoff' frequency is given by F3db = 1/(2*pi*R*C). You want the
PWM frequency to be maybe 5X this value to get reasonably small ripple. Probably better to directly access
the Arduino PWM subsystem than to use the analogWrite() function, which I believe has a fairly low frequency.

BTW, I find I'm using google images for almost everything now, in preference to a regular google search. Easier
to zero in on the perfect website, :-).
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 16, 2012, 05:05 am
hi guys,

i am plugging numbers into this calculator... could you verify some of my assumption??

http://sim.okawa-denshi.jp/en/PWMtool.php

fPWM= 480 (this is the operating freq of the pwm timer? )

duty step -- the output i want. 50% if i wanted around  5v output, based on switching  0-10v

R and C values??  I got a 'pretty' curve at R =5k and C =10u. Could i expect to get better??

what is the fc - cut off frequecy term mean?

thanks
jon

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Docedison on Nov 16, 2012, 07:08 am
It means the frequency at which the referenced level is reduced or increased (for a high pass filter) by 3 Db or a power factor of 2.

Bob
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: oric_dan on Nov 16, 2012, 07:18 am
That site is very useful. The result with those numbers is not very good, so needing something more like
Fpwm=10Khz, Fc=100Hz, or 100:1 to get low ripple.

5K and 10uF -> F3db = 3.18 Hz, which is quite low, but probably ok if all you're doing is changing slowly.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dc42 on Nov 16, 2012, 07:29 am

That site is very useful. The result with those numbers is not very good, so needing something more like
Fpwm=10Khz, Fc=100Hz, or 100:1 to get low ripple.

5K and 10uF -> F3db = 3.18 Hz, which is quite low, but probably ok if all you're doing is changing slowly.


My suggestion was 100K and 1uF, giving F3db = 1.59Hz and time constant = 100ms. I guess we need to know how fast the OP needs to move the valve.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: oric_dan on Nov 16, 2012, 07:34 am
Why aren't you asleep? It's 5:30 AM in the UK!
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: justjed on Nov 17, 2012, 01:38 am

Quote
anyone got a better grasp of technical german??

No but if you scroll down the data sheet the bottom half is repeated in English!  ;)


You could've really impressed us all by omitting that, and just posting the English part with a 'here you go!'  ]:)
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 17, 2012, 06:32 am
Quote
Why aren't you asleep? It's 5:30 AM in the UK!

Yes that is what I would like to know as well but for me this time.

Quote
You could've really impressed us all by omitting that

Yes though of that but opted for honesty, so never make a politician will I?
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 22, 2012, 04:03 am
Hi Guys,

Me again...

I'm confused at where the RC filter would be connected in the circuit. If I was switching a transistor with one of the pwm pins, the transistor is allowing the path to ground. Is the RC filter on the collector side or the emitter side? (thinking this is an NPN)

There is a path to ground via the capacitor, is the high freq. stuff is going this route? and that's the whole point...

thanks
Jon

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 22, 2012, 07:32 am
No that is totally wrong.
Collector to pull up resistor to +12V.
Collector to filter resistor. Other end of resistor to capacitor to ground and also to one of the inputs of your controller.
You need two of these circuits one for each input. You also need a common ground.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 22, 2012, 05:51 pm
...and base ?  is this shown correctly?

..and emitter?.. is this show correctly?

..and load?.. is this shown correctly?

cheers.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 22, 2012, 06:24 pm
Quote
.and base ?  is this shown correctly?

Yes
Quote
and emitter?.. is this show correctly?

Yes
Quote
and load?.. is this shown correctly?

No.
See previous answer.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: P18F4550 on Nov 22, 2012, 11:10 pm
Max232 makes a nice negative voltage source
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 22, 2012, 11:21 pm
We have already established that a negitave voltage is not needed for this.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: oric_dan on Nov 22, 2012, 11:25 pm
Quote
We have already established that a negitave voltage is not needed for this.


Ditto-ed.

However, for reference, the 7662 chip is a nice 8-pin negative-voltage generator, and has
a wider voltage range than the older 7660 chips,

http://www.google.com/webhp?source=search_app#hl=en&tbo=d&sclient=psy-ab&q=7662+converter
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Gadgeroonie on Nov 22, 2012, 11:28 pm
i was trying to do something similar a while back

http://arduino.cc/forum/index.php/topic,76821.0.html
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 12:51 am
does this one look better??

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 25, 2012, 12:56 am
Quote
does this one look better?

Yes.

Why don't you use proper symbols for transistors?
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 01:05 am
.. :-)

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Grumpy_Mike on Nov 25, 2012, 01:18 am
:) :) :)
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 01:58 am
alright...

next set of questions... resistor sizes.

I am using a  2N3904 transistor, which may not bethe correct thing to use, but maybe it is. i don't know for sure...

the way i understand this, R1 would be the current limiting resistor for Arduino. but i can seem to find what the current needs to be to operate the get the transistor to 'turn on' (yes, i sure there is a very technical term for this :)  )

i bet i would plug the need current and something like 5v's into Ohm's law and i would get something helpful???

here's the data sheet
http://www.fairchildsemi.com/ds/2N/2N3904.pdf

i'm going to guess 10k and 5v for ohm's law values... maybe? 

thanks ya'll


Title: Re: generating a -10v...+10v control signal from an arduino
Post by: be80be on Nov 25, 2012, 02:28 am
If you want to guess a 1k to 2.2k would be better if you want the right one. Read these
http://www.physics.unlv.edu/~bill/PHYS483/transbas.pdf
http://www.rason.org/Projects/transwit/transwit.htm
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 03:13 am
great links...

working through the numbers, i am going to assume a 200ma collector current, which would give me something different than an HFE of 30. but i'll use 30, since this looks to be rough numbers anyways.

200/30 = 6.67ma

so there's a bit of "double it for safety margin" to make sure the base is saturated.

6.67 *2 = ~14ma

reading the unlv.edu pdf

R1 =V/Ib = (5V - 0.75V)/0.014A = ~305?

and choose the closest standard... nice.. thanks

_J

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 25, 2012, 03:24 am
Quote
assume a 200ma collector current


That's a lot of current for what you are trying to do.

The general design process will be around how fast you need the valve to read / its input impedance. From there, you decide your pwm's period/frequency and you get the desired rc values.

I would use 10k for R2/R3, 4.7uf for the cap and 1k for the base.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 03:39 am
fantastic...

so R3 = 10k, this value comes from R/C calculator. same with C1

how about R2, where does this value come from?

thanks
_J
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 25, 2012, 03:58 am
I was guessing that your pwm is likely 500hz, and your valve has minimum speed requirement (near dc control signal). So I wanted to achieve a time constant of 50ms. That provides me with 10k/4.7u on the r/c filter.

I used 10k for the pull-up for convenience: the charge up time constant is now 100ms and the discharge time constant is 50ms. Not a big deal.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 04:27 am
thanks for the explanation, i am really trying to work through all the steps in this project to remove some of the mystery surrounding this stuff. but it seems, the more i learn, the more mystery presents itself. so yea - i guess it's all just magic :)

_J

Title: Re: generating a -10v...+10v control signal from an arduino
Post by: Jonnym on Nov 25, 2012, 04:43 am
Quote
your valve has minimum speed requirement (near dc control signal)


not sure if i understand this?? were you thinking that the control circuity in the valve needs to be updated at a certain minium frequency? which would mean the settling time of the RC portion needs to be somewhat fast?

how much would things change if i would change the PWM frequency that the Arduino is pushing out?

how is the pull-up resistor affecting the R/C filter, or does it? ( i would think this might be 'magic')

..and how did you come up with charge / discharge time ??

thanks
_J
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dhenry on Nov 25, 2012, 04:53 am
i was assuming that you dont need to change the valve quickly. aka no music fountain.

the existing time constant is very long. unless you loswer your pmw output below 200hz, i wouldnt worry about.

time constant is r*c. discharge tc is 10k*4.7u. chage-tc is 20k*4.7u.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: dc42 on Nov 25, 2012, 10:00 am
One thing we don't know is the input resistance of the valve (I couldn't find it on the datasheet). That's why I suggested using an op-amp. For the circuit you have sketched to give you the full range of control, the valve input resistance will need to be at least 55K, if you are using a 12V supply for the circuit, 1K for R2, and 10K for R3.
Title: Re: generating a -10v...+10v control signal from an arduino
Post by: andybott on Dec 19, 2013, 12:29 am
This has been one of the most usefull posts I have fond and I wanted to thank all the contributors for their time on this. blowing away the cobwebs of my electronics degree has been most enjoyable ! many thanks all