PDA

View Full Version : Stamp program stops working



gchrt
07-29-2008, 08:50 AM
Hi,

I built my first project on the BOE board and everything worked fine. I transferred over to a super carrier, soldered everything in and had things working until I hooked up the board that holds the 4 595's that run the 36 leds. As I noted prior to moving to the super carrier everything including the led setup worked fine.
Now after the leds come on the stamp program stops running.
I apologize for this is bare bones description but I thought if anyone has a moment to help me correct the problem I could provide the information needed since I am uncertain as to what is needed to debug this thing.

kenwtn
07-29-2008, 08:52 AM
Please attach your source code it would be a big help

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When you spend 10 times what it cost to build it yourself - That's when it becomes a HOBBY !

ииииииииииииииииииииииииииииииииииииииииииииииииии иииииииииииииииии

gchrt
07-29-2008, 09:33 AM
Hi,

Thanks for the reply.
Here is my program:





' {$STAMP BS2}
' {$PBASIC 2.5}
'

' -----[ I/O Definitions ]-------------------------------------------------
' ---(motor)---
Phase VAR OUTD 'phase control outputs pins 12-15

' ---(74hc595)---
Clock CON 0 'shift clock (74HC595.11)
DataOut CON 1 'serial data out (74HC595.14)
Latch CON 2 'output latch (74HC595.12)

' --------[ Constants ]-------------------------------------------------------

#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5 'trigger pulse = 10 uS
Scale CON $200 'raw x 2.00 = uS
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD 'raw x 0.80 = uS
#CASE BS2PE
Trigger CON 5
Scale CON $1E1 'raw x 1.88 = uS
#ENDSELECT

RawToIn CON 889 '1 / 73.746 (with **)
RawToCm CON 2257 '1 / 29.034 (with **)

IsHigh CON 1 'for PULSOUT
IsLow CON 0

' --------[ variables ]----------------------------------------------------
counter VAR Byte 'loop delay counter
garageDoor VAR Bit 'garage door position
passes VAR Byte 'number of pauses
passesB4sound VAR Nib 'how many pauses before setting off sound
soundFired VAR Bit 'sound event
detectHold VAR Word 'pause time amt
rndmVal VAR Word 'for main loop delay
countfrom VAR Byte 'num secs in main loop delay
houseLight VAR Bit 'led at door to house

' ---(PING)---
pingDetect VAR Bit
rawDist VAR Word 'raw measurement
inches VAR Word

' ---(motor)---
idx VAR Word 'loop counter
stpIdx VAR Nib 'step pointer
stpDelay VAR Byte 'delay for speed control
rotationAmt VAR Word 'rotation amount

' ---(74hc595)---
pattern VAR Byte 'output pattern

' -----[ EEPROM Data ]-----------------------------------------------------

Steps DATA %0101, %1001, %1010, %0110

' --------[ init ]---------------------------------------------------------

GarageLed PIN 3
Ping PIN 5
HouseLed PIN 8
'sound trigger PIN 4
'sound return PIN 7

passesB4sound = 2 'number of hold times before sound is heard
soundFired = 0
detectHold = 20000 'hold time
pingDetect = 0
rndmVal = 39778 'init random value
houseLight = 0

' ---(motor)---
Setup:
DIRD = %1111 'make P12..P15 outputs
stpDelay = 35 'set step delay (rotation speed)
rotationAmt = 280 'set rotation amount

' ---(74hc595)--
Initialize:
LOW Latch

' --------[ main ]----------------------------------------------------------

HIGH GarageLed

DO

DEBUG CRSRXY, 2, 15, CLREOL, "Checking PING ", "pingDetect is ", DEC1 pingDetect
GOSUB Get_Sonar 'get sensor value
inches = rawDist ** RawToIn 'convert to inches
DEBUG CRSRXY, 2, 16, CLREOL, "distance is ", DEC2 inches
IF (inches < 16) THEN 'must be less than 16 inches to begin cycle
pingDetect = 1
ENDIF

PAUSE 4000 'pause 4 seconds

IF (pingDetect = 1) THEN
DEBUG CLS, CRSRXY, 2, 1, "PING under 16"
PAUSE 4000 'pause 4 seconds

DO
DEBUG CRSRXY, 2, 15, CLREOL, "detection LOOP checking PING ", "pingDetect is ", DEC1 pingDetect
GOSUB Get_Sonar 'check if person still there
inches = rawDist ** RawToIn
DEBUG CRSRXY, 2, 16, CLREOL, "distance is ", DEC2 inches

IF (inches < 12) THEN 'must be less than 12 inches to proceed
DEBUG CRSRXY, 2, 3, "PING under 12"
PAUSE 2000
GOSUB Get_Sonar 'one more check
inches = rawDist ** RawToIn
DEBUG CRSRXY, 2, 16, CLREOL, "distance is ", DEC2 inches

IF (inches < 12 AND garageDoor = 0) THEN
DEBUG CRSRXY, 2, 4, "person there, garage closed"
LOW GarageLed
GOSUB OpenGarageDoor
PAUSE 2000
pattern = %11111111
GOSUB FlipLights 'turn on lights
soundFired = 0
passes = 0
FOR counter = 30 TO 0
DEBUG CRSRXY, 2, 30, CLREOL, DEC2 counter
PAUSE 1000
NEXT
counter = 0

