Arduino PWM question

I need to send a signal that varies from 0 to 430uA I want to use PWM so 0 = 0 127 = 216uA and 255 = 430uA.

I tried a very basic circuit using just a 10K pot. I set the pwm out to 127 and adjusted the pot to get my 216uA. Here is my problem, When I set PWM to 0 I am still getting 142uA out The voltage doesn't drop to zero. At PWM of 255 I only get 240uA. So, Is it possible to get what I need using the PWM out of an arduino? And why is it still have voltage output even when set to 0?

Thanks
Rob

So, Is it possible to get what I need using the PWM out of an arduino?

No.

The PWM is voltage not current.

http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Grumpy_Mike:
No.

The PWM is voltage not current.

http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Ohms Law I=E/R PWM=E Or am I totally missing something here LOL How do you have a PWM modulated voltage in a circuit without current??

Or am I totally missing something here

Yes you are.
You are missing the fact that you never mentioned what load you are driving this into.

I need to send a signal that varies from 0 to 430uA I want to use PWM so 0 = 0 127 = 216uA and 255 = 430uA.

You can not do that direct from an Arduino pin. At best you have to use the voltage signal smoothed from the PWM and use that to set the current in a constant current supply.

If you actually say what you want to do instead of being vague and woolly then maybe you could get an answer that suites your needs, but as you have not mentioned what your needs are then we just have to guess.
So that is what I gave you, an answer to the question you asked.

Now do you want to ask a real question?

By the way:

And why is it still have voltage output even when set to 0?

Because according to the data sheet a logic zero can be any voltage up to 0.9V

It is a signal to an Op Amp The op amp drives a meter movement 430uA is full deflection
It is not a constant current. It has to vary from 0 to 430uA
I actually have the arduino driving it now its just that it won't go to 0 and above 245uA
With my fluke meter set to uA inline with the signal, Varying the pwm does indeed change the current, as it should.

I can give any other info needed or measurements. I have an o-scope as well. I'm just new to the arduino world so be gentle.

I can use 1.5v battery and a 10k pot and and make the op amp move the needle on the gauge perfectly. Just want to use an arduino. And to show you that I have made progress, here is a link to video showing my real aircraft part being interfaced via my arduino and PWM. The voltage going to those meter movements is direct and not thru an Op Amp.

I do thank you for your input.

It is a signal to an Op Amp

Ah different kettle of fish.

What op amp are you using and how is it wired up.
No op amp can get to a rail voltage so if you are only powering it off a single 5V line then you will never get 0V out of it. Look at the data sheet to find out how close to the rail you can get. Also look at what the input offset voltage is, does your op amp have some way of adjusting this?

The arrangement I would use with a single rail is to create a virtual ground with two resistors and connect your meter to this. Then the output voltage can be matched to this to get no current. You will then need to ensure that a reverse voltage does not damage your meter.

See attached pic of the circuit schematic circled in RED. This is all I have plus the info I gave already on the input to the op amp that makes it drive the meter movement. I wish had more but that is all I can get without being a certified shop. Pin 26 is shown as chassis gnd and pin 25 is the 0 to 430uA positve input. This is all the info I have.

Thanks
Rob

Sorry that means little to me, and I can't see how it marries up with what you said previously.

It seems to be a logic circuit with some "other blocks" in it. But how that fits in to your question I don't know.

Grumpy_Mike:
Sorry that means little to me, and I can't see how it marries up with what you said previously.

It seems to be a logic circuit with some "other blocks" in it. But how that fits in to your question I don't know.

I'm sorry, my bad, of course no one on here would know how to read an aviation standard schematic. That symbol is for an OP AMP not a logic circuit.

Oh well thanks anyways.

Can I guess here that this is some sort of flight simulator, and you want to drive an analog meter from one end of the range to the other, under certain conditions?

If this is right, then a PWM output, suitably smoothed, would generate a varying voltage, would it not?

And the old analog meters measured voltage by getting a voltage drop over a known resistor? So you could basically do that with a bit of rejigging.

You are correct and actually at 400Hz PWM output, I am driving several gauges without any smoothing and they are functioning perfect and very smooth.

My question was sort of answered above in theone statement that the Arduino PWM never goes to a true 0volts. Don't know why but I'll wire in a voltage divider on the gnd side to guarantee a 0 v potential is available to feed the op amp. Thats where this gauge is different than most.

I see. Well you would have got a much better response if you had described that (the thing I guessed).

http://xyproblem.info/

Apart from your user name, your sniping comment towards the end of this thread gave me the idea as to your real intention:

no one on here would know how to read an aviation standard schematic

It took until reply #4 for you to even mention a meter. People try to help. You can try to help them help you.

My question was sort of answered above in theone statement that the Arduino PWM never goes to a true 0volts

I thought those old meters had an adjustment screw. You could tweak it to read zero when you want it to. Failing that, it would probably be close enough to zero you wouldn't notice.

My question was sort of answered above in theone statement that the Arduino PWM never goes to a true 0volts. Don't know why but I'll wire in a voltage divider on the gnd side to guarantee a 0 v potential is available to feed the op amp. Thats where this gauge is different than most.

PWM not fully off

How are you doing the PWM? dlloyd's post raises an interesting point. I know that, for example, if you put zero in a timer counter, you get one count out of it (it is zero relative, and therefore you get a single count). To get no pulses at all you would have to turn the pin off, not output a PWM of zero.

As a test, this sketch:

void setup ()
  {
  analogWrite (3, 0);
  }  // end of setup

void loop () { }

Gave me 5.6 mV on my meter, so close-enough to zero.

Yes but what current were you sinking? I suspect it was open circuit.

Well, yes it was. With a 1k resistor load it reads 0.0 mV.

No not load, sinking. That is 1K to the output other end to 5V with a logic zero on the output.
For a better test make it sink 20mA like the data sheet.

Look at the dates in the thread dlloyd linked to. This behavior is no longer exposed if using analogWrite(). Look in wiring_analog.c - analogWrite() now catches values of 0 and 255 and just does digitalWrite() with 0 or 1.

Sinking 20 mA, the output was 0.45V.

Sinking 5 mA (with the 1k resistor) the output was 0.1V.

That sounds like what you would expect.