We are making a hexapod robot. There are 6 legs with 3 servos on each leg. This requires 18 pwm outputs. Unfortunately, an RC only has 16. Our solution to this is to send a string of PWM values through a serial cable to another RC and have that slave RC output PWM values.
We have connect the two RCs with a serial cable and we have a null modem between them. We have tested with and without the null modem.
The baud rates are both set to 115200.
In our master RC, we call Write_To_Serial_Port_One() and in our slave RC we call Serial_Port_One_Byte_Count() and Read_Serial_Port_One().
We cannot retrieve the data sent by the master to the slave.
Our program has been simplified to the master continuously sending out ‘@’ on each iteration of Default_Routine() and our slave turns on a light on the OI if it receives that character.
The master is definitely writing the ‘@’ because I can see it show up on the terminal on my computer. Therefore, the problem must be that the slave isn’t reading it.
Any ideas?
Thanks in advance.
For receiving on the serial port to work you need to have ENABLE_SERIAL_PORT_ONE_RX defined and to call Init_Serial_Port_One() in the initialization, but I’m assuming from the content of your post that you’ve got that covered.
Are you confident in the integrity of your null modem cable? If you’re receiving input on the computer terminal, that’s fine, but that’s presumably with a different plain serial cable. Try hooking up the slave to the computer and sending the ‘@’ from the terminal.
Also, if I were trying to debug this problem I would put some temp code to flash the lights directly in the serial port rx interrupt handler in user_routines_fast.c, just to verify that the serial port is receiving independently of what’s being sent.
Lastly, when you say “null modem cable”, you do mean a male-male serial cable that has the TX and RX pins swapped along the length and not just a normal serial cable with a gender-bender, right? Just checking.
Along with Pat’s suggestions, you could also try lighting your indicator when Serial_Port_One_Byte_Count() > 0. (do this before you call the read fxn)
I’m 99% sure you have ENABLE_SERIAL_PORT_ONE_RX defined, otherwise you could not call Read_Serial_Port_One() without the compiler throwing errors.
We got it working, thanks.
We weren’t including serial.h… which is odd because MPLab still let us compile. Thanks for the help guys
check out some pictures near the bottom of the page http://www.teamechoes.com/index.php?page=9
You guys might also check into the Parallax Servo Controller: http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/28023/List/1/ProductID/376/Default.aspx?SortField=ProductName%2CProductName
It might be a cheaper and lighter way to control additional servos from one RC using the serial port. Looks like an easy way to add 16 more servo outputs and you can connect two of them together to get 32 servo outputs.