Logo Banner

ELECTRONICS - [RS-232 Interface] - [page 4/4]

RS-232 Computer Interface

The software for the computer

I wrote a controlling program in Microsoft Visual Basic .NET. This program is very easy to use. It doesn't require any hardware drivers, besides the driver for the USB to RS/232 converters (if you are using one). This is a great advantage of the serial port: you can access it without any special drivers.

My sample application just shows a bunch of checkboxes. The actual number of checkboxes depends on the number of registers you specify: you can specify 1 to 15 shift registers (8 to 120 digital outputs). The checkbox at the left will control the concerned register's output QA, while the rightmost checkbox controls the output QH.

There are some additional buttons to set, clear or invert all outputs at once. You can press the Send button once the desired outputs are checked.

The green text box at the bottom of the screen will show the response of the last request to the PIC. It will show the date/time the last command was executed.

The BVinterface class

I wrote my own Visual Basic class to provide an easy access to this interface. You can control the interface by just using a few lines of programming code. The code below shows how you could write a program that uses COM10 for the communications. It defines only a single shift register (8 outputs). Once the connection is established all outputs are cleared, output 8 is activated and the output 1 is toggled for 10 times. This creates a flashing effect.

    Dim myInterface As New BVinterface()

    With myInterface
        .comPort = "COM10"  	' use COM10
        .shiftRegisters = 1 	' use 2 shift registers (16 outputs)
        .sendImmediately = True	' send each command immediately

        If .connect() Then
            .clearAllOutputs()  ' clear all outputs
            .setOutput(8)       ' set output 8

            ' run toggling function
            For cnt As Integer = 1 To 10
        End If
    End With		

Limitations of the system

For now the computer cannot read back the actual outputs from the interface circuit. The only exception are some status codes that are transmitted after the processing of each request. The software (BVinterface class) keeps track of the actual status. Of course this data will get lost when the software needs to be restarted. I will try to add this functionality in a later stage.

I still had a few problems with the hardware: sometimes the digital outputs has unexpected values. They also flickered during the shifting process. It turned out these problems were caused by my breadboard.


Here you can download a ZIP with all files for this project: the High-Tech C files and the Visual Basic files. You can open the files with the free versions of these programs: High-Tech C Lite and Visual Basic .NET Express.

Important Notice

This software is still in D.E.V.E.L.O.P.M.E.N.T. Some bugs may still exists and under certain circumstances the PIC may stop responding. You should *NOT* control any critical hardware with this circuit.

Please contact me if you have any feedback or suggestions for either the hardware circuit, the firmware or the computer software.

Copyright ©1998-2022 Vanderhaegen Bart - last modified: May 25, 2018