Vermes
Advanced Member level 4
It is a project of a car module that implements the function Coming & Leaving Home, known from VW cars. It lights the way home, when we leave the car and the way from home, when we want to board the car. The system controls two lighting circuits:
- parking lamps through a relay (load up to 25A)
- front fog lamps with the function of smooth lighting on and off (via PWM)
- light sensor (photoresistor) input to light up the lamps only after dark
- signal for remote closing input (mass control)
- signal for remote opening input (mass control)
- open door signal input (mass control)
- voltage after turning the ignition switch input (+12V)
The system was built on a 2-sided printed circuit board (made in an external company) in surface mount technology. It was also re-built based on the Atmega8A processor (small with ADC, easily accessible and relatively cheap). Linear LM7805 acts as stabilizer. Better idea would be eg. LM2931, because its current consumption is only 0,4mA, while for LM7805 it is about 5mA. The rest of the system are inputs, relay output implemented on NEC EP1-B3G1S and high-current output for PWM adjustable fog lamps. This output was implemented on transistor P-MOSFET IRF4905SPBF (-55V -74A) and driver MCP1416T. The driver was used to minimize the losses of the transistor, while it would be handled too slowly.
The whole was covered with lacquer, which protects the system against moisture. Then it was enclosed in Z-70 housing (the same as closing windows system). The system is protected against the influence of noise and elements such as inductors, varistor, protective diodes and blocking condensers were used. The whole takes approximately 6mA during standby.
How it works:
The system turns the lights on only when the twilight sensor registers lower value than the given one. Switching the parking lamps (if enabled) and fog lamps, follows the pressing the button on the remote control for opening the car. Each subsequent press of this button results in countdown from the beginning, so you can prolong the light time. If you do not do this, the lights go out after time set in parameters (typically after 30s). Switching on the lamps is also after turning off the ignition and opening the door. After turning off the ignition only first opening the door will light up the lamps. Lamps are turned off by pressing the close button on the remote control, after turning the ignition key or passing the time set in parameters. Of course, turning on and off the fog lights occurs smoothly. Before lightning the lamps, the power voltage is controlled. Only when it is more than 11V, the system activates the lights. While the lamps are turned on, the voltage is also controlled and when it drops below 10V, the lights turn off. This is a protection against excessive discharge of the accumulator and transistor – to the correct drive at least -10V is needed.
Program
The program was written in C in WinAVR environment. Interrupts from the counter 0 (timing – stop every 50ms), interrupt from UART used for communication and parameters settings were launched. The counter 1 acts as PWM (frequency of 100Hz). Watchdog is also on, in order to protect against some accidents. All the parameters are stored in nonvolatile EEPROM memory. The processor is put to sleep between the interrupts, so that it takes the current below 1mA. The internal RC generator is set to 2MHz. Analog-digital converter starts only when the system is active (illuminates). The charge is more than 7kB, most of which is handling of the terminal (text messages and scan chains).
Changes of the parameters are done by connecting to the diagnostic connector on the board – adapter RS232TTL and issue the appropriate commands in the terminal (eg. Putty). The parameters with which communication takes place are 9600:8-N-1.
Commands available through the terminal:
- help – display the list of available commands
- maxtime – time (0-255s), through which lamps can be lit
- maxlight – maximum brightness (0-100%) of fog lights
- sensor – the value read from the light sensor (0-100%), below which the lamps will light
- service – switching on the service mode (displaying the supply voltage, the indications of the light sensor, the outputs and inputs status
- pklight – switching (0-1) the relay – parking lamps
- eread – read the settings from EEPROM
- ewrite – write the settings to EEPROM
- edef – default values for parameters (maxtime=30s, maxlight=100%, sensor=30%, service=0, pklight=1)
- reset – reset the system, initialization, reading the parameters from EEPROM
The system was installed inside the car, next to the fuse box. Near it, there are: wire for the front fog lamps, power cords and cables for the parking lamps. Cables and power supply should be protected with a fuse. The light sensor is mounted near the rear view mirror at the top of the windscreen.
Link to original thread (attachment) – Coming & Leaving Home, czyli oświetlanie drogi z/do auta