Page 104 - The Definitive Guide to Building Java Robots
P. 104
Preston_5564C03.fm Page 85 Wednesday, October 5, 2005 7:21 AM
CHAPTER 3 ■ MOTION 85
// sets pulsewidth as function of byte size
pulsewidth = 750 + (int) pwfactor;
return pulsewidth;
}
// same program
public static void main(String[] args) {
try {
// get single serial port instance
JSerialPort sPort = (JSerialPort) SingleSerialPort.getInstance(1);
// create new LM32
LM32 lm32 = new LM32(sPort);
// sets position for servo at pin 0
lm32.sscCmd(0, 100);
// sets position for servo at pin 1
lm32.sscCmd(1, 200);
// tells the servos to move there in 1 second.
lm32.move(1000);
// close serial port
sPort.close();
} catch (Exception e) {
// print stack trace and exit
e.printStackTrace();
System.exit(1);
}
}
}
Group Move with the MiniSSC-II
This will be more difficult on the MiniSSC-II because we have to control two sets of timing. The
first timing will be the move from servo position A to servo position B. The second timing is the
step size as limited by 9600 baud. This means that our servo step size for each of our servos is
dependent on the number of servos we have hooked up. Since each command is about 3 milli-
seconds if you have two servos it will take about 6 milliseconds, 9 milliseconds for three servos,
and so on.
To make this work, we will have to create a way to process these commands separately for
each step, for each servo, and for each time interval.
Code Objectives
Our objective here is to duplicate in a MiniSSC-II what is already done for us in the LM32.