Arduino PWM signal to xbee A/D - Page 1
Forum section: electronics / projects

author: NahidJM
author_rank: Newbie
timestamp: May 07, 2015, 07:57:51 pm
content: hi thereI 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.1.I attached the schematic of what I'm planning to do.2.The frequency of the PWM depends on the pin ofcourse but we can consider 500 Hz.3.I have considered R=15K and C=1uF4. 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.!!!

author: SL4P
author_rank: Super Contributor
timestamp: May 07, 2015, 09:45:53 pm
content: ? no schematic...Only an assembly / wiring diagram and the scope trace.Did you establish (view) the changing 'analog' level on the RC output before connecting the zbee?Break the problem down, then you'll know what needs to be fixed.

author: NahidJM
author_rank: Newbie
timestamp: May 07, 2015, 10:08:57 pm
content: yes I have viewed the output of the filter before connecting it to Xbee and it works just fine. I have broken the problem into million pieces. I have tried each stage multiple of time. The stage of connecting the filter to Xbee somehow changes everything. I have tried to get the most smooth analog output of the filter but I still have the same problem.!

author: SL4P
author_rank: Super Contributor
timestamp: May 08, 2015, 01:31:33 am
content: OK, that's a good start.have you proven the zbee analog input is doing what you expect / want?e.g. a pot or divider on the input to see the value change elsewhere...if yes, then you know two important things...the PWM (analog) source is working..., and the a-d input is working.So what have we learned, and what's next?The zbee input is 'loading' the analog source down - effectively defeating the RC time constant.the input impedance of your A-D may be too low for the source.Perhaps an op amp stage designed to source sufficient current into the A-D pin.

author: LukeW
author_rank: Frequent Contributor
timestamp: May 08, 2015, 07:26:20 am
content: Try using 2x 1k resistors and 2x 0.1uF caps - very easy jellybean values.CBF drawing a diagram, but the two resistors go in series between the signal source and output and the caps go between the signal line and ground "after" each resistor, so it's two stages of low-pass RC filter in series.Now, try looking at it on a scope without the XBee connected. You should be able to set the voltage ratiometrically between 0-Vcc where Vcc is 5V or whatever depending on exactly what type of Arduino you've got.Now, keep scope on it with XBee also connected. Does it still behave itself?Is the XBee set up to make that port a high-impedance input pin? It's not trying to drive it or pull it, is it?Try a voltage-follower opamp on the output of the RC filter. It may be a problem that the XBee does not have high input impedance.

author: NahidJM
author_rank: Newbie
timestamp: May 08, 2015, 11:17:24 am
content: Quote from: SL4P on May 08, 2015, 01:31:33 amYES, the PWM is working and A/D is working, seperatly!The input impedance of the A/D is 10K. SO I really don't know if this is too low for the source. since my source has a maximum voltage of 1.2V.Quote from: LukeW on May 08, 2015, 07:26:20 amI have tried it with same values of RC but one filter. I'll try connecting them in series and see how it works. But as I mentioned, the input impedance of that pin is 10K. I've been suggested a lot to use Op-amp. I'll try is soon when I get back to university and will update you.Thank you both very much

author: NahidJM
author_rank: Newbie
timestamp: May 08, 2015, 12:18:09 pm
content: 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!

author: NahidJM
author_rank: Newbie
timestamp: May 10, 2015, 09:52:26 am
content: UPDATEI added a resistor of 10K(same as the input resistance of the Xbee) parallel to the filter's capacitor. Everything is working just fine. Thank you all for the tips

author: SL4P
author_rank: Super Contributor
timestamp: May 10, 2015, 10:53:19 am
content: Congratulations on getting it working.It would be good to see a schematic (Fritzing is not a schematic!)From what you've said - it sounds like you didn't have a DC path from the PWM integrator to the Xbee A/D input.... just a capacitor in series... for all intents that will only pass AC, and your A/D reading will be meaningless in this case.I can't see what you had designed originally - but next time, post aschematicwith pins, component values etc (not an 'assembly' diagram). It's a lot easier for us to see where you are, and offer specific comments.

author: NahidJM
author_rank: Newbie
timestamp: May 11, 2015, 10:14:19 am
content: Quote from: SL4P on May 10, 2015, 10:53:19 amSure . Hopefully next time I'll provide schematic. Thanks