Friday, December 24, 2010

Wireless PWM with ADC: Xbee with No Microcontroller (Direct I/O)



Here we look at two xbees communicating, with no microcontroller. In this example one takes acts as an ADC (Analog to Digital Converter), and sends the data to the recieving xbee, which outputs a pwm signal proportional to the ADC reading.

The Xbee pins have oneto-one correspondence; Pin AD3 on one Xbee only communicates with Pin AD3 on the other, etc.

The pwm signal is at 15625 Hz, which is ideal for PWM (pulse-width modulation) motor control if I am not mistaken (there will soon be another page up with microcontroller-less xbees controlling a 24V DC, 10A, 135W motor).

The xbees in this example are using Lady Ada's adapter. With this adapter, the setup is quite simple, as it comes with a voltage regulator and a regulated 3V output. The configuration is made simple as well by its FTDI-cable-ready pinouts. However, to get to the VREF (for ADC), AD2 (for analog signal input), and PWM2 (PWM output) pins, extra jumpers were needed to be soldered. The adapter leaves these pins accesible, but as holes.

Connecting and configuring the xbee is quite simple. There are many tutorials online. For configuration, this example utilized the Lady Ada's tutorial. For mcu-less communication, the configuration code Rob Faludi's website was referenced (my circuit was quite different), as well as the xbee product manual.

I have read that only the AD1 pin will communicate with PWM1, and only AD2 will only communicate to PWM2. I chose PWM2 (for no important reason).

On the ADC xbee, I jumpered the 3V regulated output to VREF and also used the 3V output on the pot. To power the xbees, I used a ~4-4.5 V source on the 5V input on the adapter. 3.30V was measured at 100% duty cycle on the PWM output.

The configuration code is below. Good luck!

For potentiometer reader (controller):

//pot (potentiometer) reader configuration
//initialization: type "+++", WAIT few seconds for ok,
//then type "AT" and press enter, get ok, then issue commands.
//(numbers are in hexadecimal format)

ATID 4064
ATMY 40
ATDL 64
ATD1 2
ATIR A //(A=10 in hexadecimal format)
ATIT 1
ATWR

For PWM outputter (reciever):


//pwm outputter
//initialization: type "+++", WAIT few seconds for ok,
//then type "AT" and press enter, get ok, then issue commands.
//(numbers are in hexadecimal format)

ATID 4064
ATMY 64
ATDL 40
ATP1 2
ATIU 1
ATIA 40
ATWR

10 comments:

  1. Wow.. I'm doing the simillar thing on my project in school. I want to send analog signal to PC with 2 Xbees but it's not that easy.. Anyway this was useful to me. Thank you :)

    ReplyDelete
  2. Hi,
    Great demonstration on the power of the XBee's. Very nice, and I'm hoping you can help me with this question before I dive into this further:

    I have a device that outputs a 10.4KHz digital signal that varies in duty cycle (PWM)
    I also have 2 XBee Pro 900 XSC's.

    Will that PWM signal on the Din port on my sending Xbee Pro be what I receive on the Dout port of my receiving Xbee?

    See the product manual on the XBee Pro 900 XSC at for specs and features:
    http://ftp1.digi.com/support/documentation/90000938_B.pdf

    Thanks!

    ReplyDelete
  3. Well the way I used it, an xbee took in a dc (unvarying) signal and transmitted it to the other xbee, which converted it on it own to 15kHz pwm. So no, it will not output at 10.4khz, 15khz output is fixed for xbee (you may be able to configure frequency by more advanced methods that I am not yet aware of). However, the adc (analog to digital converter) on the xbee may be able to satisfactorily take in your 10.4khz signal and make the other xbee transmit a 15khz signal that is equivalent in duty cycle. I am no expert, but hope this helped. Good luck!

    ReplyDelete
  4. Hello,
    I wonder if the ADC value can be sent by the receiver using the serial port.
    Let me explain, I want to read a voltage (ADC) send it wireless (XBee) and receive in a microcontroler (RS232)
    Thanks a lot

    ReplyDelete
    Replies
    1. Not directly. You can smooth the PWM using capacitors and such. Or you can send messages and have the microcontroller interpret it, as I did in my wireless turret, which is also on this blog.

      Delete
  5. Do you know the current that the XBee can output from the PWM pins? The datasheet shows it consumes ~50 mA in normal operation but I'm assuming that's without driving anything from the PWM pins.

    ReplyDelete
  6. I read your post on XBee cheat sheet. You gave very interesting information regarding XBee. Use Xbee tutorial for learning XBee module.

    ReplyDelete
  7. Great information. I was wondering if you can lead me to some project similar but using the 5k pot to perform forward / reverse. So 2500k would be no motion on receiver side. Looking to connect to speed controller on receiver output. Thank you, Bob

    ReplyDelete
  8. Hi, Im trying to get a PWM ouput on my remote xbee by sending a value from mi PC through my base Xbee, I want to know if you've ever done it before, or if you could help me because so far I haven't been able to do it.

    ReplyDelete