Pages: [1] 2   Go Down
Author Topic: Output 0-20mA from an Arduino  (Read 1653 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Can you provide more information on the spec of this speed-indicator?
Logged

[ I won't respond to messages, use the forum please ]

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

SW Scotland
Offline Offline
Edison Member
*
Karma: 17
Posts: 1383
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?


Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you trying to Drive a Analog meter via. AVR?
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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 ?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
« Last Edit: March 12, 2012, 10:20:17 pm by retrolefty » Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad ). 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!
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad ). 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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The person who has the data sheets isn't here for the next few days. smiley-sad
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 56
Posts: 2998
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And what about a simple try ?

An Arduino can output 20 mA, at 5V you need a 250 Ohm resistor for this current.
Any normal resistor can easily burn (5V*20mA =100 mW) without overloading.
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   smiley-confuse
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 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.
http://www.allaboutcircuits.com/vol_3/chpt_8/7.html
Any Comments about this tranconductance circuit ?
Really appreciate the help!
Logged

Pages: [1] 2   Go Up
Jump to: