SLCom Overview: The demo project
We have included a demo project with the SLCom control. The best way to get started with the control is to explore the demo project.
The demo project is distributed with the SLCom control. It consists of a sample VB6 application using the control, plus a matching SPLat program.
The SPLat program is written for an MMi99 (or the older MMi88) (which has convenient front panel push button inputs). You can easily modify it to suit most standard SPLat boards by changing the EQUates and wiring a couple of external push button switches into your board.
The SPLat application is a nonsense program, designed to illustrate a few typical aspects of SPLatLink usage. It does the following:
- Rotates a single ON output around outputs 0-7, giving a moving spot effect. The speed of rotation depends on a memory variable (location 6), and can vary from 10mS to 2550mS per step. The output pattern is stored in Data Memory 0 to allow SPLatLink access with an MMi88 (SPLatLink in the MMi88 does not support the OutValue property).
- Responds to inputs iCountUP and iCountDN (two push buttons) by counting up or down a floating point counter located at 20-23.
Please study the program and experiment with it until you understand it. Make sure you don't permanently alter it!
The VB6 application implements a setup and control interface for the SPLat program. It has the following features:
- Connect and disconnect buttons.
- Display of the 8 rotating outputs. This has a choice of access method: Directly from the OutValue property for MMi99 or by storing an output image in Data Memory (RAM) if used with an MMi88.
- The ability to modify the rotation speed (step interval) and commit it to permanent memory with a PermStore operation.
- Display of the floating point counter, and a count reset button.
- Display of analog input C (AnInC). The MMi99 has an analog input, the MMi88 does not.
- A status display showing the connect state.
Because VB6 doesn't handle the movement of project files between folders, it is best to rebuild the project. Simply start a new exe project, remove the default form1 created by VB6 and then add the demo project's form1.frm. You may also have to re-insert the SLCom.ocx control. If VB6 somehow fails to load the control, you will find a picturebox control named SLCom1. Delete it, then add SLCom.ocx to the toolbar (right-click the toolbar and select Components..., from there find SLCom.ocx and check it). Then add an instance of SLCom to Form1.
There are a number of subtleties and refinements in the program. Have fun exploring them! There are also many features that could be added.
Here are a few things for you to explore:
- The relationship between rotate speed, ScanInterval and what is actually shown on the PC screen. The PC will not always show the true picture, because the board can change its outputs much faster than they can be communicated to the PC.
- How we get an initial readout of speed, but only update the PC display once. Why did we do it that way?
- The trap for NotValidFP in the MemChange event.
- It is possible to crash the program by doing the wrong thing as an innocent end-user. Add checks so it become rock solid, giving the user a message for each violation. We've done it for attempting a "Commit" when not connected. Alternatively disable/enable relevant controls in sympathy with Connected and Disconnected events.