Basic Stamp 2sx programming
Ben Grispen
Posts: 7
Hello
Me and a friend are programming a robot with soms QTI sensors, 2 colorPAL's and a ping))) sensor, we need to follow a line and turn on a green mark.
We first used the Basic Stamp 2 but it was to slow. The robot wasn't riding smooth and stopped after a 2 seconds, so we bought a BS2SX, it is 2.5 times faster.
Now we changed our program to the specs of the BS2SX and uploaded it. The program still runs 2 seconds and 1 of the 2 colorPAL's doesn't work.
The BS2SX is also getting very hot, I don't think this is normal.
For programming we use subroutines for distance, colordetection and soms other functions, the main program is the linefollower. In the linefollower we call the subs.
Does somebody have any ideas what can be wrong of why it gets hot?
Thanks!
Me and a friend are programming a robot with soms QTI sensors, 2 colorPAL's and a ping))) sensor, we need to follow a line and turn on a green mark.
We first used the Basic Stamp 2 but it was to slow. The robot wasn't riding smooth and stopped after a 2 seconds, so we bought a BS2SX, it is 2.5 times faster.
Now we changed our program to the specs of the BS2SX and uploaded it. The program still runs 2 seconds and 1 of the 2 colorPAL's doesn't work.
The BS2SX is also getting very hot, I don't think this is normal.
For programming we use subroutines for distance, colordetection and soms other functions, the main program is the linefollower. In the linefollower we call the subs.
Does somebody have any ideas what can be wrong of why it gets hot?
Thanks!
Comments
This is something we tryed, this is also the first time we programmed, so the program can be a mess and the comments in the program are is dutch (sorry for this, we are from Belgium)
This is the program: programma.txt
I can see some of the code comes from the Ping and ColorPAL sample programs as well as the Learn QTI projects.
All of the servo commands are backwards because if you look at all the Boe-Bot programs you will see that the Servo on Pin 13 is always first.
None of the times were adjusted since the BS2SX is 2-1/2 times faster than the BS2.
There was a DO...LOOP inside of one of the subroutines.
Another subroutine had a GOTO inside it which can cause the BS2 to crash. You never want to use a subroutine and not return from it.
If you can explain what your program does or what it needs to do then we can help you with it.
[code]
' {$STAMP BS2}
' {$PBASIC 2.5}
'===== Variabelen & constanten ========================================================================================
' Variables & constants (Dutch)
constante CON 2260 ' Ping))) Constant (Echo time -> cm with **)
' Conversion constant for room temperature measurements.
' At sea level sound travels through air at 1130 feet per second.
' This equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS.
' 1 / 29.034 = 0.0344423779 (with **)
' 0.0344423779 * 65.536 = 2257.21567817 -> 2257
' The Ping))) returns a pulse width of 73.746 us per inch.
' The Ping))) returns a pulse width of 29.033 us per cm.
PingTrigger CON 5 * 2.5 ' Ping))) trigger pulse = 10 uS (Added - 12.5 for BS2SX)
ServoCW CON 650 * 2.5 ' Pulse Width for Full-Speed Clockwise (Added - 1625 for BS2SX)
ServoLeft CON 700 * 2.5 ' Pulse Width to Curve Left (Added - 1750 for BS2SX)
ServoStop CON 750 * 2.5 ' Pulse Width for Full-Stop (Added - 1875 for BS2SX)
ServoRight CON 800 * 2.5 ' Pulse Width to Curve Right (Added - 2000 for BS2SX)
ServoCCW CON 850 * 2.5 ' Pulse Width for Full-Speed Counter-Clockwise (Added - 2125 for BS2SX)
PulseDodge CON 16 ' Number of 20 ms Servo Pulses Needed to Dodge (Added)
PulseDetect CON 30 ' Number of 20 ms Servo Pulses Needed for Detecting (Added)
PulseSearch CON 100 ' Number of 20 ms Servo Pulses Needed for Searching (Added)
' 122 ~ 3 sec, 61 ~ 1.5 sec, 244 ~ 6 sec, 407 ~ 10 sec, 41 ~ 1 sec
Pulse90 CON 48 ' Number of 20 ms Servo Pulses Needed for a 90-degree Turn (Added - 24)
a VAR Bit 'variabele a voor linker kleurensensor (Variable a for left color sensor)
b VAR Bit 'variabele b voor rechter kleurensensor (Variable b for right color sensor)
afstand VAR Word 'De afstand tot een object (Distance - The distance to an object)
tijd VAR Word ' (time - Ping Pulse Time)
roodL VAR Word ' (redL - Left ColorPAL)
groenL VAR Word ' (greenL - Left ColorPAL)
blauwL VAR Word ' (blueL - Left ColorPAL)
kleurL VAR Word ' (colorL - Left ColorPAL)
roodR VAR Word ' (redR - Right ColorPAL)
groenR VAR Word ' (greenR - Right ColorPAL)
blauwR VAR Word ' (blueR - Right ColorPAL)
kleurR VAR Word ' (colorR - Right ColorPAL)
teller VAR Word ' (counter - Number of Servo Pulses)
' I/O Pin Declarations
Ping PIN 9 ' Ping))) Ultrasonic Sensor (Added)
ServoRight PIN 12 ' Right Servo (Added)
ServoLeft PIN 13 ' Left Servo (Added)
sio1 PIN 14 'Seri
We don't have shorts, we checked and double checked it! the BS2 isn't getting hot. The BS2SX draws +- 0.136 Amps, and yes we use the 5volts! The regulator is also getting hot! we use 9V batteries but they are in no time empty (10minutes)
Or worse, are you running your servos off of the board's regulated 5V? Ack!
Maybe this code does what you want to do;
(%nnnn notation does not display correctly, I used %%nnnn)
Nonetheless, you may have blown your regulator in those 30 minutes. Each servo can draw over an amp, and that regulator may be toast. If it worked then but it doesn't now, you may have answered your own question. Unplug your servos from the board entirely and run your Stamp alone for a while on the 9V. First see if it works, then see if the reg still overheats.
If you're a lucky fellow, both your Stamp & reg survived and all you have to do is add a separate battery for your servos. But if you killed your board's 5V regulator, you'll also have to add a separate 5V regulator, connection that to Vdd and not using Vin. Never feed anything but 5.000000V to Vin or you can kiss your $50 BS2 goodbye.
I think you mean Vdd, not Vin. Vdd can safely be between 4.5v and 5.5v.
Thank you, Sapphire, I maid another missteak.
Yes, you're correct, Vdd is what I meant. It's the sensitive one which dearly loves 5 volts.
Yes (and that's different from the Stamps' on-board 5V.) The two are kept separated on the BoE, that servo 5V comes from a regulator located on the BoE.