Chargeing a capacitor

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Ken Sparkes
Posts: 23
Joined: Tue Nov 30, 2010 6:42 pm
Has thanked: 1 time

Chargeing a capacitor

Post by Ken Sparkes »

How can I charge a capacitor in flow code I want to charge two caps and then compare the time they charge so I can output a pin on the time it takes I am using 12F615 chips
Ken Sparkes

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Chargeing a capacitor

Post by medelec35 »

Hiya Ken.
How about using timer0 for timings. Connect a pull-up resistor from +5V to each cap/pin of chip (I would not use internal weak pull-ups as there will be less control over charging times) other end of cap connected to ground. Pins caps connected to are set as outputs to allow caps to fully discharge You can use timer to allow enough time to discharge. After elapsed time reset timer, and turn pins caps connected to into inputs. This will have two effects:
1) Turns pin into high impedance state so cap charges via pull-up resistor and
2) Monitors pins voltage so when has reached a certain level can log results of time.
The pins caps are connected to are polled and i/p voltage via ADC are read, and compared with a reference byte value. e.g 250 (250 = 5/255*250 = 4.9V). As soon as voltage rises above the stored 250 the time is noted. After time completed for both caps, then you can either o/p to RS232 via PC or via a different chip (could be another 12F615) with a LCD attached, reading out times.
You will need to have a time range in mind for charging caps, then capacitance and resistor values can be selected.
From memory a cap is fully charged after 5CR seconds.
Hope this give you an idea.
Perhaps other people would do this a different way?
Martin

Post Reply