Warning lights unit

From uCtrl.net

Jump to: navigation, search
WALU25 with four LED warning lights.

WALU25, two channels and five programs, driven by AVR ATTiny2313.

Contents

Information

Using this control unit one can control four LED warning lights, using two channels. The Waning Lights Unit has five programs (sequences) that can be selected manually or cycled trough. When selecting manually the selection is stored in EEPROM and automatically started on power-up. Powered by 12V, suitable for usage in cars.

Sequences

  1. Flashing with fade
  2. 3 x strobe, pause
  3. Delayed flash
  4. Random pause strobe
  5. Strobe

I/O

Inputs

  1. PD0 Select program
  2. PD1 Run all programs

Outputs

  1. PB3 Channel 1 (PWM)
  2. PB4 Channel 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-197-32 Plastic Enclosure (1591 FL), 120x65x40mm fixed install.
1 Elfa 48-161-53 DIL socket, 20-pin, 7,62mm
1 Elfa 48-884-18 Unthreaded round spacer, 3mm, Ø6mm
2 Elfa 75-612-36 Heatsink, 27.3 K/W, 19mm, attachable, TO220
1 Elfa 48-351-04 Terminal block, pluggable, 3.5 mm, 2-pin skrew female
5 Elfa 48-351-53 Terminal block, pluggable, 3.5 mm, 2-pin vertical male
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)
1 Elfa 75-007-13 LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30°
1 LED1.de 805082 LED holder 5mm, Black plastic
4 Elfa 60-722-84 Metal film resistor 1% 0,6W, 1 K
2 Elfa 60-106-15 Carbon film resistor 5% 1/4W, 10 K
2 Elfa 60-104-33 Carbon film resistor 5% 1/4W, 330 Ohm
3 Elfa 60-105-73 Carbon film resistor 5% 1/4W, 4,7 K
8 Elfa 43-708-05 Socket connector 2,54, 1×36, female
3 Elfa 43-708-13 Socket connector 2,54, 2×36, female
8 Elfa 43-702-19 Straight pin header 2,54, 1×36, PCB
3 Elfa 43-704-33 Straight pin header 2,54, 2×36, PCB
1 Elfa 33-167-83 Fuse 5x20 mm, 2.0A, quick-acting
1 Elfa 33-150-17 Open fuse holder, PCB, 5x20mm
1 Elfa 73-095-60 Voltage regulator +5V, L78S05CV 2.0A
1 Elfa 42-051-18 Power Jack, panel, 2,1mm
2 Elfa 71-027-59 Transistor BC547B, NPN, 45V 0.1A 0.625W
2 Elfa 71-103-23 Transistor BD242C, PNP, 100V 3A 40W
1 Elfa 35-305-57 Toggle switch, 1-pole, micro, on-off-(on)
1 Elfa 35-305-16 Toggle switch, 1-pole, micro, on-on

Images

Schematic drawing

Walu25 circuit.png

Source code

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

'--------------------------------------------------------------
'                         Thomas Jensen
'--------------------------------------------------------------
'  file: AVR_LED_VARSEL_STYRING v1.5
'  date: 21/03/2008
'--------------------------------------------------------------
$regfile = "attiny2313.dat"
$crystal = 8000000
Config Portd = Input
Config Portb = Output
Config Watchdog = 1024
 
Dim Program As Byte , A As Byte , B As Byte , C As Byte , Mode_select As Byte , Random As Byte
Dim Random_counter As Integer , Eeprom As Eram Byte
Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
 
Ddrb.3 = 1
Ddrb.4 = 1
Pwm1a = 255
Pwm1b = 255
 
'get program from eeprom
If Eeprom < 1 Or Eeprom > 5 Then Eeprom = 1
Program = Eeprom
 
Start Watchdog
 
Main:
Select Case Program
 
'1: fade quick - no pause
Case 1
For A = 1 To 25
   Pwm1a = Pwm1a - 10
   Gosub Switches
   Waitms 10
Next A
   Waitms 10
   Gosub Switches
   Waitms 10
   Gosub Switches
For A = 1 To 25
   Pwm1a = Pwm1a + 10
   Gosub Switches
   Waitms 10
Next A
 
For A = 1 To 25
   Pwm1b = Pwm1b - 10
   Gosub Switches
   Waitms 10
Next A
   Waitms 10
   Gosub Switches
   Waitms 10
   Gosub Switches
For A = 1 To 25
   Pwm1b = Pwm1b + 10
   Gosub Switches
   Waitms 10
Next A
 
'2: pulse x 3 - pause 300ms
Case 2
For A = 1 To 3
   Pwm1a = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1a = 255
   For C = 1 To 5
   Waitms 10
   Gosub Switches
   Next C
Next A
   For C = 1 To 30
   Waitms 10
   Gosub Switches
   Next C
 
For A = 1 To 3
   Pwm1b = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1b = 255
   For C = 1 To 5
   Waitms 10
   Gosub Switches
   Next C
Next A
   For C = 1 To 30
   Waitms 10
   Gosub Switches
   Next C
 
'3: long pulse singel - long delay
Case 3
   Pwm1a = 0
   For C = 1 To 5
   Waitms 10
   Gosub Switches
   Next C
   Pwm1a = 255
   For C = 1 To 10
   Waitms 10
   Gosub Switches
   Next C
 
   Pwm1b = 0
   For C = 1 To 5
   Waitms 10
   Gosub Switches
   Next C
   Pwm1b = 255
   For C = 1 To 30
   Waitms 10
   Gosub Switches
   Next C
 
'4: pulse singel - pause random ms
Case 4
   Pwm1a = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1a = 255
   Random = Rnd(20)
   For C = 1 To Random
   Waitms 10
   Gosub Switches
   Next C
 
   Pwm1b = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1b = 255
   Random = Rnd(20)
   For C = 1 To Random
   Waitms 10
   Gosub Switches
   Next C
 
'5: strobe
Case 5
   Pwm1a = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1a = 255
   For C = 1 To 8
   Waitms 10
   Gosub Switches
   Next C
 
   Pwm1b = 0
   For C = 1 To 3
   Waitms 10
   Gosub Switches
   Next C
   Pwm1b = 255
   For C = 1 To 8
   Waitms 10
   Gosub Switches
   Next C
 
End Select
 
Goto Main
End
 
'switches, mode change and random
Switches:
If Pind.1 = 1 Then Mode_select = 0
If Pind.1 = 0 And Mode_select = 0 Then
   Mode_select = 1
   Program = Program + 1
   Eeprom = Program
End If
If Pind.0 = 0 Then
   Incr Random_counter
   If Random_counter > 600 Then
      Random_counter = 0
      Program = Program + 1
   End If
   Else
   Random_counter = 0
End If
 
If Program = 6 Then Program = 1
Reset Watchdog
 
Return
End
Personal tools
Namespaces
Variants
Actions
Navigation
Categories
projects
Toolbox