Module heartbeat monitor with 15 inputs and LCD

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 module was part of the rack box project — which was terminated when I moved out of my first apartment.
MSMU2 installed in the Rack box

Information

Every AVR driven module has an output with a pulsating signal called lifesignal. This is connected to MSMU2, if this signal should come to an end MSMU2 will sound a module timeout alarm. The signal needs to be absent for 10 seconds before the alarm sounds. MSMU2 can monitor 15 modules, a LCD display shows the status:

#n/a means not connected
Ok→21 means ok, and the remaining timeout

If a module should fail MSMU2 will only show the failed module numbers, alarms must be reset manually using a push button.

I/O

Inputs

  • PA2 Module 1
  • PA3 Module 2
  • PC2 Module 3
  • PC3 Module 4
  • PC4 Module 5
  • PC5 Module 6
  • PC6 Module 7
  • PC7 Module 8
  • PD0 Module 9
  • PD1 Module 10
  • PD2 Module 11
  • PD3 Module 12
  • PD4 Module 13
  • PD5 Module 14
  • PD6 Module 15
  • PD7 Reset

Outputs

Connectors

D-Sub 9-pin

  1. 5v
  2. 0v
  3. Reset
  4. Module error LED

D-Sub 15-pin

  • Module 1 → 15

LCD display

12345678
MSMU #2
Running
1  Ok>21
4  #n/a
10 FAIL!
Reset!

Images

Schematic drawing

Module-heartbeat-monitor-with-lcd-circuit-gypm0g.png

Parts used

Qty. Part
1 AVR AT90S8515-8PC, DIL-40, 8 MHz, 32 I/Os
1 Capacitor, aluminium electrolytic, 10 µF, 25V
2 Capacitor, ceramic, 22 pF, 100V
1 Capacitor, ceramic, 1 nF, 100V
1 D-Sub soldering cups, 15 pin female
1 D-Sub soldering cups, 9 pin male
1 DIL socket, 40-pin, 15.24mm
2 Diode, small signal, 1N4148/Ph
1 Enclosure, plastic (1591), 120x80x59mm
1 Fuse 5x20 mm, 500 mA, fast-acting
1 Fuse holder, open, PCB, 5x20mm
1 Fuse holder, open, PCB, Protective cover
1 LCD display, dot matrix, 16x1, LED green
1 LED 5mm clear, Blue, 4.9V, 20mA, 350mcd, 12°
1 LED 5mm clear, Green, 2.1V, 20mA, 385mcd, 6°
2 LED holder 5mm, RTC51, black plastic
2 Mounting bracket, DIN rail, Metal
1 Quartz crystal oscillator, 4 MHz
1 Resistor, carbon film, 0.25W, 120 Ω, 5%
18 Resistor, carbon film, 0.25W, 330 Ω, 5%
2 Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
16 Resistor, carbon film, 0.25W, 10 kΩ, 5%
1 Switch, push-button, 1-pole, 1A, 50VAC, off-(on)
1 Switch, toggle, 1-pole, micro, on-on
1 Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
1 Trimmer, carbon, 10 kΩ, horizontal

Source code

Template:Basic code

'--------------------------------------------------------------
' Thomas Jensen
'--------------------------------------------------------------
' file: AVR_MSMU2
' date: 23/12/2006
'--------------------------------------------------------------
$regfile = "8515def.dat"
$crystal = 4000000
Config Portd = Input
Config Portc = Input
Config Portb = Output
Config Porta.0 = Output
Config Porta.1 = Output
Config Porta.2 = Input
Config Porta.3 = Input
Config Watchdog = 1024

Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , Db7 = Portb.0 , E = Portb.6 , Rs = Portb.7
Config Lcd = 16 * 1

Dim A As Byte
Dim B As Byte
Dim Alarm As Integer
Dim Alarmled As Integer , Is_shown As Integer
Dim Modul(15) As Byte

Deflcdchar 0 , 32 , 4 , 2 , 31 , 2 , 4 , 32 , 32 ' pil

