05 February 2015


RoboBASIC Manual

David Buckley 01Aug08
version 05Feb15
I got fed up with the poor Hitec documentation so I rewrote it.

Wonky stuff

RCportTable wonky
Girotable other giros?!!!!
Chapter 8 - PWM  @454Hz (sic p90) or should this be 45KHz ?
(Is PWM useable with SERVO and MOVE on MR-C3000? p89)

Q2: "OFFSET" said the command has been added, but like many of the command? 
A2: zero effect compensation directly from the command. To use it, 
OFFSET G6A, 99, 100, 103, 100, 150, 50 
"ZERO" command and feel the same, ZERO command is a visceral record that the EEPROM, but it  does not. 
0 x0340 ~ value of SRAM (zero-point correction) only rewrites. 
Also, ZERO, but the command is + -20, OFFSET command to -50 +. 
OFFSET command temporarily used, the zero point is changing, so please note that. 
When power from the internal EEPROM already set up zero-point correction after the value is 
  loaded, SRAM value of 0 x340 ~ only see the pulses, 
  and therefore, OFFSET command after the value is zero-point correction Changed. 
After use, you must undo. ?.? Variable does not work, so you must direct value. 
Use it to be what? ?.?variable is something that allows it is not directly in the value of ~ 

RoboBASIC Command Instruction Manual

By David Buckley, amended from RoboBASIC Command Instruction Manual v2.10
For Robobasic 2.2.61 downloaded from www.robonova.com/ > Downloads > Software, May 2008.

Command Index

Hitec Manual pageChapterContents
3 Ch1 - Command Summary
10 Ch2 - General Grammar
21 Ch3 - Declaration Commands
25 Ch4 - Flow Control
44 Ch5 - Digital I/O
55 Ch6 - Memory Commands
61 Ch7 - LCD Module
72 Ch8 - Motor Control
103 Ch9 - Music Commands
114 Ch10 - Communication
126 Ch11 - Analog Signals
138 Ch12 - Process Commands
142 Ch13 - Intention Commands

Appendix 1 - ACTION command
Appendix 2 - relevant RoboSavvy Posts
Appendix 3 - Remocon Keys and Template Actions
Appendix 4 - Servo Numbering

Chapter 1 - Command Summary

DIM declare a variable
AS assign a variable when declaring
CONST declare a Constant
BYTE assign as Byte type when declaring
INTEGER assign as Integer type when declaring

Flow control commands
DELAY delay execution
ELSE execute if condition false, see IF...THEN...
ELSEIF begin another conditional statement, see IF...THEN...
ENDIF finish conditional statement, see IF...THEN...
END finish program
FOR begin For..Next loop
GOTO jump to label
ON...GOTO skip according to value of variable
GOSUB call subroutine
IF begin conditional statement, IF...THEN...
NEXT end For..Next loop
RETURN return from subroutine
RUN run program
STOP stop program
THEN execute next statement if condition true, see IF...THEN...
TO Limit of For..Next loop
WAIT wait until servos have finished moving

Digital signal input/output
IN read I/O port
OUT write to I/O port
BYTEIN read byte from I/O port
BYTEOUT write byte to I/O port
STATE get status of I/O port
PULSE send a short pulse to I/O port
TOGGLE reverse state of I/O port
KEYIN receive analog keypad input

Memory commands
PEEK read from controller RAM
POKE write to controller RAM
ROMPEEK read from controller's external EEPROM
ROMPOKE write to controller's external EEPROM

LCD commands
BIN binary number
CLS clear all characters
CONT set contrast
CSOFF cursor off
CSON cusor on
DEC decimal number
HEX hex number
LCDINIT initialise LCD
LOCATE locate
PRINT send charater to LCD

AND logical AND
OR logical OR
MOD modulus
XOR logical XOR
NOT reverse all bits

Motor (servo) control
ALLOFF all servos off
ALLON all servos on
DIR set servo direction
FPWM change pulse width and frequency
GETMOTORSET read position of all servos
HIGHSPEED servo fast mode on/off
INIT set initial motion pose
MOTOR turn on servo
MOTOROFF turn off servo
MOVE operate several servos together
MOVEPOS move servo group
POS set a pose
PTP point to point operation
PWM set PWM for dc motor
MOVE24 move all 24 servos at same time
MOTORIN read present position of servo
SERVO control servo
SPEED set servo speed
SETON [PTP] setup on
SETOFF [PTP] setup off
ZERO set zero point

