Arduino PWM signal to xbee A/D

Hi there

Well I have been struggling to find a solution to my problem. I am trying to get analog output from Arduino and from what I know Arduino doesn't offer D/A converter. But PWM pins are provided as a D/A converter. But the pulses are of course not an analog voltage. So I tried to use a simple RC filter after the PWM signal and the output of the filter is connected to the A/D pin of xbee. According to theory the filter has to make the pulses as smooth as possible with certain value of the ripple. Even though I have decreased the value of the ripple, as soon as I connected the output of the filter to the Xbee, something strange happens!!! The A/D pin of Xbee starts reading multiple values. The voltage fluctuates randomly. Of course the voltage that I want is one of those multiple values, but because of my application, I cannot have multiples output voltages for same input. I really don't know the reason behind this and this is why I can't really solve the problem. I would appreciate any insight on this issue. Thanks.

Schematics? Screen shots of the o-scope? Frequency of PWM and RC filter design?

I'm sure someone will be able to help you out, but those are some of things they will need to know.

lmarklar:
Schematics?
Screen shots of the o-scope?
Frequency of PWM and RC filter design?

I’m sure someone will be able to help you out, but those are some of things they will need to know.

Thank you very much for the suggestion.

1.I attached the schematic of what I’m planning to do.

2.The frequency of the PWM depends on the pin of course but we can consider 500 Hz.

3.I have considered R=15K and C=1uF

  1. I have attached the output of the filter on O.Scope. Even though the PWM is passed through the filter but as soon as we connect it to Xbee, we get multiple values since the Xbee is sampling the signal. and the signal still seems to be a pulse.!!!

I have attached the output of the filter on O.Scope

This shows that the filter is not working at all. Check your wiring.

Grumpy_Mike: This shows that the filter is not working at all. Check your wiring.

I am pretty sure that the wiring is completely right. but somehow the filter is not doing well as soon as it gets connected to Xbee. Otherwise before connecting to Xbee, it works just fine.

but somehow the filter is not doing well as soon as it gets connected to Xbee.

That could happen if the input impedance of the Xbee is low, but I doubt it would be that low.

That fritzing diagram (and fritzing is crap ) shows your capacitor is the wrong way round.

If that's an electrolytic cap, try a ceramic instead.

How much of a draw does that xbee use?

Are you floating your scope's power input? Where are your leads connected when you are testing the output voltage?

Use and rc filter connected to an opamp, it will improve the output.

Grumpy_Mike:
That could happen if the input impedance of the Xbee is low, but I doubt it would be that low.

That fritzing diagram (and fritzing is crap ) shows your capacitor is the wrong way round.

the input impedance is 10 K so yes not very low. and about the capacitor, yes I connected it wrong in the fritzing. my mistake :(. but I’ve connected it right in my circuit.

lmarklar:
If that’s an electrolytic cap, try a ceramic instead.

How much of a draw does that xbee use?

Are you floating your scope’s power input? Where are your leads connected when you are testing the output voltage?

what do you mean by draw? :smiley:

The scope is connected to the output of the filter which is at the same time the input of the xbee.

mart256:
Use and rc filter connected to an opamp, it will improve the output.

The op.amp will help getting the value closer to the input. It doesn’t make any difference in the problem I’ve faced, I’v tried it and no change:(

Just another update. The Xbee has internal pullup resistor of 50K on the A/D pin. I am not familiar with these concepts at all so I don't know if it makes any difference!

What is your purpouse with this project? I think you are doing things unnecesarily complicated. You are converting digital to analog, and then xbee is going to convert it to digital again. Cant you just send the info in digital format?

what do you mean by draw?

Current draw.

The scope is connected to the output of the filter which is at the same time the input of the xbee.

Yes but where is the ground lead of your scope connected?

lmarklar: If that's an electrolytic cap, try a ceramic instead.

No that will make no difference.

Try not connecting the Xbee but connecting a 10K resistor to ground, does the effect of the filter still disappear?

mart256: What is your purpouse with this project? I think you are doing things unnecesarily complicated. You are converting digital to analog, and then xbee is going to convert it to digital again. Cant you just send the info in digital format?

I am fully aware that this looks weird. But trust me that there is no other way to solve this issure. I need to connect the sensors to the Arduino for calibration. Then the output of the Arduino will be series. but the problem is that I need Analog input to the Xbee to be able to draw it in graph. So eventually I'll need to convert everything back to analog.

Grumpy_Mike: Current draw. Yes but where is the ground lead of your scope connected? No that will make no difference.

Try not connecting the Xbee but connecting a 10K resistor to ground, does the effect of the filter still disappear?

the current draw is 40mA. The ground lead of the O.Scope is the same ground of the Xbee and the filter and the Arduino. The effect of the filter does not disappear if we don't connect it to Xbee. Only when it's connected to Xbee, it'll change back. So why should I connect the resistor to the ground?

Thank you :)

So why should I connect the resistor to the ground?

To see if it is the load resistance that is making the filter stop working or something else. These are the things I would do if I had your project and I was trying to solve it.

Grumpy_Mike: To see if it is the load resistance that is making the filter stop working or something else. These are the things I would do if I had your project and I was trying to solve it.

Oh I'm sorry I didn't get your point fully. Thank you very much for the tip. will try it and update you :).

Grumpy_Mike: To see if it is the load resistance that is making the filter stop working or something else. These are the things I would do if I had your project and I was trying to solve it.

I added a resistor of 10K(same as the input resistant of the Xbee) parallel to the filter's capacitor. Everything is working perfectly. Thank you very much for you help and tips :)

Ah so what was happening was that the Xbee input was too high an impedance. Glad you got it going, well done. :slight_smile:

NahidJM: I added a resistor of 10K(same as the input resistant of the Xbee) parallel to the filter's capacitor. Everything is working perfectly. Thank you very much for you help and tips :)

Thanks for sharing the solution, many people forget this last and important step.