Online environmental and signal unit
From uCtrl.net
Contents |
Information
OESU has two analog sensors: temperature (LM35) and light intensity (TSL252R), five colored LEDs for signals and a buzzer. The analog values are reported back in a range from 0 to 999. See formula further down. The values are not automatically sent, they have to be request by Serial Server. By using third part software it's also possible to make graphs. Green, yellow and red LED are set to copy the stack light, while the white and blue can be controlled freely by Serial Server.
Commands
- Inputs
- Value from temperature sensor
- Value from light sensor
- Switch 1 status
- Switch 2 status
- Outputs
I/O
Inputs
- PC0 Temperature
- PC1 Light intensity
- PC2 Switch 1
- PC3 Switch 2
Outputs
- PB0 LED white
- PB1 LED green
- PB2 LED yellow
- PB3 LED red
- PB4 LED blue
- PB5 Buzzer
- PD5 Link act.
- PD6 Mute LED
- PD7 Life LED
Communication
Interfacing is done with RS-232, using MAX232 or MAX202.
Analog inputs:
21:31:51 => 003:i:02:19:176 21:31:50 <= 003:i:02 21:31:46 => 003:i:01:54:174 21:31:45 <= 003:i:01
Serial settings
- Baud
- 9600
- Data bits
- 8
- Parity
- None
- Stop bits
- 1
- Start command
- *
- Module ID
- 003
Parts list
| Quantity | Supplier | Part number | Description |
| 1 | Elfa | 73-672-04 | AVR-RISC, ATmega8-16PI |
| 1 | Elfa | 50-197-40 | Plastic Enclosure (1591 FL), 150x80x50mm fixed install. |
| 1 | Elfa | 44-055-02 | D-Sub soldering cups, 9 pin female |
| 1 | Elfa | 48-161-38 | DIL socket, 16-pin, 7,62mm |
| 1 | Elfa | 48-161-87 | DIL socket, 28-pin, 7,62mm |
| 1 | Elfa | 70-003-91 | Rectifier diode, 1A 400V, 1N4004 |
| 4 | Elfa | 48-884-18 | Unthreaded round spacer, 3mm, Ø6mm |
| 1 | Elfa | 25-962-37 | D-sub cable, pin-to-pin 5m, 9-pin male-female |
| 1 | Elfa | 75-612-36 | Heatsink, 27.3 K/W, 19mm, attachable, TO220 |
| 1 | Elfa | 67-008-01 | Aluminium electrolytic capacitor, 10uF 25V |
| 5 | Elfa | 67-013-12 | Aluminium electrolytic capacitor, 1uF 50V |
| 2 | Elfa | 67-008-68 | Aluminium electrolytic capacitor, 47uF 25V |
| 2 | Elfa | 65-851-94 | Ceramic Disc Capacitor, 1 nF 100V |
| 2 | Elfa | 65-550-64 | Foil capacitor, 0,01uF |
| 1 | Elfa | 48-396-76 | Laboratory card, 100x160mm (1/5) |
| 1 | LED1.de | 50747302 | LED 5mm clear, Blue, 3.4V, 20mA, 7.200mcd, 20° |
| 1 | LED1.de | 51051001 | LED 5mm clear, Green, 3.4V, 20mA, 10.000mcd, 25° |
| 1 | LED1.de | 51059001 | LED 5mm clear, Yellow, 2.1V, 20mA, 10.000mcd, 20° |
| 1 | LED1.de | 51200001 | LED 5mm clear, White, 2.95V, 20mA, 12.000mcd, 20° |
| 1 | LED1.de | 50762002 | LED 5mm clear, Red, 2.1V, 20mA, 7.000mcd, 20° |
| 1 | Elfa | 75-061-65 | LED 5mm, Yellow, 2.0V, 20mA, 10mcd, 30° |
| 1 | Elfa | 75-007-13 | LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30° |
| 1 | Elfa | 75-056-21 | LED lense 5mm, CLF 280, blue |
| 1 | Elfa | 75-056-13 | LED lense 5mm, CLF 280, green |
| 1 | Elfa | 75-056-39 | LED lense 5mm, CLF 280, yellow |
| 1 | Elfa | 75-056-47 | LED lense 5mm, CLF 280, clear |
| 1 | Elfa | 75-056-05 | LED lense 5mm, CLF 280, red |
| 2 | LED1.de | 805082 | LED holder 5mm, Black plastic |
| 2 | Elfa | 55-722-35 | Control cable 4-cores, 0,25mm2, 14x0,15mm 250 V, Ø 4,6mm |
| 1 | Elfa | 73-221-34 | Light-to-voltage sensor, TSL 252R, 9.4mV / (μW/cm2) |
| 1 | Elfa | 73-023-26 | MAX232, CPE RSR232double |
| 2 | Elfa | 60-106-15 | Carbon film resistor 5% 1/4W, 10 K |
| 2 | Elfa | 60-103-75 | Carbon film resistor 5% 1/4W, 100 Ohm |
| 1 | Elfa | 60-103-83 | Carbon film resistor 5% 1/4W, 120 Ohm |
| 2 | Elfa | 60-103-91 | Carbon film resistor 5% 1/4W, 150 Ohm |
| 2 | Elfa | 60-104-33 | Carbon film resistor 5% 1/4W, 330 Ohm |
| 2 | Elfa | 60-105-73 | Carbon film resistor 5% 1/4W, 4,7 K |
| 3 | Elfa | 60-104-58 | Carbon film resistor 5% 1/4W, 470 Ohm |
| 33 | Elfa | 43-708-05 | Socket connector 2,54, 1×36, female |
| 33 | Elfa | 43-702-19 | Straight pin header 2,54, 1×36, PCB |
| 1 | Elfa | 33-167-26 | Fuse 5x20 mm, 500 mA, quick-acting |
| 1 | Elfa | 33-150-17 | Open fuse holder, PCB, 5x20mm |
| 1 | Elfa | 33-150-25 | Open fuse holder, PCB, Protective cover |
| 3 | Elfa | 48-858-02 | Skrew, wood, recessed, 3x12mm, + |
| 1 | Elfa | 73-095-60 | Voltage regulator +5V, L78S05CV 2.0A |
| 1 | Elfa | 42-051-18 | Power Jack, panel, 2,1mm |
| 1 | Elfa | 42-048-97 | Power Jack, plug-in, 2,1mm |
| 1 | Elfa | 37-782-06 | Alarm indicator 95 dB, panel, 24x18 mm, 10–26 V |
| 1 | Elfa | 73-090-57 | Temperature sensor LM35DZ, 0 to +100°C, +-0,6°C |
| 1 | Elfa | 71-049-87 | Transistor BC337-25, NPN, 45V 0.5A 0.8W |
| 1 | Elfa | 35-305-40 | Toggle switch, 1-pole, micro, (on)-off-(on) |
| 1 | Elfa | 35-333-46 | Rubber Boot, O-ring sealing |
Images
LEDs and switches |
|||
Temp and light sensor PCB |
|||
PCB connected |
PCB connected |
||
Schematic drawing
Source code
The program is written in basic, using Bascom-AVR.
'-------------------------------------------------------------- ' Thomas Jensen '-------------------------------------------------------------- ' file: AVR_OESU_v.1.0 ' date: 22/05/2007 '-------------------------------------------------------------- $regfile = "m8def.dat" $crystal = 8000000 $baud = 9600 Config Portb = Output Config Portd.5 = Output Config Portd.6 = Output Config Portd.7 = Output Config Portc.2 = Input Config Portc.3 = Input Dim W1 As Word , W2 As Word Dim Lifesignal As Word , Life As Integer , Send As String * 20 Dim Inn(4) As Byte , A As Byte , A2 As String * 1 Dim Serialcharwaiting As Byte , Serialchar As Byte Dim Comminput As String * 15 , Input_nr As String * 3 Dim Input_com As String * 1 , Input_ut As String * 2 Dim Input_stat As String * 1 , Led As Byte , Ut(7) As Byte Dim Ut_t(6) As Word , B As Byte Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Const Id = "003" Life = 1000 Waitms 5000 Top: Serialcharwaiting = Ischarwaiting() If Serialcharwaiting = 1 Then Serialchar = Inkey() Goto Myroutine End If Goto Main Myroutine: Select Case Serialchar Case 42 '* Goto Set_value End Select Main: 'input send off signal For A = 3 To 4 If Inn(a) = 1 Then Led = 103 A2 = Str(a) If Len(a2) < 2 Then A2 = "0" + A2 Send = Id + ":i:" + A2 + ":0:" Print Send ; Checksum(send) End If Next A 'input send on signal If Inn(1) = 1 Then 'input 1 W1 = Getadc(0) If W1 > 999 Then W1 = 999 Led = 103 Send = Id + ":i:01:" + Str(w1) + ":" Print Send ; Checksum(send) Inn(1) = 0 End If If Inn(2) = 1 Then 'input 2 W2 = Getadc(1) If W2 > 999 Then W2 = 999 Led = 103 Send = Id + ":i:02:" + Str(w2) + ":" Print Send ; Checksum(send) Inn(2) = 0 End If If Pinc.2 = 0 Then 'input 3 If Inn(3) = 0 Then Led = 103 Send = Id + ":i:03:1:" Print Send ; Checksum(send) End If Inn(3) = 250 End If If Pinc.3 = 0 Then 'input 4 If Inn(4) = 0 Then Led = 103 Send = Id + ":i:04:1:" Print Send ; Checksum(send) End If Inn(4) = 250 End If 'set input counters For A = 3 To 4 If Inn(a) > 0 Then Decr Inn(a) Next A 'set output counters For B = 1 To 6 If Ut_t(b) > 0 Then Decr Ut_t(b) Next B 'handle outputs For B = 1 To 5 If Ut(b) = 1 And Ut_t(b) = 0 Then Ut_t(b) = 667 Next B If Ut(6) = 2 And Ut_t(6) = 0 Then Ut_t(6) = 5001 If Ut(6) = 1 Then Ut_t(6) = 1201 Ut(6) = 0 Send = Id + ":o:06:" + Str(ut(6)) + ":" Print Send ; Checksum(send) End If If Ut_t(1) = 334 And Ut(7) = 0 Then Portb.0 = 1 If Ut_t(1) = 1 Then Portb.0 = 0 If Ut_t(2) = 334 And Ut(7) = 0 Then Portb.1 = 1 If Ut_t(2) = 1 Then Portb.1 = 0 If Ut_t(3) = 334 And Ut(7) = 0 Then Portb.2 = 1 If Ut_t(3) = 1 Then Portb.2 = 0 If Ut_t(4) = 334 And Ut(7) = 0 Then Portb.3 = 1 If Ut_t(4) = 1 Then Portb.3 = 0 If Ut_t(5) = 334 And Ut(7) = 0 Then Portb.4 = 1 If Ut_t(5) = 1 Then Portb.4 = 0 If Ut_t(6) = 1101 And Ut(7) = 0 Then Portb.5 = 1 If Ut_t(6) = 701 Then Portb.5 = 0 If Ut_t(6) = 301 And Ut(7) = 0 Then Portb.5 = 1 If Ut_t(6) = 201 Then Portb.5 = 0 If Ut_t(6) = 101 And Ut(7) = 0 Then Portb.5 = 1 If Ut_t(6) = 1 Then Portb.5 = 0 'led timer If Led > 0 Then Decr Led If Led = 100 Then Portd.5 = 1 If Led = 0 Then Portd.5 = 0 'lifestring If Life > 0 Then Decr Life If Life = 0 Then Led = 103 Send = Id + ":s:01:1:" Print Send ; Checksum(send) Life = 20000 End If 'lifesignal If Lifesignal > 0 Then Decr Lifesignal If Lifesignal = 500 Then If Ut(7) = 1 Then Portd.6 = 1 If Ut(7) = 0 Then Portd.7 = 1 End If If Lifesignal = 0 Then Portd.6 = 0 Portd.7 = 0 Lifesignal = 2100 End If Waitms 1 Goto Top End Set_value: Input Comminput Noecho 'read serialport Input_nr = Left(comminput , 3) 'id check Input_com = Mid(comminput , 5 , 1) 'command check Input_ut = Mid(comminput , 7 , 2) 'output nr check Input_stat = Mid(comminput , 10 , 1) 'output stat check 'output If Input_nr = Id Then If Input_com = "o" Then Led = 103 Select Case Input_ut Case "01" 'output 1 If Input_stat = "1" Then Ut(1) = 1 If Input_stat = "0" Then Ut(1) = 0 Send = Id + ":o:01:" + Str(ut(1)) + ":" Print Send ; Checksum(send) Case "02" 'output 2 If Input_stat = "1" Then Ut(2) = 1 If Input_stat = "0" Then Ut(2) = 0 Send = Id + ":o:02:" + Str(ut(2)) + ":" Print Send ; Checksum(send) Case "03" 'output 3 If Input_stat = "1" Then Ut(3) = 1 If Input_stat = "0" Then Ut(3) = 0 Send = Id + ":o:03:" + Str(ut(3)) + ":" Print Send ; Checksum(send) Case "04" 'output 4 If Input_stat = "1" Then Ut(4) = 1 If Input_stat = "0" Then Ut(4) = 0 Send = Id + ":o:04:" + Str(ut(4)) + ":" Print Send ; Checksum(send) Case "05" 'output 5 If Input_stat = "1" Then Ut(5) = 1 If Input_stat = "0" Then Ut(5) = 0 Send = Id + ":o:05:" + Str(ut(5)) + ":" Print Send ; Checksum(send) Case "06" If Input_stat = "2" Then Ut(6) = 2 'output 6 If Input_stat = "1" Then Ut(6) = 1 If Input_stat = "0" Then Ut(6) = 0 Send = Id + ":o:06:" + Str(ut(6)) + ":" Print Send ; Checksum(send) Case "07" 'output 7 If Input_stat = "1" Then Ut(7) = 1 If Input_stat = "0" Then Ut(7) = 0 Send = Id + ":o:07:" + Str(ut(7)) + ":" Print Send ; Checksum(send) End Select End If If Input_com = "i" Then Select Case Input_ut Case "01" If Inn(1) = 0 Then Inn(1) = 1 'status input 1 Case "02" If Inn(2) = 0 Then Inn(2) = 1 'status input 2 Case "03" If Inn(3) = 0 Then Inn(3) = 2 'status input 3 Case "04" If Inn(4) = 0 Then Inn(4) = 2 'status input 4 End Select End If End If Goto Main End