Power pin arrangement with Maestro/XBee

Just want to make sure I’m doing this right… I’m staging up from simple connectivity to more complex.

First, I got the servo to move by using the Maestro Control Center connected with a USB cable and separate power to the servo pins.

Next, I got the servo to move by using the same hookups, but using a python script. All good so far.

Now I am trying to hook it up via wireless xbee modules. I am powering the servo the same way and I am using a 5V, 1A mini-usb phone charger to power the logic side with the USB plug.

The XBee is being supplied 5V from the +5V regulator output and it’s associated ground and the TX/RX are crossed over between the XBee and the Maestro TX/RX pins.

Is this a reasonable approach to hooking an XBee to a Maestro?

In the prior arrangements I saw activity on the green power LED and I saw the yellow TX/RX lights flashing. In this setup I see no light on the power LED and one of the TX/RX pins light up momentarily when I plug in the USB 5V. I can see activity on the RSSI light of the XBee so it seems something is being sent to the XBee.

I just want to make sure I’ve got the connections right before I go trying to debug the data I’m sending over the XBee.

Thanks for any tips,
Chris.

Perhaps an image of the connections; crude as it may be. I hope it makes sense.

OK, so no response to my question so I continue to “try things”. Perhaps someone will see the errors of my ways.

Instead of powering the logic side (as opposed to the servo side) by a phone charger, I decided to see if there was any difference when I powered it from a USB line attached to a laptop. This is an independent laptop without any maestro software. So it should be acting like a dumb charger, right?

Now I see the green power LED is on (it was not on with only a charger USB) and the yellow LED is flashing (again, it was not with the USB charger).

So now the question is… what’s the difference between powering the device from a USB phone charger plugged into the wall and a USB cable plugged into a PC?

On the remote side I thought I could power the Maestro from a USB charger. Does this mean I need to build my own 5V regulator setup? I can do it, but would rather just use the 5V I get from the USB charger.

Thanks in advance for any tips,
Chris.

From the documentation about powering the Maestro:

In this configuration, if the computer (or other USB host) that the Maestro is connected to goes to sleep, then by default the Maestro will go to sleep and stop sending servo pulses. If you need to drive your servos while your computer is off, you can use the Never sleep (ignore USB suspend) option in the Serial Settings tab of the Maestro Control Center. Note that this will only work if the computer is supplying power to the USB port while it is asleep, and it will make your Maestro be non-USB-compliant.

What does it mean by “non-USB-compliant”?

Is a USB charger “non-USB-compliant”?

Now I set the “Never Sleep (ignore USB suspend)” setting ON and Apply.

What I see is that both the PC powered USB and the charger powered USB turn on the flashing yellow light, but they also set the Error light. As soon as I plug in the USB, the red Error light comes on.

The green power light is only on when the I’m powering from a laptop, not from the charger USB.

Curious.

Hi Chris,