Alarm = 0
Alarmled = 0
Is_shown = 0
Const Timeout = 21

'boot
Porta.0 = 0
Porta.1 = 0

Cls
Cursor Off
Cls
Locate 1 , 1
Lcd "MSMU #2"

For A = 1 To 15
    Porta.0 = Not Porta.0
    Porta.1 = Not Porta.1
    Waitms 250
Next A

Porta.0 = 0
Porta.1 = 0

Cls
Locate 1 , 1
Lcd "Running"
Waitms 1500
Cls

Start Watchdog

Main:

'lcd display
For B = 1 To 15
Gosub Sjekk

    If Alarm <> 1 Then
    Is_shown = 1
    Waitms 50
    Locate 1 , 1
    Lcd B
      Locate 1 , 4
      If Modul(b) > 1 Then Lcd "Ok" ; Chr(0) ; Modul(b)
      If Modul(b) = 0 Then Lcd "#n/a "
      For A = 1 To 9
      Waitms 50
      Gosub Sjekk
      Next A
    End If

    If Modul(b) = 1 And Alarm = 1 Then
    Is_shown = 1
    Waitms 50
    Locate 1 , 1
    Lcd B
      Locate 1 , 4
      Lcd "FAIL!"
      For A = 1 To 9
      Waitms 50
      Gosub Sjekk
      Next A
    End If


Endoflcd:

If Is_shown = 1 Then
For A = 1 To 15
If Modul(a) > 1 Then Decr Modul(a)
If Modul(a) = 1 Then Alarm = 1
Next A

'lifelight
If Alarm = 0 Then Porta.1 = Not Porta.1
If Alarm = 1 Then Porta.1 = 0

'setting alarmled
If Alarm = 1 And Alarmled = 0 Then Alarmled = 2
If Alarmled > 0 Then Alarmled = Alarmled - 1
If Alarmled = 1 Then Porta.0 = 1
If Alarmled = 0 Then Porta.0 = 0
End If

Is_shown = 0
Cls
Next B
Cls

Goto Main
End

Sjekk:
'setting 15 second timeout
If Pina.2 = 0 And Modul(1) <> 1 Then Modul(1) = Timeout
If Pina.3 = 0 And Modul(2) <> 1 Then Modul(2) = Timeout
If Pinc.2 = 0 And Modul(3) <> 1 Then Modul(3) = Timeout
If Pinc.3 = 0 And Modul(4) <> 1 Then Modul(4) = Timeout
If Pinc.4 = 0 And Modul(5) <> 1 Then Modul(5) = Timeout
If Pinc.5 = 0 And Modul(6) <> 1 Then Modul(6) = Timeout
If Pinc.6 = 0 And Modul(7) <> 1 Then Modul(7) = Timeout
If Pinc.7 = 0 And Modul(8) <> 1 Then Modul(8) = Timeout
If Pind.0 = 0 And Modul(9) <> 1 Then Modul(9) = Timeout
If Pind.1 = 0 And Modul(10) <> 1 Then Modul(10) = Timeout
If Pind.2 = 0 And Modul(11) <> 1 Then Modul(11) = Timeout
If Pind.3 = 0 And Modul(12) <> 1 Then Modul(12) = Timeout
If Pind.4 = 0 And Modul(13) <> 1 Then Modul(13) = Timeout
If Pind.5 = 0 And Modul(14) <> 1 Then Modul(14) = Timeout
If Pind.6 = 0 And Modul(15) <> 1 Then Modul(15) = Timeout
Reset Watchdog

'reset
If Pind.7 = 0 Then
   Alarm = 0
   For A = 1 To 15
   Modul(a) = 0
   Next A
   Cls
   Locate 1 , 1
   Lcd "Reset!"
      For A = 1 To 9
      Waitms 50
      Reset Watchdog
      Next A
   Cls
   Waitms 50
   B = 0
   Goto Endoflcd
   End If

Return