| davidbuckley.net |
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 Like. "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 ~…
| Hitec Manual page | Chapter | Contents |
| 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 - relevent RoboSavvy Posts
Appendix 3 - Remocon Keys and Template Actions
Appendix 4 - Servo Numbering
| 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 |
| FORMAT | |
| HEX | hex number |
| LCDINIT | initialise LCD |
| LOCATE | locate |
| send charater to LCD |
Operands
| 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 C3024+RTOS.txt]
| 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 |
Processing
| 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. |
BYTE | byte | 0-255 |
INTEGER | integer | 2 bytes 0-65535 |
CONST | constants | must be in integer range |
| Symbol | Description | Example
| + | addition
| - | subtraction
| * | multiplication
| / | division
| % | remnant
| . | bit designation
| & | numeral
| ?? | text
| ?? | character string
| : | label
| = | equal
| < | less than
| > | greater than
| << | bit shit 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
| |
| 1 | arithmetic operator/bit operator |
| 2 | relational operator |
| 3 | logical operator |
| binary number | &B | 0,1 | &B111101 |
| Octal number | &O | 0,..,7 | &O75 |
| Decimal number | 0,..,9 | 61 | |
| Hex number | &H | 0,..,F | &H3D |
Variables
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 C3024+RTOS.txt]
DIM motor_1 AS INTEGER
DIM sensor_1 AS BYTE
Logic operators
Assignment =
Bit Operations
Modulus
Labels
AND, OR, XOR, NOT
NOT inverts all the bits
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
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.
START:
....
IF x=y THEN GOTO START
....
GOSUB 10
....
GOTO start
....
10 OUT 1,0
....
RETURN
Chapter 3 - declaration commands
DIM variable AS type
DIM a AS BYTE
DIM b AS BYTE, c AS INTEGER
CONST
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
END
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 withIF...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
STOP/RUN
[does?]
makes the program either stop or run continously. When the program is stopped, using the RUN command will initiate it again. (sic)
WAIT
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 aSERVOcommand
CONST or variable
IN(portnumber)
DIM a AS bYTE a =IN(0) 'read port #0OUT portnumber,value
DIM a AS bYTE OUT 3,0 'write 0 to port #3BYTEIN(byte portnumber)
DIM a AS bYTE a =BYTEIN(0) 'read ports #0 - #7 into aBYTEOUT byte portnumber,value
BYTEOUT 0,255 'send 1 to all bitsSTATE(portnumber)
DIM a AS BYTE OUT 0,1 a =STATE(0) 'read state of port #0, a should be 1PULSE(portnumber)
PULSE 3 ' send a 5us +ve pulse to port #3TOGGLE(portnumber)
TOGGLE(4) 'reverse state of port #4KEYIN(
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?],number of keys 1-16)
PEEK(address) 'read internal memory
address = 0 - 65535POKE 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,13ROMPEEK(address) 'read external memory
ROMPOKE address,data 'write external memory
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}
FORMAT()
DEC()
HEX()
BIN()s
CSON() cursor ON/OFF
CSOFF()
CONT contrast value, default is 7
Gxx
Motors can be grouped for use in theMOTORcommand.
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.
eg
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
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
MOTOR
'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
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
MOVE G6A,60, ,100,120
MOVE G24,85,32 'the same as MOVE24 85,32
See alsoWAITwhich waits for aMOVEto finish.
SPEED byte_value
'normal value is 3 'byte_value can be a variablePTP {SETON|SETOFF|ALLON|ALLOFF}
'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 WAITSERVO 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 SERVOPWM port,duty
PWM 0,120 'pulse output of 120 duty rate at PWM port #0HIGHSPEED {SETON|SETOFF}
highspeed is about 3 times faster than normal speedMOVEPOS 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 - 255MOVE24 'move all 24 servos simultaneously
MOVE G24 'move all 24 servos simultaneously
MOVE24 100,23,56,73,120,,,,,,45,66,,56INIT G8A 100,45,67,44,132,122,76,81
'for analog servos, sets initial power-on positionMOTORIN()
DIM S0 AS BYTE S0 =MOTORIN(0) 'read position (10 -190) of Motor #0, 0=> not connectedGETMOTORSET 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 onAIMOTOR
see manual p98 - 101 'serial controlled servos. not used in RoboNova. The Ai motor is the same visually as the RoboBuilder, servos p73
MUSIC....
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)
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
AD(AD_port)
The MR-C3000 controller has 8 AtoD ports {0-7}, (Digital I/O ports 32-39).
DIM a AS BYTE a =AD(1) 'get an analog value from port 1
REMOCON(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
SONAR
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]
RCIN(port)
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
ON...GOTO
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 dorestRND
V =RND 'assign a random number to VREMARK
REMARK this is a comment 'so is this and ' is easier to type
'$DEVICE
'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
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 byRETURN.
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_valuecan be any value, {0 - 255}.
FILL 255,10000 'fills 10000 bytes with 255number_of_bytes_to_fill must be 10000 forACTIONto work.
High-memory program, must be loaded first.
Low-memory program, must be loaded second.'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
'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
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
"Overall Tempate Program(Version 1.00 20051115).bas"