JAL Program Design Help

Thread Starter

ajhoward

Joined Nov 16, 2011
46
Hi there

I need some help designing a JAL program for this door alarm project. I don't know how to implement interrupts or use sleep mode. I need the PIC to go into sleep mode once the door is closed and wake up when the door is opened. I have attached what I have so far.

Happy New Year! :)
 

Attachments

thatoneguy

Joined Feb 19, 2009
6,359
Here is an intro to jal and interrupts, looks pretty easy. The assembly listing is what is produce by the small program.

sleep is the command to go to low power mode, but you need to set up the PIC for interrupt on change (in datasheet for your PIC, also described in the doc below)

Interrupts in jal, part 1

I'm not sure of the reason you have so many switches.

Why not just have the door switch pull up where you have R3 to wake from interrupt, wait 10 seconds, then light LEDs on the other ports?

P.S. Your LED's are pointing the wrong way.
 

Thread Starter

ajhoward

Joined Nov 16, 2011
46
Here is an intro to jal and interrupts, looks pretty easy. The assembly listing is what is produce by the small program.

sleep is the command to go to low power mode, but you need to set up the PIC for interrupt on change (in datasheet for your PIC, also described in the doc below)

Interrupts in jal, part 1

I'm not sure of the reason you have so many switches.

Why not just have the door switch pull up where you have R3 to wake from interrupt, wait 10 seconds, then light LEDs on the other ports?

P.S. Your LED's are pointing the wrong way.
OK, I'll give it a read. S1 and S2 are reed switches, one is aligned to the fridge and one to the freezer. S3 is just there so that I can get direct feedback on what the reed switches are doing without waiting for the timer, so that I can align the switches easier. I realized about the LEDS after I posted the pic, is because I have been changing the circuit around a bit because I am tossing up on whether to switch the earth or power.
 

thatoneguy

Joined Feb 19, 2009
6,359
OK, I'll give it a read. S1 and S2 are reed switches, one is aligned to the fridge and one to the freezer. S3 is just there so that I can get direct feedback on what the reed switches are doing without waiting for the timer, so that I can align the switches easier. I realized about the LEDS after I posted the pic, is because I have been changing the circuit around a bit because I am tossing up on whether to switch the earth or power.
That can be set in software, often it is a pull up switch to wake.
 

thatoneguy

Joined Feb 19, 2009
6,359
When the switch closes, if you have the config registers set up correctly, it will "wake up" from sleep mode and run at full/standard speed. Then, once the tasks it needs to complete are done (waiting 10 seconds, then annoying people), your code will ensure the uC's "wake on change" interrupt on the chosen pin is ready, and go back to sleep.
 
Top