Author Topic: Arduino PWM signal to xbee A/D  (Read 4104 times)

0 Members and 1 Guest are viewing this topic.

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Arduino PWM signal to xbee A/D
« on: May 07, 2015, 07:57:51 pm »
hi there
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.

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=1uF

4. 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.!!!
« Last Edit: May 08, 2015, 10:55:28 am by NahidJM »
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Arduino PWM signal to xbee A/D
« Reply #1 on: May 07, 2015, 09:45:53 pm »
? 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.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Re: Arduino PWM signal to xbee A/D
« Reply #2 on: May 07, 2015, 10:08:57 pm »
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.!
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Arduino PWM signal to xbee A/D
« Reply #3 on: May 08, 2015, 01:31:33 am »
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.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 686
Re: Arduino PWM signal to xbee A/D
« Reply #4 on: May 08, 2015, 07:26:20 am »
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.
 

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Re: Arduino PWM signal to xbee A/D
« Reply #5 on: May 08, 2015, 11:17:24 am »
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.

YES, 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.


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.

I 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 :)
 

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Re: Arduino PWM signal to xbee A/D
« Reply #6 on: May 08, 2015, 12:18:09 pm »
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!  |O
 

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Re: Arduino PWM signal to xbee A/D
« Reply #7 on: May 10, 2015, 09:52:26 am »
UPDATE

I 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 :)
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Arduino PWM signal to xbee A/D
« Reply #8 on: May 10, 2015, 10:53:19 am »
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 a schematic with pins, component values etc (not an 'assembly' diagram).  It's a lot easier for us to see where you are, and offer specific comments.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline NahidJMTopic starter

  • Newbie
  • Posts: 6
Re: Arduino PWM signal to xbee A/D
« Reply #9 on: May 11, 2015, 10:14:19 am »
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 a schematic with pins, component values etc (not an 'assembly' diagram).  It's a lot easier for us to see where you are, and offer specific comments.

Sure . Hopefully next time I'll provide schematic. Thanks :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf