Warning strobe light controller for car

From uCtrl
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

This car has been scrapped.
Warning lights unit 2

Information

This unit has three channels and five outputs. The aux outputs is equal to the yellow light outputs when a flash signal is present, strobing back and fourth between #1 and #2. When it is not the yellow light outputs will operate at about 10% duty cycle (PWM). The red light outputs has double the strobe frequency of the other outputs, being in sync with both #1 and #2.

I/O

Inputs

  1. PD6 - Flash signal (Optoisolator)

Outputs

  1. PB0 + Red light
  2. PB1 - Aux 1
  3. PB2 - Aux 2
  4. PB3 - Yellow light 1 (PWM)
  5. PB4 - Yellow light 2 (PWM)

LEDs

Pluggable-led-connector-g25oxg.png

Images

Schematic drawing

Strobe-light-controller-circuit-4nmdeq.png

Parts list

Qty. Part
1 AVR ATtiny2313-20PU, DIL-20, 20 MHz, 18 I/Os
1 Capacitor, aluminium electrolytic, 10 µF, 25V
2 Capacitor, aluminium electrolytic, 47 µF, 25V
1 Capacitor, ceramic, 1 nF, 100V
1 Capacitor, metallized polyester foil, 0.01 µF
1 DIL socket, 20-pin, 7.62mm
1 DIL socket, 6-pin, 7.62mm
1 Enclosure, plastic (1591 FL), 100x50x25mm, flange
1 Fuse 5x20 mm, 500 mA, fast-acting
1 Fuse 5x20 mm, 1 A, fast-acting
2 Fuse holder, wire, 5x20 / 6.3x32mm
1 Heatsink, 27.3K/W, 19mm, attachable, TO220
1 Optocoupler, single, CNY17F-3, DIL-6
32 cm2 PCB, stripboard, 100x160mm, 160cm2
1 Resistor, carbon film, 0.25W, 330 Ω, 5%
7 Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
1 Resistor, carbon film, 0.25W, 10 kΩ, 5%
1 Resistor, metal film, 0.6W, 1 kΩ, 1%
8 Straight pin header, female, Single row, 2.54mm
9 Straight pin header, male, Single row, 2.54mm
16 Terminal block, screw, 2.5 mm
1 Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
4 Transistor, NPN, 800 mA, 45V, 0.625W, BC337-25
1 Transistor, PNP, 800 mA, 45V, 0.625W, BC327-25
1 Voltage regulator +5V, 2 A, L78S05CV
4 m Wire, stranded, 0.50mm2, Yellow
25 m Wire, stranded, 0.75mm2, Blue

Source code

Template:Basic code

'--------------------------------------------------------------
' Thomas Jensen
'--------------------------------------------------------------
' file: Vehicle_light_control2_v1.1
' date: 03/05/2010
'--------------------------------------------------------------
$regfile = "attiny2313.dat"
$crystal = 8000000
Config Portd = Input
Config Portb = Output
Config Watchdog = 1024

Dim A As Byte , B As Byte , Strobe_was_on As Bit
Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up

Const Pwm_off = 255 '255
Const Pwm_low = 235 '235
Const Pwm_high = 0 '0
Const On = 1
Const Off = 0

Portb = 0
Ddrb.3 = 1
Ddrb.4 = 1
Pwm1a = Pwm_off
Pwm1b = Pwm_off
Strobe_was_on = 0

If Pind.6 = 1 Then
   Waitms 100
   For A = 1 To 20
   Decr Pwm1a                                               'decr
   Waitms 20
   Next A
   Waitms 100
   For A = 1 To 20
   Decr Pwm1b                                               'decr
   Waitms 20
   Next A
End If

Start Watchdog

Main:
If Pind.6 = 1 Then
   Waitms 10

   If Strobe_was_on = 1 Then                                'sidelights on
      Portb.0 = Off
      Pwm1a = Pwm_low
      Pwm1b = Pwm_low
      Portb.1 = Off
      Portb.2 = Off
      Strobe_was_on = 0
   End If
End If

If Pind.6 = 0 Then
   Strobe_was_on = 1

   'signal 1
For B = 1 To 2
   For A = 1 To 3
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100

   For A = 1 To 3
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.2 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100
Next B

   'signal 1-all
   For A = 1 To 3
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Portb.2 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100

   'signal 2
For B = 1 To 2
   For A = 1 To 5
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Waitms 20
      Reset Watchdog
   Next A
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Waitms 100
   Reset Watchdog

   For A = 1 To 5
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.2 = Off
      Waitms 20
      Reset Watchdog
   Next A
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.2 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.2 = Off
      Waitms 100
   Reset Watchdog
Next B

   'signal 2-all
   For A = 1 To 5
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Portb.2 = Off
      Waitms 20
      Reset Watchdog
   Next A
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Portb.2 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Portb.2 = Off
      Waitms 100
   Reset Watchdog

   'signal 3
For B = 1 To 2
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Waitms 100
      Reset Watchdog
   For A = 1 To 2
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100

      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.2 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.2 = Off
      Waitms 100
      Reset Watchdog
   For A = 1 To 2
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.2 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100
Next B

   'signal 3-all
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Portb.2 = On
      Waitms 300
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Portb.2 = Off
      Waitms 100
      Reset Watchdog
   For A = 1 To 2
      Portb.0 = On
      Pwm1a = Pwm_high
      Pwm1b = Pwm_high
      Portb.1 = On
      Portb.2 = On
      Waitms 50
      Portb.0 = Off
      Pwm1a = Pwm_off
      Pwm1b = Pwm_off
      Portb.1 = Off
      Portb.2 = Off
      Waitms 50
      Reset Watchdog
   Next A
      Waitms 100

End If

Reset Watchdog 'loop cycle
Goto Main
End