Warning lights unit 2

From uCtrl.net

Jump to: navigation, search
Warning lights unit 2

WLU2, driven by AVR ATTiny2313.

Contents

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

Kontakt-aux-2-12V.png

Parts list

Quantity Supplier Part number Description
1 Elfa 73-646-56 AVR-RISC, ATtiny2313-20PI
1 Elfa 50-348-55 Plastic Enclosure (1551), 50x50x20mm
1 Elfa 50-197-16 Plastic Enclosure (1591 FL), 100x50x25mm fixed install.
1 Elfa 48-161-53 DIL socket, 20-pin, 7,62mm
1 Elfa 48-161-04 DIL socket, 6-pin, 7,62mm
2 Elfa 70-003-91 Rectifier diode, 1A 400V, 1N4004
1 Elfa 75-612-36 Heatsink, 27.3 K/W, 19mm, attachable, TO220
21 Elfa 48-356-90 Terminal block, screw, 2,5 mm
1 Elfa 67-008-01 Aluminium electrolytic capacitor, 10uF 25V
2 Elfa 67-008-68 Aluminium electrolytic capacitor, 47uF 25V
1 Elfa 65-851-94 Ceramic Disc Capacitor, 1 nF 100V
1 Elfa 65-550-64 Foil capacitor, 0,01uF
1 Elfa 48-326-06 Laboratory card, 100x160mm (1/5)
4 Elfa 55-284-43 Stranded Wire, 0.50mm2, 16x0.2mm 50 V yellow
25 Elfa 55-330-62 Stranded Wire, 0.75mm2, 20x0,21mm blue
1 Elfa 60-722-84 Metal film resistor 1% 0,6W, 1 K
1 Elfa 60-106-15 Carbon film resistor 5% 1/4W, 10 K
1 Elfa 60-104-33 Carbon film resistor 5% 1/4W, 330 Ohm
7 Elfa 60-105-73 Carbon film resistor 5% 1/4W, 4,7 K
1 Elfa 75-355-94 Optocoupler DIL-6, CNY17F-3
8 Elfa 43-708-05 Socket connector 2,54, 1×36, female
9 Elfa 43-702-19 Straight pin header 2,54, 1×36, PCB
1 Elfa 37-162-22 Relay 2 contacts, PCB, 12V, 1 A 120V
1 Elfa 33-167-59 Fuse 5x20 mm, 1.0A, quick-acting
1 Elfa 33-167-26 Fuse 5x20 mm, 500 mA, quick-acting
2 Elfa 33-152-31 Fuse Holder, wire, 5x20 / 6,3x32mm
1 Elfa 73-095-60 Voltage regulator +5V, L78S05CV 2.0A
1 Elfa 71-049-46 Transistor BC327-25, PNP, 45V 0.5A 0.8W
4 Elfa 71-049-87 Transistor BC337-25, NPN, 45V 0.5A 0.8W
1 Elfa 71-027-59 Transistor BC547B, NPN, 45V 0.1A 0.625W

Images

Schematic drawing

Wlu2 circuit.png

Source code

The program is written in basic, using Bascom-AVR.

'--------------------------------------------------------------
'                         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
Personal tools
Namespaces
Variants
Actions
Navigation
Categories
projects
Toolbox