Announcement

Collapse
No announcement yet.

PIC startup/shutdown controller

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • PIC startup/shutdown controller

    Hey everyone. I was just wondering if anyone worked with a PIC startup/shutdown controller. I'm trying to get more into them, but I need some more example code to learn from. Does anyone here have some source they can send to me, or some ducomentation? I have a programmer, and some 4mhz resonators, along with an assortment of pics I've been practicing with.

    If anyone can come up with some source, I'll be more than glad to program a few of these up for people, and ship them out.

  • #2
    http://www.tomdownload.com/utilities.../pc_wakeup.htm
    A software solution?

    Also see this thread for a hardware solution:
    http://www.mp3car.com/vbulletin/showthread.php?t=53336

    Comment


    • #3
      Kirbycope - I was going more for a hardware controlled solution that I could rely on, with some "keep pc on while pump gas", and turns PC off on hang.

      Comment


      • #4
        BTW, Here is some C code I made, for the shutdown controller. I just need someone to fill in the PIC bits, and find a way to check voltage.

        Basically what needs to be done is listed at the top. Feel free to modify my code, but keep my name at the top, please.

        If anyone can finish the code up, I'll be more than glad to program them a chip and send it out with a 4mhz resonator.

        Additionally - The Time variable needs to be figured out. I'm hoping I can make time count down over 3-4 minutes, before Dlay = 0.

        Anyways enough ranting. here's the code.

        Code:
        //Friday, July 15, 2005
        //PIC16F877A at 4mhz
        //Kyle Yankanich
        
        // ACC needs to goto ACC line (with voltage divider)
        // Dlay needs to be figured out for 5 minute delay
        // RelayPort needs to goto I/O pin, to control the relay connecting all power
        // VoltCheck() needs to get voltage on an A2D pin
        // ThrowButton() needs to trigger power button
        
        
        int Time = 1500;	//Need to figure out a value
        unsigned Dlay = Time;   //Set counter
        bool ACC = 0;		//Conted to digital I/O pin with ACC line
        bool ACCold = 0;	// Previous ACC
        bool RelayPort = 0;	// Be safe!
        bool TurningOff = 0;	//In shutdown sequence?
        
        int main() {
        
        	while (1) {					//Infinite loop
        		
        		if (VoltCheck()) {			//Check Battery
        			Dlay--;
        	
        			if ((ACC == 1) && (Dlay <0)) {  //ACC on and within delay
        				RelayPort = 1;		//Relay on
        				Dlay = Time;		//Reset Delay
        				ThrowButton();		//Hit power button
        				TurningOff = 0;
        	
        			}
        
        			if ((ACC == 0) && (Dlay <0)) {  //ACC off and within Delay
        				Dlay = Time;		//Reset Delay
        				Throw Button();		//Hit power button
        				TurningOff = 1;
        			}
        			
        			if (ACC != ACCold) {		//Reset timer if ACC is switched
        				Dlay = Time;
        			}
        
        			if ((Dlay < 0) && (ACC == 0) && (TurningOff == 1)) {	//when ACC is off, and and Delay is over, and in turning off
        				RelayPort = 0;		//Relay Off
        				TurningOff = 0;		//Reset TurningOff
        
        			}
        
        		
        		}
        	}
        
        }
        
        
        int VoltCheck() {
        
        	// ADC is the Analog voltage of the battery
        	// Get ADC
        	
        	if (ADC < 11)		// If less than 11 volts dont turn on relay
        		RelayPort = 0;  // Turn power off
        		return 0;       // Skip the rest of loop
        	else
        		return 1;	// All good!
        
        
        
        }
        
        void ThrowButton() {
        	
        	//Connect to relay to trigger power button
        
        }

        Comment

        Working...
        X