It sounds like you are trying to do a lot of different things at the same time. I recommend simplifying the problem a bit, e.g. first getting the Maestro to turn on correctly with the USB charger and NO XBee, controlling it with a direct wired connection (still no XBee), and then finally adding in the XBee. Anyway, I can try to address some of your questions and problems:

  • Your XBee connections look reasonable. (But I have never used an XBee before.)
  • USB devices are required according to the USB specification to go to sleep under certain situations, and the way we have implemented this on the Maestro apparently also causes them to sleep when plugged in to a charger. You did the right thing by disabling sleep.
  • The green LED is a USB connectivity LED, not a power LED. When you are not plugged into an actual computer, it will probably not turn on.
  • As described in the User’s Guide linked above, the pattern of blinking on the yellow LED can give you feedback about what the Maestro is doing.
  • To see what error is indicated by the red LED, you can connect the Maestro to USB and run the Control Center.
  • The control center can also tell you what servo signals the Maestro is sending, so you do not need to have a servo plugged in for testing.
  • Make sure to set your serial mode correctly on the Maestro. You will probably want to choose a fixed baud UART mode for communication with the XBee. (But like I said earlier, you should probably debug it with a direct connection to the microcontroller first, to eliminate any uncertainty about what problems the XBee is introducing.

Does that help?
-Paul

It helps a lot, Paul.

I was looking in the Command application to see if it would show what it was sending to the Maestro, but that has eluded me.

I’ll keep posting what I find for future reference.

Thanks,
Chris

Here’s some sample python code that works with USB on COM6.

Device manager shows this:
Pololu Micro Maestro 6-Servo Controller Command Port (COM6)
Pololu Micro Maestro 6-Servo Controller TTL Port (COM7)
USB Serial Port (COM4) - my xbee ftdi cable is connected to this port

# testing the servo direct via USB
# original code from this site:
# http://dmt195.wordpress.com/2009/01/19/python-to-interface-with-the-pololu-8-channel-servo-controller/ 
# using the command maestro command device, set the Serial mode to UART, fixed baud rate: 9600

import serial
import sys

SERIALPORT = "COM6"
BAUDRATE = 9600

# for servo direct
ser=serial.Serial(SERIALPORT)
ser.baudrate=BAUDRATE

def setpos(device,angle):

	#Check that things are in range
	minAngle = 0.0
	maxAngle = 180.0
	if angle > maxAngle or angle <minAngle:
		angle = 90
		print "WARNING: Angle range should be between 0 and 180. Setting angle to 90 degrees to be safe..."
		print "moving servo "+str(device)+" to "+str(angle)+" degrees."

	minTarget = 4000
	maxTarget = 7500
	scaledValue = int((angle / ((maxAngle - minAngle) / (maxTarget - minTarget))) + minTarget)

	print "scaledValue: ", scaledValue
	print "angle: ", angle

	#Get the lowest 7 bits
	bytelow=scaledValue&127
	#Get the highest 7 bits
	bytehigh=(scaledValue-(scaledValue&127))/128

	#move to an absolute position in 8-bit mode (0x04 for the mode, 0 for the servo, 0-255 for the position (spread over two bytes))
	# this works - Pololu protocol: 0xAA, device number, 0x04, channel number, target low bits, target high bits
	# bud=chr(0xAA)+chr(device)+chr(0x04)+chr(0x00)+chr(bytelow)+chr(bytehigh)

	# this works - compact protocol: 0x84, channel number, target low bits, target high bits
	bud=chr(0x84)+chr(0x00)+chr(bytelow)+chr(bytehigh)

	print "sending: " + bud
	ser.write(bud)

m=int(sys.argv[1]) # angle as an argument
setpos(12,m)

Here’s the code I’m using to work with XBee Series 1 radios.
Serial mode UART, fixed baud: 9600

I’m using the 2.0 python-xbee libs from here:

code.google.com/p/python-xbee/

# testing the servo/xbee function
# original code from this site:
# http://dmt195.wordpress.com/2009/01/19/python-to-interface-with-the-pololu-8-channel-servo-controller/ 

import serial
import sys
from xbee import XBee
# import time

SERIALPORT = "COM4"    # the com/serial port the XBee is connected to
BAUDRATE = 9600      # the baud rate we talk to the xbee

# for xbee
serial_port = serial.Serial(SERIALPORT,BAUDRATE)
xbee = XBee(serial_port)
Destination = '\x00\x18' # Dec 24, MY=18

def setpos(device,angle):

	#Check that things are in range
	minAngle = 0.0
	maxAngle = 180.0
	if angle > maxAngle or angle <minAngle:
		angle = 90
		print "WARNING: Angle range should be between 0 and 180. Setting angle to 90 degrees to be safe..."
		print "moving servo "+str(device)+" to "+str(angle)+" degrees."

	minTarget = 4000
	maxTarget = 7500
	scaledValue = int((angle / ((maxAngle - minAngle) / (maxTarget - minTarget))) + minTarget)

	print "scaledValue: ", scaledValue
	print "angle: ", angle

	#Get the lowest 7 bits
	bytelow=scaledValue&127
	#Get the highest 7 bits
	bytehigh=(scaledValue-(scaledValue&127))/128

	#move to an absolute position in 8-bit mode (0x04 for the mode, 0 for the servo, 0-255 for the position (spread over two bytes))
	# Works - Pololu protocol: 0xAA, device number, 0x04, channel number, target low bits, target high bits
	# bud=chr(0xAA)+chr(device)+chr(0x04)+chr(0x00)+chr(bytelow)+chr(bytehigh)

	# Works - Compact protocol: 0x84, channel number, target low bits, target high bits
	bud=chr(0x84)+chr(0x00)+chr(bytelow)+chr(bytehigh)

	print "sending: " + bud
	xbee.tx(dest_addr=b"\x00\x18", data=bud)

m=int(sys.argv[1])
setpos(12,m)

The final power pin arrangement was just like the drawing above. I hooked up a 12V 1A wall wart to the servo PWR and GND pins and a phone charger (5V 1A) to the USB plug.

There is no voltage regulator on the servo pins; just the raw output of the wall wart.

The XBee is being powered by the 5V out pin and the associated GND. The XBee TX/RX pins are being crossed over to the Maestro TX/RX pins; meaning TX on XBee goes to RX on Maestro, RX on XBee goes to TX on Maestro. As I understand it, you don’t actually need the RX on the XBee connected to TX on the Maestro unless you’re trying to read data back from the Maestro. In this setup, I’m just trying to make the servo move from 0 to 180 degrees; one way communications.

Wondering if it would be safe to connect that unregulated 12V to the Vin plug so I wouldn’t need the USB input?

I’ve connected a giant servo (perhaps overkill - GWS S689-2BB/MG/JR Giant Servo) to turn a damper in an air conditioning vent to see if I can temperature control the opening and closing of a vent to any given room in a house.

The numbers…

In my code, I created some values that represent the maximum and minimum range of the servo. You can see them as:

	minTarget = 4000
	maxTarget = 7500
	scaledValue = int((angle / ((maxAngle - minAngle) / (maxTarget - minTarget))) + minTarget)

The angle range is from 0 to 180.

The servo target value ranges from about 1000 to 2000 µs with a mid-range around 1500. (I set the low and high values inside the default range using the command control center software to keep the servo from pegging max or min).

Then there are some other values (see code above) that I have no idea what they mean, but I needed them in the original sample code I found. The original range was from 500 to 5000.

I needed to set these to 4000 to 7500. 4000 would give me a near zero angle and 7500 would give me a nearly 180 degree angle. Obviously I just want to input the angle I want (0 to 180) and have the servo go to the requested angle.

Can someone please explain the relationships or point me to the documentation that relates these three range values; angle, µs, and whatever the 3rd value is?

Thanks in advance,
Chris.

Hello, Chris.

So, does this mean that you have wireless communication with a Maestro working? If so, great!

Anyway, the code that you started with was for a different servo controller, and phrases like “absolute position in 8-bit mode” do not apply to the Micro Maestro. If you look at the documentation for the command 0x84 that you are using, called “Set Target”, in the User’s Guide, you should see that the units are quarter-microseconds. As for converting microseconds to an angle, that depends on your servo, and the conversion factor is not usually specified. You will have to calibrate it yourself.

12V is way too much for normal servos, which are usually designed for operation up to a little over 6V. The Maestro itself, however, is fine with a regulated 12V on Vin. Most wall warts these days are regulated - if yours is not, you should check the actual voltage coming out of it before connecting it to the Maestro.

By the way, if you do power the Maestro using Vin, you should note that the 5V output will be limited to about 20mA, which is likely to not be enough to power your XBee.

-Paul

Yes, I have it working. Wirelessly.

I am powering the servo side with a simple 6V 500mA wall wart.

While the XBee uses only about 50mA in receive mode, it’s still a bit more than the 20mA you referenced so I am powering the logic side with a usb phone charger 5V, 1A.

My exercise was to show how it would be possible to control a damper in a heating duct. The duct/damper was purchased from Home Depot and it had a 100V to 24V transformer and a motor to turn the damper. You apply power and it mover the damper. To keep the damper closed, you had to keep power applied.

I removed the transformer and the motor and hooked up the GWS S689-2BB/MG/JR Giant Servo. I think it’s overkill, but I’m still learning how these things work.

I have a temperature sensor on another xbee. I set a temperature threshold and then the code reads the values from the temperature sensor. If it goes below 68F it sends codes to open the damper. When it goes back up to 72F it sends the codes to close the damper.

I’ve been running a wireless sensor network to track various environmental values in my house; temperature, light, air quality, plug loads, etc. I send the data to sites like Cosm (was Pachube), Thingspeak, Open.Sen.se, etc. for storage and charting. I am using a wifi router re-flashed with OpenWRT and with python added as a scripting language. The sensor boards have an xbee radio and send up to 4 sensor readings each.

This is my first experiment about how to go the other way and control things based on the data I collect. Lots of fun to come.

I plan to show how I did this at the upcoming Maker Faire next weekend so thanks for your help.

The circled pins line up conveniently with the pins of the xbee explorer (power regulated - 3.3-16V input) board. I use a 4-pin female/female jumper wire to connect them which keeps things neat on my airplane and quadcopter. You could also use a 3-pin jumper if you don’t need feedback from the servo controller.