No announcement yet.

Can someone write me a PIC program 4 a awesome s/down controller please?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Can someone write me a PIC program 4 a awesome s/down controller please?

    Hey guys,

    I know you dont know me, and this is completely out of the blue, i have a favout to ask , reguarding PIC programming, specifically the design of a shutdown controller.

    Firstly an introduction, I have built a in-car MP3 player, it has the following features:

    - Runs win 95 = winamp
    - a LCD display connected to the parallel port
    - UIR IR remote, connected to the serial port.
    - lorty LCD plugin for the LCD display, and keypad control,
    - I am also using a program called uICE to recieve data from the UIR, and send the required keystrokes to the Lorty plugin, this allows me to fully control the plugin from the IR remote.
    - I also have a hacked keypad in the head unit in the dash with 5 keys, play, pause, stop, nxt track, and prev track, and shutdown/power up. these keys are the same ones emulated by uICE, so i can control basic functions of LORTYS plugin from the head unit, aswell as the IR remote, the IR Remote is also able to take advantage of the full search functions of lortys plugin, aswell as the other functions.
    - A homemade power supply supplying the required power for the motherboard.
    Its a Pretty standard setup really.

    What i need now is a shutdown controller, and this is where i need you help, i have designed the electronics, and i would like you to write a quick PIC program for them, sorry for having the cheek to ask you this but i am only a studing studying/ training to be a Electrical Engineer at university, and i havent learnt how to prog PICs yet, also, there is not a device like i wish to build available on the market yet, and i think there is a need for one, for the good of the MP3 community.

    Here is what i would want the device to do:

    I would like to make the device from a 12C509 or 16F84 PIC, because i can get these cheap from University.

    The circuit would have to monitor 4 inputs, one from the accessory line of the car, a "startup" button, a "shutdown" button, and the other from the LCD display, The program would also have to drive 2 output, one is to turn on and off the powersupply (output 1), and the other is to close one contact on a hacked keypad (this causes the lorty plugin to shutdown the computer.0(output 2)


    When the start button is pushed, OR the acessory line goes on (i.e. the car is started) set output 1 high indefinately (this would turn on the powersupply)

    When the line connected to the LCD display goes High (i habe designed a missing pulse detector circuit which goes high when the pc stops sending data to the lcd on its E line)(i.e. the pc has shut down, and is ready to be turned off), then a 2 minute timer should start, after the 2 minutes has elapsed, then output 1 should go low indefinately (turn off the pc),

    When the accessory line goes low (i.e. the car is turned off), a 10 minute timer shoud start, after that time, output 2 should go high for half a second or so. (issuing a command to the PC to shut down (emulating a key, which uns a shutdown command to anpther plugin))

    when the shutdown button is held down for 1 sec or more, then output 2 should go high for 1/2 a sec (i.e. this issues the command to the plugin to shut down the PC)

    Other conditions,

    if the start button is pushed while output 1 is high, this should not affect anything, likewise, if shutdown button is pushed while output 1 is low, this should not affect anything.

    to eliminate false triggering, the input from the LCD must remain high for 2-5 seconds, before starting the 2 min timer.

    the program should be on indefinately (i.e. run forever, the shutdown controller is always got power)

    the input button must be held on for 1 sec, this acts as a debouncer, and means you can accidentally turn on the 'puter, like wise for the shutdown button, it must be held down for 1 sec, to prevent accidentally shutting down the 'puter.

    More info:

    The LCD input is via a missing pulse detector, the ouput of this detector goes high when data is stopped being sent to the LCD (i.e. the computer is showing the "now ready to turn of you pc screen")

    In conclusion,

    this device is in charge of starting or shutting down the PC

    I think this is well worth building, as no such device currently exists on the market, and this shutdown controller is entirely hardware orientated, so it needs no software to be running on the PC at the time.

    I'm sorry for pestering you, please think about the project, and get back to me reguarding your response.

    Thanks for your time

    Yours Sincerely

    John Stowers
    Gizmos' MP3 Car - Check it out

  • #2
    What you are asking wouldn't take long at all with a 16F84. A few quick hardware notes:

    1. What input/output ports did you want to use? The 16F84 has 13 I/O lines, divided into one 8bit port (Port B) and one 5bit port (port A). Two of the pins on port A are special, so I recommend that you use port B to make it simple; any of the 8 pins on port B can be used as either an input or output with no problem.
    2. To configure the chip (and properly time the loops in the programmer), you need to specify what type of oscillator it will be using. You can use:
    A cheap resistor/capacitor circuit
    A ceramic resonator
    A quartz crystal.
    Going down this list, cost increases, but so does accuracy. Accuracy probably doesn't matter much here, (we are working with tens of seconds here, not microseconds).

    Before code can be written, you need to know which oscillator (type and speed) and what pins you will be using on the PIC for which purpose.

    Do you have a way to program the chip? If not, check out for a very low-cost programmer and the software to go with it.


    BTW, If you are connecting the accessory line to an input on the PIC, you should make sure to clamp the car's 12 volts to TTL levels (5 volts) on that pin, because the chip has an absolute maximum of about 6.5 volts on the input pins. This is easy to do with a zener diode.


    • #3

      Thanks for your reply,

      I was going to use port B, and had a quartz crystal in mind for the timing because i can get them for free.

      And yes i have a PIC programmer, it is the P16 pro and the PICALL software

      Thanks for your help


      [This message has been edited by gizmos (edited 07-14-2000).]
      Gizmos' MP3 Car - Check it out


      • #4
        Do you have all of the circuitry planned? One of the great things about the PIC is that you can change just one pin in port B leaving all of the others alone.
        To write the program, you need to know what pins each of the inputs and outputs will be on. (i.e., power switch on RB7, LCD on RB4, etc.)
        You also need to know the clock speed you are using. Remember that the PIC's internal clock is 1/4 of the crystal speed you choose. Each instruction (except for jumps) takes one clock cycle. By knowing this, you can plan how long each loop in your program will take, how often the timer will interrupt, etc. For example, with a 4MHz crystal, each instruction takes 1 microsecond. If there are 10 instructions in a loop, it takes 10 microseconds to run the loop.

        Hope this helps. If you have any questions, I'll try to help.