• 990.014 MuIN LCD - Computer display example in VB.NET

    In this article I'll show you how to realize a simple computer information display using free version of Visual Basic.NET (I'll use 2008 express edition) and a MuIN LCD.
    At the end of the article you can dowload source code too.

    On the display we are going to show:

    • Date and time as displayed by computer
    • Free Available space on a selected drive (percent and dimension in Mb or Gb ecc)
    • Free Available RAM (percent and dimension)
    • Temperature in C

    The display will look like this:


    In order to display temperature you'll need an LM35 temperature sensor. LM35 will be connected on port RA0 of MuIN LCD using a 1KOhm resistor and a 100nF polyester capacitor. Follow this schematic:

    Note
    For further informations please refer to LM35 datasheet and MuIN LCD datasheet and user manual. Remeber to close Jumper Logic/USB!

    VB.Net code is quite simple: we'll use a serial port component to send serial data over USB/VCom connection and 4 timers:


    Refresh of display informations is obtained using the timers "tick" event: one for every single display line.
    Note
    The code is optimized for use a 4x20 display.
    Refresh times for lines are different: e.g. Hard disk space is refreshed every 20 seconds.

    Time is obtained using string.format function:

    Code: [View]
    Dim DaS As String = String.Format("{0:ddd dd MMM \'yy HH\:mm}", Now)
    Available free space on the selected drive is obtained using a System.IO.DriveInfo object, drive letter is loaded from a combobox, in order to display percent we must get total free space too:

    Code: [View]
    ' Selected drive properties
    Dim Drive As New DriveInfo(cmbDrive.Text.Substring(0, 2))
    ' Total available free space (to all users)
    SpaceA = Drive.TotalFreeSpace
    ' Total space
    SpaceT = Drive.TotalSize
    Free available RAM is obtained using My.Computer.Info:

    Code: [View]
    ' Available physical memory
    Dim RamA As Long = My.Computer.Info.AvailablePhysicalMemory
    ' Total physical memory
    Dim RamT As Long = My.Computer.Info.TotalPhysicalMemory
    Temperature is calculated as the mean of 3 consecutive values. Every 1 second (TimerTemperature Tick) a command is sent to MuIN LCD in order to read analog value. After the serial receive buffer is set an event will occur (SerialPort1.DataReceived): here we sum 3 values and got the mean.
    Reading on port RA0 is obtained from first and second byte of serial received data as specified in MuIN LCD User Manual:

    Code: [View]
    rx = SerialPort1.ReadExisting
    and then (where t1 is the high-byte or analog reading on RA0 and t2 is the low byte):

    Code: [View]
    Dim ADVal As Integer
    Dim t1, t2 As Byte
    t1 = Asc(Mid(rx, 1, 1))
    t2 = Asc(Mid(rx, 2, 1))
    ADVal = (256 * t1) + t2
    The temperature mean will be multiplied by 0.5 to obtain the C value:

    Code: [View]
    Dim St As String = String.Format("{0:0.0}" & Chr(223) & "C", (TempMean * 0.5))
    Chr(223) is the degree symbol as stored in character rom of display (HD44780 Controller, Rom code A00), not ascii code on computer.

    Since we must wait some seconds before first temperature reading is ready, a [wait] string will shown on display:


    We must respect a minimum delay of 10mS every time a command is sent to display:

    Code: [View]
    System.Threading.Thread.Sleep(10)
    The application interface is minimal:



    You must select the COM port where MuIN LCD is attached and the Drive to monitor, then press "GO" button.
    Note
    You must connect MuIN LCD to computer before launch the application or COMport will not be displayed.
    If you select an empty drive (empty floppy drive or cd-rom) a warning message will be shown:



    Once application is running, "Go" button become "Stop" and COMport selection is disabled but you can change drive to monitor in real time.

    Feel free to edit and customize this software and share your experience in our forum.

    Code is distributed "as is" without any warranty. Do not use it for commercial purpose.

    Download "BIN" if you want use the executable or "SOURCE" if you want the source code.

    .NET Framework 3.5 required.

    If you want to edit source code, you need Visual Basic 2008 Express Edition (or 2010). Express version are freeware!