Problems with BS2, Microcontrollers, Servos, and programming.
Ian Tai
Posts: 3
Hi, my name is Ian Tai and I am part of Project Lead The Way (engineering program) at my high school. We are working on our senior project and we are using the Basic Stamp BS2 Board of Education, the Serial 8-servo Controller, and 5 Power HD Micro Servos. Our problem is described as follows.
Our project's Problem Statement: It is inconvenient to turn a page of sheet music while playing an instrument.
Basically we are designing something that turns the pages for you on a music stand. So our solution is a device that attaches to the music stand that has 5 pins. These 5 pins each attach to one sheet of music (at the top of each sheet), and turn one at a time from right to left, 180 degrees. Each pin has one servo motor. Thus we need to write a program that turns each motor one at a time controlled with a swtich.
A basic idea we were thinking of is:
Switch pressed one time,
Motor 1 turns 180 degrees and stops.
Switch pressed two times,
Motor 2 turns 180 degrees and stops.
etc....until
Motor 5 turns 180 degrees and stops.
And after all this, when the motor is pressed 6 times, it resets all motors to turn back to their original position, essentially -180 degrees.
That is our basic idea of what our program should be. However, we cannot even get a micro servo to turn.
What are we doing wrong?
Our setup is as follows:
We have a USB cable from the computer to the Board of Education and BS2. We have power to the Basic Stamp.
From the Basic Stamp we have a three wire cable running from pulsout 12 to the input and output of the Serial Servo Controller. (http://www.pololu.com/catalog/product/727)
On the Servo Controller we have one motor (http://www.pololu.com/catalog/product/1041) at this time, we're just testing one motor first. The motor is coming out from the serout number 0. We have power running to the Servo Controller at two spots. One to the servo power inputs and another to the VIN and GND of the actual controller.
We were sent a demo program previously (below) We ran it, but we saw no movement at all.
' {$STAMP BS2}
' {$PBASIC 2.5}
sdat PIN 12
baud CON 396
buff VAR Byte(3)
FindPSC:
DEBUG "Finding PSC",CR
SEROUT sdat,baud+$8000,[noparse][[/noparse]"!SCVER?",CR]
SERIN sdat, baud,500,FindPSC,[noparse][[/noparse]STR buff\3]
DEBUG "PSC ver: ", buff(0),buff(1),buff(2),CR
END
Long Story Short, we can't get any movement in the motor. What do we need to do to get movement in the Micro Servo?
Thanks.
Our project's Problem Statement: It is inconvenient to turn a page of sheet music while playing an instrument.
Basically we are designing something that turns the pages for you on a music stand. So our solution is a device that attaches to the music stand that has 5 pins. These 5 pins each attach to one sheet of music (at the top of each sheet), and turn one at a time from right to left, 180 degrees. Each pin has one servo motor. Thus we need to write a program that turns each motor one at a time controlled with a swtich.
A basic idea we were thinking of is:
Switch pressed one time,
Motor 1 turns 180 degrees and stops.
Switch pressed two times,
Motor 2 turns 180 degrees and stops.
etc....until
Motor 5 turns 180 degrees and stops.
And after all this, when the motor is pressed 6 times, it resets all motors to turn back to their original position, essentially -180 degrees.
That is our basic idea of what our program should be. However, we cannot even get a micro servo to turn.
What are we doing wrong?
Our setup is as follows:
We have a USB cable from the computer to the Board of Education and BS2. We have power to the Basic Stamp.
From the Basic Stamp we have a three wire cable running from pulsout 12 to the input and output of the Serial Servo Controller. (http://www.pololu.com/catalog/product/727)
On the Servo Controller we have one motor (http://www.pololu.com/catalog/product/1041) at this time, we're just testing one motor first. The motor is coming out from the serout number 0. We have power running to the Servo Controller at two spots. One to the servo power inputs and another to the VIN and GND of the actual controller.
We were sent a demo program previously (below) We ran it, but we saw no movement at all.
' {$STAMP BS2}
' {$PBASIC 2.5}
sdat PIN 12
baud CON 396
buff VAR Byte(3)
FindPSC:
DEBUG "Finding PSC",CR
SEROUT sdat,baud+$8000,[noparse][[/noparse]"!SCVER?",CR]
SERIN sdat, baud,500,FindPSC,[noparse][[/noparse]STR buff\3]
DEBUG "PSC ver: ", buff(0),buff(1),buff(2),CR
END
Long Story Short, we can't get any movement in the motor. What do we need to do to get movement in the Micro Servo?
Thanks.
Comments
Have you seen this page? http://www.pololu.com/file/0J41/stamp.pdf
It appears that your baud is off. You probably want to use the constant 84, instead of two different values.
Do not connect the logic level serial output connection to the same I/O pin as the logic level serial input. This can damage the servo controller. You can leave the logic level serial output connected unconnected or connect it to a different Stamp I/O pin.
Follow the example shown in the link that SRLM provided.
The problem might be the set up, so I am going to as specifically as I can describe how we have this set up.
Basic Stamp
1. USB cable from computer output to Basic Stamp USB input. This allows communication between our PBASIC program and the Basic Stamp.
2. 9-volt battery powering the Basic Stamp.
ServoController
1. 6-volt battery pack powering the servo motors, with + and - correctly aligned.
2 Servo motor output 0 going to a micro servo.
3. Three-wire cable from Basic Stamp output 12 to 3 pins on servo controller: Black going into reset, middle wire (red) going into logic-level serial output, and orange wire going into logic level serial input.
4. 6-volt battery pack powering the controller: black into neg and red into positive.
When the basic stamp is off, all three LEDs on the servo controller are lit. When the Basic Stamp is turned to the 2 position, no LEDs on the servo controller come on.
We then used the sample program from the Pololu site - serout 15,84,[noparse][[/noparse]$80,$01,$01,0,1] - and nothing happens. Nothing. No LEDs, no servo movement, nothing.
Do we have a set up problem? Or are we just floating down the river with a waterfall in sight waiting for the inevitable?
thanks.
Ian
Also, make sure that your jumper is in the right position for the mode that you're using, Pololu mode.
We have already talked to a technician named Josh over the phone. And to make things easier we are going to post our program on the forum.
Here is the current program we have. Please let us know if there is anything wrong with this. Our basic idea is we have four motors and one switch. When we press the switch once, we want motor 1 to turn, when we press the switch twice, we want motor 2 to turn, etc. up to motor 4.
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
counter = 0
INPUT 4
IN4 = 0
Checking:
IF counter = 1 AND IN4= 1 THEN
GOSUB add
GOSUB turn1
ENDIF
IF counter = 2 AND IN4= 1 THEN
GOSUB add
GOSUB turn2
ENDIF
IF counter = 3 AND IN4= 1 THEN
GOSUB add
GOSUB turn3
ENDIF
IF counter = 4 AND IN4= 1 THEN
GOSUB add
GOSUB turn4
ENDIF
add:
counter = counter + 1
RETURN
turn1:
PULSOUT 12, 500
PAUSE 20
GOTO Checking
turn2:
PULSOUT 13, 500
PAUSE 20
GOTO Checking
turn3:
PULSOUT 14, 500
PAUSE 20
GOTO Checking
turn4:
PULSOUT 15, 500
PAUSE 20
GOTO Checking