0% found this document useful (0 votes)
8 views2 pages

SCAP10

This document provides a QBASIC example program for communicating with the ServoCenter 3.1 controller board to control servos via serial port. It includes sample code demonstrating how to initialize the COM port and send commands to move the servo. Additional resources and the complete protocol can be found in the ServoCenter 3.1 manual and on the Yost Engineering website.

Uploaded by

Alhassan Omran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

SCAP10

This document provides a QBASIC example program for communicating with the ServoCenter 3.1 controller board to control servos via serial port. It includes sample code demonstrating how to initialize the COM port and send commands to move the servo. Additional resources and the complete protocol can be found in the ServoCenter 3.1 manual and on the Yost Engineering website.

Uploaded by

Alhassan Omran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ServoCenter3.

1 Direct Serial I/O Examples - QBASIC


1. Overview

This document provides a simple QBASIC example program illustrating how to access the serial port and
directly communicate with the ServoCenter 3.1 controller board to control a servo. Note that the program
is provided to illustrate simple raw serial communication using the ServoCenter 3.1 protocol and does not
demonstrate the full feature set of the ServoCenter 3.1 controller. Refer to section 4.1 of the ServoCenter
3.1 manual for a description of the entire ServoCenter 3.1 protocol and feature set.

2. Sample Code

DECLARE SUB initCOMPort (port AS INTEGER,baud as INTEGER)


DECLARE SUB MoveServoRaw (BoardNum AS INTEGER, ServoNum AS INTEGER,_
Position AS INTEGER, Speed AS INTEGER)
'*************************************************************
'* This demo program illustrates how to move servo motors *
'* using raw serial communication access to the *
'* Yost Engineering, Inc. ServoCenter 3.1 controller board. *
'* *
'* (c) 2001-2004 Yost Engineering, Inc. *
'* [Link] *
'* *
'*************************************************************

DIM svBoardnum AS INTEGER


DIM svServonum AS INTEGER
DIM svPosition AS INTEGER
DIM svSpeed AS INTEGER

CLS
COLOR 15, 1
PRINT " "
PRINT " ServoCenter 3.1 Demonstration Program "
PRINT " (c)2000-2004 Yost Engineering, Inc. "
PRINT " [Link] "
PRINT " "

COLOR 7, 0

PRINT ""
'initialize the serial port com1 to 9600
CALL initCOMPort(1,9600)

DO WHILE 1 = 1
INPUT " Enter a board number (0-15): ", svBoardnum
INPUT " Enter a servo number (0-15): ", svServonum
INPUT " Enter a position value (0-200): ", svPosition
INPUT " Enter a seek speed value (1-100): ", svSpeed

©2004 Yost Engineering, Inc. 1/2


COLOR 4, 0
PRINT " Sending Servo Command now... "
CALL MoveServoRaw(svBoardnum, svServonum, svPosition, _
svSpeed)
COLOR 2, 0
PRINT " Done!": PRINT
COLOR 7, 0
LOOP

SUB initCOMPort (port AS INTEGER, baud as INTEGER)


settings$ = "COM"+LTRIM$(STR$(port))+":"+LTRIM$(STR$(baud))+_
",N,8,1,CD0,CS0,DS0"
OPEN settings$ FOR RANDOM AS #1
END SUB

SUB MoveServoRaw (BoardNum AS INTEGER, ServoNum AS INTEGER, _


Position AS INTEGER, Speed AS INTEGER)
PRINT #1, CHR$(&HF0 + BoardNum MOD 16); CHR$(16);
PRINT #1, CHR$(ServoNum MOD 16);
PRINT #1, CHR$(Position MOD 201); CHR$(Speed MOD 101);
PRINT #1, CHR$(0);
END SUB

3. Additional Information
This code is available in the [Link] file in the Examples directory of the ServoCenter3.1 CD or
online at [Link]/ServoCenter.

©2004 Yost Engineering, Inc. 2/2

You might also like