View source
From HobbyVex
for
VEX Command Set
Jump to:
navigation
,
search
Most information here has been copied and pasted from select posts by members of the [http://www.vexforum.com VEX forum]. Using the online code, I am able to initialize the controller and monitor it's broadcasts. ==Manual (sort of)== [http://www.vexforum.com/local_links.php?catid=26&sort=N&pp=10&page=3 The Vex Controller Code] is a Reverse Engineer of the Vex Controller On-Line Code for IFI/intelitek Loader v2.8.0.1. <br> That means that it (should) react just like the Vex Controller On-Line Code shipped with the IFI/intelitek Loader v2.8.0.1. <br> RS-232 communication has many parameters that can be adjusted, but all the PC<->Vex communication occures at a speed of 115200 Bits Per Second, 8 Data Bits, NO Stop Bits, and One Stop Bit (You will see this written as "115200bps, 8N1") <br> It also means that the Vex Controller On-Line Code is limited to 4 Analog Inputs in I/O block 1-4, 6 Digital Inputs in I/O block 5-10, and 6 Digital Outputs in I/O block 11-16. The 6 Interrupts are also used as Digital Inputs as well, giving a Total of 12 Digital Inputs. There is also the 8 PWM (Motor and Servo) Outputs as well. This (currently) limits the Inputs to stright Analog Devices, (e.g. Line Follower, Light Sensor, and Potentiometer), Digital Devices (e.g. Limit Switch, Bumper Switch, and the Orange Jumpers).<br> Analog Inputs will report an Integer Number between 1023 and 0. Digital Inputs will report an Integer Number between 1 and 0 (TRUE and FALSE). The Optical (Quadrature or otherwise) Encoder's and Ultrasonic Range Finder won't work with the Current Code (Never Fear, I have a plan). Also Devices that Transmit Serial Data (e.g. GPS and some Compesses) won't work either, (Never Fear, I have a plan for that too). Now, lets talk some terminology.. Broadcast and/or Request.<br> At my day job, the devices I work with that communicate together, send Data in two different paradigms, the Broadcast and/or Request. A Communication Device may ONLY Broadcast data, or ONLY Transmit data (on a Request from another Communication Device) or may do Both (some data is Broadcast other data is Transmitted on a Request, or data is typically Transmitted on a Request and Broadcast on a Warning, Error or Limit condition).<br> That is a total of Four different paradigms, and I have not even got to the hybred paradigm that the Vex Controller On-Line Code for IFI/intelitek Loader v2.8.0.1 uses. The Vex Controller On-Line Code uses a Broadcast paradigm for ALL Input Data to the Vex Controller, BUT, you have to Activate It (That is where the Request part comes in)!! To get the Vex Controller to Broadcast, you must send it this Init Data Packet ("0xC9 0x17 0x01 0x00 0x00 0x00"). The Vex Controller will Broadcast until the Battery goes Dead, it Locks Up (AKA Hangs) or you send the Exit Data Packet ("0xC9 0x17 0x02 0x00 0x00 0x00"). There is also a Reset Data Packet ("0xC9 0x17 0x03 0x00 0x00 0x00"), which will turn off ALL the Digital Outputs (And probably Stops all the PWM devices, but the IFI/intelitek Loader will send a STOP for each PWM Output, so I don't know how the Vex Controller really works on this point). Once the Vex Controller receives the Init Data Packet, it starts Broadcasting the following data, about 2 times per second. There is 54 Characters, including a Terminating Carrage Return (Symbol "CR", Hexadecimal "0x0d") ALL Charcters are Printable ASCII characters, delimited(i.e. To be Divided or Seperated) by Spaces: "BOARDDATA 1018 1022 1022 1022 1 1 1 1 1 1 1 1 1 1 1 1" This Data is broken down like this:<br> "BOARDDATA " 10 Characters, This is the Header, it never changes.<br> "1018 " 5 Characters, This is Analog Input #1 (in I/O block position 1).<br> "1022 " 5 Characters, This is Analog Input #2 (in I/O block position 2).<br> "1022 " 5 Characters, This is Analog Input #2 (in I/O block position 3).<br> "1022 " 5 Characters, This is Analog Input #2 (in I/O block position 4).<br> "1 " 2 Characters, This is Digital Input #5 (in I/O block position 5).<br> "1 " 2 Characters, This is Digital Input #6 (in I/O block position 6).<br> "1 " 2 Characters, This is Digital Input #7 (in I/O block position 7).<br> "1 " 2 Characters, This is Digital Input #8 (in I/O block position 8).<br> "1 " 2 Characters, This is Digital Input #9 (in I/O block position 9).<br> "1 " 2 Characters, This is Digital Input #10 (in I/O block position 10).<br> "1 " 2 Characters, This is Digital Input #1 (in Interrupt block position 1).<br> "1 " 2 Characters, This is Digital Input #2 (in Interrupt block position 2).<br> "1 " 2 Characters, This is Digital Input #3 (in Interrupt block position 3).<br> "1 " 2 Characters, This is Digital Input #4 (in Interrupt block position 4).<br> "1 " 2 Characters, This is Digital Input #5 (in Interrupt block position 5).<br> "1\x0d" 2 Characters, This is Digital Input #6 (in Interrupt block position 6).<br> ===Sending Commands=== all commands must be sent in binary format, here is how you do it in linux. For example to send the init packet <pre>echo -e "\xC9\x17\x01\x00\x00\x00" > /dev/ttyS0</pre> here is what my stty output looks like when it works <pre> speed 115200 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 5; -parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke </pre> ==Commands== Init: 0xC9 0x17 0x01 0x00 0x00 0x00<br> Exit: 0xC9 0x17 0x02 0x00 0x00 0x00<br> Reset: 0xC9 0x17 0x03 0x00 0x00 0x00<br> PMW and Motor Ports<br> 0xC9 0x17 0x04 0x00 0x7F 0x00 (Motor Port #01, STOPPED).<br> 0xC9 0x17 0x04 0x01 0x7F 0x00 (Motor Port #02, STOPPED).<br> 0xC9 0x17 0x04 0x02 0x7F 0x00 (Motor Port #03, STOPPED).<br> 0xC9 0x17 0x04 0x03 0x7F 0x00 (Motor Port #04, STOPPED).<br> 0xC9 0x17 0x04 0x04 0x7F 0x00 (Motor Port #05, STOPPED).<br> 0xC9 0x17 0x04 0x05 0x7F 0x00 (Motor Port #06, STOPPED).<br> 0xC9 0x17 0x04 0x06 0x7F 0x00 (Motor Port #07, STOPPED).<br> 0xC9 0x17 0x04 0x07 0x7F 0x00 (Motor Port #08, STOPPED).<br> 0xC9 0x17 0x04 0x00 0xFF 0x00 (Motor Port #01, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x01 0xFF 0x00 (Motor Port #02, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x02 0xFF 0x00 (Motor Port #03, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x03 0xFF 0x00 (Motor Port #04, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x04 0xFF 0x00 (Motor Port #05, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x05 0xFF 0x00 (Motor Port #06, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x06 0xFF 0x00 (Motor Port #07, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x07 0xFF 0x00 (Motor Port #08, MOTOR CLOCK WISE, SERVO COUNTER CLOCK WISE).<br> 0xC9 0x17 0x04 0x00 0x00 0x00 (Motor Port #01, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x01 0x00 0x00 (Motor Port #02, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x02 0x00 0x00 (Motor Port #03, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x03 0x00 0x00 (Motor Port #04, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x04 0x00 0x00 (Motor Port #05, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x05 0x00 0x00 (Motor Port #06, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x06 0x00 0x00 (Motor Port #07, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE).<br> 0xC9 0x17 0x04 0x07 0x00 0x00 (Motor Port #08, MOTOR COUNTER CLOCK WISE, SERVO CLOCK WISE). The First Two Bytes are the Header, they are always the same.<br> The Third Byte is the "Device Family", "0x04" is Motor/Servos (PWM Outputs).<br> The Fourth Byte (for the "Device Family PWM") is the Individual Device.<br> The Fifth Byte is the Actual Speed Value for the Individual Device.<br> The Sixth Byte always seems to be 0x00. Digital Output Ports<br> 0xC9 0x17 0x06 0x00 0x00 0x00 (Output Port #11, FALSE).<br> 0xC9 0x17 0x06 0x01 0x00 0x00 (Output Port #12, FALSE).<br> 0xC9 0x17 0x06 0x02 0x00 0x00 (Output Port #13, FALSE).<br> 0xC9 0x17 0x06 0x03 0x00 0x00 (Output Port #14, FALSE).<br> 0xC9 0x17 0x06 0x04 0x00 0x00 (Output Port #15, FALSE).<br> 0xC9 0x17 0x06 0x05 0x00 0x00 (Output Port #16, FALSE).<br> 0xC9 0x17 0x06 0x00 0x01 0x00 (Output Port #11, TRUE).<br> 0xC9 0x17 0x06 0x01 0x01 0x00 (Output Port #12, TRUE).<br> 0xC9 0x17 0x06 0x02 0x01 0x00 (Output Port #13, TRUE).<br> 0xC9 0x17 0x06 0x03 0x01 0x00 (Output Port #14, TRUE).<br> 0xC9 0x17 0x06 0x04 0x01 0x00 (Output Port #15, TRUE).<br> 0xC9 0x17 0x06 0x05 0x01 0x00 (Output Port #16, TRUE).<br> The First Two Bytes are the Header, they are always the same.<br> The Third Byte is the "Device Family", "0x06" is Digital (Digital Outputs).<br> The Fourth Byte (for the "Device Family DIO") is the Individual Device.<br> The Fifth Byte is the Actual Output Value for the Individual Device.<br> The Sixth Byte always seems to be 0x00.<br> Vex On-Line Controller Code v2.<br>0, 0.<br>81 Beta, Supports OUTPUT Control of I/O Ports 01-10, if you are not using them for INPUT.<br> 0xC9 0x17 0x06 0x06 0x00 0x00 (Output Port #01, FALSE).<br> 0xC9 0x17 0x06 0x07 0x00 0x00 (Output Port #02, FALSE).<br> 0xC9 0x17 0x06 0x08 0x00 0x00 (Output Port #03, FALSE).<br> 0xC9 0x17 0x06 0x09 0x00 0x00 (Output Port #04, FALSE).<br> 0xC9 0x17 0x06 0x0A 0x00 0x00 (Output Port #05, FALSE).<br> 0xC9 0x17 0x06 0x0B 0x00 0x00 (Output Port #06, FALSE).<br> 0xC9 0x17 0x06 0x0C 0x00 0x00 (Output Port #07, FALSE).<br> 0xC9 0x17 0x06 0x0D 0x00 0x00 (Output Port #08, FALSE).<br> 0xC9 0x17 0x06 0x0E 0x00 0x00 (Output Port #09, FALSE).<br> 0xC9 0x17 0x06 0x0F 0x00 0x00 (Output Port #10, FALSE).<br> 0xC9 0x17 0x06 0x06 0x01 0x00 (Output Port #01, TRUE).<br> 0xC9 0x17 0x06 0x07 0x01 0x00 (Output Port #02, TRUE).<br> 0xC9 0x17 0x06 0x08 0x01 0x00 (Output Port #03, TRUE).<br> 0xC9 0x17 0x06 0x09 0x01 0x00 (Output Port #04, TRUE).<br> 0xC9 0x17 0x06 0x0A 0x01 0x00 (Output Port #05, TRUE).<br> 0xC9 0x17 0x06 0x0B 0x01 0x00 (Output Port #06, TRUE).<br> 0xC9 0x17 0x06 0x0C 0x01 0x00 (Output Port #07, TRUE).<br> 0xC9 0x17 0x06 0x0D 0x01 0x00 (Output Port #08, TRUE).<br> 0xC9 0x17 0x06 0x0E 0x01 0x00 (Output Port #09, TRUE).<br> 0xC9 0x17 0x06 0x0F 0x01 0x00 (Output Port #10, TRUE).<br> If you try to ACTIVATE an OUTPUT for a Port set to INPUT, it should be Ignored.<br> ==MarkO Notes== My Notes from my research on the Vex On-Line Code (05/09-SEP-2008) IFI/Intelitek Loader 2.8.0.1 Sent on Open of "On-Line Window" (Not Sure purpose)<br> 0x0F 0x0F 0x08 0x40 0xB8 0x04 Init (Occurs on Open of "On-Line Window" and "IFI>" prompt from Vex Controller)<br> 0xC9 0x17 0x01 0x00 0x00 0x00 Exit (Occurs on Close of "On-Line Window")<br> 0xC9 0x17 0x02 0x00 0x00 0x00 Reset (Occurs on Press of "Reset All" Button on "On-Line Window")<br> 0xC9 0x17 0x03 0x00 0x00 0x00<br> Reset (For PWM outputs NOT at 0x7F [127], a PWM Control Message with a Data Value of 0x7F is sent)<br> All Digital Outputs are set to OFF.<br> Response of Vex Controller (Vex On-Line Code )<br> Information is Always BROADCAST (like On-Line Code for Version 1.x, unlike DDT Code)<br> (Format Example)<br> BOARDDATA 1018 1022 1022 1022 1 1 1 1 1 1 1 1 1 1 1 1 On EXIT Command from "On-Line Window" Vex Controller RESETS resulting in a "IFI>" prompt from Vex Controller. Power Up of Vex Controller<br> 0x00 0x49 0x46 0x49 0x3E 0x00 (NUL IFI> NUL) ==Bash Script For Testing== <pre>#!/bin/bash # # test and configure serial port for use with VEX conroller running on-line code # set TTY to your port # TTY=/dev/ttyS0 PORT=$[$2-1] if [ ! $1 ]; then echo Usage: echo "vex [device] [number] [command] eg: vex port 1 on OR vex motor 2 down" echo "vex [command] (prepare,init,exit,reset)" exit fi if [ $1 = "prepare" ]; then stty -F $TTY 115200 -parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts \ ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 \ -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 \ -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke \ min 1 time 5 elif [ $1 = "init" ]; then echo -e "\xc9\x17\x01\x00\x00\x00" > $TTY elif [ $1 = "exit" ]; then echo -e "\xc9\x17\x02\x00\x00\x00" > $TTY elif [ $1 = "reset" ]; then echo -e "\xc9\x17\x03\x00\x00\x00" > $TTY elif [ $1 = "motor" ]; then if [ $3 = "up" ]; then echo -e "\xc9\x17\x04\x0$PORT\x00\x00" > $TTY elif [ $3 = "off" ]; then echo -e "\xc9\x17\x04\x0$PORT\x7f\x00" > $TTY elif [ $3 = "down" ]; then echo -e "\xc9\x17\x04\x0$PORT\xff\x00" > $TTY else echo "options are up/off/down" fi elif [ $1 = "port" ]; then if [ $3 = "on" ]; then echo -e "\xc9\x17\x06\x0$PORT\x01\x00" > $TTY elif [ $3 = "off" ]; then echo -e "\xc9\x17\x06\x0$PORT\x00\x00" > $TTY else echo "options are on/off" fi else echo Usage: echo "vex [device] [number] [command] eg: vex port 1 off" echo "vex [command] (prepare,init,exit,reset)" fi</pre> [[Category:VEX Robotics]] [[Category:Robotics]] [[Category:Robotics]]
Return to
VEX Command Set
.
Views
Page
Discussion
View source
History
Personal tools
3.145.9.12
Talk for this IP
Log in
Navigation
Main Page
Community portal
Current events
Recent changes
Random page
Help
Search
Toolbox
What links here
Related changes
Special pages