Home

ServoCenter 4.1 Manual Volume 4: Sequencer/SC

image

Contents

1. Character Byte Value Token Name Description Lexical Rule Note A T ERROR Lexical scanning error None 32 NONE No operation None 0 T EOFI End of File End of Input 0 End of File 10 T EOL End of Line V An v 13 T EOL End of Line An 43 T ADD Addition unary plus V 45 T SUB Subtraction unary negative V T 47 T DIV Division T ad 42 T MUL Multiplication 37 T MOD Modulus ue 94 T EXP Exponentiation ui 40 T LPAREN Left Parenthesis 6 41 T RPAREN Right Parenthesis y ut 61 T EQUAL Equal Sign ut n 44 T COMMA Comma 59 T SEMI Semicolon Es nf 58 T_COLON Colon 5 lt 60 T LT Less than gt 62 T GT Greater than gt 91 T LE Less than or Equal to T 93 T GE Greater than or Equal to 88 Not Equal lt gt 38 Logical And Operator and T 124 T_OR Logical Or Operator or T 33 T NOT Not Operator not P 80 T_PRINT Print command token print 73 T IF If command token if T 84 T THEN Then command token then 101 T ELSEIF Elself command token elseif if 105 T ENDIF Endlf command token endif end if 70 T FOR For command token for tet 126 T TO To command token 5 83 T STEP Step command token step 78 T NEXT Next command token next w 87 T WHILE While command token while dowhile while yc
2. sees sess sese eee 29 59 OF SE Sue TR e E 6 1 Hexadecimal Decimal Binary Nibble Conversion 26 6 2 Hexadecimal Decimal ASCH 20 6 3 Tok n Ioa GA Error Gri obe User s Manual ServoCenter 4 1 Sequencer SC BASIC Language Interpreter This document is intended to explain the details of the SC BASIC language script sequencer that is used in the ServoCenter 4 1 servo controller boards 1 Sequencer Overview The ServoCenter 4 1 controller provides a built in Sequencer BASIC Interpreter called SC BASIC that allows the ServoCenter board to be programmed to perform various tasks via the use of a simple tokenized BASIC like scripting language This feature can be used to implement customer specific logic I O and servo control tasks without the need for a PC or other external command device The use of a fully functional scripting language allows the sequencer to perform complex logical and control tasks that can run independently on the SC4 1 board itself The sequencer programs are stored on the SC4 1 board in a non volatile EEPROM memory that retains the program even when the unit it reset or powered off The loaded sequencer program can be started remotely via the Start Sequencer command
3. Dens LO Setled Viode Mode Number 220524 LS 3 ServoCenter Sequencer Control Comma nd ssccccssscccsssseccsssseccssssessssssssssee 19 3 1 Protocol Command Summary 4 eere eee esee eene e eene e eene sees see essseeessssese eese ssssseeee 19 3 2 Pr tocol Command pleb vet cba 4 Using the ServoCenter Control Panel Sequence Editor 20 4 1 Sequencer Programming engen osea e kon oe 21 4 2 Basic Us Tutorial eer cc PRA 4 3 More Advanced Examples eio osse a Meade A 5 SC BASIC Programming Examples eene sees esee enses seen 23 5 1 Helo Eesti PRETI 3 2 Hel WOT Sui aee ETUR 53 OE VO EKER CIS tu so sores riso 5 4 Servo Exercise With SUB Ser X 9 6 SHOW All ADC V DII 2 M 5 7 Move all Servos to a Random POSI ONn euer re errores 5 8 Demo of global variable retaining eee eee eerte eee
4. ed PN S UR EATER 6 Variable Value So ee o te tdi pde panchina M S 6 2 3 Arithmetic Operations and Expressions eese ceres eerte 7 2 3 1 Bro iri aes UA 7 2 3 2 Arithmetic Order of 2222 65 7 2 3 3 Arithmetic Operation esee eene eee set 7 2 3 4 Arithmetic EXpDreSSIOMS Eno eoe a epe enia Creep oae n E ete Ne SE 8 2 4 Relational and Logical Operations eere crees crees ee eese seen 8 2 4 1 Relational ODGFatOES INNER Re MNT 8 2 4 2 Logical ODGFAtOES eee e enc Fe Ye Peg osisssa bed xe SEEN adu 8 2 4 3 Relational Logical Order of Operations eee 9 2 4 4 Relational Logical Operation 0 4 9 2 5 Language Stat melts o de 9 25 APHIS Cate Men ty 9 Print Statement Details o oe erede male wide 9 Statement Example Srpen
5. ERROR FUNCTION SUB cannot be defined inside SUB 8 ERROR FUNCTION SUB cannot be definied inside FUNCTION 9 ERROR BUILTIN or VARIABLE expected after CALL 0 ERROR ENDSUB without SUB 1 ERROR EXITSUB without SUB 2 ERROR ENDFUNC without FUNCTION 3 ERROR EXITFUNC without FUNCTION 4 ERROR unexpected token in statement 5 ERROR VARIABLE expected in DIM 6 ERROR Unsupported type STRING in DIM 7 ERROR Unsupported type SINGLE in DIM 8 ERROR Unexpected token after AS in DIM 9 ERROR unexpected token in DIM 20 ERROR variable name expected after SUB FUNCTION call 21 ERROR Missing right parenthesis on SUB FUNCTION parameter list 22 ERROR Unexpected token in parameter list of CALL 23 ERROR unexpected token in CALL 24 ERROR Unexpected token in SUB parameter list 25 ERROR Missing right parenthesis on parameter list in SUB definition 26 ERROR Unexpected token in SUB parameter list 27 ERROR Unsupported 28 ERROR Unsupported 29 ERROR Unexpected 30 ERROR Unexpected 3 ERROR parameter count mismatch in call 32 ERROR Unexpected token in WHILE loop 33 ERROR EOF encountered within WHILE 34 ERROR variable expected after FOR 35 ERROR EQUAL expected after variable in FOR 36 ERROR missing TO in FOR statement 37 ERROR unexpected token after FOR 38 ERROR variable
6. 15 to act as an input The SetDIODirectionIn function always returns 0 14 User s Manual SetDIODirectionOut DIONum The SetDIODirectionOut DIONum function sets the digital I O pin specified by the DIONum parameter 0 15 to act as an output The SetDIODirectionOut function always returns 0 ReadDIO DIONum The ReadDIO DIONum function reads and returns the state of the digital I O pin specified by the DIONum parameter 0 15 The ReadDIO function returns logic state 0 1 of the specified DIO pin ReadAD ADNum The ReadAD ADNum function reads and returns the 10 bit conversion value from the ADC pin specified by the ADNum parameter 0 7 The ReadAD function returns 10 bit conversion value 0 1023 of the specified ADC pin ServoEnable SvNum The ServoEnable SvNum function enables the control signal on the servo channel specified by the SvNum parameter 0 15 The ServoEnable function returns 0 ServoDisable SvNum The ServoDisable SvNum function disables the control signal on the servo channel specified by the SvNum parameter 0 15 A disabled servo channel s logical state state is determined by the servo channel s Disabled State The ServoDisable function always returns 0 ServoDisabledStateHigh SvNum The ServoDisabledStateHigh SvNum function sets the disabled logical state of the servo channel specified by the SvNum parameter 0 15 to high logic 1 The S
7. 69 45 E 101 65 e 6 6 ACK 38 26 amp 70 46 F 102 66 f 7 7 BEL 59 D A 71 47 G 103 67 g 8 8 BS 40 28 72 48 H 104 68 h 9 9 TAB 41 29 73 49 I 105 69 i 10 A LF 42 2A x 74 4A J 106 6A j 11 43 2B an 75 4B K 107 6B k 12 C FF 44 D 76 4 L 108 6C l 13 D CR 45 2D 77 4D M 109 6D m 14 E SO 46 2E 78 4E N 110 6E n 15 F SI 47 2F 79 4F 111 6F 16 10 DLE 48 30 0 80 50 P 112 70 p 17 11 DCI 49 31 1 81 51 Q 113 71 q 18 12 DC2 50 32 2 82 52 R 114 12 r 19 13 DC3 51 33 3 83 53 S 115 73 5 20 14 DC4 52 34 4 84 54 T 116 74 t 21 15 NAK 53 35 5 85 55 U 117 75 u 22 16 SYN 54 36 6 86 56 V 118 76 v 23 17 ETB 55 37 7 87 57 W 119 7 w 24 18 CAN 56 38 8 88 58 X 120 78 X 25 19 EM Sl 39 9 89 59 Y 121 79 y 26 1A SUB 58 3A 90 5A Z 122 TA 7 27 1B ESC 59 3B 91 5B 123 7B 28 FS 60 3C lt 92 5C 124 7C 29 1 GS 61 3D 93 5D 125 7D 30 1E RS 62 3E gt 94 SE 126 7E 31 US 63 3F 7 95 5F c 127 7F DEL 26 User s Manual 6 3 Token Specification It is possible to program the ServoCenter4 1 SC BASIC sequencer directly using byte code representations of the program and directly loading them into the sequencer memory using the Write Sequencer EEPROM Page protocol command The following section describes each of the low level byte tokens as they are stored in memory
8. SC BASIC supports the following arithmetic operations Operator Name Use Parenthesis Group other operations Addition Add values Subtraction or Unary Negation Subtract values or negate a value Multiplication Multiply values Division Divide values Exponentiation Raise a value to a power Mod Modulus Determine the remainder of a division Note that since SC BASIC only supports integer data types division will result in only the integer division result Additionally floating point values and constants are not legal 2 3 2 Arithmetic Order of Operations SC BASIC implements standard algebraic order of operations as follows Order Operators Name 1 Parenthesis 2 Unary Negation Negative 3 n Exponentiation 4 Mod Multiplication Division Modulus from Left to Right 5 Addition and Subtraction form Left to Right 2 3 3 Arithmetic Operation Examples Operation Result 5 10 15 15 14 1 14 15 1 3 6 18 3 6 18 10 3 3 3 10 0 2 4 16 10 Mod 3 1 User s Manual 2 3 4 Arithmetic Expressions Many SC BASIC commands use expressions A valid arithmetic expression is formed from any combination of the following 1 Integer numeric literals 2 Correctly used arithmetic operators 3 Variable names 4 Correctly formed function calls 5 Correctly used logical operators Logical o
9. 3 Numeric literals 4 Logical expressions 5 Arithmetic expressions When a comma is used as an argument separator a TAB ASCII HT character is inserted between the output of the arguments User s Manual When a semicolon is used as an argument separator items are printed without any space between subsequent arguments The print statement normally prints carriage return and line feed characters at the end of each print lines automatically This behavior is suppressed if the print statement line ends with a semicolon or a comma When print is used on a line by itself with no arguments a blank line CRLF is printed Print Statement Examples rint Hello World rint position rint count is count rint Count by tens 10 20 30 rint six digits 107 20 30 rint Average 10420 30 3 rint First line rint same line Eine rint Together TU Jg Jg TO TO TO TO g tu 2 5 2 If Statements If statements allow the SC BASIC language to make decisions based upon an evaluated expression SC BASIC supports the same standard if statement forms as other commonly encountered BASIC interpreters Single Line If Statement Forms Single line If statements can have one of two forms Form 1 If expression Then command line to execute Form 2 If expression Then command line to execute Else command line to execute Block If Statement Forms Block If statements can have one of thre
10. 76 T LOOP Loop command token wend w 119 T EXITWHILE Exit While command token exit while 7T 101 T EXITFOR Exit For command token exit for 72 T HALT Halt end command token end 68 T DEFSUB Sub definition token sub 100 T ENDSUB End sub token end sub endsub x 120 T EXITSUB Exit sub token exit sub exitsub 67 T CALL Call command token 85 DEFFUNC Function definition token function 117 T ENDFUNC End function token end function endfunction 82 Exit function token exit function exitfunction 100 T DIM Dim command token dim 97 As command token as 0 48 T TYPE INT Integer type specifier integer A 34 T CONST STRING String Constant een 1 35 CONST INT Integer Constant 0 9 2 v 86 T VARIABLE Variable Token a z a z 0 9 _ 3 46 T BUILTIN Built in specifier token Matches a built in name 4 on 39 T_COMMENT Comment Specifier 2 5 27 User s Manual Token Notes l T CONST STRING string constant tokens are stored as a string of characters enclosed within double quotes For example this is a string token T CONST INT integer constant tokens are 3 bytes stored as MSB LSB where MSB and LSB combine to form a signed integer T VARIABLE variable specifier t
11. QuickMoveServoScaled SvNum Pos next SvNum End Sub move all servos to Min positions Call MoveAllServos 0 wait for a second Call 1 move all servos to Max positions Call MoveAllServos 16383 wait for a second Call DelaySec 1 move all servos to Min positions Call MoveAllServos 0 wait for a second Call DelaySec 1 move all servos to Center positions Call MoveAllServos 8191 5 5 Digital Exercise This program exercises all 16 Digital I O channels by setting them all as outputs and cycling through each one with a 10 of a second high pulse Set all Digital I O pins as output For DioNum 0 To 15 SetDIODirectionOut DioNum Call SetDIOLow DioNum Next DioNum Cycle through all 16 digital I O pins setting each high for 1 10th of a second then low For DioNum 0 To 15 Call SetDIOHigh DioNum Call DelayMilliSec 100 Call SetDIOLow DioNum Next DioNum print done 5 6 Show all ADC Values This program prints the ADC values for all 8 ADC channels For AdNum 0 to 7 Print ADC Channel AdNum reads ReadAD AdNum next AdNum 5 7 Move all Servos to a Random Position This program moves all servos to a random position For SvNum 0 To 15 Call QuickMoveServoScaled SvNum RandRange 0 16383 Next SvNum 24 User s Manual 5 8 Demo of global variable retaining v
12. SC BASIC sequencer script programming 3 1 Protocol Command Summary Description Command Data Len Data Descriptions Read Sequencer EEPROM Page 208 0 40 1 EepromPageNum 0 127 Write Sequencer EEPROM Page 209 Oxd1 33 EepromPageNum 0 127 32 x EepromDataByte Start Sequencer 210 Oxd2 1 SequencerArg 0 255 Stop Sequencer 211 0xd3 0 Reset Sequencer 212 0xd4 0 Write Character to Sequencer 213 0xd5 1 DataByte 0 255 Set Sequencer Startup Mode 214 0xd6 1 SequenceStartupMode 0 1 Get Sequencer Startup Mode 215 0xd7 0 Get Sequencer Status 216 Oxd8 0 Get Sequencer Last Error 217 0 9 0 3 2 Protocol Command Details Function Read Sequencer EEPROM Page Command Value 208 0x40 Data Bytes 1 Data Format EepromPageNum 0 127 Description The Read Sequencer EEPROM Page allows the contents of the EEPROM sequencer memory to be read one page at a time Each page consists of 32 bytes of non volatile EEPROM data The data within the EEPROM is a tokenized P Code program for the SC4 1 BASIC Interpreter Function Write Sequencer EEPROM Page Command Value 209 0xd1 Data Bytes 33 Data Format EepromPageNum 0 127 32 x EepromDataByte Description The Write Sequencer EEPROM Page allows the contents of the EEPROM sequencer memory to be written one page at a time Each page consists of 32 bytes of
13. SUB EXITFUNCTION encountered within SUB ENDFUNCTION encountered within SUB an identifier VARIABLE must follow a FUNCTION definition missing end parenthesis in FUNCTION declaration unexpected token in FUNCTION parameter list unexpected token in FUNCTION declaration EOF encountered before ENDFUNCTION SUB definition encountered within FUNCTION FUNCTION definition encountered within FUNCTION EXITFUNCTION encountered within FUNCTION ENDFUNCTION encountered within FUNCTION Unsupported type STRING in parameter list Unsupported type SINGLE in parameter list Unexpected token after AS in parameter list variable not found variable table full SUB FUNCTION not defined turn type STRING in FUNCTION definition turn type SINGLE in FUNCTION definition ken after AS in FUNCTION definition ken in SUB e e 28
14. Values usse e tete eee 13 Callins 3 abeo M E Aqu d 14 Exit Potictioft iaa e shee o lebe 14 2 5 6 The End State men e 14 PASCI mr 14 PASS ve w M 14 SetDIOHigh 14 SetDIOLow DIONUI 14 SetDIODire ctionIn DIONUI siisisisciscessscestsveiedscesansacisveoesciassscnscsvedecstasseencenascasacbuamcsadaasssees 14 SetDIODire caonOut da enano Dok a epa dosi 15 R a3dDIO DIONUI 225556 Ree Vinea ER nare MEIN ERE 15 User s Manual Read A DCAD IN UH ServolEnable LD D ServoDisabledStateHigh 5 24 ServoDisabledStateLow SvNUm eee e ecce eee eee ee een esee eeesosese
15. and supports the passing of a parameter byte when a sequence is started The sequencer also implements a Sequencer Startup feature that allows a loaded script to be executed when the SC4 1 board is reset or powered up thus allowing the SC4 1 board to be used as a stand alone controller 2 Sequencer Features The SC BASIC language was designed for the ServoCenter 4 1 Servo Controller as a simple easy to learn language that is specifically suited to the architecture and problem domain of the controller board SC BASIC supports a syntax that will be familiar to users of other flavors of BASIC such as QBASIC and Visual Basic as well as some instructions and built in functions that are specifically suited to the SC4 1 controller board SC BASIC supports the following features Compact tokenized program format 4096 bytes of non volatile program space Familiar structured BASIC like language syntax Dynamic variable allocation Support for up to 64 simultaneously allocated global and local integer variables Support for up to 16 user defined subroutines functions Scripts can be passed a parameter byte when started via the Start Sequencer command Scripts can be started upon board reset power up via the Sequencer Startup feature Sequencer status and sequencer error reporting Built in servo control and digital I O functions Additional built in functions for commonly needed programming tasks Sequencer communication support allows the
16. mismatch in NEXT 39 ERROR Unexpected token in FOR loop 40 ERROR EOF encountered in FOR 4 ERROR Missing THEN in IF statement 42 ERROR EOF encountered within IF 43 ERROR unexpected token in ELSE clause 44 ERROR Missing THEN in ELSEIF statement 45 ERROR unexpected token following ELSEIF 46 ERROR unexpected token in IF 47 ERROR Unexpected Token found Expression expected 48 ERROR Missing right parenthesis in expression 49 ERROR unexpected token in expression 50 ERROR variable expected as lvalue in assignment 51 ERROR invalid assignment EQUAL expected 52 ERROR invalid token in PRINT 53 ERROR invalid builtin call expected 54 ERROR invalid builtin call expected 55 ERROR unknown built in function 56 ERROR division by zero 57 ERROR DSTACK overflow 58 ERROR HSTACK overflow 59 ERROR Improperly formed CONST STRING 60 ERROR Improperly formed COMMENT 61 99 Reserved CALL STACK overflow CALL STACK underflow Duplicate SUB FUNCTION definition FUNCTION SUB table full an identifier VARIABLE must follow a SUB definition missing end parenthesis in SUB declaration unexpected token in SUB parameter list unexpected token in SUB declaration EOF encountered before ENDSUB SUB definition encountered within SUB FUNCTION definition encountered within
17. no Cog tae een d acetate caede tenta Vb 10 2 5 2 EORR HO rn 10 Single Line Lf Statement us coemiterio ere ero tre Rake ee p e ed E e 10 2 5 3 Next DOO erc niiae aeri oiae eaS 11 bor Next Statement Gd pad een a ences 11 Exit For Statetnbtib s auo ce e to Mee vetet Puede etas Need Dev atn 11 23 4 MAIL m 11 Do iile TEGO utate sete tepido 11 Exit Whale Statements 11 Infinite tei ce re abet area D e OP Ere RU 12 2 5 5 Procedures Subs and PuUmctions sseccsscccisccccsctcsccccecescdecsncsacciessesiacsuonscicesescsdonsencecescodecea s 12 Procedure haves ted tuae een 12 D fi ing atus M tensa e ue RUN ue EN Lu au QU AE iR SUE 12 Calig a SUD cd Crate ueri canda beata uu nd Reus ra Mud pu MEE RENS 12 Passing Information to a SUD iiiter ete RH etr eo euasit tene iR vie PPAR ER US 13 Exit SUD SAL OMe Ils te RU e UR LR Uu 13 Defining Pune ions oe tU d aen PP EUER 13 Specifying Function Return
18. sequencer to print receive messages Sequencer Start Stop Reset control functions User s Manual 2 Language Reference 2 1 Comments Comments provide a way of annotating and documenting source code Also since comments are ignored during execution they provide a convenient means of temporarily commenting out code for debugging testing purposes Comments start with the single quote character or pound sign character and continue to the end of the line For example This is a comment This is another comment dim syl variable for servo position 1 2 2 Variables 2 2 1 Variable Basics A variable is a way of assigning a name to a information stored in memory SC BASIC only supports integer variables As such each variable can hold an integer value in the range 32 768 to 32 767 Variables are dynamically allocated meaning that they are constantly created and destroyed as the program runs Variables will not retain their value when the board is power cycled or reset or when the Reset Sequencer command is received SC BASIC supports up to 64 simultaneously allocated variables 2 2 2 Variable Scope and Lifetime ec A variable s scope describes where a variable is accessible or visible to the program A Variable s lifetime describes how long a variable exists before it is destroyed SC BASIC supports two variable classifications that each have distinct lifetime scope rules global v
19. ways Using the Call statement or using the name of the procedure Method 1 call Hello Method 2 12 User s Manual Passing Information to a Sub Often it is desirable to send information to a procedure to tell it how or what to do This information is as a group called the parameter list or argument list of the procedure The procedure definition identifies and references these data items by using variable names For example the Sub defined as Sub HelloMany count For i 1 to count Print Hello World Next i End Sub Allows a single parameter count is defined that allows a number to passed to the procedure Multiple parameters can be passed to a function but since each parameter uses a local variable care must be taken so as not to exceed the capacity of the local variable table When passing multiple parameters a comma separated list of parameters is included in the procedure s definition Parameter lists support the use of type specification via the typical As Integer specifier but integer types are exclusively supported Parameters in SC BASIC are exclusively passed by value and there is no support for parameters passed by reference Global variables should be considered if a procedure must return multiple values When a procedure is called the number of parameters passed to the function must match the number of parameters listed in the procedure definit
20. SpeedPercent The MoveServoScaled SvNum SvPositionScaled SvSpeedPercent moves the servo position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionScaled 0 16383 according to the speed determined by SvSpeedPercent 0 10000 Position 0 is the servo channel s defined min position position 16383 is the servo channel s defined max position values between 0 and 16383 are linearly interpolated between the defined min and max positions SvSpeedPercent is in 100ths of a percent of the speed defined for the specified servo channel Thus a speed of 10000 will move the servo instantly to the defined positions 5000 will move at half the full speed 1000 will move at 1 10 full speed etc The MoveServoScaled function always returns 0 MoveServoPercent SvNum SvPositionPercent SvSpeedPercent The MoveServoPercent SvNum SvPositionPercent SvSpeedPercent moves the servo position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionPercent 0 10000 according to the speed determined by SvSpeedPercent 0 10000 Positions are in 100ths of a percent of the full scale min to max range Thus position 0 is the servo channel s defined min position position 10000 is the servo channel s defined max position values between 0 and 10000 are linearly interpolated between the defined min and max positions SvSpeedPercent is in 100ths of a percent of the speed defined for
21. User s Manual ServoCenter 4 1 Volume 4 Sequencer SC BASIC Interpreter Language Reference amp Programming Guide Yost Engineering Inc 630 Second Street Portsmouth Ohio 45662 www YostEngineering com 2002 2009 Yost Engineering Inc Printed in USA User s Manual Table of Contents ServoCenter 4 1 Sequencer SC BASIC Language Interpreter 4 RII eaoaai ena Mae 2 HCATUTES eT UN 2 Langudse ERE EVA I QU NER RIEN Pa Naruto E CR 5 T E 5 2 2 NE III T 5 2 2 2 Variable Scope and Lifetimes si csesccesussscsnsvsesusesuasdcsinasevnvesesanevenuvastauacdeasdsavveccdoanssdesosvavente 5 Global Variable didus trees UP EI ended Labia PLA UM UE Uo Gs 5 Procedure Variables DES Ue Pat D do be blu dace aeu 2 2 2 3 Variable NAMES Dm 5 2 2 4 D claring rx 6 Implicit Declaration eo ose aeui EE expose eset eeu icto veo texas oth 6 Explicit ite ett iab tete dac hance ue rA DUE 6 2 215 Using C 6 Variable Assignment
22. alue The following program demonstrates the ability of SC BASIC to retain global variable values between executions Run the program multiple times to see the bahavior To prevent this behavior initialize variables before use or issue the Reset Sequencer command before issuing the Start Sequencer command print The variable count is count count count 1l 5 9 Demo of CmdArg This program illustrates the use of the CmdArg function to control the behavior of a program when it is started choice CmdArg If choice 0 Then Print CmdArg was 0 Else If choice 1 Then Print CmdArg was 1 Else If choice 2 Then Print CmdArg was 2 Else If choice 3 Then Print CmdArg was 0 Else Print CmdArg was greater than 3 End if 25 User s Manual 6 Appendix 6 1 Hexadecimal Decimal Binary Nibble Conversion Chart 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 6 2 Hexadecimal Decimal ASCII Chart 1 1 SOH 33 21 65 41 A 97 61 a 2 2 STX 34 22 66 42 B 98 62 b 3 3 ETX 35 23 67 43 99 63 4 4 36 24 68 44 D 100 64 d 5 gt ENQ 37 25
23. ariables amp procedure variables Global Variables Global Variables are variables declared within the main program body this means that these variables are not declared inside a Sub or Function A global variable retains information until the board is power cycles or reset or until a Reset Sequencer command is received A global variable is visible and usable anywhere within the program Procedure Variables Procedure Variables are variables that are declared within a Sub or Function Procedure variables only retain information and are only visible within the Sub or Function in which they are declared This means that a procedure variables are created when they are declared within a sub or function and are automatically destroyed when that sub or function completes 2 2 3 Variable Names Variable names must adhere to the following naming rules Variable names are not case sensitive Must start with a letter Must be composed entirely of only letters numbers and the underscore character Must not be a language keyword or built in function name User s Manual 2 2 4 Declaring Variables There are two ways to create variables for use by your script program Variables can be declared implicitly or explicitly Implicit Declaration Implicit variable declaration lets the program create the variable for you automatically This is done by simply assigning a value to a legal variable name For example count 10 impl
24. button This button sends the start sequencer protocol command to the attached controller board and passes the start parameter byte selected in the Start Parameter pull down see 12 Note that a program must be uploaded see 5 before it can be started 10 Stop Sequencer button This button sends the stop sequencer protocol command to the controller board Ifa program is running it is immediately halted Variables are not cleared 21 User s Manual 1 Reset Sequencer button This button sends the reset sequencer protocol command to the controller board Ifa program is running it is immediately halted and all variables are cleared 12 Start Parameter selection This selection box allows the selection of the parameter byte that is sent to the controller when the Start Sequence button is clicked 13 Sequencer start mode control These controls allow the setting of the sequencer s start mode When on the sequencer will execute the loaded program whenever the controller board is reset or powered up This can allow the controller board to be used without any external connections When off the sequencer must be started by sending the Start Sequencer protocol command 14 Show Terminal I O button This allows the display of the terminal snooper that allows the inspection of outgoing and incoming communications messages This is especially useful for monitoring the communication output of SC BASIC pro
25. ction 5 contains several additional examples that each illustrate different features of the SC BASIC language It is recommended that these examples be analyzed and understood before trying your own programs and sequences 5 SC BASIC Programming Examples 5 1 Hello World Simple Hello World Program Print Hello World 5 2 Hello World Sub Hello World Program using a Sub Procedure Sub Hello Print Hello World End Sub Call Hello 5 3 Servo Exercise This program exercises all 16 servo channels by moving them from min to max to min to center with 1 second delay between each movement move all servos to Min positions for SvNum 0 to 15 QuickMoveServoScaled SvNum 0 next SvNum wait for a second Call DelaySec 1 move all servos to Max positions for SvNum 0 to 15 QuickMoveServoScaled SvNum 16383 next SvNum wait for a second Call DelaySec 1 move all servos to Min positions for SvNum 0 to 15 QuickMoveServoScaled SvNum 0 next SvNum wait for a second Call DelaySec 1 move all servos to center positions for SvNum 0 to 15 QuickMoveServoScaled SvNum 8191 next SvNum 23 User s Manual 5 4 Servo Exercise With Sub This program exercises all 16 servo channels by moving them from min to max to min to center with 1 second delay between each movement Sub MoveAllServos Pos move all servos to position Pos for SvNum 0 to 15
26. d The Srand seed function seeds the random number generator with the value indicated by seed 0 32767 The Srand function always returns 0 Rand The Rand function returns a pseudo random integer in the range 0 32767 RandRange rangeStart rangeLast The RandRange rangeStart rangeLast function returns a pseudo random integer in the range specified by rangeStart rangeLast kbhit The kbhit function returns the number of characters waiting in the sequencer input buffer 0 is returned if the buffer is empty Note that characters are placed in the buffer by ServoCenter command 213 0xd5 Write Character to Sequencer The sequencer communication buffer is 16 characters in size getch The getch function returns the next character waiting in the sequencer input buffer If the buffer is empty the function blocks and awaits a character Note that characters are placed in the buffer by ServoCenter command 213 0xd5 Write Character to Sequencer The sequencer communication buffer is 16 characters in size putch AsciiValue The putch AsciiValue function writes the character specified by AsciiValue to the output communication stream Note that this write is unbuffered so care must be taken so as not to interrupt other communication messages or requests being communicated The putch function always returns 0 17 User s Manual CmdAr The CmdArg function returns the command argumen
27. d Insert Usage Stats Bue Total Tokens Used 17 Variables Idenitifies 1 of 128 Messages Load From File Save To File Upload to Board T 1 1 i 1 1 i 1 j 1 H 1 1 Code Editor window This window allows you to type and edit SC BASIC programs 2 Message window This window shows errors and warnings generated by the SC4 1 tokenizer Only lexical errors are reported logic semantic and syntax errors are reported when the program is executed 3 Load From File button This button allows programs to be loaded into the editor windows from file 4 Save to File button This button allows programs in the editor window to be saved to file 5 Upload to Board button This button allows the tokenized code to be uploaded to the SC4 1 controller s non volatile EEPROM program storage 6 Usage Statistics information pane This area is used to display the program memory variable and procedure usage information about the program code that is in the editing window 7 Code Assistant pane This area allows the selection of commonly used code constructs and built in functions Code is inserted at the location of the cursor when the Insert button is clicked 8 Sequencer Status pane This area allows the reading and display of the sequencer s running status and last error message These are individually read when the respective Read button is pressed 9 Start Sequence
28. e forms Form 1 If expression Then multiple lines of code to execute if true End If Form 2 If expression Then multiple lines of code to execute if true Else multiple lines of code to execute if false End If Form 3 If expression1 Then multiple lines of code to execute if expression true Elself expression2 Then multiple lines of code to execute if expression2 true Elself expression3 Then multiple lines of code to execute if expression3 true Else multiple lines of code to execute if all expressions are false End If 10 User s Manual 2 5 3 For Next Loops For Next Loop statements are a counting loop construct that allows the SC BASIC language to repeat a section of code a specific number of times by counting through a sequence of values The counting sequence uses a specified variable to keep track of the count and counts from the specified start value to the specified end value counting by the optional step value provided For Next Statement Forms Form 1 For variable start expression To end expression multiple lines of code to repeat Next variable Form 2 For variable start expression To end expression Step step count expression multiple lines of code to repeat Next variable Exit For Statement The Exit For statement when encountered within an executing For Next loop immediately causes the termination of the innermost For Next loop Program executio
29. ed reset or had the time explicitly cleared Unlike the delay functions the time functions do not pause execution but simply return time clock readings The time clock runs even when the sequencer is stopped or idle The time functions can be useful for measuring time intervals or triggering events based upon time passage TimeClear The TimeClear function sets the millisecond second and minute values of the time clock to 0 Unlike the delay functions the time functions do not pause execution but simply return time clock readings The time clock runs even when the sequencer is stopped or idle The time functions can be useful for measuring time intervals or triggering events based upon time passage SetLedMode ModeNumber The SetLedMode ModeNumber function sets the LED display mode for the on board indicators and LED2 to the value indicated by ModeNumber 0 7 This can be useful for troubleshooting purposes or specifying a desired LED output The default settings is mode 4 Mode values are as follows Mode 0 LED2 off LED1 off Mode 1 LED2 off LED1 on Mode 2 LED2 on LED1 off Mode 3 LED2 on LED1 on Mode 4 LED2 statAction LED1 statRx Mode 5 LED2 statServoAction LED1 statRx Mode 6 LED2 statServoAction LED1 statAction Mode 7 reserved 18 User s Manual 3 ServoCenter Sequencer Control Commands The ServoCenter controller provides several commands that are related to the
30. encer has instructions that can transmit or print data from the SC4 1 board to the controller This could cause mis interpretation of responses when issuing commands that get data from the controller so care must be taken when reading from a SC4 1 board while the sequencer is running a program that transmits characters or uses the print statement Function Stop Sequencer Command Value 211 0xd3 Data Bytes 0 Data Format Description The Stop Sequencer command causes any running sequencer program to immediately halt execution Note that when a program is stopped variables declared in the global scope are not cleared This allows a program to remember information from one run to the next if desired 19 User s Manual Function Reset Sequencer Command Value 212 0xd4 Data Bytes 0 Data Format Description The Reset Sequencer command causes any running sequencer program to immediately halt execution and the contents of all globally declared variables are cleared Function Write Character to Sequencer Command Value 213 0xd5 Data Bytes 1 Data Format DataByte 0 255 Description The Write Character to Sequencer command causes a single byte of data specified by DataByte to be passed to the sequencer s character input buffer This provides a means of communicating with and control
31. ervoDisabledStateHigh function always returns 0 ServoDisabledStateLow SvNum The ServoDisabledStateLow SvNum function sets the disabled logical state of the servo channel specified by the SvNum parameter 0 15 to low logic 0 The ServoDisabledStateLow function always returns 0 QuickMoveServoScaled SvNum SvPositionScaled The QuickMoveServoScaled SvNum SvPositionScaled immediately sets the position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionScaled 0 16383 Position 0 is the servo channel s defined min position position 16383 is the servo channel s defined max position values between 0 and 16383 are linearly interpolated between the defined min and max positions The QuickMoveServoScaled function always returns 0 QuickMoveServoPercent SvNum SvPositionPercent The QuickMoveServoPercent SvNum SvPositionPercent immediately sets the position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionPercent 0 10000 Positions are in 100ths of a percent of the full scale min to max range Thus position 0 is the servo channel s defined min position position 10000 is the servo channel s defined max position values between 0 and 10000 are linearly interpolated between the defined min and max positions The QuickMoveServoPercent function always returns 0 15 User s Manual MoveServoScaled SvNum SvPositionScaled Sv
32. esses sese sese esssssssssssssss 15 QuickMoveServoScaled SvNum SvPositionScaled 2 8 15 QuickMoveServoPercent SvNum SvPositionPercent 1 1 L5 MoveServoScaled SvNum SvPositionScaled SvSpeedPercent 16 MoveServoPercent SvNum SvPositionPercent SvSpeedPercent 16 TimedMoveServoScaled SvNum SvPositionScaled SvTime 16 TimedMoveServoScaled SvNum SvPositionScaled SvTime 16 QuickLoadPreset SceneN lh eeie cacesscasceaccecsscaacienserassacassactseavdssscsessaseeveedscaesstanssbvecsel 7 5 1 L7 delay Sec me Sec delayMilliSec timeMilliSec eee enses esas ee ens sesso eese ssseeeeeesssssses 7 SSF AIG SECO 7 PRAT vecors n T 7 dre cr cr ASCH VALUE nc ABTI m nt f repe LO ABEC D e terc mE SEN f
33. grams 15 Communication Setup These controls allow the configuration of port baud and board id settings for the board that is to be controlled 4 2 Basic Use Tutorial To write and test a program follow these steps 1 Type a program in the Code Editor window Try the following program Sub Hello Print Hello End Sub Call Hello 2 If desired save the program using the Save to File button 3 Upload the program to the board using the Upload to Board button If the program uploaded correctly click Ok to dismiss the dialog Ifthe program didn t upload successfully check the communications port baud board Id settings 4 Bring up the terminal window by clicking the Show Terminal I O button 5 Start the program by clicking the Start Sequence button 6 Observe the output in the Terminal I O window The window should look like this SC4 1 TerminalSnooper 2007 2009 Yost Engineering Inc FO D2 00 00 Hello Add Newline Before Tx Send String Send Raw Send Sequencer v Display Unprintable Characters in Hex Send Character t 0 0x0 Display Printable Characters in Hex 0x0 Sk catus Clear Window Close Window Display CR LF TAB Characters in Hex Note that the communication messages being sent are shown in blue and the messages being received are shown in green 22 User s Manual 4 3 More Advanced Examples Se
34. icitly creates a variable named count and assigns the value 10 to it Note that the left side of the assignment operator requires a variable name and the left side requires a valid expression Additionally a variable will be implicitly created if it is used and hasn t previously been declared For example count 10 y will implicitly create two variables count and y Variables that are created implicitly this way are initialized with a value of 0 Explicit Declaration Explicit variable declaration uses the Dim keyword to explicitly state that you want a variable created For example Dim count Dim y As Integer declares two variable count and y Note that the As Integer is optional and that variables that are declared without this are still created as integer variables Dim statements can be used at any time within the program but are generally placed at the top of the program sub function in which the variable is declared 2 2 5 Using Variables Variable Assignment Variables are assigned values using the assignment operator For example i 10 count 0 position 1000 Variable Values When the name of a variable is used in an expression it is evaluated as the value that that variable is holding For example i 10 count 0 Print 1 count count 4l position count 10 User s Manual 2 3 Arithmetic Operations and Expressions 2 3 1 Arithmetic Operations
35. inity Loop Note that infinite loops can still be exited by using the Exit While statement 2 5 5 Procedures Subs and Functions Procedure Basics A procedure is a defined section of code that can be called upon to perform a particular task Procedures are defined by associating a procedure name with code that is outside of the main execution area A define procedure can be called to invoke the execution of its defined code Procedures can have data passed to them when invoked via the use of parameters sometimes called arguments Function procedures can return data upon completion SC BASIC provides support for two types of procedures 1 Sub Procedures A procedure that doesn t return a value 2 Function Procedures A procedure that returns a value Thus the only real difference between Sub procedures and Function procedures is the ability of functions to return a value In SC BASIC functions and procedures can be defined either before or after the main code block thus freeing the programmer to organize code in whichever way is most convenient Naming rules for procedures follow the same conventions as variable names Defining a Sub A Sub procedure is defined using the Sub End Sub statements For example Sub Hello Print Hello World End Sub The above example defines a Sub procedure named Hello that prints out the message Hello World Calling a Sub A Sub procedure can be invoked in two
36. ion Exit Sub Statement The Exit Sub statement when encountered within an executing Sub procedure immediately causes the termination of the procedure call Program execution resumes following the statement that invoked the call Defining a Function A Function procedure is defined using the Function End Function statements For example Function Midpoint numl num2 Midpoint numl num2 2 End Function The above example defines a Function procedure named Midpoint that accepts two parameter values and returns the midpoint between those two numbers Specifying Function Return Values Functions in SC BASIC can specify their return value by assigning a value to the name of the function within the function body When the function terminates by encountering the End Function or Exit Function statements the value assigned to the name of the function is returned If no return value is explicitly assigned a value of 0 is returned 13 User s Manual Calling a Function A Function procedure can be invoked in several ways but generally the function call is embedded within an arithmetic expression For example xmid Midpoint x1 x2 or Print Midpoint is Midpoint x1 x2 Thus a function can be used in any context a variable can be used Functions can also be called identically to the methods of calling Sub procedures For example DelaySec 3 or Call DelaySec 3 Exit Funct
37. ion Statement The Exit Function statement when encountered within an executing function procedure immediately causes the termination of the function The currently set function return value is returned to the point where the function call was made If no return value had been set a 0 is returned 2 5 6 The End Statement The End statement causes the executing program to immediately halt execution 2 6 Built in Functions SC BASIC includes many built in functions that complement the capabilities of the ServoCenter4 1 family of controller boards Built in functions are not case sensitive Pass The Pass function simply returns a value of 0 This can be useful when a place holder function is needed during testing or debugging SetDIOHigh DIONum The SetDIOHigh DIONum function sets the digital I O pin specified by the DIONum parameter 0 15 to a high logic 1 state If the port is configured as an input the pin s internal pull up resistor is activated The SetDIOHigh function always returns 0 SetDIOLow DIONum The SetDIOLow DIONum function sets the digital I O pin specified by the DIONum parameter 0 15 to a low logic 0 state If the port is configured as an input the pin s internal pull up resistor is deactivated The SetDIOLow function always returns 0 SetDIODirectionIn DIONum The SetDIODirectionIn DIONum function sets the digital I O pin specified by the DIONum parameter 0
38. l 2 4 3 Relational Logical Order of Operations SC BASIC evaluates expressions using the following order of operations arithmetic expressions followed by relational and logical expressions Standard relational and logical order of operations as follows Order Operators Name 1 lt gt lt gt lt gt Relational Operators from left to right 2 Not Unary Logical Negation 2 And Logical And Operators from Left to Right 4 Or Logical Or Operators from Left to Right 2 4 4 Relational Logical Operation Examples Operation Result 121 1 true 5210 0 false 10 15 true 1 2 2 gt 1 1 true 1 0 Or 0 gt 1 0 false Not 1 1 0 false 2 5 Language Statements Language statements are detailed in the following sections Note that language statements are not case sensitive 2 5 1 Print Statement Print Statement Details The Print statement allows a SC BASIC program to print information to the communication serial or USB port Caution must be used when using this feature since the program printing directly to the port could affect or corrupt other communication message data that is being requested from the SC4 1 boards The print statement accepts a sequence of arguments that are each separated by a comma or asemicolon Argument items can be any of the following 1 Literal strings hello world program done etc 2 Variable names
39. ling a running sequencer program The sequencer program can read and respond to these messages by using the built in getch and kbhit functions Function Set Sequencer Startup Mode Command Value 214 0xd6 Data Bytes 1 Data Format SequenceStartupMode 0 1 Description The Set Sequencer Startup Mode command allows the setting of the sequencer startup mode to one of the following 0 The stored sequencer program can only be started by the reception of the Start Sequencer command 1 The stored sequencer program is automatically started when the board is reset powered up or when the Start Sequencer command is received This effectively allows the SC4 1 to be used in stand alone applications Function Get Sequencer Startup Mode Command Value 2 5 0xd7 Data Bytes 0 Data Format Description The Get Sequencer Startup Mode command allows the reading of the sequencer startup mode Valid startup modes are 0 The stored sequencer program can only be started by the reception of the Start Sequencer command 1 The stored sequencer program is automatically started when the board is reset powered up or when the Start Sequencer command is received This effectively allows the SC4 1 to be used in stand alone applications Function Get Sequencer Status Command Value 216 0xd8 Data Bytes 0 Data Format Description The Get Sequencer Status command allows the reading of the sequencer status byte The sequencer statu
40. n resumes following the exited loop s Next statement 2 5 4 Do While Loops For Do While statements are a conditional loop construct that allows the SC BASIC language to repeat a section of code while an expression is evaluated as true If the conditional expression is evaluated as false execution resumes following the corresponding Loop statement Do While Loop Forms SC BASIC provides slightly different While keyword forms to preserve familiarity with other versions of BASIC Form 1 Do While expression multiple lines of code to execute while expression is true Loop Form 2 While expression multiple lines of code to execute while expression is true Wend Form 3 While expression multiple lines of code to execute while expression is true End While Exit While Statement The Exit While statement when encountered within an executing While loop immediately causes the termination of the innermost While Loop Program execution resumes following the exited loop s Loop Wend End While statement 11 User s Manual Infinite Loops It is possible to make an infinite loop in SC BASIC by ensuring that the condition always evaluates as true This is most easily accomplished by simply inserting a non zero number as the conditional expression in the do while statement For example Do While 1 condition is always true Print to infinity Loop or Do While 1 1 condition is always true Print to inf
41. n 0 and 10000 are linearly interpolated between the defined min and max positions SvTime is in 100ths of a second Thus a speed of 1000 will take 10 seconds a speed of 300 will take 3 seconds 100 will take 1 second etc The TimedMoveServoScaled function always returns 0 16 User s Manual QuickLoadPreset SceneNum The QuickLoadPreset SceneNum immediately loads the preset scene indicated by the SceneNum parameter 0 63 Scenes provide a method of storing and loading preset servo and digital IO configurations The QuickLoadPreset function always returns 0 CrossfadePreset SceneNum xFadeTimeTenths The CrossfadePreset SceneNum xFadeTimeTenths loads the preset scene indicated by the SceneNum parameter 0 63 but smoothly crossfades the scene s servo positions from current positions taking the amount of time indicated by the xFadeTimeTenths parameter Scenes provide a method of storing and loading preset servo and digital IO configurations The CrossfadePreset function always returns 0 delaySec timeSec The delaySec timeSec function pauses execution of the running program for the amount of seconds indicated by timeSec 0 32767 The delaySec function always returns 0 delayMilliSec timeMilliSec The delayMilliSec timeMilliSec function pauses execution of the running program for the amount of milliseconds indicated by timeMilliSec 0 32767 The delayMilliSec function always returns 0 Srand see
42. non volatile EEPROM data The data within the EEPROM is a tokenized P Code program for the SC4 1 BASIC Interpreter Function Start Sequencer Command Value 210 0xd2 Data Bytes 1 Data Format SequencerArg 0 255 Description The Start Sequencer command causes the execution of the program stored within the EEPROM sequencer memory When the script is started a single byte parameter argument SequencerArg can be passed to the script This allows a script to be started in different ways by the Start Sequencer command When a program is started it always begins at the beginning of the script and runs to completion until stopped by the Stop Sequencer or Reset Sequencer commands or until a sequencer error is encountered Although execution always begins at the beginning of the script variables declared within the global scope are not cleared when a program is started This allows a program to remember information from one run to the next if desired While the sequencer is running a program the ServoCenter board can still respond to other control messages Care must be taken to avoid having these incoming control messages interfere with the programmed operation of the sequencer program For example the sequencer could be programmed to move Servo 50 to position 0 and an incoming command could instruct Servo 50 to move to position 100 In cases such as this the most recently issued command will take precedence Additionally be aware that the sequ
43. okens are 2 bytes stored as V IVARIABLE NUM where VARIABLE NUM represents a unique numeric identifier for the variable name T BUILTIN built in specifier tokens are 2 bytes stored as where BUILTIN NUM represents the number index of the builtin functions as follows 0 Pass 1 SetDIOHigh 2 SetDIOLow 3 SetDIODirectionIn 4 SetDIODirectionOut 5 ReadDIO 6 ReadAD 7 ServoEnable 8 ServoDisable 9 ServoDisabledStateHigh 10 ServoDisabledStateLow 1 1 QuickMoveServoScaled 12 QuickMoveServoPercent 13 MoveServoScaled 14 MoveServoPercent 15 TimedMoveServoScaled 16 TimedMoveServoPercent 17 QuickLoadPreset 18 CrossfadePreset 19 delaySec 20 delayMilliSec 21 Srand 22 Rand 23 RandRange 24 kbhit 25 getch 26 putch 27 CmdAr 28 TimeMSec 29 TimeSec 30 TimeMin 31 TimeClear 32 SetLedMode T_COMMENT comment tokens are stored as a string of characters enclosed within single quotes For example This is a comment token 6 4 Error Codes When an executing SC BASIC sequencer program encounters an error the execution is halted and the error code byte is set to indicate the error encountered The following list provides a description of each error code 0 Error 1 ERROR assignment or function call expected after EQUAL 2 ERROR NEXT without FOR 3 ERROR LOOP without WHILE 4 ERROR ELSE without IF 5 ERROR ELSEIF without IF 6 ERROR ENDIF without IF 7
44. perators and function calls are explained in further detail later in this document 2 4 Relational and Logical Operations Relational operators provide a way to get SC BASIC programs to perform standard numeric comparisons Logical operators provide a way to get SC BASIC programs to perform the standard boolean logical operations And Or Not These are particularly useful in decision statements and looping statements discussed later in this document SC BASIC uses a value of 0 to represent false and a non zero value to represent true 2 4 1 Relational Operators SC BASIC supports the following relational operations Operator Name Use Equals True if two expressions are equal in value Greater than True if left side expression is greater than right side Less than True if left side expression is less than right side gt Greater or equal to True if left side expression is greater or equal to right side lt Less or equal to True if left side expression is less or equal to right side lt gt Not equal to True if two expressions are not equal in value 2 4 2 Logical Operators SC BASIC supports the following logical operations Operator Name Use Or Logical Or True if either left side or right side expression is true And Logical And True if both left side and right side expression are true Not Logical Unary Not True is following expression is false User s Manua
45. s byte values are 0 Sequencer Idle Stopped 1 Sequencer Running 2 Sequencer Error Stopped Function Get Sequencer Last Error Command Value 2 7 0xd9 Data Bytes 0 Data Format Description The Get Sequencer Last Error command allows the reading of the sequencer error code byte of the last error that the sequencer encountered The sequencer error byte values are described in detail in appendix 6 4 Error Codes 4 Using the ServoCenter Control Panel Sequence Editor The ServoCenter Control Panel application allows for easy editing and configuration of many aspects of the ServoCenter 4 1 servo controller This includes an SC BASIC program editor that allows the writing compiling uploading testing of SC BASIC programs The sections below describe the use of the SC BASIC related aspects of the Control Panel application 20 User s Manual 4 1 Sequencer Programming Tab To access the SC BASIC related features of the Control Panel application click on the Sequencer Programming tab ServoCenter4 1 Control Panel Utility 2007 2009 Yost Engineering Inc a ng In e Ohio 45662 OU print elio equencer Start Parameter Passer Call 110 77 Start Sequence Stop Sequence ResetSequencet B seguros siue 10 quencer Status Sequencer Error D m Code From Template Sub End Sub h
46. t byte value that was set when the sequencer program was started with the ServoCenter command 210 0xd2 Start Sequencer This gives a way of controlling how or what the program does upon execution A program that is started automatically on power up or reset due to the sequencer startup mode will have a CmdArg of 0 TimeMSec The TimeMSec function returns the millisecond portion of the time clock The time clock measures the amount of time since the board was last power cycled reset or had the time explicitly cleared Unlike the delay functions the time functions do not pause execution but simply return time clock readings The time clock runs even when the sequencer is stopped or idle The time functions can be useful for measuring time intervals or triggering events based upon time passage TimeSec The TimeSec function returns the second portion of the time clock The time clock measures the amount of time since the board was last power cycled reset or had the time explicitly cleared Unlike the delay functions the time functions do not pause execution but simply return time clock readings The time clock runs even when the sequencer is stopped or idle The time functions can be useful for measuring time intervals or triggering events based upon time passage TimeMin The TimeMin function returns the minutes portion of the time clock The time clock measures the amount of time since the board was last power cycl
47. the specified servo channel Thus a speed of 10000 will move the servo instantly to the defined positions 5000 will move at half the full speed 1000 will move at 1 10 full speed etc The MoveServoPercent function always returns 0 TimedMoveServoScaled SvNum SvPositionScaled SvTime The TimedMoveServoScaled SvNum SvPositionScaled SvTime moves the servo position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionScaled 0 16383 and takes the amount of time specified by SvTime 0 16383 Position 0 is the servo channel s defined min position position 16383 is the servo channel s defined max position values between 0 and 16383 are linearly interpolated between the defined min and max positions SvTime is in 100ths ofasecond Thus a speed of 1000 will take 10 seconds a speed of 300 will take 3 seconds 100 will take 1 second etc The TimedMoveServoScaled function always returns 0 TimedMoveServoScaled SvNum SvPositionScaled SvTime The TimedMoveServoScaled SvNum SvPositionPercent SvTime moves the servo position of the servo channel specified by SvNum 0 15 to the scaled position specified by SvPositionPercent 0 10000 and takes the amount of time specified by SvTime 0 16383 Positions are in 100ths of a percent of the full scale min to max range Thus position 0 is the servo channel s defined min position position 10000 is the servo channel s defined max position values betwee

Download Pdf Manuals

image

Related Search

Related Contents

MARC RTP - Ross Johnson`s Personal Web Page  Manual - MasteringWorks  vibradora circular s320 dman  3.4-8 CHRYSO Cure HPE  Sony 7819900133 User's Manual  Manual Audio - Ford Argentina  PROFESSIONAL PLUS MODEL USER`S MANUAL  View - Lysator  Notice d`utilisation : 3 Manual del usuario : 8 Manuale utente : 13  Edital PGE 026-2012 RP ADEQUAÇÃO AM E RR  

Copyright © All rights reserved.
Failed to retrieve file