ELSEIF (inches < 12 AND garageDoor = 1) THEN
DEBUG CRSRXY, 2, 4, CLREOL, "PING under 12, garage open"
DEBUG CRSRXY, 2, 5, CLREOL, "passes are ", DEC1 passes
DEBUG CRSRXY, 2, 6, CLREOL
IF (passes > passesB4sound AND soundFired = 0) THEN
DEBUG CRSRXY, 2, 6, CLREOL, "sound is fired"
HIGH HouseLed
houseLight = 1
PAUSE 2000
GOSUB RunSound 'turn on sound
soundFired = 1
ENDIF
passes = passes + 1
ENDIF

ELSEIF (garageDoor = 1) THEN
DEBUG CRSRXY, 2, 3, "person gone, close garage"
DEBUG CRSRXY, 2, 4, CLREOL
DEBUG CRSRXY, 2, 5, CLREOL
DEBUG CRSRXY, 2, 6, CLREOL
IF (houseLight = 1) THEN
LOW HouseLed
houseLight = 0
ENDIF
pattern = %00000000
GOSUB FlipLights 'turn off lights
GOSUB CloseGarageDoor
FOR counter = 60 TO 0
DEBUG CRSRXY, 2, 30, DEC2 counter
PAUSE 1000
NEXT
counter = 0
pingDetect = 0
EXIT

ELSE
DEBUG CRSRXY, 2, 3, CLREOL, "PING over 12, person gone"
pingDetect = 0
EXIT
ENDIF

DEBUG CRSRXY, 2, 9, CLREOL, "pause in detection loop" ' hold time before checking PING distance again
FOR counter = 20 TO 0 ' pause 20 seconds before checking PING distance
DEBUG CRSRXY, 2, 30, DEC2 counter
PAUSE 1000
NEXT
counter = 0

LOOP

ELSE
DEBUG CLS, CRSRXY, 2, 1, "PING over 16"

ENDIF

DEBUG CRSRXY, 2, 9, CLREOL, "pause main loop"
RANDOM rndmVal
countfrom = (rndmVal // 8 + 2) * 10
FOR counter = countfrom TO 0 'Wait random # Seconds before checking PING
DEBUG CRSRXY, 2, 30, CLREOL, DEC2 counter
PAUSE 1000 'Display Counter Every Second
NEXT
counter = 0
LOOP


' --------[ subs ]---------------------------------------------------------

Get_Sonar:
Ping = IsLow 'make trigger 0-1-0
PULSOUT Ping, Trigger 'activate sensor
PULSIN Ping, IsHigh, rawDist 'measure echo pulse
rawDist = rawDist */ Scale 'convert to uS
rawDist = rawDist / 2 'remove return trip
RETURN

OpenGarageDoor:
PAUSE 3000
DEBUG CRSRXY, 2, 6, CLREOL, "open garage door"
FOR idx = 1 TO rotationAmt 'controls how much rotation
GOSUB Step_Fwd 'rotate clockwise
NEXT
garageDoor = 1
RETURN

CloseGarageDoor:
PAUSE 1000
FOR idx = 1 TO rotationAmt 'controls how much rotation
GOSUB Step_Rev 'rotate counter-clockwise
NEXT
garageDoor = 0
inches = 0 'reset inches to zero
PAUSE 4000 'pause 4 secs before turning light back on
HIGH GarageLed
RETURN

FlipLights:
SHIFTOUT DataOut, Clock, MSBFIRST, [pattern] 'send pattern to 74x595
SHIFTOUT DataOut, Clock, MSBFIRST, [pattern] 'send pattern to 2nd 74x595
SHIFTOUT DataOut, Clock, MSBFIRST, [pattern] '3rd
SHIFTOUT DataOut, Clock, MSBFIRST, [pattern] '4th
PULSOUT Latch, 5 'latch outputs
RETURN

RunSound:
SEROUT 4, 84, ["VSV $00", CR] 'set volume full in hex
SEROUT 4, 84, ["VPF gSnd01.mp3", CR] 'Play sound file
PAUSE 2000 'pause 2 secs
RETURN

' Turn stepper clockwise one full step (7.5 degrees)
Step_Fwd:
stpIdx = stpIdx + 1 // 4 'point to next step
GOTO Do_Step


' Turn stepper counter-clockwise one full step (7.5 degrees)
Step_Rev:
stpIdx = stpIdx + 3 // 4 'point to previous step
GOTO Do_Step


' Read new step data and output to pins
Do_Step:
READ (Steps + stpIdx), Phase 'output new phase data
PAUSE stpDelay 'pause between steps
RETURN

allanlane5
07-29-2008, 10:18 AM
This sounds like a classic "too much current browning-out the voltage (dragging it down) problem".

How much current DO those LED's take? How many of them are on at the same time? And how are you powering your board?

gchrt
07-29-2008, 01:28 PM
I am using 6000mcd leds, wf3.4 with 100ohm resisters. All 32 are on at the same time.
The board is powered by the wart that came with the super carrier board - 1000ma.
Would the BOE transfer power different than soldered board, since I did not see this behavior before?
How might I go about trouble shooting a current draining problem?
Can this be rectified by using a higher amperage wart?

Post Edited (gchrt) : 7/30/2008 6:41:40 AM GMT