Pulsout problem.
cododd777
Posts: 8
I'm using a BASIC stamp BS2 to take PWM input from a 2-channel RC receiver, modify the signal values, and output the modified signals to a DC motor controller. The program is running perfectly, it takes in the values via PULSIN and transforms them to what they should be, (the output pulse widths are exactly what they need to be on the DEBUG window.) The problem is that there is no pulse at the pin. I have tried PULSOUT on all the pins, including the servo pins. No dice. The pin will output steady 5V fine, but not a pulse, (at least by my PULSOUT command.) I've used BASIC stamps before, but not for a few years now. Has PBASIC changed in functionality since I last used it? Or is the problem something obvious and I'm just rusty? Here is the program I'm using.
' {$STAMP BS2}
' {$PBASIC 2.5}
ch1 VAR Word
ch2 VAR Word
chA VAR Word
diffX VAR Word
diffY VAR Word
diffXA VAR Word
diffYA VAR Word
INPUT 0
INPUT 1
DO
PULSIN 0, 1, ch1
PULSIN 1, 1, ch2
ch1=770
diffX=770-ch2
diffY=770-ch1
diffXA=ABS(diffX)
diffYA=ABS(diffY)
IF diffXA >= (diffYA/2) THEN
IF ch2 > 770 THEN
chA = 770+(diffYA/4)
ELSEIF ch2 <= 770 THEN
chA = 770-(diffYA/4)
ENDIF
ELSE
chA=ch2
ENDIF
PULSOUT 5, ch1
PULSOUT 4, chA
DEBUG ? ch1
DEBUG ? chA
LOOP
(Keep in mind, the program is working fine, it takes the correct values in and the output pulse lengths are correct, there is just no pulse coming out. )
' {$STAMP BS2}
' {$PBASIC 2.5}
ch1 VAR Word
ch2 VAR Word
chA VAR Word
diffX VAR Word
diffY VAR Word
diffXA VAR Word
diffYA VAR Word
INPUT 0
INPUT 1
DO
PULSIN 0, 1, ch1
PULSIN 1, 1, ch2
ch1=770
diffX=770-ch2
diffY=770-ch1
diffXA=ABS(diffX)
diffYA=ABS(diffY)
IF diffXA >= (diffYA/2) THEN
IF ch2 > 770 THEN
chA = 770+(diffYA/4)
ELSEIF ch2 <= 770 THEN
chA = 770-(diffYA/4)
ENDIF
ELSE
chA=ch2
ENDIF
PULSOUT 5, ch1
PULSOUT 4, chA
DEBUG ? ch1
DEBUG ? chA
LOOP
(Keep in mind, the program is working fine, it takes the correct values in and the output pulse lengths are correct, there is just no pulse coming out. )
Comments
Have you made sure that I/O pins 4 & 5 are working???(and not burnt-out)
'
I don't see any DEBUG commands for a DEBUG window?
'
Posting a fragment of the code you think is faulty doesn't help either!
'
Keep in mind that you know what the correct values are, But no one else on the forums knows what these values are because you didn't post them.
'
A little more info would help your post!
I tried every pin on the board (Making sure to switch the PULSOUT pin each time.) And each pin will output a steady 5V fine in testing, just no pulse.
The pulse width values it is intended to output are between 500-900 for both channels. The is no one correct answer because it is taking a PWM signal from a remote control joystick channel. The input signals are also in the 500-900 range.
Can you describe exactly how you are testing if the PULSOUT is working?
Rich H
Thanks for the edit! I'm still a little rusty with PBASIC 2.5!
BTW, are you using a BoE or a HW board or a board you made?
a:for b0=500 to 1000
pulsout 0,b0' servo to pin P0
pause 20
next
goto a
b:high 0' high pin P0
pause 1' pause 1 ms
low 0' low pin P0
pause 20' typ servo delay between pulses
goto b' repeat
That will give you a stream of pulsouts 600-ish or so with processor overhead. That should let you test servos and your controller.
Did you have the grounds of the two BS2s connected?
Rich H
1. The power switch has three positions, it must be slid all the way over to send power to the servo headers.
2. There is a jumper for choosing where the servo power comes from. If it is missing then the servo would not get power.
Rich H
Now run this program:
' {$STAMP BS2}
' {$PBASIC 2.5}
a: toggle 0: pause 500:goto a
Does it flash? Will it blend? Of course you can use any pin, as long as the code matches the pin.
Is this a plain (green) BS2? Is it plugged into a BoE? How about post a photo of your hardware.
' {$STAMP BS2}
' {$PBASIC 2.5}
a: high 0: pause 1000:low 0: pause 1000:goto a
' {$STAMP BS2}
' {$PBASIC 2.5}
a: toggle 0: pause 500:goto a
It sounds like your stamp is fine. If it puts out enough current to light an LED, it has enough output to drive a servo. I think you have a wiring error somewhere. Hook up a good servo in place of your speed controller, make sure all of your batteries have their negatives connected and retry. You need to post a photo or video for us to help you any further.