Serial Terminal:

Controlling RealTerm from Excel

RealtermDemo.xls is in Examples on Download page

 

Contents

Microsoft Excel is one of the easiest programming interfaces. Now you can do easy serial comms using Realterm.
  • There's no easier way to knock up a GUI
  • Send data live from cells to a display
  • read A-D data back into Excel and graph it

A Simple Demo

This demo shows how to

Download

Public RT As Object
'Realterm object is in workbook so it can be accessed from all sheets

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Realterm_Close
End Sub
Public Sub Realterm_Close()
If Not RT Is Nothing Then RT.Close
Set RT = Nothing
End Sub
Public Sub Realterm_Open()
Set RT = CreateObject("Realterm.RealtermIntf")
RT.HalfDuplex = True
RT.Caption = "Realterm Controlled from Excel"
RT.portopen = True
RT.SelectTabSheet ("I2C")
End Sub
Private Sub Workbook_Open()
' Could start Realterm here!
Realterm_Open
End Sub
Public Sub SendStringToLED(S As String)
'You need the I2CHelper DLL, and to register it for this to work
'http://www.i2cchip.com/digital_display_module.html#I2CHelper DLL
Dim IH As Object

Set IH = CreateObject("I2CHelper.M5451")
RT.PutString ("YW0000000000") 'this always resets the display
LED_Data = "Y101" + IH.Str2M5451D4(S)
RT.PutString (LED_Data)
End Sub
'-------------- Worksheet Code ---------------
Private Sub CommandButtonSendA1_Click()
ThisWorkbook.RT.PutString (Cells(1, 1))
End Sub
Private Sub CommandButtonSendA2ToLED1_Click()
ThisWorkbook.SendStringToLED (Cells(2, 1))
End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' This seems to be an unreliable excel event. Depending on your version
' of excel, it may not fire when you would expect it to!
Dim VRange As Range
Set VRange = Range("A2", "A2")
If Not Intersect(Target, VRange) Is Nothing Then _
ThisWorkbook.SendStringToLED (Cells(2, 1))
End Sub
Private Sub CommandButtonHideRealterm_Click()
ThisWorkbook.RT.Visible = Not ThisWorkbook.RT.Visible
End Sub

back to contents


Using Capture

When you want to get data from an instrument, just capture data to a file with Realterm, then have Scilab read the file. This is a "design pattern" that appears ugly, but has been easy to get going, and sucessful. It is well decoupled, which is what makes it so easy to do.

From Excel you may have to close the file while you read it from Excel, as Excel often locks files.

Simple DataLogging

back to contents


Books

This is what I used to write the example...


Contact Us

crun@users.sourceforge.net

back to contents