If you have been following my posts here you know I have been working on a master/slave set of apps for the Pololu Wixel module, with my specific thing being large scale garden railroads. But I think this will work for lots of applications so I’m going to try to distribute a kit.
Anyhow, what this system entails is a master Wixel connected to a Raspberry Pi (although any host would work) using USB. The master can control and monitor up to 64 wireless slaves. Each slave can control 6 servos and send 3 analog inputs back to the master.
I have had the servo outputs working on multiple slaves for some time now, today I got the analog inputs to flow back to the master and the Python Class now reads them correctly. So the Software layer is now complete and transparent. It just runs.
I’ve built a bunch of prototypes and the soldering is quite a pain, so I’ve designed a PCB that makes all of this easy. Solder in the wixel and a set of servo header pins, connect power and servos and it works. A complete slave.
So, I’m contemplating a run of boards, in small quantities they are about $5 a board. While the software may change over time, these will always be the standard physical platform for servo slaves.
If anyone is interested in all of this and getting a board and the current software, email me, I’ll order extra boards.
EMAIL MARTAN
I have a python class that communicates with the master and thus reads and writes the slaves. I’ve posted it’s current incarnation below, it has lots of debug info in it and is just provided so you can see where I’m going with this. Obviously this fits into my other explorations with RPi tornado web sockets and all that 
import serial
import time
import random
class wixelMasterController:
def __init__(self):
usbPort = '/dev/ttyACM0'
self.sc = serial.Serial(usbPort, timeout=1)
self.initializeTables()
def initializeTables(self):
self.masterTxTable = [] # create the transmit and
self.masterRxTable = [] # receive tables
for i in range(0,64): # as lists
self.masterTxTable.append([])
for j in range(0,6):
self.masterTxTable[i].append(0)
for i in range(0,64):
self.masterRxTable.append([])
for j in range(0,16):
self.masterRxTable[i].append(0)
def closeMaster(self):
self.sc.close() # close serial port
def setServoPosition(self, slave, servo, data):
self.masterTxTable[slave][servo] = data
self.sendSlaveData(slave)
def getSlaveData(self, slave):
datapacket = [] # init list
datapacket.append(chr(0x81)) # command byte, write tx table
datapacket.append(chr(slave)) # slave to control goes here
for d in datapacket: # send command to the serial port
self.sc.write(d)
returndata = [] # now read data returned by master
for d in range(0,16): # for this slave
returndata.append(self.sc.read(1))
s = "slave: %d " % slave # DEBUG print the data
print s,
sv=""
for r in range(4,16): # skip the length and address
sv+="%2x " % ord(returndata[r]) # print analog low, hi
print sv
def sendSlaveData(self, slave):
datapacket = [] # init list
datapacket.append(chr(0x82)) # command byte, write tx table
datapacket.append(chr(slave)) # slave to control goes here
for i in range(0,6): # queue up the master data for tx
db = self.masterTxTable[slave][i]
d0 = db & 0x7f # data must be adj for 7 bit chars
d1 = (db & 0x7f80) >> 7 # or reception gets confused
datapacket.append(chr(d0)) # note the convolutions here?
datapacket.append(chr(d1)) # don't like it but it works
datapacket.append(chr(0)) # only have six servos, 12 bytes plus the command and slave
datapacket.append(chr(0)) # so add last two for 16 total packet size
for d in datapacket: # send them to the serial port
self.sc.write(d) # note that it HAS to be exactly 16 bytes total
#
#
## main ##
#
#
master = wixelMasterController()
random.seed()
while(True):
for j in range(0, 64):
for i in range(0, 6):
master.setServoPosition(j, i, random.randint(950, 1000))
time.sleep(1)
print "*******************************"
for j in range(0, 8):
master.getSlaveData(j)
for j in range(0, 64):
for i in range(0, 6):
master.setServoPosition(j, i, random.randint(1700, 2200))
time.sleep(1)
print "*******************************"
for j in range(0, 8):
master.getSlaveData(j)
master.closeMaster()