Parameter assigning motor group
G6A assign #0-#5 to group A
G6B assign #6-#11 to group B
G6C assign #12-#17 to group C
G6D assign #18-#23 to group D
G6E assign #24-#29 to group E
G8A assign #0-#7 to group A
G8B assign #8-#15 to group B
G8C assign #16-#23 to group C
G8D assign #24-#31 to group D
G12 assign #0-#11
G16 assign #0-#15
G24 assign #0-#23
G32 assign #0-#31

Sound control commands
MUSIC play music on piezo
TEMPO set up a sounds rythm

Communication commnds
[Note - the MR-C3024 can comunicate by the programming port and place a value in the first defined RoboBasic variable, see
ERX receive RS-232 through RX port
ETX transmit RS-232 through TX port

Analog commands
AD read Analog value from AD port
REMOCON read key value from IR remote control
SONAR read distance from U/S sensor
RCIN read pulse from RC receiver
GYRODIR set direction of a Gyro
GYROSET assign a gyro to a servo
GYROSENSE set sensitivity of a gyro

ON...GOTO skip according to value of variable

Other commands
REMARK remark
RND create a random number

Intention commands
$DEVICE set the controller used
$LIMIT confine range of a servo
This does not work for the Robonova
with the MR-C3024 controller.

Chapter 2 - General grammar

No operator precedence.
Parentheses () cannot be used.
Only byte or integer types supported.
Strings are not supported.
Negative numbers not supported.
BYTE byte 0-255
INTEGER integer 2 bytes 0-65535
CONST constants must be in integer range

  • Symbols
  • Operators
  • operator type precedence
  • Number bases
  • Variables
  • Logic operators
  • Assignment
  • Bit pointing
  • Bit Operations
  • Modulus
  • Labels
  • Symbol Description Example
    + addition
    - subtraction
    * multiplication
    / division
    % remnant
    . bit designation
    & numeral
    ?? text
    ?? character string
    : label
    = equal
    < less than
    > greater than
    <<bit shift left A<<2
    >> bit shift right A>>1

    Operator relation expression
    = equal X=Y
    <> not equal X<>Y
    < less than X<Y
    > greater than X>Y
    <= less or equal to X<=Y
    >= greater or equal to X>=Y

    operator type precedence
    1 arithmetic operator/bit operator
    2 relational operator
    3 logical operator

    Number bases
    binary number &B  0,1 &B111101
    Octal number &O 0,..,7   &O75
    Decimal number  0,..,9 61
    Hex number &H 0,..,F &H3D

    must be declared
    first letter must be a character
    _ and numerals can be used
    maximum length of name is 64 characters
    names are not case sensitive
    maximum of 256 bytes of variable space
    [Note - the MR-C3024 can communicate by the programming port and place a value in the first defined RoboBasic variable, see

         DIM motor_1 AS INTEGER
         DIM sensor_1 AS BYTE

    Logic operators

         AND, OR, XOR, NOT
    NOT inverts all the bits

    Assignment =

         DIM a AS INTEGER
         DIM b AS INTEGER
         a =2
         b =a	
    Bit pointing
         A.1 =1
         A.3 =IN(1)
         OUT 2,A.1

         DIM a AS INTEGER
         CONST BIT_2 =2
         a.BIT_2 =0

    Bit Operations
    The table illustrates bit operations given
    A=33, binary 00100001 and B=15, binary 00001111

    Modulus calculations use % or "MOD" to give the modulus

    labels must not be longer than 64 characters and must be followed by :
    line numbers 0-65535 can be used for labels, no : is needed
    labels are not case sensitive.

             IF x=y THEN GOTO START
             GOSUB 10
             GOTO start
         10  OUT 1,0

    Chapter 3 - declaration commands

    DIM variable AS type



    CONST name = value CONST a =125 CONST c =45238

    Chapter 4 - flow commands


    ACTION {p42}

    See Appendix 1

    Goto AUTO {p43}

    See Appendix 1

    DELAY milliseconds

    milliseconds can be literal, CONST or variable


    Ends the program

    FOR .... NEXT

    FOR variable=start TO end statements NEXT
    end must be greater than start
    Loops can be nested
    Loops can be exited with IF...THEN GOTO...
    Don't change the value of the loop variable

    GOSUB label .... RETURN

    ... GOSUB Dothis ... Dothis: statements RETURN
    only 5 deep GOSUB nesting

    GOTO label

    jump to label
    ON...GOTO	'skip according to value of variable

    IF condition THEN statement

    IF condition THEN statement ELSEIF condition THEN statement ELSE statement ENDIF eg IF a>0 AND a<5 THEN b=2


    makes the program either stop or run continously. When the program is stopped, using the RUN command will initiate it again. (sic)


    All servos in the group will finish a move at the same time {p87}.
    Wait for all previous MOVEs to finish [i-Bot RoboSavvy Forum 30 Jul 2008].
    Has no efect for a SERVO command

    Chapter 5 - digital I/O

    MRC3000 has 40 digital I/O ports
    portnumber can be literal, CONST or variable

    Ports 0~24 are the servo ports, G24 or G6A,G6B,G6C,G6D
    Ports 32~39 are also the
    Analog ports.


    DIM a AS bYTE a =IN(0) 'read port #0

    OUT portnumber,value

    DIM a AS bYTE OUT 3,0 'write 0 to port #3

    BYTEIN(byte portnumber)

    DIM a AS bYTE a =BYTEIN(0) 'read ports #0 - #7 into a

    BYTEOUT byte portnumber,value

    BYTEOUT 0,255 'send 1 to all bits


    DIM a AS BYTE OUT 0,1 a =STATE(0) 'read state of port #0, a should be 1


    PULSE 3 ' send a 5us +ve pulse to port #3


    TOGGLE(4) 'reverse state of port #4

    KEYIN(,number of keys 1-16)

    DIM k AS BYTE {p54} k =KEYIN(0,16) 'input values of 16 keys connected to port #0 0 <= k <= 16 0 => no keys pushed [how are keys connected?]

    Chapter 6 - Memory commands

    256 bytes of variable space
    12K,32K,64K bytes of external memory

    PEEK(address) 'read internal memory

    address = 0 - 65535

    POKE address,data 'write internal memory

    The command doesn't work for variables, it only works with CONSTANTs address = 0 - 65535 data = 0 - 255 POKE 25,13

    ROMPEEK(address) 'read external memory

    ROMPOKE address,data 'write external memory

    Chapter 7 - LCD commands

    MR-1602 module
    The port is preconfigured to 4800 baud, 8 databits, 1 stopbit, no parity. The signal levels are TTL.
    Dedicated LCD port on MR-C3000.
    	LCDINIT		'initialise LCD
    	CLS		'clear LCD screen
    	LOCATE character position 0-15,line 0-1	
    	LOCATE 4,1
    	PRINT "miniROBOT",126,"LCD"	'{see photo p66, char table p67}
    	CSON()		cursor ON/OFF
    	CONT contrast value, default is 7

    Chapter 8 - Motor control commands

    There are 3 PWM ports, 0,1,2
    PWM @454Hz (sic p90) or should this be 45KHz ?
      (Is PWM useable with SERVO and MOVE on MR-C3000? p89)
    MR-C3000 has 32 ports for 32 servos
    Note, servos are turned OFF during a
    MUSIC command
    Servo travel is +-90 degrees
    servo angle is 10 - 190
    zero is ~100


    Motors can be grouped for use in the MOTOR command.
    The group name should be followed by a list of servo position values.
    A compile error will arise if there are too many entries.
    The values will be assigned in turn, not all entries need to be supplied.


    G6A,50,60,70,80,90,100   '#0-#5  to group A
    'set servos; 0 to 50, 1 to 60, 2 to 70, 3 to 80, 4 to 90, 5 to 100
    G6B,50,60,70,80          '#6-#11  to group B 
    'set servos; 6 to 50, 7 to 60, 8 to 70, 9 to 80, do not alter servos 10,11
    G6C,50,,,80,90,100       '#12-#17  to group C 
    'set servos; 12 to 50, 15 to 80, 16 to 90, 17 to 100, do not alter servos 13,14

    RoboNova standard wiring
    G6A assign #0-#5 to group A left leg
    G6B assign #6-#11 to group B left arm
    G6C assign #12-#17 to group C right arm
    G6D assign #18-#23 to group D right leg
    G6E assign #24-#29 to group E (no connectors)
    G8A assign #0-#7 to group A
    G8B assign #8-#15 to group B
    G8C assign #16-#23 to group C
    G8D assign #24-#31 to group D (no connectors)
    G12 assign #0-#11
    G16 assign #0-#15
    G24 assign #0-#23
    G32 assign #0-#31 (no connectors)



    'select which motors are ON MOTOR 0 'servo #0 MOTOR variable 'use variable to specify motor MOTOR G6A 'use group 6A MOTOR G24 'use #0 - #23 MOTOR ALLON 'use all


    MOTOROFF 0 'servo #0 off - doesn't work! MOTOROFF n sets servo n ON MOTOROFF G6A 'group 6A off MOTOROFF G24 'servos #0 - #23 off MOTOROFF ALLOFF 'all servos off

    DIR group,direction bits 'default bitvalue is 0

    'DIRbit=1 => clockwise rotation is +ve viewing on servo disk 'DIRbit=0 => clockwise rotation is -ve viewing on servo disk DIR G6B,1,0,1,1,1,1 'or DIR G6B,1,,1,1,1,1 'servo #1 will turn anticlockwise for +ve 'others will turn clockwise for +ve

    ZERO 'adjust zero point

    ZERO G8B, 80,120,115,117,88,95,120 'set zeros of group 8B #8-#15


    MOVE G6A,60, ,100,120 MOVE G24,85,32 'the same as MOVE24 85,32
    See also WAIT which waits for a MOVE to finish.

    SPEED byte_value

    'normal value is 3 'byte_value can be a variable


    'all servos end their move at the same time PTP SETON 'enable PTP for Groups PTP SETOFF 'cancel PTP for Groups PTP ALLON 'enable PTP for all servos PTP ALLOFF 'cancel PTP for all servos see also WAIT

    SERVO number,angle

    angle is from 10 to 190 equivalent to 180deg range 100 is the default mid point number can be a variable angle can be a variable SERVO doesn't turn on a servo MOTOR 19 'turn on servo 19 SERVO 19,88 'set servo 19 to 88 WAIT doesn't work for SERVO

    PWM port,duty

    PWM 0,120 'pulse output of 120 duty rate at PWM port #0


    highspeed is about 3 times faster than normal speed

    MOVEPOS group,label .... POS

    MOVEPOS G6Ax,label2 'do the move at label2 ... label1: POS G6A,10,32,15,120,78,93 label2: POS G6A,67,47,32,153,23,33 label3: POS G6A,34,47,122,162,84,28 [the Hitec manual, "roboBASIC English Command Instruction Manual(Version 2.10 20051115).pdf" is wrong on the grammar for MOVEPOS]

    FPWM port,frequency,duty 'a variable frequency PWM

    frequency 1 is low, 5 is high 'no mention of actual frequencies duty 0 - 255

    MOVE24 'move all 24 servos simultaneously

    MOVE G24 'move all 24 servos simultaneously

    MOVE24 100,23,56,73,120,,,,,,45,66,,56

    INIT G8A 100,45,67,44,132,122,76,81

    'for analog servos, sets initial power-on position


    DIM S0 AS BYTE S0 =MOTORIN(0) 'read position (10 -190) of Motor #0, 0=> not connected

    GETMOTORSET group,bit_list

    GETMOTORSET G8A,1,1,1,1,0,0,0,0 'servos #0-#3 will be left at their current position, 'servos #4-#7 will be set to 100 at power on


    see manual p98 - 101 'serial controlled servos. not used in RoboNova. The Ai motor is the same visually as the RoboBuilder, servos p73

    Chapter 9 - Music commands



    Note, servos are turned OFF during a MUSIC command
    Octaves are O0 ~ O6, O0 is lowest only O0 ~ O4 work properly with piezo sounder. M is O3 The default octave is O3 'MUSIC "O34GGAA GGE GGEED" 'MUSIC "03GGA4.A GGE GEDEC" '(H,L only work in the lowest program in memory - see Appendix 1)

    TEMPO byte_value {p113}

    'higher values are faster '(only works in the lowest program in memory - see Appendix 1)

    Chapter10 - communication commands

    [Note - the MR-C3024 can communicate by the programming port and place a value in the first defined RoboBasic variable, see C3024+RTOS.txt]
    miniBUS communication not possible with MR-C3000
    max RS232 speed is 115,200bps

    ERX speed,variables,error label 'receive

    DIM a AS BYTE ReadChar: ERX 4,a,ReadChar 'GOTO ReadChar if an error occurs 'or Receive buffer is empty. IF a=48 THEN OUT 2,0 ELSE OUT 2,1 ENDIF ....

    TRX speed,data 'transmit

    DIM i AS BYTE i ="A" ETX 9600,i

    Chapter11 - Analog signal commands


    The MR-C3000 controller has 8 AtoD ports {0-7}, (Digital I/O ports 32-39).

    a =AD(1)     'get an analog value from port 1


    Port 7 is used for the REMOCON IR controller.
    The controller can be assigned up to 4 different IDs.
    To change the ID
    Press P1 and the desired ID number (1~4) and hold for two seconds.

    DIM cmnd AS BYTE
    CONST ID = 0         ' 1:0, 2:32, 3:64, 4:96,
    cmnd =REMOCON(1)     'get a control value from REMOCON(1)
    cmnd =cmnd -ID       'subtract ID to get actual control value


    Digital I/O ports 0-23 can be used as Ultrasound ports
    On a standard RoboNova only ports 5, 9, 10, 11, 15, 16, 17, 23 are free.

    SONAR must be within the range of 0 to 3000.
    0 implies the distance was not sensed.
    DIM us AS BYTE
    us =SONAR(3)      'get SONAR value from US_port 3, uses I/O_ports 6,7. See table

    [Note the later SRF05 works much better]


    DIM rc AS BYTE
    rc =RCIN(0)      'get RC-servo pulse length from port 0

    GYRODIR(group,motor_direction...) sets the control direction of servos

    GYRODIR G6A,1,1,0,0,1,0      '1 increases servo value, 0 decreases it

    GYROSET(group,gyro_port...) associates a gyro with a servo

    [what are these? different sets of port numbers for different Gyros? {p136}]
    01,02,03,04 :GWS PG03   11,12,13,14 : KRG-1
    21,22,23,24 : reserved  31,32,33,34 : reserved
    GYROSET G6B,1,1,2,2,0,0
    		'servo #6 is controlled by Gyro #1
    		'servo #7 is controlled by Gyro #1
    		'servo #8 is controlled by Gyro #2
    		'servo #9 is controlled by Gyro #2
    		'servo #10 is not controlled by a Gyro
    		'servo #11 is not controlled by a Gyro

    GYROSENSE(group,gyro_sensitivity...) sets a servo's sensitivity to a gyro

    A sensitivity of 0 means the servo value will be unaffected by the Gyro
    255 is the maximum sensitivity.
    GYROSENSE G6A,100,100,255,255,50,50
    		'servo #0 Gyro sensitivity is 100
    		'servo #1 Gyro sensitivity is 100
    		'servo #2 Gyro sensitivity is 255
    		'servo #3 Gyro sensitivity is 255
    		'servo #4 Gyro sensitivity is 50
    		'servo #5 Gyro sensitivity is 50

    Chapter12 - Process commands and others



    V =BYTEIN(0) ON V GOTO 10,20,30 'lines to GOTO for BYTEIN() values 0,1,2 IF V>2 THEN GOTO 40 V =BYTEIN(0) ON V GOTO do0,do1,do2 'labels to GOTO for BYTEIN() values 0,1,2 IF V>2 THEN GOTO dorest


    V =RND 'assign a random number to V


    REMARK this is a comment 'so is this and ' is easier to type

    Chapter13 - Intention commands

    Note the ' before the commands.


    'Select the controller type to download to 'must be set MRC3024 for RoboNova 'Changes the IDE settings '$DEVICE MRC2000 'select the MRC-2000 controller

    '$LIMIT servo_number,minimum_value,Maximum_value Unfortunately this does not work for the Robonova with the MR-C3024 controller

    'set the minimum and maximum travel for a servo 'use where the servo travel is limited by the mechanics '$LIMIT 0,50,100 'limit the travel of servo 0 to between 50 and 100 'default is '$LIMIT x,10,190

    Appendix 1 - ACTION command

    It is possible to have two programs in memory and pass a parameter between them using the first defined variable.

    This means a library of moves could be stored in the program in high-memory and called from the program in low-memory. Various low-memory programs could be written, each with their own set of moves or commands associated with the roboRemocon keys. The low memory programs can be small, so they load fast and can tailor RoboNova to different scenarios.

    ACTION number {p42}

    ACTION 3 'perform motion #3 ACTION 8 'perform motion #8

    This takes number {1 - 32}
    adds 50 to it and puts it into the first variable location,
    then jumps to another program loaded higher in memory.
    That program can examine its first variable and use the value.
    Return to the first program is done by RETURN.

    Goto AUTO 'move to the template Program {p43}

    [This sets up a jump over the FILLed bytes so the interpretor can read the start the program.]

    FILL byte_value, number_of_bytes_to_fill

    this leaves space below the program for another program to be loaded or for data.
    byte_value can be any value, {0 - 255}.

    FILL 255,10000	'fills 10000 bytes with 255
    number_of_bytes_to_fill must be 10000 for ACTION to work.

    High-memory program, must be loaded first.

    'Multi-Program2 'David Buckley 1Aug08 GOTO AUTO 'needed so the interprtor can find the start of Program2 FILL 255,1000 'Reserve 10000 bytes space before start of this program DIM Var1 AS BYTE 'first variable, can be any legal name DIM i AS BYTE 'loop counter Var1 =Var1 -50 'subtract the 50 added by ACTION 'loop depending on value from Program1 'if Var1=0 then nothing gets played 'if Var1=1 then "B" gets played 'if Var1=2 then "BB" gets played 'if Var1=3 then "BBB" gets played 'etc TEMPO 100 'has no effect in here, neither do H,L FOR i=1 TO Var1 MUSIC "B" NEXT MUSIC "HGGLAA" 'end of Program2, (H,L have no effect here) RETURN 'RETURN TO Program1
    Low-memory program, must be loaded second.
    'Multi-Program1 'David Buckley 1Aug08 begin: TEMPO 80 MUSIC "LCDE" 'so we know we are at start of program ACTION 2 'pass 2 to Multi-Program2 TEMPO 200 MUSIC "EDC" 'so we know we are back from ACTION DELAY 1000 GOTO begin

    Appendix 2 - relevant RoboSavvy Posts

    Fritzoid PostPosted: Tue Feb 12, 2008 4:28 pm Sadly, the HMI servo programmer will not write to the Robonova servos.
    i-Bot Savvy Roboteer PostPosted: 30 Jul 2008 16:19 To understand the action command you must really understand how the template works. The start of the template GOTO AUTO FILL 255,10000 compiles to: 0x10 @0x40 = 0 0x15 GOTO [ 0x2728] then 10000 nops so the next line IF RR > 50 AND RR < 83 THEN GOTO action_proc will sit at location 0x2728 and subsequent code loaded there If the template is run it operates as expected. The important thing is that when a new program is stored lower in memory the template is not overwritten, so you can still call the template routines from a program which does not have the fill instruction. In this lower program you use the ACTION command ACTION 5 will compile to: @0x40 = 55 ' location 40 is the first variable and is RR GOSUB [ 0x2728] so the ACTION will call the template routine

    Appendix 3 - Remocon Keys and Template Actions

    "Overall Tempate Program(Version 1.00 20051115).bas"

    Appendix 4 - Servo Numbering


    05Feb15 revised Gxx table to indicate RoboNova standard wiring
    29Jan15 corrected shit to shift
    18Jul12 corrected relevent to relevant
    17Aug11 corrected all oops <a name="# to <a name=" so labels work in other than IE !!!!
    17Aug11 ETX transmit RS-232 through RX port corrected to '...TX port'
    17Aug11 added note to Chapter10 - communication commands about serial communication via programming connector
    31Mar10 Ch8. added page no. to PWM queries