|
|
ServoCenter™ 4.1 SC-BASIC Built-in SequencerThe 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. Sequencer Overview
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 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. Sequencer FeaturesThe 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:
Summary of Manual ContentsThe Language Reference and Programming Guide is a full guide to using the Sequencer application, including both the Control Panel sequence editor and the programming methods. General Sections include:
SC-BASIC Programming ExamplesHello World' Simple Hello World Program Print "Hello World" Hello World with Subroutine' Hello World Program using a Sub Procedure. Sub Hello() Print "Hello World" End Sub Call Hello() Servo Exercise
' This program exercises all 16 servo channels by
' moving them from min to max to min to center
' with a 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
Servo Exercise with Subroutine
' This program exercises all 16 servo channels by
' moving them from min to max to min to center
' with a 1 second delay between each movement.
Sub MoveAllServos(Pos)
'move all servos to position Pos
for SvNum = 0 to 15
QuickMoveServoScaled(SvNum,Pos)
next SvNum
End Sub
'move all servos to Min positions
Call MoveAllServos(0)
'wait for a second
Call DelaySec(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)
Digital I/O Exercise
' This program exercises all 16 Digital I/O channels by
' setting them all as outputs and cycling through each one
' with a 10th 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"
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 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
Demo of global variable retaining value' The following program demonstrates the ability of SC-BASIC to retain ' global variable values between executions. Run the program multiple times ' to see the behavior. 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+1 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 Download Sequencer
|
|
