Shop OBEX P1 Docs P2 Docs Learn Events
Problem: HB-25's go on after END — Parallax Forums

Problem: HB-25's go on after END

SzarzynskiSzarzynski Posts: 16
edited 2006-07-27 02:32 in BASIC Stamp
I am having an issue with my HB-25's.

I have the Basic Stamp 2, PWMPAL, and HB25's in the loop.· I have had some erratic behavior from the mators and I am trying to determine the reason.

The problem is that after and END statement, the the motors turn·on.· I have tried toggling the communication time-out mode on the HB25's, enabling the PWMPAL motor chanels and sending PWMMO as a final statement, and lots of·other things, but·I cant pinpoint the problem.

Both motors turn on at the same time and follow the same pulse pattern.· If I disconnect the·cable from one of the HB25's, the motor does not come on - so that seems to narrow it down to the code, Stamp or PWMPAL.· When I reconnect the cable, it will turn on.

Any ideas?· The only way I can fix it is with a·DO LOOP·that sends a stop pulse instead of END.

Here is·code that creates the problem:



' =========================================================================
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
PpPin·········· PIN···· 0······················ ' PWMPAL Serial I/O
HB25··········· PIN···· 14····················· ' I/O Pin For HB-25 motor right
HB25_2········· PIN···· 15····················· ' I/O Pin For HB-25 motor left

'
[noparse][[/noparse] Constants ]
#SELECT $stamp
· #CASE BS2, BS2E, BS2PE
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· T38K4······ CON···· 45
#ENDSELECT
PpBaud········· CON···· T38K4
'
[noparse][[/noparse] Variables ]
cntr1·········· VAR···· Word··················· ' counter for P10, right wheel
cntr2·········· VAR···· Word··················· ' counter for P11, Left Wheel
index·········· VAR···· Word··················· ' Counter For Ramping

'
[noparse][[/noparse] Initialization ]
Setup:
· SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSS", %00000000]···· 'disable PWM outputs
· SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSP", %00001100]···· 'counters enabled.
· SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMX0"]··············· 'clear counters

'
Program
main:
· DO
··· index = index + 1
····· PULSOUT hb25, 750 + index
····· PULSOUT hb25_2, 750 + index
··· GOSUB get_counters
··· PAUSE 10
· LOOP UNTIL cntr1 = 24

··· PULSOUT hb25, 750
··· PULSOUT hb25_2, 750

END

'at this point the motors stay off for a moment, then fire up at about full speed.

'
subs
get_counters:
··· SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMC3"]
··· SERIN· PpPin, PpBaud, [noparse][[/noparse]cntr1.BYTE0, cntr1.BYTE1]
··· SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMC4"]
··· SERIN· PpPin, PpBaud, [noparse][[/noparse]cntr2.BYTE0, cntr2.BYTE1]
RETURN

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-27 01:38
    Hello,

    ·· This is a known condition...Not of the HB-25, but of the BASIC Stamp.· When you END a program the BASIC Stamp goes into LOW-Power mode and wakes up about every 2.3 seconds when the watchdog timer resets.· When this happens the I/O lines change states briefly causing a pulse which triggers the HB-25.· This is why the example code doesn't allow the program to end.· You could replace the END with a STOP command and achieve the same effect.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • SzarzynskiSzarzynski Posts: 16
    edited 2006-07-27 02:32
    Great. Thanks.
Sign In or Register to comment.