PDA

View Full Version : pic vs cigarettes



bogdan
- 5th February 2009, 01:22
Objective:
-to take one cigarette every 2 hours

Mechanical description:
-the cigarettes will be on a sliding tray who slide out of the box
-the tray will be locked bye a latching solenoid
-the box will have a “dumb” LCD to display the countdown “timer” (999 to 000)
-The sensor (switch) will be normal open and will close when the tray is all the way out

Parts:
-microcontroller
-latching solenoid
-h-bridge
-optoisolators
-“dumb” LCD
-spst switch

Requirements:
-The box (including the solenoid) should be powered by one 9v battery
-The pcb shouldn’t be bigger than 1” diameter

Logic:
1.Configure the microcontroller, variables, …
2.Lock the box
3.Start the count down
a.For LCD=999 to 0
b.GoSub display_to_LCD
c.Add delay 2hours/999
d.Next
4.Unlock the box
5.Display_to_LCD
6.END

Questions:
-Do you think the pic16F913 is suitable for this application?
-Should I use external interrupts (by the switch) or just power on reset will be enough?
-Should I use external or internal clock source (the 5% timing tolerance is acceptable)?

Any recommendation regarding the circuit and programming are welcome

Thanks in advance guys
… from a newbie who try to quit smoking

Jerson
- 5th February 2009, 03:26
Well described. I think the 913 has the LCD driver built in and as such is suited for this kind of application. Tray fully opened switch - thats something which might be an issue. What if you want to cheat on the timer? hehehe You could open the tray just half way and take a cigarette. I'd rather have the switch close when the tray moves out from fully closed position.

Internal clock source will be just fine for this app. See 2 hours or 2hrs 1min dont really matter when it comes to avoiding a smoke.

Why do you need interrupts? You may need to clarify this more. If this is battery powered, it makes sense to use sleep mode and an interrupt to notify the switch changeover to your program code.

1" dia, possible.

bogdan
- 5th February 2009, 06:45
At the beginning I was thinking to use external interrupts (INTE bit)…but anyway the interrupts will occur only at the END (point 6) of the cycle, when the uC will be in the sleep mode and the box was already unlocked.

So, what about if I will use a reset circuit (pull-up resistor connected to the MCLR/Vpp pin + pushbutton switch connected to ground)… will not be the same for this application?…please take a look at the pictures

Jerson
- 5th February 2009, 11:37
Definitely a good idea. However, you should consider the SLEEP command to put the PIC in ultra low power mode while counting if you power this box by a battery OR you may get just a few hours of operation.

nomad
- 11th February 2009, 05:24
that's an interesting way to quit smoking.. *cough* I'll have to try it!