PDA

View Full Version : Circuit Design Question



bradb
- 8th August 2009, 05:59
I'm working on building a circuit to keep tracking of machine online time (An electronic hour meter). I'd like to do this with 2 wires, a 12 volt power while running and ground.

My thought of the circuit is to use an IOC pin to detect when power is removed from the circuit. To keep power to the chip I want to use a large cap, the cap size will need to be determined once I get power consumption and time needed to shut down safely, but I'm thinking as long as I keep 90% of the charge on the cap for at least 50ms, that should be plenty of time.

Basically when power is removed from the circuit, the IOC will interrupt instantly. I'll write my counter vairables from Timer 1 into eeprom using a DT Interupt routine, then set the chip into nap mode. As long as my cap is big enough I should have plenty of time to write my vars to the EEPROM (Green circled cap).

When the circuit is powered up, I'll read my eeprom vars and then continue counting. Does anyone want to throw $.02 in on the design? Thoughts?

I'll have no issue writing the code, I'm just wondering about using the large cap to store enough power to write the vars to eeprom.

Thanks
Brad

http://74.219.236.172/timing.jpg

Archangel
- 8th August 2009, 07:49
Hi Brad, here's my 2 cents. What do you think about putting the "storage cap" just after the diode and before the regulator, thereby storing 12v and feeding the regulator until it bleeds down ? I think it will give you more time to write and power down with full 5v drive.

mackrackit
- 8th August 2009, 08:53
What Joe said and I will add run the PIC at maybe 3 volts.

bradb
- 8th August 2009, 16:20
Ah, that makes a lot more sense, yes! Thank you.

I'm in love with the 18F4550 (or 2550) because of the USB, so I'm stuck with 5v. But I can use a TI 78ST105 switching regulator instead of the LM7805 which will bring my effeciency from 12v to v5 to > 85%.

I've used the 4550 for a couple other projects so I'm familair with it. As far as power consumption I plan on using a USB sense from the 5V USB power to turn off the USB when not connected to save power, thus not affecting my ability to write to the EEPROM on shutdown. The USB will be used mainly for setup and to retrieve data, but will be disconnected 99.99% of the time.

New Schematic:
http://74.219.236.172/timing2.jpg

mackrackit
- 8th August 2009, 17:33
I am running the same chip at 48Mhz with a 4 Mhz osc at 3.3 volts.
The only thing about USB that is 5 volts is the positive power line. That has nothing to do with the signal. As far as I know even a USB flash drive runs on 3 something. Part of the stuff in the stick is a 5 to 3.3 regulator.

sayzer
- 10th August 2009, 07:29
At the second schematic, I would change the cap to 2200uf, and also I would add 100uf parallel to the 50K resistor on the interrupt pin.

I would also add a BOR level or an endless loop, like a STOP command, immediately after the writing to the eeprom is complete.


When the power is lost, 2200uf will go down far after 100uf.
Once 100uf is down, you read zero at the interrupt pin and act right away to save to eeprom, and stop the PIC from doing anything else.

sougata
- 11th August 2009, 08:18
Hi,

Read section 24.0.

There is an on-board High Low Voltage Detection module present on the chip you are talking about.

You can use an external analogue input or the dedicated HLVD pin. Causes an interrupt. Store your values to the eeprom in the int itself. A high priority int would not int itself.

Take care not to get trapped by brownouts that affect your circuit but not the machine.

Shut off outputs turn off peripherals within 1uS and have ample time

Put an LED and see that the 2200 storage cap can give you over 2 seconds. You are asking for 20mS....

I used it as last memory for an industrial depth counter. Otherwise the eeprom could have weared out in a week. Not on 4550 though another PIC18.

PBP does not support oscillator switching, if you can handle it things become more sweeter... in terms of SLEEP.
Your PIC gets more ..... you get less, implementing it. :D