Description
These instructions demonstrate the upgrade of an Arlo robot from Propeller 1 to Propeller 2 control with the new Parallax Universal Motor Controller Add-on #64010.
The operation and example code are demonstrated in the included video. The example code features the basic instructions required to drive the Arlo robot, and has been designed to operate via a terminal connection, either with a PropPlug cabled USB connection or wirelessly with the Parallax WiFi module.
The code demonstrates the use of a non-blocking human interface, such that you can issue multiple instructions without waiting for the first instructions to complete. For example, the non-blocking interface allows the user to interrupt a drive command with a stop command. This might be very important to prevent a robot collision!
The SPIN2 source code archive is included.
This project aims to provide a starting point for user code and demonstrates the basic principles of robot control and communication. Join us at P2 Live Forum to ask questions or share your robot design! You can always post your ideas and questions at our forums too! https://forums.parallax.com.
Connections
- Plug WX SIP Module into the WX Adapter. Observe the orientation markings on the WX Adapter- the white bump matches the metal can bump on the WiFi module.
- P2 Edge Module Breadboard
- Recommend to set the “ACC VOUT” header 5V jumper to OFF position.
- Plug P2 Edge Module into the socket
Plug WX Adapter with WiFi module into IO pin header P56-P63 - Plug 64010 Universal Motor Driver into IO pin header P0-P15 and P16-P23
- Plug four encoder cables (two from each motor) into IO pin headers as follows:
- Left wheel A encoder, Black pin to GND pin, White pin to IO pin 26
- Left wheel B encoder, Black pin to GND pin, White pin to IO pin 27
- Right wheel A encoder, Black pin to GND pin, White pin to IO pin 18
- Right wheel B encoder, Black pin to GND pin, White pin to IO pin 19
- Connect 5V power from Arlo 5V output terminal to the Breadboard DC Barrel Jack.
- 64010 Universal Motor Driver Add-on
- Left Motor Blue Cable to U channel spring terminal connector
- Left Motor Red Cable to V channel spring terminal connector
- Right Motor Blue Cable to W channel spring terminal connector
- Right Motor Red Cable to X channel spring terminal connector
- Arlo Motor output positive terminal to VIN spring terminal connector
- Arlo Motor output negative/GND terminal to GND spring terminal connector
Steps
- Attach the P2 Edge with Universal Motor Controller to your Arlo robot, or your own custom robot. Follow the photos, connections and video for guidance.
- Download the zip code archive file and unzip it.
- Open PropellerTool on your computer, and load the example code file extracted from the zip: 64010_Universal_Motor_Driver_Demo_MMWK.spin2
- Ensure your robot is powered on, and the WiFi module is connected to the same network as your computer or laptop. (For help with setting up WiFi refer to this guide :
- In Propeller Tool, verify that the two IO pin “con” sections near the start of the code have the same IO pin settings as your robot. The example code has them set to the same positions as shown in the Photos and Video, but you can change them as required.
- In the code section “con { encoder io pins }”, set the IO pins to match the encoder cables coming from your motors. If you do not have encoders then set all the Encoder pins to -1.
- In the code section “con { motor io pins }”, set the BASEPIN value to match the lowest IO pin number of the headers your Universal Motor Driver is plugged into.
- Save the code with your changes (CTRL + S), and then press F8 to generate a binary file. A window will appear- at the bottom click the “Save as binary” button, choose the folder that you unzipped the code archive into (where you saved 64010_Universal_Motor_Driver_Demo_MMWK.spin2), choose a filename to save the binary (recommended: 64010_Universal_Motor_Driver_Demo_MMWK.binary) and confirm.
- Now you have created the code binary file, the next step is to program and control your robot!
- Open a command prompt (Press the windows key on your keyboard, type “cmd”, press ), then follow these steps:
- Navigate to the folder where you unzipped the code archive (and saved the binary).
- Type (or copy/paste) this proploader command into the command prompt window and press :
proploader -T -D chipver=P2 -D reset=cts -r - 64010_Universal_Motor_Driver_Demo_MMWK.binary
After some moments you should see a message “Download Successful”. Press to start communications with your robot, then refer to the API section to control your robot. - If you have a pop-up request from Windows asking to confirm firewall access then press OK and if necessary try the proploader command again. You might be asked for permission the first time you open the connection to your robot.
API
Command | Parameter Options | Description |
ECHO | No Parameter ON OFF | Toggle command echo on or off (On by default) Set command echo on Set command echo off |
STOP | No Parameter | Immediately abort previous command and stop the motors |
GOLEFT | speed | speed can be -1000 to 1000. Negative is reverse rotation, Positive is forward rotation, 1000 is fastest, 0 is stop. Note that depending on the size and load of a DC motor, a minimal amount of speed will be required to turn them. Example- At moderate load the Arlo motors will start turning when speed is greater than 200. (or -200 in reverse). |
GORIGHT | speed | |
GO | No Parameter | Repeat previous GO command Set both the GOLEFT and GORIGHT speeds and drive the wheels together Examples: GO 300 300 (drive forward) GO -300 -300 (drive backwards) GO 300 -300 (spin the robot!) |
DRIVE | left-speed right-speed left-speed right-speed | Set multiple pairs of left and right speed settings. Important to also set the TIME or TICK greater than 0! Robot will execute each pair of values until the TIME or TICK limit expires for each move, looping through the entire DRIVE string. Tip: Pre-prepare a DRIVE statement in notepad to perform a driving manoeuvre, then paste it into the command window. |
TIME | time in milliseconds movement limit | 0-5000, 0 is OFF This is the movement time limit for each command. After which the robot will stop and be ready to process the next command. If set to 0 the robot will ignore the time and may move indefinitely, until a new command is issued, such as STOP. |
TICK | tick count movement limit | 0-360, 0 is OFF This is the movement encoder ticks limit for each command. After which the robot will stop and be ready to process the next command. If set to 0 the robot will ignore the encoder ticks and may move indefinitely, until a new command is issued, such as STOP. |
RAMP | ramp up / down rate | 0-100, 0 is OFF This is the ramp up and down rate for the motors, to prevent sudden power surges and mechanical stresses. 0 disables the ramp feature. Otherwise the speed setting is divided into ramp steps and each step pauses for 10milliseconds. Such that a ramp rate of 100 represents a 1 second ramp-up and ramp-down time. Note that the ramp time is included in the “TIME” calculation. If ramp up and down are each 1 second, you will observe that total drive “TIME” is reduced by that amount and therefore drive distance will also be impacted. |
HELP | No Parameter | Display a list of commands |
Command Delimiter
Where multiple parameters are used, either a SPACE or COMMA can be used as the delimiter between the command and first parameter, and also between subsequent parameters.
Command Hints
For TIME, TICK and RAMP commands, if you enter the command without parameters it will reply with the currently stored value. In the case of the GO command, it will execute the command using the previously stored speed values.
Notes about Parts Used
- Power Cable to the P2 Edge Module Breadboard. I used a DC Barrel Jack pigtail cable (2.1mm x 5.5mm) from the Arlo Power Distribution Board 5V output to the P2 Edge Module Breadboard. You might already have such a cable powering the old Propeller 1 Board on the Arlo. Here is an example of the item from Amazon
- The PlugPlug could be used to program and operate the robot via USB, instead of over the wireless connection. In that case, program your P2 Edge module in the usual way (Typically F10 in Propeller Tool), and then press F12 in PropellerTool to open a terminal window and hit enter to start communication with the robot.
Parts Used
Additional Resources
Document Author
- Michael Mulholland
Source Code Author
- Michael Mulholland