Go Down

### Topic: Output 0-20mA from an Arduino (Read 3198 times)previous topic - next topic

#### Jewel

##### Mar 12, 2012, 06:13 am
Hi! I am using a Arduino Duemilanove for my project.

I need an input of 0-20mA into a speed indicator. I know that the Ardunio pins have a current output of 0-40 mA and was wondering if I could use one of the pics to input 0-20mA into the speed indicator. I know that directly connecting the pin will give me 0-5V so I need some external hardware. Right? However, I have no clue how to do this. Can someone please help ? The current has to be variable from 0mA (or close to 0) to 20mA.

#### MarkT

#1
##### Mar 12, 2012, 12:20 pm
You want an analog current output?  One approach is to use a low-pass-filter on a PWM output pin.  However the simple RC-filter approach gives a voltage output rather than current.

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### retrolefty

#2
##### Mar 12, 2012, 03:48 pm
Without a datasheet for your speed indicator it's hard to progress. The +5vdc may not be enough voltage to force a 0-20ma signal into the indicator. However you accomplish the task you are going to have to generate a analog output voltage, convert it to a constant current (wire a current feedback signal so the arduino can 'measure' the current?) and adjust the output voltage up or down to maintain the desired output current signal. This is not a trivial task and without specific electrical interface information on the speed indicator, not worth proceeding with.

Lefty

#### jackrae

#3
##### Mar 12, 2012, 04:33 pm
On the basis that you can generate the 0-5volt signal you simply need a load resistance of 250ohms to give you a 0-20ma output.  You need to measure the input resistance of the speed indicator.  On the basis that it is a 20ma input unit it WILL have a measurable resistance, let's call it Rx.  So, in series with this you need to provide a further resistance Rl, the value of which is Rl = 250 - Rx

However, a further complication will be the RC filter you use to convert the PWM output signal to a 0-5 volts.  This will have a series resistance Rf and your 20ma load will decrease the filter output since drawing current through Rf will reduce the 5volt PWM level to something less than 5 volts.  This being so, the loop resistance will have to be reduced from the original 250ohms - which will further load your RC filter !!

Also the RC filter is a non-linear conversion of PWM duty cycle to smooth analogue output so you may need to build in some linearisation algorithm into your programme.

Are you sure the input is 0-20ma and not 4-20ma (which is an industry standard for analogue current devices).

So, what at first seemed like a fairly simple task will require a degree of bench work to produce an effective system.

#### Techone

#4
##### Mar 12, 2012, 05:40 pm
Quote
I need an input of 0-20mA into a speed indicator

I am thinking more of a car speed indicator. Analog type. Work like an old VOM.  A needle meter. Need a current from x to y to move the needle.  So you want a circuit from PWM or digital convert into current value ? I am correct ?

#### retrolefty

#5
##### Mar 12, 2012, 06:20 pm

Quote
I need an input of 0-20mA into a speed indicator

I am thinking more of a car speed indicator. Analog type. Work like an old VOM.  A needle meter. Need a current from x to y to move the needle.  So you want a circuit from PWM or digital convert into current value ? I am correct ?

Basically yes, but one needs to know the resistance of the indicator device to calculate the required total series resistance. And if the indicator's resistance is higher then 250 ohms then it will not be possible to drive it with a +5vdc max output signal. Again it's foolish to claim possible solutions without knowing specifics about the speed indicator device. Otherwise proposed solutions must be couched with assumptions and caveats.

Lefty

#### NI\$HANT

#6
##### Mar 12, 2012, 07:14 pm
Are you trying to Drive a Analog meter via. AVR?
"Real Men can Accomplish  Anything"

- skype : nishants5
ਫ਼ਤੇਹ ਕਰੁਂ!
www.winacro.com

#### Techone

#7
##### Mar 13, 2012, 04:01 am
@retrolefty

Ok, I get it. You need to know more details about the OP speed meter, like current, ohms, voltage max, etc.  But you agree with me the OP stil need a circuit to drive properly that speed meter from the Arduino. Right ?

#### retrolefty

#8
##### Mar 13, 2012, 04:15 amLast Edit: Mar 13, 2012, 04:20 am by retrolefty Reason: 1

@retrolefty

Ok, I get it. You need to know more details about the OP speed meter, like current, ohms, voltage max, etc.  But you agree with me the OP stil need a circuit to drive properly that speed meter from the Arduino. Right ?

Certainly. The circuit might be a PWM output pin driving a low pass filter and then buffered with an op-amp capable of driving a 20ma output current via a possible series resistor wired to the indicator. The questions then revolves around what the input resistance of the indicator is, as that dictates what source driving voltage will be required. If the OP could just take a resistance reading of the speed indicator that could help point to the actual circuit details required. +5vdc may not be sufficient, again depending on the actual input resistance of the indicator is.

Heck it's even possible to drive the indicator straight from the PWM output pin, with no filter and no opamp as again it's all about what the indicators resistance is, it's all about ohm's law. But if the indicator was designed for automotive use it might very well have been designed for 12vdc to be able to generate the 20ma top of scale value.

Lefty

#### Techone

#9
##### Mar 13, 2012, 04:32 am
Quote
But if the indicator was designed for automotive use it might very well have been designed for 12vdc to be able to generate the 20ma top of scale value.

I was thinking about just that.

#### Jewel

#10
##### Mar 13, 2012, 06:56 am
Thanx everyone for your responses! I didn't realise how complicated this is till I read through all of this!

The issue is there is no ONE speed indicator but three to four types which this current input should run (Part of project ). So, I guess this will be problematic seeing that the calculations will depend on the specifications for the speed indicators.
Yes, an input of 4-20mA is fine.
Does having a separate higher voltage source solve the issue of the possibility of the ATMega not being able to push enough current through? (Not connecting it to the Arduino at all.)
Thanx again!

#### retrolefty

#11
##### Mar 13, 2012, 07:50 am

Thanx everyone for your responses! I didn't realise how complicated this is till I read through all of this!

The issue is there is no ONE speed indicator but three to four types which this current input should run (Part of project ). So, I guess this will be problematic seeing that the calculations will depend on the specifications for the speed indicators.
Yes, an input of 4-20mA is fine.
Does having a separate higher voltage source solve the issue of the possibility of the ATMega not being able to push enough current through? (Not connecting it to the Arduino at all.)
Thanx again!

Well still nothing specific about the indicators? No datasheet? No manfacture link?

#### Jewel

#12
##### Mar 13, 2012, 08:39 am
The person who has the data sheets isn't here for the next few days.

#### michael_x

#13
##### Mar 13, 2012, 12:11 pm
And what about a simple try ?

An Arduino can output 20 mA, at 5V you need a 250 Ohm resistor for this current.
Now add your device in series and see ( measure voltage across your device ) what happens.

"Probably" even reducing the resistor to 0 Ohm won't show full output (20 mA @ 5V), however.

Then you'd need a higher ( 12V ?) power source and some amplifying transistor circuit, minimally.
Probably your needle device effectively does the low pass filter itself, you might simply switch the 12v by your PWM output.

Linearisation is your next issue   :~

#### Jewel

#14
##### Mar 14, 2012, 01:23 am

michael_x :
My initial idea was to use a rheostat and what you say does sound similar to that. Might as well give it a shot will I can get specs for the indicators.
Meanwhile, I found this.
Really appreciate the help!

Go Up

Please enter a valid email to subscribe