First of all I have to say that I’m an absolute beginner in PIC’s programming, I’ve never written a basic program before and my knowledge of basic language is very very limited.
I’m playing with a 16F84A, tryng to make a simple alarm system
At the moment I’m trying to write the part of software related to the start-stop of siren.
The siren has to work for 45 seconds, after that it must return in stand-by mode, ready for a possible new cycle of alarm, if required.
To do that, I’ve written this simple subroutine:
SirenON:
set portA.0 on
wait 45 s
SirenOFF:
set portA.0 off
wait 10 s 'this is the “pause time” between two possible consecutive cycle of siren
return
The subroutine works fine, but here comes my problem:
if I want disable the alarm while the siren is sounding (so while the waiting cycle of 45 seconds is running), what can I do (in terms of software instructions) to stop in advance the waiting time?
Maybe the problem is easy to solve for most of you, but because of my ignorance about it, I really don’t know what to do.
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Nobody, thanks for your swift reply, but as I have already said, I'm an absolute beginner and I don't know what is an interrupt.
Maybe this fact was not clear enough in my previous post.
Anyway, a friend of mine, to solve the problem, just told me to use a simple cycle FOR-NEXT instead of WAIT.
In this way you can "enter" the cycle including a continuos check of another parameter during the counting.
I think it is the best solution.
Thanks however for your help.
Have a nice day ;-)
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everybody, I’m Fabio, from Rome.
First of all I have to say that I’m an absolute beginner in PIC’s programming, I’ve never written a basic program before and my knowledge of basic language is very very limited.
I’m playing with a 16F84A, tryng to make a simple alarm system
At the moment I’m trying to write the part of software related to the start-stop of siren.
The siren has to work for 45 seconds, after that it must return in stand-by mode, ready for a possible new cycle of alarm, if required.
To do that, I’ve written this simple subroutine:
SirenON:
set portA.0 on
wait 45 s
SirenOFF:
set portA.0 off
wait 10 s 'this is the “pause time” between two possible consecutive cycle of siren
return
The subroutine works fine, but here comes my problem:
if I want disable the alarm while the siren is sounding (so while the waiting cycle of 45 seconds is running), what can I do (in terms of software instructions) to stop in advance the waiting time?
Maybe the problem is easy to solve for most of you, but because of my ignorance about it, I really don’t know what to do.
Thanks in advance.
Try with some interrupt, if your pic have portb.0 ext interrupt or on portb change…
Hi Nobody, thanks for your swift reply, but as I have already said, I'm an absolute beginner and I don't know what is an interrupt.
Maybe this fact was not clear enough in my previous post.
Anyway, a friend of mine, to solve the problem, just told me to use a simple cycle FOR-NEXT instead of WAIT.
In this way you can "enter" the cycle including a continuos check of another parameter during the counting.
I think it is the best solution.
Thanks however for your help.
Have a nice day ;-)
Fabio
Rancido
I am new to GCBasic also and so someone may have a more efficient way to do this but you can try this.
The problem is while you wait you can do noting else.
Instead of
wait 45 s
Try
For x = 1 to 45
wait 1 s
If Disable = 1 then goto sirenOFF
Next x
You will have to define Disable as an input and x as a varable.
I hope this helps.