MicroTrac Controller v17.10/Code: Difference between revisions
Jump to navigation
Jump to search
Line 57: | Line 57: | ||
//CREATE STRING | //CREATE STRING | ||
string_currentstate ="abcdefgi"; | String string_currentstate ="abcdefgi"; | ||
//START COMMUNICATING WITH XBEE | |||
Serial.begin(9600); | |||
} | } | ||
Line 65: | Line 67: | ||
if pin | if pin | ||
string_currentstate +="a"; | string_currentstate +="a"; | ||
print string_currentstate; | |||
string_currentstate = ""; | |||
</nowiki> | </nowiki> |
Revision as of 16:35, 29 October 2017
Goals
- Establish serial communication over xbee radio
- Transmit commands from the "remote controller" box to "onboard controller" box.
- Attempt to run identical arduino control software on both boxes.
- Will run in onboard mode if jumper set between defined pins.
- When in onboard mode, transmit GPS location.
- Boxes will ping each other and will shut down if connection lost.
- Store radio information in EEPROM. Update on startup.
- Create a program to define the EEPROM
- Operate relay switches when "HAND" switch is on
Terms, Pins and Variables
Each Solenoid and corresponding relay switch will be defined by a single alphabet letter.
- A - Left Track Forward
- B - Left Track Backward
- C - Right Track Forward
- D - Right Track Backward
- E - Arms Up
- F - Arms Down
- G - Bucket Up
- H - Bucket Down
AT Commands
- ATIDXXXX - set radio network ID
- ATWR - save settings to long term memory
Code Theory
When a switch is thrown, its letter followed by a 1 or 0 will be transmitted over serial.
- example: "E1" will engage the solenoid to raise the arms. "E0" will turn off the solenoid and will stop raising the arms.
- While "F1" will lower the arms and "F0" will stop lowering the arms.
If vehicle is stopped, gather and transmit position and orientation data. otherwise briefly stop vehicle every X minutes.
Code
Controller Box
void setup() { //pins //SET PINS AS INPUT FROM TOGGLE SWITCHES //SET PINS AS OUTPUT TO RELAY MODULE //CREATE STRING String string_currentstate ="abcdefgi"; //START COMMUNICATING WITH XBEE Serial.begin(9600); } void loop() { if pin string_currentstate +="a"; print string_currentstate; string_currentstate = "";