SW problem

alexthefox

Senior Member
hi, im new in picaxe microprocessor, and i have a problem:
i want put on 1 out every 30 sec. if input 1 is off, or 3sec off and 1 sec on if input 1 is on until 10 sec.
i wrote the program as follow.
i want to use millisecond to scan pin1 and it dont work. if i replace pause 100... with wait 1 sec it work. there is easy way to write what i wrote?
thank to evrybody, and sorry for my english and my code ;)


b0=0 ; bit conteggio per bip 30 secondi
b1=0 ; bit conteggio per bip ciclo 1 sec ON 3 sec OFF dopo 10 che in=1
main:
if pin1= 1 then
b1=0
goto alarm
else
if b0=>30 then goto attesa
endif
wait 1
let b0=b0+1
goto main
alarm: if pin1= 1 then
pause 100
let b1=b1+1
if b1=>70 then
goto ciclo
else
goto alarm
endif
else
goto main
endif

ciclo:
wait 3
high 2
wait 1
low 2
if pin1=1 then
goto alarm
endif

attesa:
wait 1
high 2
wait 1
low 2
goto main




thk.
Alessandro
 

solderman

New Member
I tried this program and it appears to work, without syntax errors; although I haven't guessed what its purpose is.
However, if pin1 goes high during the Wait, then it's missed - you need an interrupt system to avoid this. ( Setint )
Can you explain the purpose?
 

alexthefox

Senior Member
hi, and thk for your message. what i want to do is a beeper to know when the dog is in waiting.. when he stop to run. so, every 30 second i need a beep for 1 second to know whre the dog is, and if the dog stop, after 10 second i whant 1 beep every 3 second so 1 sec on and 3 sec off. hope is clear for you
 

Pekari

Senior Member
program example

alexthefox, is this program working like you wish:

Code:
'dogprogram
b0=0
b1=0 
b2=0
main:
pause 1000
b1=b1+1
if pin1=0 then part3
if bit1=1 then part1
b1=0 b2=0 low 2 bit1=1 goto main
part1:
if b1<10 then main
b2=b2+1
if b2<3 then main
if b2>3 then part2
high 2 goto main
part2:
low 2
b1=20 b2=0 low 2 goto main
part3:
if bit1=0 then part4
b1=0 bit1=0
part4:
if b1>1 then part5
high 2 goto main
part5:
low 2
if b1<30 then main
b1=0 goto main
 

alexthefox

Senior Member
i have to modify my firt project.
i need to have one output every 30 second (this timer running in background), and if pin 3 is on for 7 seconds it set output high for 1 second every 4. if pin 3 go back low, start to check timer for 30 seconds and input 3.

i thinked to use button command to check input (the circuit is in movement so must to put filter on input), but cant find the way to use it. if i can set 1 time, not other can set.
i dont know the way to put one program in background (it running always and without interference of other condition). can somebody help me?
 
Last edited:
Top