Home

ServoCenter 4.1 Manual Volume 3: Programming

image

Contents

1. PRINT 1 CHRS amp HFO BoardNum MOD 16 CHR 0 PRINT 1 CHRS ServoNum MOD 16 PRINT 1 CHRS int Position 128 CHR Position MOD 128 PRINT 1 CHRS 0 END SUB 1 2 C Microsoft Visual C 6 Example Program KKK KK KKK KK KK K k KK K k KK KK K K KK K K KK K K K K K K AA K k k A k K I K K K N This demo program illustrates how to move servo motors using raw serial communication access to the Yost Engineering Inc ServoCenter 4 1 controller board using Visual C 6 0 c 2001 2010 Yost Engineering Inc www YostEngineering com f Tt HF S KKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK include lt windows h gt include lt stdio h gt define PORTNUM 1 define BAUDRATE 9600 void moveservo HANDLE int int int int InitPort unsigned int unsigned int HANDLI ea s E3 Q D S int main int argc char argv DCB dcb HANDLE hCom int i 0 BoardNum ServoNum Position printf An printf ServoCenter 4 1 Demonstration Program NETR printf c 2000 2010 Yost Engineering Inc n pEINEL www YostEngineering com n printe vr printf This program demonstrates the QuickMove Raw command n printf T n if InitPort PORTNUM BAUDRATE a
2. Function int ServoEnable int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be enabled Return Value 0 Fail Non 0 Success Function int ServoDisable int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be disabled Return Value 0 Fail Non 0 Success Function int ServoInvert int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be inverted Return Value 0 Fail Non 0 Success Function int ServoUninvert int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be normalized Return Value 0 Fail Non 0 Success Function int SetServoDisabledStateLow int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID
3. 18 User s Manual Compact Movement Group Commands Command CompactGroupQuickMoveRaw ServoPositions As Integer Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of integers Return Value None Command CompactGroupQuickMoveScaled ServoPositions As Integer Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a 16 element array of integers Return Value None Command CompactGroupQuickMovePercent ServoPositions As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a 16 element array of doubles Return Value None Command CompactGroupMoveRaw ServoPositions As Integer ServoSpeed As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of doubles ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactGroupMoveScaled ServoPositions As Integer ServoSpeed As Double Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a 16 element array of doubles ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactGroupMovePercent ServoPositions As Double ServoSpeed As Double Parameters ServoPositio
4. Command MoveRawCCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MoveScaled ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MoveScaledCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MoveScaledCCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MovePercent ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command Mov
5. no parity bit dcb gt StopBits ONESTOPBIT one stop bit fSuccess SetCommState hCom dcb if fSuccess Handle the error printf tSetCommState failed with error d n GetLastError return 4 printf tSerial port successfully reconfigured n return 0 1 3 C Linux GCC Example Program KK KK KK KKK K KKK K k K K K k KK K K K AA AA A I A I I I HY incl incl incl incl incl incl Yost lude lude lude lude lude lude This demo program illustrates how to move servo motors using raw serial communication access to the Engineering Inc ServoCenter 4 1 controller board in Linux This code was compiled using GCC c 2001 2010 Yost Engineering Inc i www YostEngineering com F KKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK lt stdio h gt lt string h gt lt unistd h gt lt fcentl h gt lt errno h gt lt termios h gt int open_port int portnum int fd char portfile 100 0 if portnum 1 sprintf portfile dev ttyS0 else if portnum 2 sprintf portfile dev ttyS1 else if portnum 3 sprintf portfile dev ttyS2 else if portnum 4 else sprintf portfile dev ttyS3 printf open_port unrecognized port number n return 1 if fd open portfile O_RDWR O_NOCTTY O_NDELAY
6. 1 perror open_port unable to open dev ttyS0O return fd void init_port int fd unsigned long baud struct termios options note the termios structure does not support a baud rate of 14400 tcgetattr fd amp 0ptions User s Manual void moveservo int fd switch baud case 9600 case 38400 case 57600 case 115200 default options c_cflag options c_cflag options c_cflag options c_cflag options c_cflag tcsetattr fd TCSANOW amp options int main CLOCAL B amp amp cfsetispeed amp option cfsetospeed amp option break cfsetispeed amp option cfsetospeed amp option break cfsetispeed amp option cfsetospeed amp option break cfsetispeed amp option s B s B9600 s B9600 s B38400 s B38400 s B57600 s B57600 15200 cfsetospeed amp o0ption s Bl UJ 15200 break cfsetispeed option cfsetospeed amp option break CREAD PARENB CSTOPB CSIZE CS8 int boardnum s B9600 s B9600 int servonum int position char buffer 6 int num buffer 0 boardnum 16 Oxf0 Board ID buffer 1 0x00 command ID for QuickMove Raw buffer 2 servonum 16 servo number buffer 3 position 128 raw position MSB 7 bits buffer 4 position 128
7. Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMovePercentCW int Comm mt BoardNum mt ServoNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMovePercentCCW int Comm int BoardNum int ServoNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Compact Movement Group Commands Function
8. Function int TimedMovePercent int Comm int BoardNum int ServoNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success 30 User s Manual Function int TimedMovePercentCW int Comm int BoardNum mt ServoNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMovePercentCCW int Comm int BoardNum int ServoNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoTime Length of time
9. Se Se OSE t SHE SHE SHE SH H import serial systems pywin32 extensions may also need to be This program communicates with the ServoCenter 4 1 board module The program demonstrates using the Quickmove Raw command c 2000 2010 Yost Engineering www YostEngineering com def quickMoveServoRaw boardID svNum svPosition outString chr 0xf0 boardID boardID byte outString chr 0 command ID outString chr svNum servo number outString chr int svPosition 128 position MSB 7 bits outString chr svPosition 128 position LSB 7 bits outString chr 0 checksum byte serial_port write open the port outString serial_port serial Serial port COM1 baudrate 9600 print Port opened serial_port portstr move the servo to the position specified boardID int raw_input enter a board ID 0 15 svNum int raw_input enter a servo number 0 15 svPosition int raw_input enter a servo position 0 16383 print sending Quickmove Raw command send the message quickMoveServoRaw boardl print Done close the port serial_port close D svNum svPosition 10 User s Manual 2 Programming With the ServoCenter 4 1 ActiveX Control The ServoCenter 4 1 ActiveX Control can be used in a Visual Basic 6 0 project to control the ServoCenter 4 1 This control is designed t
10. As Integer Parameters None Return Value 1 Fail 0 Sequencer Idle Stopped 1 Sequencer Running 2 Sequencer Error Stopped Command GetSequencerLastError As Integer Parameters None Return Value 1 Fail Non negative The sequencer error byte value 26 User s Manual General Commands Command SetLEDMode LEDMode As Integer Parameters LEDMode 0 7 specifies the LED display mode for LED and LED2 Return Value None Command SetWatchdogTime WdTimeTenths As Integer Parameters WdTimeTenths 0 239 Sets the internal watchdog time to the value specified by WdTimeTenths as measured in 1 10 second increments Return Value None Command CommitSettings Parameters None Return Value None Command LoadFactorySettings Parameters None Return Value None Command ResetAsStartup Parameters None Return Value None Command DisplayVersion Version As String Parameters Version Will be filled with the ServoCenter s version information once the function returns Return Value False Fail True Success 2 5 Programming in Visual Basic 6 0 with the YEIServoControl The following code examples illustrate the use of the YEIServoControl in Visual Basic 6 0 Here is an example of how to initialize your ServoCenter 4 1 Board Private Sub Form Load YEIS
11. BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non O0 Success Function int ResetSequencer int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non 0 Success Function int WriteCharToSequencer int Comm int BoardNum int DataByte Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DataByte 0 255 Single byte parameter to be passed to the sequencer s character input buffer Return Value 0 Fail Non 0 Success 45 User s Manual Function int SetSequencerStartupMode int Comm int BoardNum int SequencerStartupMode Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent SequencerStartupMode 0 1 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 Return Value 0 Fail Non 0 Succe
12. ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactGroupMoveScaled int Comm int BoardNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactGroupMovePercent int Comm int BoardNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactGroupTimedMoveRaw int Comm int BoardNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attache
13. int ReadSequencerEEPROM int Comm int BoardNum int Page unsigned char EEPROMData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Page 0 127 Specifies which sequencer EEPROM page to read EEPROMData A pointer to a 32 element unsigned char array The array is filled with the specified page if the function returns successfully Return Value 0 Fail Non 0 Success Function int WriteSequencerEEPROM int Comm int BoardNum int Page unsigned char EEPROMData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Page 0 127 Specifies which sequencer EEPROM page to write EEPROMData A pointer to a 32 element unsigned char array filled with the contents to be written to the specified sequencer EEPROM page Return Value 0 Fail Non 0 Success Function int StartSequencer int Comm int BoardNum int SequenceArg Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent SequenceArg 0 255 Single byte parameter argument passed to the sequencer Return Value 0 Fail Non 0 Success Function int StopSequencer int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached
14. raw position LSB 7 bits buffer 5 0O checksum of 0 is ignored num write fd buffer 5 send packet int fd board servo position portnum printf n printi ServoCenter 4 1 Demonstration Program n printf CH c 2000 2010 Yost Engineering Inc n printf www YostEngineering com n printf n printf This program demonstrates the QuickMove Raw command An printf n printf Enter Port Number 1 4 n scanf d amp portnum if fd open_port portnum 1 open serial port return 1x init_port amp fd 9600 set serial port to 9600 8 n 1 while 1 printf Enter Board Number 0 15 n scanf Sd amp board printf Enter Servo Number 0 15 n scanf dqd amp servo printf Enter Position 0 16383 n scanf Sd amp position return prin tf Sending Command moveservo amp fd board servo position printf done n 0 User s Manual 1 4 C Borland Turbo C Sample Program KK KK KK KKK KK KK K k KK K k K K KK K AA AA K K k k K K k A I I A I KK N YOSE Engineering LAG c 20 w incl include lt dos h gt incl defin defin defin defin COM COM COM COM4 0x3 0x2 0x3 0x2 e 1 e 2 e 3 e 01 2010 www Yost Yost ude lt stdio h gt ude lt conio h gt 8 8 e8 e8 This demo program illustrates how t
15. 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to set as output Return Value 0 Fail Non 0 Success Function int SetDIOPinStartStateDirection int Comm int BoardNum int DIONum int DIOState Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to set start state and direction DIOState 0 input no internal pull up 1 input with internal pull up 2 output low 3 output high Return Value 0 Fail Non 0 Success Function int SetAlIDIOPinStartStatesDirections int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non 0 Success Servo Group Mask Commands Function int GroupMaskQuickMoveRaw int Comm int BoardNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated Return Value 0 Fail Non 0 Success Function int GroupMaskQuickMoveScaled int Comm int BoardNum int ServoP
16. 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Normal Movement Group Commands Function int GroupQuickMoveRaw int Comm int BoardNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Return Value 0 Fail Non 0 Success Function int GroupQuickMoveScaled int Comm int BoardNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Return Value 0 Fail Non 0 Success Function int GroupQuickMovePercent int Comm int BoardNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Return Value 0 Fail Non 0 Success Function int GroupMoveRaw int Comm int BoardNum int ServoPos float ServoSpeed Paramete
17. 0 Fail Non 0 Success Function Int GetMaxPosition int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Max is being queried ServoPos Pointer which will be filled with the servo position 0 16383 once the function returns Return Value 0 Fail Non 0 Success Function int GetStartPosition int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which start position is being queried ServoPos Pointer which will be filled with the servo position 0 100 once the function returns Return Value 0 Fail Non 0 Success 39 User s Manual Function int GetSmoothingFactor int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which smoothing factor is being queried Return Value 1 Fail Smoothing factor 0 127 of th
18. 16 element array of doubles Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value None Command GroupMaskMoveScaled ServoPositions As Integer ServoSpeed As Double Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a 16 element array of doubles Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value None Command GroupMaskMovePercent ServoPositions As Double ServoSpeed As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of doubles Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value None Command GroupMaskTimedMoveRaw ServoPositions As Integer ServoTime As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of integers Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value None 23 User s Manual Command GroupMaskTimedMoveScaled ServoPositions As Integer ServoTime As Double Parameters ServoPositions Scaled position 0 16383 to which servos will be moved
19. Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int GroupTimedMoveScaled int Comm int BoardNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int GroupTimedMovePercent int Comm int BoardNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success Compact Movement Servo Commands Function in
20. Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Specifies which preset slot to initialize Return Value 0 Fail Non 0 Success 44 User s Manual Function int ReadPresetEEPROM int Comm int BoardNum int Page unsigned char EEPROMData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Page 0 127 Specifies which preset EEPROM page to read EEPROMData A pointer to a 32 element unsigned char array The array is filled with the specified page if the function returns successfully Return Value 0 Fail Non 0 Success Function int WritePreset EEPROM int Comm int BoardNum int Page unsigned char EEPROMData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Page 0 127 Specifies which preset EEPROM page to write EEPROMData A pointer to a 32 element unsigned char array filled with the contents to be written to the specified preset EEPROM page Return Value 0 Fail Non 0 Success Sequencer BASIC Interpreter Commands Function
21. Communications Port to which ServoCenter 4 1 controller is attached BaudRate Data rate at which the serial port will communicate Return Value 0 Success Other Error Normal Movement Servo Commands Function int QuickMoveRaw int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Raw position 0 16383 to which servo will be moved Return Value 0 Fail Non 0 Success Function int QuickMoveScaled int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Scaled position 0 16383 to which servo will be moved Return Value 0 Fail Non 0 Success Function int QuickMovePercent int Comm int BoardNum int ServoNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Scaled position 0 100 to which servo will be moved Ret
22. Expects a 16 element array of integers Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value None Command GroupMaskTimedMovePercent ServoPositions As Double ServoTime As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of doubles Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value None Preset Commands Command SetPresetServoData PresetSlot As Integer ServoPositions As Double EncodingFlags As Long SkipFlags As Long Parameters PresetSlot 0 63 Selects which preset slot to set preset servo data ServoPos Scaled position of servos 0 16383 if binary scaled encoded 0 100 if percentage scaled encoded Expects a 16 element array of doubles EncodingFlags Bitmask used to determine encoding of servo data Servo encoding is as follows 0 servo is binary scaled encoding 1 servo is percentage scaled encoding The most significant bit b15 selects servo S15 while the least significant bit b0 selects SO All other bits represent their respective servo SkipFlags Bitmask used to set the servo skip status Skip encoding is as follows 0 servo is not skipped 1 servo is skipped The most significant bit b15 selects servo S15 while the least signi
23. Function int GetServoEnableStatus int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which enable status is being queried Return Value 1 Fail 0 servo is disabled 1 servo is enabled Function int GetServoInvertStatus int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which invert status is being queried Return Value 1 Fail 0 servo is non inverted 1 servo is inverted Function int GetServoDisabledState int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which disable state is being queried Return Value 1 Fail 0 servo disable state is low 1 servo disable state is high Function int GetCurrentPositionRaw int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which position is being queried ServoP
24. ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMoveScaledCC W ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMovePercent ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMovePercentCW ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMovePercentCCW ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None
25. Interpreter E 26 General Comin ands issor e a e a E En maaan 27 2 5 Programming in Visual Basic 6 0 with the VElServotControl 27 3 Programming With the ServoCenter 4 1 DLL sseoessooecssoessssocessooseesesssoooosesessoo 28 3 1 ServoCenter 4 1 DLL Functional Overview 28 OECD UH ITS ars As ae cae Shey 2p sce a Ee 28 Normal Movement Servo Commandes 28 Normal Movement Group Commands lt x 3 sices icercecsesdaavsteeccle etdans Ueeades iad veduursaacdsdeeuner noes 31 Compact Movement Servo Commandes 32 Compact Movement Group Commande 35 Set Serva Settings RE E 37 Get Servo Settings EE 39 Input Output Eent E EE EE 40 Servo Group Mask Eet 41 LE EN EE EE 43 Sequencer BASIC Interpreter Commands seccssccssevscasssccevscvsarcvandscnnsssonetetabdocenvtessarabniets 45 General Commands EE 46 3 2 Installing the yeisrvo dll Runtime Libar 47 3 3 Programming with yeisrvo dll in Visual Basic 60 47 3 4 Programming with yeisrvo dll in Visual Ciion 49 3 5 Programming with yeisrvo dll in Visual C NET 50 3 6 Programming with yeisrvo dll in the Microsoft NET Framework cccccsseeeees 50 Visual Basic NE pats ley ein DO aie aie at a ale Att ie Ae ae ade 51 EE 51 4 Programming With the ServoCenter 4 1 NET Assembly ccsscccsssscssseeseees 52 4 1 Operation with ServoCenter 4 1 NET Assembly 52 4 2 Installing the ServoCenter 4 1 NET Assembly eseseeseesseeseessessresresssreessressseresseeesse 52 4 3 Using the ServoCe
26. an integer 47 User s Manual To use any of the ServoCenter 4 1 DLL functions a declaration like the one above must be written and stored in a code module The ServoCenter bas file located on the ServoCenter 4 1 CD contains declarations for all of the ServoCenter 4 1 runtime library s functions After making declarations for the DLL functions they can be called in the same fashion as any other Visual Basic routine The code snippet below illustrates calling a DLL function in Visual Basic Private Sub Form_Load If InitPort l1 9600 lt gt 0 Then MsgBox Port could not be opened Else MsgBox Port opened successfully End If End Sub This code snippet calls the InitPort function declared previously The ServoCenterDLLExample vbp project located on the ServoCenter 4 1 CD is a sample Visual Basic project that demonstrates usage of the ServoCenter 4 1 DLL from the Visual Basic 6 0 environment 48 User s Manual 3 4 Programming with yeisrvo dll in Visual C 6 0 To use the ServoCenter 4 1 runtime library within the Visual C 6 0 environment you must first copy the yeisrvo lib import library to Visual C 6 0 s library directory By default this is C Program Files Microsoft Visual Studio VC98 LIB The yeisrvo lib file contains object code that needs to be linked to your programs when they are compiled To ensure that Visual C links to the import library you will ne
27. int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMoveScaledCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMoveScaledCCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success
28. int CompactGroupQuickMoveRaw int Comm int BoardNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Return Value 0 Fail Non 0 Success Function int CompactGroupQuickMoveScaled int Comm int BoardNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Return Value 0 Fail Non 0 Success 35 User s Manual Function int CompactGroupQuickMovePercent int Comm int BoardNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Return Value 0 Fail Non 0 Success Function int CompactGroupMoveRaw int Comm int BoardNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum
29. 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to set disabled state low Return Value 0 Fail Non 0 Success Function int SetServoDisabledStateHigh int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to set disabled state high Return Value 0 Fail Non 0 Success Function int SetMin int Comm int BoardNum int ServoNum int ServoMinPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Min is being set ServoPos Minimum value to be set Return Value 0 Fail Non 0 Success Function int SetMax int Comm int BoardNum mt ServoNum int ServoMaxPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Max is being set ServoPos Maximum value to be set Return Value 0 Fail Non 0 Success Function int SetStart int Comm int BoardNum int ServoNum int ServoStartPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the comm
30. 0 15 of servo whose position is to be changed ServoPosition Scaled position 0 100 to which servo will be moved Return Value None Command CompactMoveRaw ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None 16 User s Manual Command CompactMoveRawCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMoveRawCCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMoveScaled ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMoveScaledCW ServoNum
31. 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success 34 User s Manual Function int CompactTimedMoveScaledCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMoveScaledCC W int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMovePercent int Comm int BoardNum int ServoNum float ServoPos float ServoTime Parameters
32. 16 element array of integers Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value 0 Fail Non 0 Success Function int GroupMaskTimedMoveScaled int Comm int BoardNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value 0 Fail Non 0 Success Function int GroupMaskTimedMovePercent int Comm int BoardNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Values out of range are ignored and servo positions are not updated ServoTime Length of time 0 23 9 in seconds for servos to move Return Value 0 Fail Non 0 Success 42 User s Manual Preset Commands Function int SetPresetServoData i
33. 24 User s Manual Command GetPresetControlData PresetSlot As Integer PresetData As ControlData As Integer Parameters PresetSlot 0 63 Selects which preset slot to read preset control data PresetData Expects a ControlData type variable that will be filled in with the preset control data once the function returns Return Value False Fail True Success Command SetPresetName PresetSlot As Integer PresetName As String Parameters PresetSlot 0 63 Selects which preset slot is named PresetName Expects a string up to 16 characters long Return Value None Command GetPresetName PresetSlot As Integer PresetName As String As Boolean Parameters PresetSlot 0 63 Selects which preset slot name is read PresetName The string will contain the name of the selected preset if the function returns successfully Return Value False Fail True Success Command QuickLoadPreset PresetSlot As Integer Parameters PresetSlot 0 63 Specifies the preset to be loaded Return Value None Command CrossfadePreset PresetSlot As Integer CrossfadeTime As Double Parameters PresetSlot 0 63 Specifies the preset to be loaded CrossfadeTime 0 23 9 Time in seconds the preset is to be cross faded from the current servo positions Return Value None Command StoreCurrentAsPreset PresetSlot As Integer Parameters PresetSl
34. 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot to set preset control data PresetData Expects a structure consisting of four integers ServoEnabledFlags DIOSkipFlags DJODirections and DIOValues ServoEnabledFlags 16 bit value with each bit corresponding to the enabled state of a servo Thus b is servo Se enabled state bl is servo S1 s enabled state etc DIOSkipFlags 16 bit value with each bit corresponding to the skip state of a digital I O channel Thus bO is DIOO s skip state b1 is DIO1 s skip state etc When the skip state bit is high for a channel the state and direction for that digital I O channel is unmodified This allows digital I O presets to be effectively masked and layered D ODirections 16 bit value with each bit corresponding to the pin direction of a digital I O channel Thus b is DIOO s direction value b1 is DIOI s direction value etc When the direction bit is 0 the direction for that digital I O channel is set as an input When the direction bit is 1 the direction for that digital I O channel is set as an output DIOValues 16 bit value with each bit corresponding to the pin state of a digital I O channel Thus b0 is DIOO s state value b1 is DIOI s state value etc When the state bit is 0 the state for that digital VO channel is set low When the state bit is 1 the state for that digital I O channel is set high When a pin is configured as an input the value bit c
35. B form consisting of four Text Boxes a Command Button and the MSComm Control was used Please refer to the project file on the CDROM for further details This example makes use of two program events the Form_Load event and the cmdMove Click event The code attached to these events can be seen below This program communicates with the ServoCenter 4 1 board by using the raw packet format in Visual Basic 6 The serial port is accessed in this example via the Microsoft Comm Control c 2000 2010 Yost Engineering www YostEngineering com Private Sub cmdMove_Click txtBoardNum Text Trims txtBoardNum Text txtServoNum Text Trims txtServoNum Text txtPosition Text Trims txtPosition Text MSComml Output Chr amp HFO Val txtBoardNum Text amp Chrs 0 _ amp Chr Val txtServoNum Text amp ChrS int Val txtPosition Text 128 _ amp Chr int Val txtPosition Text Mod 128 amp Chr 0 End Sub Private Sub Form_Load MSComm1 CommPort 1 use comml MSComm1 Settings 9600 N 8 1 set up comm port MSComml PortOpen True open the port End Sub User s Manual 1 6 Python Sample Program The Python sample program should run on any platform running Python 2 2 or newer so long as the pyserial Python module has been downloaded and properly installed For installation on Windows installed by using the pyserial to move a servo
36. Load Call InitPort 1 9600 End Sub The Visual Basic NET project ServoCenterVBNETDLL vbproj located on the ServoCenter 4 1 CD demonstrates using the yeisrvo dll functions from a VB NET program C The following code snippets demonstrate importing classes and calling DLL functions in C using System Text using System Runtime InteropServices public class ServoCenter DllImport yeisrvo dll EntryPoint InitPort public extern static int InitPort int PortNum long BaudRate private void Forml_Load object sender System EventArgs e int ay if ServoCenter InitPort 1 9600 0 Console WriteLine Could not open serial port return The C project ServoCenterExampleC csproj located on the ServoCenter 4 1 CD demonstrates using the yeisrvo dll functions from a C program 51 User s Manual 4 Programming With the ServoCenter 4 1 NET Assembly The ServoCenter 4 1 NEI Assembly can be used in programs utilizing the NET Framework to control the ServoCenter 4 1 This control is designed to allow the programmer to communicate with the ServoCenter 4 1 board without having to worry about the communications protocol Below is an explanation of how to control the ServoCenter 4 1 using the ServoCenter 4 1 NET Assembly 4 1 Operation with ServoCenter 4 1 NET Assembly The ServoCenter 4 1 CD contains the ServoCenter 4 1 NET As
37. Speed As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are skipped to allow for the individual control of Servos ServoSpeed Speed 0 100 at which servo will move Return Value None 15 User s Manual Command GroupMoveScaled ServoPositions As Integer ServoSpeed As Double Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are skipped to allow for the individual control of Servos ServoSpeed Speed 0 100 at which servo will move Return Value None Command GroupMovePercent ServoPositions As Double ServoSpeed As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Values out of range are skipped to allow for the individual control of servos ServoSpeed Speed 0 100 at which servo will move Return Value None Command GroupTimedMoveRaw ServoPositions As Integer ServoTime As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are skipped to allow for the individual control of Servos ServoTime Length of time 0 23 9 in seconds for s
38. State DIONum As Integer As Integer Parameters DIONum 0 15 Digital I O pin to read Return Value 1 Fail 0 Low 1 High Command ReadDIJOPinDirection DIONum As Integer As Integer Parameters DIONum 0 15 Digital I O pin direction to read Return Value 1 Fail 0 Pin is configured as an input 1 Pin is configured as an output Command ReadDIOPinChangeFlag int DIONum As Integer Parameters DIONum 0 15 Digital I O pin change flag to read Return Value 1 Fail 0 Pin has not changed 1 Pin has changed Command ReadDIJOPinStartStateDirection DIONum As Integer As Integer Parameters DIONum 0 15 I O pin to read starting state and direction Return Value 1 Fail 0 Input no internal pull up 1 Input with internal pull up 2 Output low 3 Output high Command SetDIOPinLow DIONum As Integer As Integer Parameters DIONum 0 15 I O pin to set state low Return Value 0 Fail Non 0 Success Command SetDIOPinHigh DIONum As Integer As Integer Parameters DIONum 0 15 I O pin to set state high Return Value 0 Fail Non 0 Success Command SetDIOPinAsInput DIONum As Integer As Integer Parameters DIONum 0 15 I O pin to set as input Return Value 0 Fail Non 0 Success 22 User s Manual Command SetDIOPinAsOutput DIONum As Integer As Integer Parameters DIONum 0 15 I O pin to set as output Return Value 0 Fail Non 0 Success Command SetDIOPinStartStateDire
39. User s Manual SservoCenter A i Volume 3 Programming Guide amp Programming Examples 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 1 Programming with Raw Serial 1 O ccsecssccssssssscsssscscsssscecssscccessscsscsesessssssnees 3 1 1 OBASIC Example Fetter EE ege dee EE ed Ee 3 1 2 C Microsoft Visual C 6 Example Program 4 1 3 C Linux GCC Example EE 6 1 4 C Borland Turbo C Sample Program 8 1 5 Visual Basic 6 Sample Broetattt eet Ee E 9 1 6 Python Sample Program ennienni E E EAT E dE eEEe 10 2 Programming With the ServoCenter 4 1 ActiveX Control sesssessssoessssssoesssooo 11 2 1 Operation with ServoCenter 4 1 ActiveX Control 11 2 2 Installing the ServoCenter 4 1 ActiveX Control 11 2 3 Using the ServoControl in Visual Basic oi 12 2 4 ServoCenter 4 1 OCX Control Mergen Ee eher 13 Publie Propert EE 13 EH 13 Normal Movement Group Commands jo sciseccsrwsstets cae nceatenmaneeoemtaterg marianne 15 Compact Movement Servo Commande seess este sacs ee 16 Compact Movement Group Commande 19 Set Servo Settings e 20 Get Seryo Settings E TEE 21 Input Output EE E 22 Servo Group Mask Commands s sessseseeseessseserssessresetssessresrtsstssressressseressrresssresseeesse 23 Preset Command Sereni eer 24 Sequencer BASIC
40. Yost Engineering Inc ServoCenter 4 1 controller board LES g c 2001 2010 Yost Engineering Inc a de www YostEngineering com K VT KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK iw IM svBoardnum AS INTEGER IM svServonum AS INTEGE IM svPosition AS INTEGER oO vs iw n 1 CH O D LA ol n ServoCenter 4 1 Demonstration Program c 2000 2010 Yost Engineering Inc A www YostEngineering com This program demonstrates the QuickMove Raw command QW YYYY OD AAAAAD AOE CH DO Or OZ 22222 2z 7 O PRINT Di initialize the serial port coml to 9600 CALL initCOMPort 1 9600 DO WHILE 1 1 y Enter a board number 0 15 svBoardnum de Enter a servo number 0 15 svServonum Enter a position value 0 16383 svPosition 4 0 KW Sending QuickMove Raw Command now MoveServoRaw svBoardnum svServonum svPosition LOR 2 0 NT Sent PRINT COLOR 7 0 ae bes fc Ms SUB initCOMPort port AS INTEGER baud as INTEGER settingsS COM LTRIMS STRS port LTRIMS STRS baud _ N 8 1 CD0 CS0 DSO OPEN settings FOR RANDOM AS 1 END SUB vs User s Manual SUB MoveServoRaw BoardNum AS INTEGER ServoNum AS INTEGER Position AS INTEGER
41. and will be sent ServoNum ID 0 15 of servo for which Start is being set ServoPos Start value to be set Return Value 0 Fail Non 0 Success 37 User s Manual Function int SetSmoothingFactor int Comm int BoardNum int ServoNum int SmoothingFactor Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Start is being set SmoothingFactor 0 127 Sets Smoothing Factor for the specified servo Return Value 0 Fail Non 0 Success Function int SetMaxSpeed int Comm int BoardNum int ServoNum int ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Speed is being set ServoSpeed Maximum speed of servo 1 200 in centi seconds 60 degrees Return Value 0 Fail Non 0 Success Function int SetMinCurrent int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Min is being set Return Value 0 Fail Non 0 Success Function int SetMaxCurrent
42. be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMovePercentCCW ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Normal Movement Group Commands Command GroupQuickMoveRaw ServoPositions As Integer Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of integers Values out of range are skipped to allow for the individual control of servos Return Value None Command GroupQuickMoveScaled ServoPositions As Integer Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a 16 element array of integers Values out of range are skipped to allow for the individual control of servos Return Value None Command GroupQuickMovePercent ServoPositions As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of doubles Values out of range are skipped to allow for the individual control of Servos Return Value None Command GroupMoveRaw ServoPositions As Integer Servo
43. ber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMoveScaledCCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMovePercent ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMovePercentCW ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactMovePercentCCW ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command Compa
44. ctTimedMoveRaw ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None 17 User s Manual Command CompactTimedMoveRawCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMoveRawCCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMoveScaled ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command CompactTimedMoveScaledCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber
45. ction DIONum As Integer DIOState As Integer As Integer Parameters DIONum 0 15 I O pin to set start state and direction DIOState 0 input no internal pull up 1 input with internal pull up 2 output low 3 output high Return Value 0 Fail Non 0 Success Command SetAlIDIOPinStartStatesDirections As Integer Parameters None Return Value 0 Fail Non 0 Success Servo Group Mask Commands Command GroupMaskQuickMoveRaw ServoPositions As Integer Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of integers Values out of range are ignored and servo positions are not updated Return Value None Command GroupMaskQuickMoveScaled ServoPositions As Integer Parameters ServoPositions Scaled position 0 16383 to which servos will be moved Expects a 16 element array of integers Values out of range are ignored and servo positions are not updated Return Value None Command GroupMaskQuickMovePercent ServoPositions As Double Parameters ServoPositions Scaled position 0 100 to which servos will be moved Expects a 16 element array of doubles Values out of range are ignored and servo positions are not updated Return Value None Command GroupMaskMoveRaw ServoPositions As Integer ServoSpeed As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a
46. d BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactGroupTimedMoveScaled int Comm int BoardNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactGroupTimedMovePercent int Comm int BoardNum float ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats ServoTime Length of time 0 23 9 in seconds for servo to move Return Value 0 Fail Non 0 Success 36 User s Manual Set Servo Settings Commands
47. d BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to read starting state and direction Return Value 1 Fail 0 Input no internal pull up 1 Input with internal pull up 2 Output low 3 Output high 40 User s Manual Function int SetDIOPinLow int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to set state low Return Value 0 Fail Non O0 Success Function int SetDIOPinHigh int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to set state high Return Value 0 Fail Non 0 Success Function int SetDIOPinAsInput int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 I O pin to set as input Return Value 0 Fail Non 0 Success Function int SetDIOPinAsOutput int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID
48. d to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMoveRawCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMoveRawCCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int CompactTimedMoveScaled int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4
49. e disabled Return Value None Command ServoInvert ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to be inverted Return Value None Command ServoUninvert ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to be normalized Return Value None Command SetServoDisabledStateLow ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to set disabled state low Return Value None Command SetServoDisabledStateHigh ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to set disabled state high Return Value None Command SetMin ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo for which Min is being set ServoPosition Minimum value to be set Return Value None Command SetMax ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo for which Max is being set ServoPosition Maximum value to be set Return Value None Command SetStart ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo for which Start is being set ServoPosition Start value to be set Return Value None Command SetSmoothingFactor ServoNumber As Integer SmoothingFactor As Integer Parameters ServoNumber ID 0 15 of servo for which Start is being set SmoothingFactor 0 127 Sets Smoothing Factor for the specified servo Return Value None Command SetMaxSpeed Serv
50. e particular servo Function int GetMaxSpeed int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which max speed is being queried Return Value 1 Fail Maximum speed of servo 1 200 in centi seconds 60 degrees Function int GetPulseWidthMin int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 1 Fail Minimum 1 239 width of servo control pulses Function int GetPulseWidthMax int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 1 Fail Maximum 1 239 width of servo control pulses Input Output Commands Function int ReadAD8 int Comm int BoardNum int ADNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ADNum 0 7 analog to digital input pin to read Return Value 1 Fail Voltage 0 255 that is present on analog to digital input pin Function int ReadAD10 int Comm int BoardNum int ADNum Parameters Comm Communications Port t
51. ePercentCW ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MovePercentCCW ServoNumber As Integer ServoPosition As Double ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command TimedMoveRaw ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMoveRawCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMoveRawCCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None 14 User
52. ed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMoveRawC W int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMoveRawCCW int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMoveScaled int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of Se
53. ed to alter your project settings such that yeisrvo lib is is in the link list To do this click Project gt Settings and then click the Link tab At the end of the list of Object library modules append a space and yeisrvo lib The following illustration shows a properly modified module list Settings For Win32 Debug D General Debug C C Link Resourci agi Category General D Output file name Debug yeisivo dll Object library modules Heset 2 lib oleaut32 lib uuid lib odbc32 lib odbecp32 lib yeisrvo lib V Generate debug info J Ignore all default libraries JW Link incrementally J Generate mapfile J Enable profiling I Doesn t produce LIB Project Options kernel32 lib user32 lib gdi32 lib winspool lib comdlg32 lib A adyapi32 lib shell32 lib ole32 lib oleaut32 lib uuid lib odbe32 lib odbecp32 lib nologo dll incrementalyes Cancel After adding yeisrvo lib to the project s module list you must now include the servocenter h header file This file contains function prototypes for the functions contained within the ServoCenter 4 1 runtime library The file can be found on the ServoCenter 4 1 CD After including the header file you may call any of the functions listed above The Visual C 6 0 project ServoCenterDLL dsp located on the ServoCenter 4 1 CD contains examples of how to call these functions 49 User s Manual 3 5 Programming with yeisrv
54. ervo to move Return Value None Command GroupTimedMoveScaled ServoPositions As Integer ServoTime As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are skipped to allow for the individual control of Servos ServoTime Length of time 0 23 9 in seconds for servo to move Return Value None Command GroupTimedMovePercent ServoPositions As Double ServoTime As Double Parameters ServoPositions Position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Values out of range are skipped to allow for the individual control of servos ServoTime Length of time 0 23 9 in seconds for servo to move Return Value None Compact Movement Servo Commands Command CompactQuickMoveRaw ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo whose position is to be changed ServoPosition Raw position 0 16383 to which servo will be moved Return Value None Command CompactQuickMoveScaled ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo whose position is to be changed ServoPosition Scaled position 0 16383 to which servo will be moved Return Value None Command CompactQuickMovePercent ServoNumber As Integer ServoPosition As Double Parameters ServoNumber ID
55. ervoCtrll BaudRate vb9600 set the baud to 9600 bps YETServoCtrll BoardID vbBoard0 set board id to 0 YEIServoCtrll InitBoard initialize the control End Sub Here is an example of how to move a servo by clicking on a button Private Sub cmdMoveServo_ Click Call YEIServoCtr1ll QuickMoveRaw 0 100 Move servo 0 to raw position 100 End Sub Here is an example of how to show the ServoCenter control panel Private Sub cmdShowConfig Click YEIServoCtr1ll1 ShowControlPanel show control panel nd Sub ti The DirectSerial vbp project located on the ServoCenter 4 1 CD is a sample Visual Basic project that demonstrates usage of the YEIServoControl in the Visual Basic 6 0 environment 27 User s Manual 3 Programming With the ServoCenter 4 1 DLL ServoCenter 4 1 comes packaged with the yeisrvo dll runtime library which gives programmers access to low level predefined functions that can be used with the ServoCenter 4 1 controller board This section covers the capabilities of the DLL installing the DLL and writing programs using the DLL functions 3 1 ServoCenter 4 1 DLL Functional Overview The functions provided by the ServoCenter 4 1 DLL correspond with the ServoCenter 4 1 controller board commands detailed in Section 4 1 4 except as noted in the table descriptions listed below Port Functions Function void InitPort int Comm long BaudRate Parameters Comm
56. ficant bit b0 selects SO All other bits represent their respective servo Return Value None Command GetPresetServoData PresetSlot As Integer ServoPositions As Double EncodingFlags As Long SkipFlags As Long As Boolean Parameters PresetSlot 0 63 Selects which preset slot to read preset servo data ServoPositions Expects a 16 element array of doubles The array is filled with the preset data after the function returns Detailed information about the preset data can be found in the ServoCenter 4 1 Protocol Manual under the Get Preset Servo Data command EncodingFlags Long variable to be filled with the encoding flags Servo encoding is as follows 0 servo is binary scaled encoding 1 servo is percentage scaled encoding The most significant bit b15 selects servo S15 while the least significant bit b0 selects SO All other bits represent their respective servo SkipFlags Long variable to be filled with the skip flags Skip encoding is as follows 0 servo is not skipped 1 servo is skipped The most significant bit b15 selects servo S15 while the least significant bit b0 selects SO All other bits represent their respective servo Return Value False Fail True Success Command SetPresetControlData PresetSlot As Integer PresetData As ControlData Parameters PresetSlot 0 63 Selects which preset slot to set preset control data PresetData Expects a custom type consisting of
57. for that digital I O channel is set as an input When the direction bit is 1 the direction for that digital I O channel is set as an output DIOValues 16 bit value with each bit corresponding to the pin state of a digital I O channel Thus bO is DIOO s state value b1 is DIOI s state value etc When the state bit is 0 the state for that digital VO channel is set low When the state bit is 1 the state for that digital I O channel is set high When a pin is configured as an input the value bit controls the application of an internal pull up resistance for each channel Return Value 0 Fail Non 0 Success Function int SetPresetName int Comm int BoardNum int PresetSlot char PresetName Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot is named PresetName Expects a pointer to a null terminated string up to 16 characters long Return Value 0 Fail Non 0 Success Function int GetPresetName int Comm int BoardNum int PresetSlot char PresetName Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot is named PresetName Expects a pointer to an array of characters 17 elements
58. four longs ServoEnabledFlags DIOSkipFlags D ODirections and DIOValues The custom type is accessible within the control ServoEnabledFlags 16 bit value with each bit corresponding to the enabled state of a servo Thus bO is servo Se enabled state bl is servo S1 s enabled state etc DIOSkipFlags 16 bit value with each bit corresponding to the skip state of a digital I O channel Thus b0 is DIOO s skip state b1 is DIO1 s skip state etc When the skip state bit is high for a channel the state and direction for that digital I O channel is unmodified This allows digital I O presets to be effectively masked and layered D ODirections 16 bit value with each bit corresponding to the pin direction of a digital I O channel Thus b is DIOO s direction value b1 is DIOI s direction value etc When the direction bit is 0 the direction for that digital I O channel is set as an input When the direction bit is 1 the direction for that digital I O channel is set as an output DIOValues 16 bit value with each bit corresponding to the pin state of a digital I O channel Thus b0 is DIOO s state value b1 is DIOI s state value etc When the state bit is 0 the state for that digital VO channel is set low When the state bit is 1 the state for that digital I O channel is set high When a pin is configured as an input the value bit controls the application of an internal pull up resistance for each channel Return Value None
59. h sequencer EEPROM page to write EEPROMData A 32 element byte array filled with the contents to be written to the specified sequencer EEPROM page Return Value False Fail True Success Command StartSequencer SequenceArg As Integer Parameters SequenceArg 0 255 Single byte parameter argument passed to the sequencer Return Value None Command StopSequencer Parameters None Return Value None Command ResetSequencer Parameters None Return Value None Command WriteCharToSequencer SequencerChar As Integer Parameters SequencerChar 0 255 Single byte parameter to be passed to the sequencer s character input buffer Return Value None Command SetSequencerStartupMode SequencerStartupMode As Integer Parameters SequencerStartupMode 0 1 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 Return Value None Command GetSequencerStartupMode As Integer Parameters None Return Value 1 Fail 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 Command GetSequencerStatus
60. ink line ex kernel32 lib configuration specific Help Cancel Once the yeisrvo lib import library has been added to your project you may follow the instructions provided in Section 4 4 4 to program the ServoCenter 4 1 controller board The Visual C NET project ServoCenterCppNETDII vcproj located on the ServoCenter 4 1 CD contains examples of how to call these functions 3 6 Programming with yeisrvo dll in the Microsoft NET Framework The process for accessing the runtime library functions of the ServoCenter 4 1 DLL is very similar on both the Visual Basic NET and the C platforms In both instances the programs must import System Runtime InteropServices which provides the DlilImport function and System Text which provides the StringBuilder class The DlilImport function allows you to call runtime library functions directly in your code and the StringBuilder class provides a way to pass mutable strings to the DLL functions 50 User s Manual Visual Basic NET The following code snippets demonstrate importing classes and calling DLL functions in Visual Basic NET Imports System Runtime InteropServices Imports System Text lt DllImport yeisrvo dl1l gt Function InitPort ByVal PortNum As Integer ByVal Baud As Long As Integer End Function Private Sub Forml_Load ByVal sender As System Object ByVal e As System EventArgs Handles MyBase
61. int Comm mt BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Max is being set Return Value 0 Fail Non 0 Success Function int SetStartCurrent int Comm int BoardNum int ServoNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Start is being set Return Value 0 Fail Non 0 Success Function int SetPulseWidthMin int Comm int BoardNum int WidthVal Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent WidthVal Minimum 1 239 width of servo control pulses Return Value 0 Fail Non 0 Success Function int SetPulseWidthMax int Comm int BoardNum int WidthVal Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent WidthVal Maximum 1 239 width of servo control pulses Return Value 0 Fail Non 0 Success 38 User s Manual Get Servo Settings Commands
62. int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MovePercentCW int Comm int BoardNum int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MovePercentCCW int Comm int BoardNum int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success 29 User s Manual Function int Ti
63. ion int GroupMaskMoveScaled int Comm int BoardNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value 0 Fail Non O0 Success Function int GroupMaskMovePercent int Comm int BoardNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value 0 Fail Non 0 Success Function int GroupMaskTimedMoveRaw int Comm int BoardNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a
64. long The array is filled with the null terminated string of the selected preset if the function returns successfully Return Value 0 Fail Non 0 Success Function int QuickLoadPreset int Comm int BoardNum int PresetSlot Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Specifies the preset to be loaded Return Value 0 Fail Non 0 Success Function int CrossfadePreset int Comm int BoardNum int PresetSlot float CrossfadeTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Specifies the preset to be loaded CrossfadeTime 0 23 9 Time in seconds the preset is to be cross faded from the current servo positions Return Value 0 Fail Non 0 Success Function int StoreCurrentAsPreset int Comm int BoardNum int PresetSlot Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Specifies which preset slot to save current settings Return Value 0 Fail Non 0 Success Function int InitializePreset int Comm int BoardNum int PresetSlot Parameters
65. m CO OD OD CAAAANAAANA NA fe D B l FA 52 User s Manual 3 If the ServoCenter41 Assembly is properly installed it will appear in the dialog box If not it can still be added by clicking the Browse button and browsing to the directory where it is stored Once the ServoCenter41 Assembly has been selected click the OK button to add it to your project 4 With the ServoCenter41Assembly now added to your project the contents of the assembly can be browsed through the Solution Explorer 4 4 ServoCenter 4 1 NET Assembly Methods The functions provided by the ServoCenter 4 1 NET Assembly correspond directly with the methods in the ServoCenter 4 1 DLL For detailed information please see section 3 1 of this document 53 User s Manual 5 Appendix 5 1 Hexadecimal Decimal Binary Conversion Chart Decimal Hex Binary 0 0 0000 l 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 2 7 OIII 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 5 2 Serial Cable Diagram The diagrams below illustrate the wire connections necessary for ServoCenter 4 1 compatible serial cables 9 Pin to 9 Pin Serial Connection 9 Pin 9 Pin Connector Connector Receive Data Se ES Transmit Data ek H Sig
66. m ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success 33 User s Manual Function int CompactMovePercentCW int Comm int BoardNum int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non O0 Success Function int CompactMovePercentCCW int Comm int BoardNum int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 100 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactTimedMoveRaw int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Boar
67. mber ID 0 15 of servo for which start position is being queried Return Value 1 Fail Start position of servo 0 16383 21 User s Manual Command GetSmoothingFactor ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which smoothing factor is being queried Return Value 1 Fail Smoothing factor 0 127 of the particular servo Command GetMaxSpeed ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which max speed is being queried Return Value 1 Fail Maximum speed of servo 1 200 in centi seconds 60 degrees Command GetPulseWidthMin As Integer Parameters None Return Value 1 Fail Minimum 1 239 width of servo control pulses Command GetPulseWidthMax As Integer Parameters None Return Value 1 Fail Maximum 1 239 width of servo control pulses Input Output Commands Command ReadAD8 ADNum As Integer As Integer Parameters ADNum 0 7 analog to digital input pin to read Return Value 1 Fail Voltage 0 255 that is present on analog to digital input pin Command ReadAD10 ADNum As Integer As Integer Parameters ADNum 0 7 analog to digital input pin to read Return Value 1 Fail Voltage 0 1023 that is present on analog to digital input pin Command ReadDIOPin
68. medMoveRaw int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMoveRawCW int Comm int BoardNum int ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMoveRawCCW int Comm int BoardNum mt ServoNum int ServoPos float ServoTime Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value 0 Fail Non 0 Success Function int TimedMoveScaled int Comm
69. mode for LED and LED2 Return Value 0 Fail Non 0 Success Function int SetWatchdogTime int Comm int BoardNum int WdTimeTenths Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent WdTimeTenths 0 239 Sets the internal watchdog time to the value specified by WdTimeTenths as measured in 1 10 second increments Return Value 0 Fail Non 0 Success Function void CommitSettings int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non 0 Success Function void LoadFactorySettings int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non 0 Success Function void ResetAsStartup int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 0 Fail Non 0 Success 46 User s Manual Function int DisplayVersion int Comm int BoardNum char VersionInfo Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached Ve
70. mp hCom amp dcb 0 open serial port printf tCould not initialize Comm Port n return 1 else while 1 printf n Enter Board Number 0 15 scanf Sd amp BoardNum printf n Enter Servo Number 0 15 scanf Sd amp ServoNum printf n Enter Position 0 16383 scanf Sd amp Position printf n tSending QuickMove Raw Command now n moveservo amp hCom BoardNum ServoNum Position printf n tDone n return 0 void moveservo HANDLE hCom int board int servo int position unsigned char buffer 6 create empty command packet User s Manual in DC unsigned long BytesWritted cecords of bytes sent Se oard 16 Oxf0 board id buffer 1 QuickMove Raw command buffer 2 SE servo used to identify which servo buffer 3 position 128 position MSB 7 bits buffer 4 position 128 position LSB 7 bits buffer 5 0 NULL character added to disable checksum WriteFile hCom 1 B dcb InitPort unsigned int PortNum buffer 5 amp BytesWritted NULL send packet kel B HANDL unsigned int BaudRate hCom BOOL fSuccess char pcCommPort 4 0 if PortNum 1 sprintf pcCommPort COM1 else if PortN
71. munications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot to read preset servo data ServoPos Expects a pointer to a 16 element array of floats The array is filled with the preset data after the function returns Detailed information about the preset data can be found in the ServoCenter 4 1 Protocol Manual under the Set Preset Servo Data command EncodingMask Expects a pointer to an integer to be filled with the preset servo position encoding mask Servo encoding is as follows 0 servo is binary scaled encoding 1 servo is percentage scaled encoding The most significant bit of EncodingMask b15 selects servo S15 while the least significant bit b0 selects SO All other bits represent their respective servo SkipFlags Expects a pointer to an integer to be filled with the skip flags of the specified preset Skip flag encoding is as follows 0 servo is not skipped 1 servo is skipped The most significant bit b15 represents servo S15 while the least significant bit b0 represents SO All other bits represent their respective servo Return Value 0 Fail Non 0 Success Function int SetPresetControlData int Comm int BoardNum int PresetSlot ControlData PresetData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter
72. nal Ground 5s EE S 9 Pin to 25 Pin Serial Connection 9 Pin 25 Pin Connector Connector Receive Data 2 2 Transmit Data 3 3 Signal Ground EE See 54 User s Manual 5 3 ServoCenter 4 1 Circuit Schematic SL SL D I I EL Le Zt LL DL 6 8 d 3 S D E Z L A z 6206 GSE OFL HA S woo DuUsaufu2IeO A AAA T B f Neb A Z99SP OIYO ynowsyod Joie puodas OC id oul Buueeuibuz eo t NIL ou 2 EENG A aul Duueeu fun 180A 6007 4007 ano e 5 5 mE SE z L 7 JOJUSQOAISS EECH bei HS oon E 43 alata CH Vs 6 E Sus E E ILOSIMO GEN 2 d E coe ame ls Wa Llnozy 8 cH va gnoi r 5 zl inoz wi or z 8 NaH lt br mnou Nu Fy g Ka Rad D A S 2 tO an Kee a F 19 REENEN ERAN EWEG ils Vad LLNIOd OXL 100Y l dd ZO E ZAd ZLNIOG ONIVOX le 6 S z m EFd ELNIOd INIY eoav e4d 8 G n T PAd PLNIOAMOSMOSN HOLPOV bsd T eho S3d SLNIOdWaSIG SWL S00Y S3d 5 4 SSA i 93d GLNIOd OO Tolga T gto lt L 19410 awoavdd gt g NI EN E OC Le i g 2 LOa O LN bs zd Se OOO OOO OOO COO COO COO COO CO Sd say ZAV K 10d lt a B FA FA l
73. ns Scaled position 0 100 to which servos will be moved Expects a 16 element array of doubles ServoSpeed Speed 0 100 at which servo will move Return Value None Command CompactGroupTimedMoveRaw ServoPositions As Integer ServoTime As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of doubles ServoTime Length of time 0 23 9 in seconds for servo to move Return Value None Command CompactGroupTimedMoveScaled ServoPositions As Integer ServoTime As Double Parameters ServoPositions Position 0 16383 to which servos will be moved Expects a 16 element array of doubles ServoTime Length of time 0 23 9 in seconds for servo to move Return Value None Command CompactGroupTimedMovePercent ServoPositions As Double ServoTime As Double Parameters ServoPositions Position 0 100 to which servos will be moved Expects a 16 element array of doubles ServoTime Length of time 0 23 9 in seconds for servo to move Return Value None 19 User s Manual Set Servo Settings Commands Command ServoEnable ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to be enabled Return Value None Command ServoDisable ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo to b
74. nt BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MoveScaledCW int Comm int BoardNum mt ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MoveScaledCCW int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MovePercent int Comm int BoardNum
75. nt Comm int BoardNum int PresetSlot float ServoPos int EncodingMask int SkipFlags Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot to set preset servo data ServoPos Scaled position of servos 0 16383 if binary scaled encoded 0 100 if percentage scaled encoded Expects a pointer to a 16 element array of floats Values out of range are ignored and servo positions are not updated This allows servo presets to be effectively masked and layered EncodingMask Bitmask used to determine encoding of servo data Servo encoding is as follows 0 servo is binary scaled encoding 1 servo is percentage scaled encoding The most significant bit of EncodingMask b15 selects servo S15 while the least significant bit b0 selects SO All other bits represent their respective servo SkipFlags Bitmask used to determine skip flags of the specified preset Skip flag encoding is as follows 0 servo is not skipped 1 servo is skipped The most significant bit b15 represents servo S15 while the least significant bit b0 represents SO All other bits represent their respective servo Return Value 0 Fail Non 0 Success Function int GetPresetServoData int Comm int BoardNum int PresetSlot float ServoPos int EncodingMask int SkipFlags Parameters Comm Com
76. nter 4 1 NET Assembly in Visual Basic 2008 52 4 4 ServoCenter 4 1 NET Assembly Methode 53 Ee secoss siaaa o iooi ras sso sas oes sEtr SoSo a sS Sai SOE o EEAS Eaei E ato 54 5 1 Hexadecimal Decimal Binary Conversion Chat tebegrkeegeg Sege 54 5 2 Seri l ER EE 54 5 3 ServoCenter LEE 55 User s Manual 1 Programming with Raw Serial UO The following section provides simple example programs in a variety of programming languages and environments Each example program illustrates how to access the serial port and directly communicate with the ServoCenter 4 1 controller board to control a servo Note that the programs are provided to illustrate simple raw serial communication using the ServoCenter 4 1 protocol and do not demonstrate the full feature set of the ServoCenter 4 1 controller Refer to the document Volume 2 Protocol Reference for a description of the entire ServoCenter 4 1 protocol and feature set 1 1 QBASIC Example Program DECLARE SUB initCOMPort port AS INTEGER baud as INTEGER DECLARE SUB MoveServoRaw BoardNum AS INTEGER ServoNum AS INTEGER _ Position AS INTEGER Speed AS INTEGER VKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 1x This demo program illustrates how to move servo motors X using raw serial communication access to the
77. o allow the programmer to communicate with the ServoCenter 4 1 board without having to worry about the communications protocol Below is an explanation of how to control the ServoCenter 4 1 using the ServoCenter 4 1 ActiveX Control 2 1 Operation with ServoCenter 4 1 ActiveX Control The ServoCenter 4 1 CD contains the ServoCenter 4 1 ActiveX Control The ServoCenter Control was designed to handle the details of raw serial communication with the ServoCenter 4 1 2 2 Installing the ServoCenter 4 1 ActiveX Control 1 Navigate to the Resources directory on the CD 2 Run the ServoCenter 4 1 ActiveX Installer To do this double click ServoCenter 4 1 ActiveX Control Setup exe to begin the installation process ie Setup ServoCenter 4 1 ActiveX Control Welcome to the ServoCenter 4 1 ActiveX Control Setup Wizard This will install ServoCenter 4 1 ActiveX Control v1 0 0 on your computer It is recommended that you close all other applications before continuing Click Next to continue or Cancel to exit Setup 3 Follow the onscreen instructions to complete the installation ie Setup Servocenter 4 1 Activex Control Ready to Install Setup is now ready to begin installing ServoCenter 4 1 ActiveX Control on your computer Click Install to continue with the installation or click Back if you want to review or change any settings Destination location C Program Files YEI ServoCenter 4 1 ActiveX Control Star
78. o dll in Visual C NET Programming with the yeisrvo dll runtime library in Visual C NET is very similar to programming in Visual C 6 0 The only real difference is the process by which the project settings are modified to use the yeisrvo lib import library For Visual C NET the default library directory is C Program Files Microsoft Visual Studio NET Vc7 1lib To add yeisrvo lib to the list of libraries to link right click on the name of the project in the Solutions Explorer then select Properties Select Linker from the Property Pages dialog that appears and then click Input Next add yeisrvo lib to the Additional Dependencies and click OK to apply the settings The illustration below shows a properly modified Properties Dialog ServoCenter3 1 Property Pages x Configuration Active Debug DI Platform Jactive win32 DI Configuration Manager Additional Dependencies yeisrvo lib Si Configuration Propertie a General Ignore All Default Libraries No Debugging Ignore Specific Library Gi C C Module Definition File Linker Add Module to Assembly General Embed Managed Resource File Input Force Symbol References Debug Delay Loaded DLLs System Optimization Embedded IDL Advanced Command Line C Resources 9 MIDL Browse Information 9 Build Events J Custom Build Step G web References Y Additional Dependencies Specifies additional items to add to the l
79. o move servo motors using raw serial communication access to the ServoCenter 4 1 controller board This program was written and compiled in the Turbo C environment Engineering TC Engineering com KKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Set following line to desired port defin defin e COMPORT e BAUDRAT T G Bi U void initcom uns void moveservo i COM1 9600 igned long FE AE CHE main int board servo pos clrscr printf PEIEE printf printf printf initco while T OH Ch m 1 1 printf scan prin scan prin scan prin CE tf BAUDRATI Enter f CSO Enter Servol f In Sdn Enter Position Sd amp pos tf Moving servo ServoCenter 4 1 Demonstration Program Engineering Engineering com c 2000 2010 www YoOs ID Board amp board D amp servo Yost Borland n n Tne t 0 15 n 0 15 n 0 16383 n oe NIE moveservo board servo pos speed printf Done n n Vtt ID Board Command ID for QuickMove Raw Servo Number Position MSB 7 bits Position LSB 7 bits Checksum of 0 is ignored void moveservo int BoardId int ServoNum int Position ou
80. o which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ADNum 0 7 analog to digital input pin to read Return Value 1 Fail Voltage 0 1023 that is present on analog to digital input pin Function int ReadDIOPinState int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 Digital I O pin to read Return Value 1 Fail Low 1 High Function int ReadDIOPinDirection int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 Digital I O pin direction to read Return Value 1 Fail 0 Pin is configured as an input 1 Pin is configured as an output Function int ReadDIOPinChangeFlag int Comm int BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent DIONum 0 15 Digital I O pin change flag to read Return Value 1 Fail 0 Pin has not changed 1 Pin has changed Function int ReadDIOPinStartStateDirection int Comm mt BoardNum int DIONum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attache
81. oNumber As Integer ServoSpeed As Integer Parameters ServoNumber ID 0 15 of servo for which Speed is being set ServoSpeed Maximum speed of servo 1 200 in centi seconds 60 degrees Return Value None Command SetMinCurrent ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo for which Min is being set Return Value None 20 User s Manual Command SetMaxCurrent ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo for which Max is being set Return Value None Command SetStartCurrent ServoNumber As Integer Parameters ServoNumber ID 0 15 of servo for which Start is being set Return Value None Command SetPulseWidthMin PulseWidthValue As Integer Parameters PulseWidthValue Minimum 1 239 width of servo control pulses Return Value None Command SetPulseWidthMax PulseWidthValue As Integer Parameters PulseWidthValue Maximum 1 239 width of servo control pulses Return Value None Get Servo Settings Commands Command GetServoEnableStatus ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which enable status is being queried Return Value 1 Fail 0 servo is disabled 1 servo is enabled Command GetServolnvertStatus ServoNumber As Integer As Integer Parameters Ser
82. ode to control the servos attached to your ServoCenter 4 1 To ensure the proper functionality of the YEIServoControl please note that the InitBoard method must be invoked before attempting to access the ServoCenter 4 1 board Once the InitBoard method has been executed the servos attached to the ServoCenter 4 1 board can be manipulated 12 User s Manual 2 4 ServoCenter 4 1 OCX Control Methods Public Properties BoardID Selects which ServoCenter board will receive commands BaudRate Data rate at which the com port will communicate with the board ComPort Selects the com port to which the ServoCenter is connected Port Functions Command InitBoard As Boolean Description None Return Value True Success False Failure Command GetAvailableComms As Integer Description Used to query the system for a list of available com ports Return Value Array of integers containing available com ports on the system Command CloseCom Description Used to the close com port previously opened with the InitBoard function Return Value None Command ShowControlPanel Description Displays the integrated ServoCenter 4 1 Control Panel The control panel can be used to configure and program the ServoCenter 4 1 board Return Value None Command HideControlPanel Description Hides the Se
83. ontrols the application of an internal pull up resistance for each channel Return Value 0 Fail Non 0 Success 43 User s Manual Function int GetPresetControlData int Comm int BoardNum int PresetSlot ControlData PresetData Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent PresetSlot 0 63 Selects which preset slot to read preset control data PresetData Expects a pointer to a structure consisting of four integers ServoEnabledFlags DIOSkipFlags DIODirections and DIOValues The struture is filled with the preset control data once the function has returned ServoEnabledFlags 16 bit value with each bit corresponding to the enabled state of a servo Thus b is servo Se enabled state bl is servo S1 s enabled state etc DIOSkipFlags 16 bit value with each bit corresponding to the skip state of a digital I O channel Thus bO is DIOO s skip state b1 is DIO1 s skip state etc When the skip state bit is high for a channel the state and direction for that digital I O channel is unmodified This allows digital I O presets to be effectively masked and layered D ODirections 16 bit value with each bit corresponding to the pin direction of a digital I O channel Thus b is DIOO s direction value b1 is DIO1 s direction value etc When the direction bit is 0 the direction
84. os Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated Return Value 0 Fail Non 0 Success Function int GroupMaskQuickMovePercent int Comm int BoardNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated Return Value 0 Fail Non 0 Success 41 User s Manual Function int GroupMaskMoveRaw int Comm int BoardNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers Values out of range are ignored and servo positions are not updated ServoSpeed Speed 0 100 at which servos will move Return Value 0 Fail Non 0 Success Funct
85. os Pointer which will be filled with the servo position 0 16383 once the function returns Return Value 0 Fail Non 0 Success Function int GetCurrentPositionScaled int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which position is being queried ServoPos Pointer which will be filled with the servo position 0 16383 once the function returns Return Value 0 Fail Non 0 Success Function float GetCurrentPositionPercent int Comm int BoardNum int ServoNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which position is being queried ServoPos Pointer which will be filled with the servo position 0 100 once the function returns Return Value 0 Fail Non 0 Success Function int GetMinPosition int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo for which Min is being queried ServoPos Pointer which will be filled with the servo position 0 16383 once the function returns Return Value
86. ot 0 63 Specifies which preset slot to save current settings Return Value None Command InitializePreset PresetSlot As Integer Parameters PresetSlot 0 63 Specifies which preset slot to initialize Return Value None Command ReadPresetEEPROM Page As Integer EEPROMData As Byte As Boolean Parameters Page 0 127 Specifies which preset EEPROM page to read EEPROMData A 32 element byte array The array is filled with the specified page if the function returns successfully Return Value False Fail True Success Command WritePresetEEPROM Page As Integer EEPROMData As Byte As Boolean Parameters Page 0 127 Specifies which preset EEPROM page to write EEPROMData A 32 element byte array filled with the contents to be written to the specified preset EEPROM page Return Value False Fail True Success 25 User s Manual Sequencer BASIC Interpreter Commands Command ReadSequencerEEPROM Page As Integer EEPROMData As Byte As Boolean Parameters Page 0 127 Specifies which sequencer EEPROM page to read EEPROMData A 32 element byte array The array is filled with the specified page if the function returns successfully Return Value False Fail True Success Command WriteSequencerEEPROM Page As Integer EEPROMData As Byte As Boolean Parameters Page 0 127 Specifies whic
87. rs Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int GroupMoveScaled int Comm int BoardNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 16383 to which servos will be moved Expects a pointer to a 16 element array of integers ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success 31 User s Manual Function int GroupMovePercent int Comm int BoardNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoPos Scaled position 0 100 to which servos will be moved Expects a pointer to a 16 element array of floats ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int GroupTimedMoveRaw int Comm int BoardNum int ServoPos float ServoTime Parameters
88. rsionInfo 64 element char buffer to hold version information BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value Length of VersionInfo string Function void CloseCom int Comm Parameters Comm Communications Port to be closed Return Value None Function void CloseAllComs Parameters None Return Value None Function void SetComTimeouts int Comm int ReadMultiplier int ReadConstant int WriteMultiplier int WriteConstant Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached ReadMultiplier The multiplier used to calculate the total time out period for read operations in milliseconds For each read operation this value is multiplied by the requested number of bytes to be read ReadConstant A constant used to calculate the total time out period for read operations in milliseconds For each read operation this value is added to the product of the ReadMultiplier and the requested number of bytes WriteMultiplier The multiplier used to calculate the total time out period for write operations in milliseconds For each write operation this value is multiplied by the requested number of bytes to be written WriteConstant A constant used to calculate the total time out period for read operations in milliseconds For each write operation this value is added to the product of the WriteMultiplier and the bytes to be writ
89. rvoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMoveScaledC W int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMoveScaledCCW int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Scaled position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int CompactMovePercent int Comm int BoardNum int ServoNum float ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNu
90. rvoCenter 4 1 Control Panel Return Value None Command QuickMoveRaw ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo whose position is to be changed ServoPosition Raw position 0 16383 to which servo will be moved Return Value None Command QuickMoveScaled ServoNumber As Integer ServoPosition As Integer Parameters ServoNumber ID 0 15 of servo whose position is to be changed ServoPosition Scaled position 0 16383 to which servo will be moved Return Value None Command QuickMovePercent ServoNumber As Integer ServoPosition As Double Parameters ServoNumber ID 0 15 of servo whose position is to be changed ServoPosition Scaled position 0 100 to which servo will be moved Return Value None Command MoveRaw ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None Command MoveRawCW ServoNumber As Integer ServoPosition As Integer ServoSpeed As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value None 13 User s Manual
91. s Manual Command TimedMoveScaled ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMoveScaledCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMoveScaledCCW ServoNumber As Integer ServoPosition As Integer ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 16383 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMovePercent ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to be moved ServoPosition Scaled position 0 100 to which servo will be moved ServoTime Length of time 0 239 99 in seconds for servo to move Return Value None Command TimedMovePercentC W ServoNumber As Integer ServoPosition As Double ServoTime As Double Parameters ServoNumber ID 0 15 of servo to
92. sembly The ServoCenter Control was designed to handle the details of raw serial communication with the ServoCenter 4 1 4 2 Installing the ServoCenter 4 1 NET Assembly Navigate to the Resources directory on the CD 1 Run the ServoCenter 4 1 NET Assembly Installer To do this double click ServoCenter 4 1 NET Assembly Setup exe to begin the installation process 2 Follow the onscreen instructions to complete the installation 3 The control is now installed and ready for use 4 3 Using the ServoCenter 4 1 NET Assembly in Visual Basic 2008 1 Open a new project in the Visual Basic 2008 editor 29 2 Add the ServoCenter41Assembly to your project To do this click the Project menu at the top of the editor and then select Add Reference The menu will appear Add Reference NET COM Projects Browse Recent Component Name ServoCenter41Assembly 1 0 3765 v2 0 50727 SQL Server Secure String Package 10 0 0 0 v2 0 50727 7 0 3300 0 vi 0 3705 2 0 0 0 v2 0 50727 2 0 0 0 v2 0 50727 System Addin 3 5 0 0 v2 0 50727 System AddIn Contract 2 0 0 0 v2 0 50727 System ComponentModel DataAnnotations 3 5 0 0 v2 0 50727 System Configuration 2 0 0 0 v2 0 50727 System Configuration Install 2 0 0 0 v2 0 50727 System Core 3 5 0 0 v2 0 50727 System Data 2 0 0 0 v2 0 50727 System Data DataSetExtensions 3 5 0 0 v2 0 50727 System Data Entity 3 5 0 0 v2 0 50727 System Data Entity Design 3 5 0 0 v2 0 50727 is Ji
93. ss Function int GetSequencerStartupMode int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 1 Fail 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 Function int GetSequencerStatus int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 1 Fail 0 Sequencer Idle Stopped 1 Sequencer Running 2 Sequencer Error Stopped Function int GetSequencerLastError int Comm int BoardNum Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Return Value 1 Fail Non negative The sequencer error byte value General Commands Function int SetLEDMode int Comm int BoardNum int Mode Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent Mode 0 7 specifies the LED display
94. t 00d g g lt a lod Ka d L d LO ziy Ma dd gt 8 bod L 90d g 90d 5 2m Lod E 23 O8d BLNIOd SS EEGEN SECH lt OSI o BS o S8d ELLNIOANL30 K 98d pLLNIOd 8100 18a 1LNIOdvZ9O Ea ova oa Wd z9 ad lt fd ya aaasn tyd Co H Syd a a t gvd waasn a iid e LNOEAE OOO COO OOO OOO OOO O00 O00 COO S 3 sa toa cold cod rol cod 9010 Zold Ei S al ES 2 3 Si w S S 4 2 2 2 A i 3 a Ed E Lin lt E kel H D R YLOOSSLLELGT 4 g a 2 e edr EISEN Bo a 9 D Ze YOLOANNOOYAMOd SIS PLS els cls WS OLS 6S co Se EENS Md LXS 55
95. t CompactQuickMoveRaw int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Raw position 0 16383 to which servo will be moved Return Value 0 Fail Non 0 Success Function int CompactQuickMoveScaled int Comm int BoardNum int ServoNum int ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Scaled position 0 16383 to which servo will be moved Return Value 0 Fail Non 0 Success Function int CompactQuickMovePercent int Comm int BoardNum int ServoNum float ServoPos Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo whose position is to be changed ServoPos Scaled position 0 100 to which servo will be moved Return Value 0 Fail Non 0 Success 32 User s Manual Function int CompactMoveRaw int Comm int BoardNum int ServoNum int ServoPos float ServoSpe
96. t Menu folder Yost Engineering Inc ServoCenter 4 1 ActiveX Control 4 The control is now installed and ready for use 11 User s Manual 2 3 Using the ServoControl in Visual Basic 6 0 1 Open a new project in the Visual Basic 6 0 editor 2 Add the YEIServoControl to your project To do this click the Project menu at the top of the editor and then select Components The Components menu will appear Components Controls Designers insertable Objects VB 6 MSChart Wizard VCWiz 9 0 Type Library VIActiveXForm Library VIDTC1 1 0 Type Library VIDTC2 1 0 Type Library vidtc3 VisModelBrowser Visual FoxPro HWND Control Visual FoxPro TypeLib Info Control webvw 1 0 Type Library Windows Media Player Pret servocerter A 1AcweX Conta LG Bees Browse lt Di EI Selected Items Only YEI ServoCenter 4 1 ActiveX Control Location C YEI ServoC YEIServoControl ocx If the YEIServoControl is properly installed it will appear in the dialog box If not it can still be added by clicking the Browse button and browsing to the directory where it is stored Once the YEIServoControl has been selected click the OK button to add it to your project 3 With the YEIServoControl now added to your project select it from the toolbox and draw it on the form This completes the process of preparing the project for ServoCenter 4 1 use You may now begin writing c
97. ten Return Value 0 Success Non 0 Fail 3 2 Installing the yeisrvo dll Runtime Library For your programs to be able to use the ServoCenter 4 1 DLL the DLL must first be placed somewhere that your running program will be able to find it The best location for your DLL is in the same directory as your running program For example if your program is found in C ServoCenter program copy the ServoCenter 4 1 DLL to that directory Another location where you can store the ServoCenter 4 1 DLL is the folder where Windows stores the system wide runtime libraries In Windows 95 and 98 this folder is C WINDOWS system In Windows ME 2000 and XP the folder is C WINDOWS system32 Once the ServoCenter 4 1 DLL has been copied to one of these directories you are ready to begin writing programs that use it 3 3 Programming with yeisrvo dll in Visual Basic 6 0 To use the functions provided by yeisrvo dll from a Visual Basic program you must first provide the Visual Basic environment with a way to know where to find these functions and how to treat them To do this the following form is used Public Declare Function InitPort Lib yeisrvo dll ByVal PortNum As Long ByVal Baud As Long _ As Integer This code snippet declares a public function named InitPort that is located in the yeisrvo dll runtime library The InitPort function receives two long integers as arguments and returns
98. tportb COMPORT 0xf0 BoardId 16 while inportb COMPORT 5 amp 0x20 0 outportb COMPORT 0x00 while inportb COMPORT 5 amp 0x20 0 outporthb COMPORT ServoNum 16 while inportb COMPORT 5 amp 0x20 0 outportb COMPORT Position 128 while inportb COMPORT 5 amp 0x20 0 outportb COMPORT Speed 128 while inportb COMPORT 5 amp 0x20 0 outportb COMPORT 0 1 while inportb COMPORT 5 amp 0x20 0 User s Manual void initcom unsigned long BaudRate outportb COMPORT 3 0x83 DLAB high set format 8N1 switch BaudRate case 9600 outportb COMPORT 0x0c set rate LSB outporth COMPORT 1 0x00 set rate MSB break case 38400 outportb COMPORT 0x03 set rate LSB outporth COMPORT 1 0x00 set rate MSB break case 57600 outportb COMPORT 0x02 set rate LSB outporth COMPORT 1 0x00 set rate MSB break case 115200 outportb COMPORT 0x01 set rate LSB outporth COMPORT 1 0x00 set rate MSB break default use 9600 as default baud rate outporth COMPORT 0x0c set rate LSB outporth COMPORT 1 0x00 set rate MSB break outportb COMPORT 3 0x03 DLAB now low outportb COMPORT 1 0x00 Interrupts off 1 5 Visual Basic 6 Sample Program For the purpose of this sample a simple V
99. um 2 sprintf pcCommPort COM2 else if PortNum 3 sprintf pcCommPort COM3 else if PortNum 4 sprintf pcCommPort COM4 else printf tPort Number not recognized n hCom CreateFile pcCommPort GENERIC_READ GENERIC_WRITE 0 must be opened with exclusive access NULL no security attributes OPEN_EXISTING must use OPEN_EXISTING 0 not overlapped I O NULL hTemplate must be NULL for comm i if hCom INVALID _HANDLE VALUE Handle the error printf tCreateFile failed with error d n GetLastError return 2 Build on the current configuration and skip setting the size of the input fSuccess if Success GetCommState hCom and output buffers with SetupComm dcb Handle the error printf tGetCommState failed with error d n GetLastError return 3 Fill in DCB Baudrate 8 data bits no parity 1 stop bit switch BaudRate case 9600 dcb gt BaudRate CBR_9600 break case 38400 dcb gt BaudRate CBR_38400 break case 57600 dcb gt BaudRate CBR_57600 break case 115200 dcb gt BaudRate CBR_115200 break default printf tBaud Rate not recognized n printf dcb gt Baudl tUsing default rate of 9600bps n Rate CBR_9600 break User s Manual dcb gt ByteSize 8 data size xmit and rcv dcb gt Parity NOPARITY
100. urn Value 0 Fail Non 0 Success Function int MoveRaw int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Position 0 16383 to which servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MoveRawCW int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success 28 User s Manual Function int MoveRawCCW int Comm int BoardNum int ServoNum int ServoPos float ServoSpeed Parameters Comm Communications Port to which ServoCenter 4 1 controller is attached BoardNum ID 0 15 of ServoCenter 4 1 Board to which the command will be sent ServoNum ID 0 15 of servo to be moved ServoPos Units 0 16383 servo will be moved ServoSpeed Speed 0 100 at which servo will move Return Value 0 Fail Non 0 Success Function int MoveScaled int Comm i
101. voNumber ID 0 15 of servo for which invert status is being queried Return Value 1 Fail 0 servo is non inverted 1 servo is inverted Command GetServoDisabledState ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which disable state is being queried Return Value 1 Fail 0 servo disable state is low 1 servo disable state is high Command GetCurrentPositionRaw ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which position is being queried Return Value 1 Fail Current position of servo 0 16383 Command GetCurrentPositionScaled ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which position is being queried Return Value 1 Fail Current position of servo 0 16383 Command GetCurrentPositionPercent ServoNumber As Integer As Double Parameters ServoNumber ID 0 15 of servo for which position is being queried Return Value 1 Fail Current position of servo 0 100 Command GetMinPosition ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which Min is being queried Return Value 1 Fail Minimum position of servo 0 16383 Command GetMaxPosition ServoNumber As Integer As Integer Parameters ServoNumber ID 0 15 of servo for which Max is being queried Return Value 1 Fail Maximum position of servo 0 16383 Command GetStartPosition ServoNumber As Integer As Integer Parameters ServoNu

Download Pdf Manuals

image

Related Search

Related Contents

UHF Synthesized Transmitter  Page 1 Page 2 この肥料はリン酸2アンモンを主成分と し、 ` 用目巴料  IQ Analyzer  PDST24/PDST32 GASOLINE SNOW THROWER  Lenovo IdeaPad Y500  SIMATIC NET - Services  Telecamere PTZ dome 10x TVT77DI - TVT77DE  FLEXIVOZ PABX OD308  Kensington S7062046B document holder  Mode d`emploi  

Copyright © All rights reserved.
Failed to retrieve file