Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

auto_off function in microcontroller

Status
Not open for further replies.

hemnath

Advanced Member level 3
Joined
Jun 24, 2012
Messages
702
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Activity points
6,588
Hi,

PIC 18F2620, 1MHz internal oscillator,

I want to auto-off the circuit when there is no change in PV for about 10 minutes. Due to some factors, PV will change slightly. So that we shall provide a limit like PV+x and PV-X. If the PV is within this range, a digital pin will switch off the circuit. Could you please help on the logic to work it out. I have been trying it. But couldn't find the solution.

Let's say, on 5th minute, if the PV changes largely or outside the limits as mentioned above. time should start from 0.
 

1) what is “PV”?
2) Do you want to power down the PIC or some external “circuit”?
 

The general principle is to use a resettable counter. You maintain a timer that counts up or down at a fixed rate, this could be seconds, minutes or whatever suits your process. At each 'tick' of the timer you check to see if the PV voltage had changed by more than your defined tolerance, if it has, you load the counter with the starting value again. When the counter reaches terminal value, the period of stable PV voltage has finished.

Example in steps rather than real code because you didn't say what language you are using:
1. make a timer counting at 1 second intervals (use TMR1 and interrupts)
2. use an unsigned integer as the counter so it has a range up to 65535.
3. read and store the PV voltage.
4. load the counter with your 'auto-off' period in seconds. (600 for 10 minutes in seconds)

at each timer interval:

5. decrement the counter at each timer interval so it counts down each second.
6. read the PV again and compare with the previous reading
7. overwrite the stored value with the new one.
8. if the difference is more than allowed, go back to step 4.

If the counter reaches zero it means the 'auto-off' period has elapsed with no change in PV measurement. By changing the starting value in the counter you can make the period as small as 1 second or as long as 65536 seconds = 18 hours, 12 minutes, 16 seconds!

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top