Vermes
Advanced Member level 4
It's a module controlling performance of the 3-way sunroof with the function of closing.
Assumptions:
- controlling performance of the sunroof by original buttons
- closing input activated by the mass
- opening/tilting/closing the sunroof by impulse from the buttons
- diode signalization of performance and errors
- constant control of positions and closing/opening times and when error occurs – transition into the alarm state until autobasing
- autobasing after power
- ability to control the sunroof for some time after switching off the ignition
Description:
The system was made on a double-sided circuit board.
The main element is Atmega8A, the rest is made in SMD. There are four inputs responsive to the mass (two buttons, SW limit switch, closing input), one input +12V, two engine outputs, power supply input, OC output for a LED and the mass. NEC EN2-B1N1S transmitter was also used in the project. It's a double transmitter in bridge connection. It gives polarized +12V and the mass or 2 from those signals at once. It also has a big load current (35A) and a certified automotive.
The processor in the system is driven with an internal generator RC for 2MHz. The whole takes about 6-7mA, most of which really gets 7805 stabilizer. The program was written in WinAVR C and takes exactly 7,98kB. All works on interrupts and the processor is put to sleep to reduce power consumption. Watchdog is also running.
The plates were coated with lacquer isolating the electronics from water and the whole was mounted in Z68 housing and positioned behind the headlining.
Installation:
Modification of the car installation consisted of throwing away the original elements and remaking everything. The cables with constant +12V were added (originally the sunroof was powered only by the key), a cable for closing the windows module and mode LED mounted in light.
Error codes:
After the system is connected to power supply and the ignition is turned on, the system LED flashes indicating a problem with the loss of data of the previous position. Errors are signaled by a long LED flash and a proper number of short flashes:
- 1 long, 0 short – error 0 (the loss of data of the actual position after power)
- 1 long, 1 short – error 1 (too long time of exit of the limit switch)
- 1 long, 2 short – error 2 (too long time of performance in section of tilting – closed position)
- 1 long, 3 short – error 3 (too long time of performance in section of closed – open position)
- 1 long, 4 short – error 4 (reset from watchdog)
- 1 long, 5 short – error 5 (too low supply voltage)
The sunroof basing:
In each error the system waits for the permission for autobase – pressing S1 button. In that moment, the sunroof motion into the direction of tilting position starts. Depend on the signals from the limit switches and timeframes in which these signals appear, the system rejects another possibilities of the current location and after it is determined, the sunroof moves to the closed position. After 'basing' and closing, the sunroof is ready to work.
Support of the sunroof:
Pressing S1 button results in tilting the sunroof to the max position, unless S2 button was pressed before (in this case the sunroof would stop in the middle position). Pressing S2 button results in opening the sunroof to the max position, unless S1 button was pressed before. During working, for example towards the tilting position, while the sunroof stays in the open position, pressing S1 would result in passing through the middle position and tilting. When it's tilted, pressing S2 two times would result in fully opening the sunroof. During the drive time is counted and in the event that there was no entry/exit of limit switch, the system would stop the engine and goes into error state. Operating times in both directions are programmable and can be changed by connecting the RS232 cable to the computer and commands through the terminal (e.g. Putty).
The terminal window screenshot:
The terminal commands:
- timel=<time> – time of exit of the limit switch
- time13=<time> - time of performance in section of tilting – closed position
- time35=<time> - time of performance in section of closed – open position
- srv=<0/1> - in/off service mode (displaying in the terminal of input modes, supply voltage, the set and actual position, times)
- eread – reading the settings from eeprom memory
- ewrite – saving the settings on eeprom memory
- edef – defaults
- reset – the system reset
- help – a list of available commands and description how to use them
Impulse from the closing module has 30sec and the sunroof closes only when the impulse is active. When during this operation, closing is interrupted (by pressing the car opening button), the sunroof also stops. When the sunroof is closed and the impulse of closing is still, the mode LED lights constantly – it stops when the module of closing the windows releases the line.
Link to original thread (useful attachment) – Sterownik szyberdachu 3-pozycyjnego z funkcją domykania