debug and functionality problem

jonphenry

New Member
When I download my program to a 40x1 without a debug command, it does not work. If I out a debug command in it anywhere, it works perfectly.
Can anyone explain this.

Also, when working with the programming editor, after 2-3 downloads it stops connecting to the picaxe. I have to restart the programming editor to download again. Anyone see this before?

Heres the code

init:

serout 7,N2400,(254,1) 'Initialize and clear LCD
pause 500
high 6 'Inital LED-DISARMED
let b1=0
let b3=0 'Initial status-DISARMED

scan: 'Scans keypad for btn pushes

let b2=0
low 3 'Scan btn 1,2,3
high 0
gosub keytest
let b2=3
low 0 'Scan btn 4,5,6
high 1
gosub keytest
let b2=6
low 1 'Scan btn 7,8,9
high 2
gosub keytest
let b2=9
low 2 'Scan btn *,0,#
high 3
gosub keytest
goto scan

keytest: 'column test

if pin0=1 then add3
if pin1=1 then add2
if pin2=1 then add1
return

add1:let b2=b2+1 'Add three to row base
add2:let b2=b2+1 'Add two to row base
add3:let b2=b2+1 'Add one to row base
serout 7,N2400,(254,192,#b2)

let b1=b1+1 'PIN order logic

if b1>4 then res
branch b1,(test1,test2,test3,test4)
test1: 'PIN first num validation
if b2=7 then continue
goto res
test2: 'PIN second num validation
if b2=8 then continue
goto res
test3: 'PIN third num validation
if b2=9 then continue
goto res
test4: 'PIN fourth num validation
if b2=7 then validate
goto res

validate: 'Validation simply for visual effect
serout 7,N2400,(254,1)
serout 7,N2400,(254,128,"Validating")
serout 7,N2400,(254,138,"..")
pause 500
serout 7,N2400,(254,140,"..")
pause 500
serout 7,N2400,(254,142,"..")
pause 300

status: 'Test armed/disarmed state
if b3=1 then disarm
if b3=0 then arm

arm: 'ARM command
low 6 'Switch off unarmed LED
high 3 'Send arm command to MASTER
serout 7,N2400,(254,128," System ARMED ")
high 5 'Switch on armed LED
let b3=1 'Set keypad state to armed
goto res

disarm: 'DISARM command
low 5 'Switch off armed LED
low 3 'Send disarm command to MASTER
serout 7,N2400,(254,128,"System DISARMED")
high 6 'Switch on unarmed LED
let b3=0 'Set keypad state to disarmed

res: 'Resets PIN order logic
let b1=0

continue: 'Returns to scan cycle
return

Edited by - Jon Henry on 01/08/2007 16:25:42
 

BeanieBots

Moderator
By "it does not work", I guess you mean nothing is seen happening at the PC.
Does the rest continue to work?
Combining this problem with the other fact that your PC serial seems to fail after a few downloads suggests that the fault is PC side. Check that you don't have any other software running that is trying to control the serial port.
 

Technical

Technical Support
Staff member
As rick says, debug also adds a time delay. It could be that without it your keypad scan program is detecting more than one hit from a switch press (e.g. mechanical bounce) or similar. Try adding a pause 10 where the debug was.
 

jonphenry

New Member
By it doesnt work I mean it doesnt work on the breadboard. With debug in, keying in the PIN 7897 on the keypad takes me to the statusing and validation phases. With no debug, keying in 7897 just keeps showing the numbers I key in it never gets to the statusing and validation phases.
Technical, i replace debug with a pause 10 and still have the same problem. I kept going up on the time and at pause 150 it works like a champ. The delay doesnt hurt my function at all so Ill consider this one solved.
Looks like it was a timing issue,
Thanks guys.

Edited by - Jon Henry on 01/08/2007 19:26:48
 
Top