A friend of mine jokingly proposed using multiple cortexes in competition. I am aware this is not competition legal. However, I was wondering how one might go about doing this as a side project. My first guess was to take the input/output ports and run 10 of the 3 wire cables between two cortexes. The master cortex would simply output the motor value down the respective cable. The second cortex would read the value and send it to the respective motor. (assuming the 3 wire cables can handle a signed 6 bit value)
My second train of thought was to replace the 10 wire setup with a 2 wire setup using a heartbeat algorithm (which may have trouble with consecutive motors whose values are the same. I was considering using a variable of a different datatype, but again with the cable limitations) to confirm each of the data transfers and to ensure the right motors have the right values.
My third train of thought was to replace the 2 wire setup with only a single wire using programming to reconfigure this port as an input/output port on each of the cortexes. Then, a modified version of the heartbeat algorithm would be used to ensure correct motor function.
Can anyone confirm or deny that this will work? I was going to pitch the idea of a robot constructed of our school’s 5 teams after competition time ended to our mentor.
You have enough time between refreshes (20ms) to send (some) data over a serial link such as the SPI or UART headers. I would recommend UART, four cables. It’s a fast link and will allow two way communication.
I had a BeagleBone Black talking to a Cortex in this thread. I also worked on a protocol for the messaging, which is here. I don’t recommend using it but the project may help you develop some insights.
Also Sparkfun has an amazing guide on UART and SPI.
Some quick math shows that you can send 288 bytes in the 20ms window. Probably a low less since I assumed baud = bps which isn’t true.
Nevertheless one motor values fits into one byte, so sending 10 bytes of data is definately possible.
Having said that, why not use something like:
It’s a more involved solution but probably a better one IMHO.
Ya so UART is the way to go. It is really rugid and easy to setup. You could get a cortex telling another what to command its motors with a dozen lines of code.
edit: If you wanted to do it using output ports here would be my approach
If I was going to try to send motor commands over standard digital ports and was coding everything myself I would probably do everything in parallel rather than serial.
1 pin to signal messages
3 pins to select motors
8 pins to instruct what power to set motors
motorNumber = pin1 << 2 | pin2 <<1 | pin3;
motorPower = pin1<<7 |pin2 <<6 |pin3 <<5 etc
and use the rising edge of the signal pin to know when to check the parallel lines
NOTE this method is pretty terrible and slow.
Isn’t using a power expander essentially the
Nope. Power expander still takes up motor ports on the primary cortex. Two cortexes gives more controllable ports for motors. Two cortexes and two power expanders would have four batteries to draw from across 20 motor ports.
In the second cortex, you should put in some timers to shut off the motors if no command has been received and processed in X milliseconds. That way your other motors turn off if the UART wire came loose or some other catastrophic thing happened to cortex one.
You could also have four joysticks on this if Cortex 2 had a Vexnet key. :head explodes: