Programming K8090 in Excel VBA

I have soldered a K8090 realy board and it works with the manual buttons, and with the Demo application version 1.0.

I would like to use the functions of the .dll file, but apparently the function declarations for Excel VBA are not available. Therefore I am trying to program the K8090 with standard RS232 calls. But I have a few problems.

In K8090/VM8090 PROTOCOL MANUAL the baud rate is specified at 19200 baud. However when I connect with the Demo application my device manager (Windows 7) tells me that the baud rate is 9600. Which is correct?

The protocol manager gives a log of the traffic on the RS232 bus. In this traffic I do not recognize the protocol specified in the manual. It seems from the Demo application the the device receives a character 55 (hex), 2 bytes resp. " mask relays on" and “mask relays off”, and one bite that is in my case always “00”. This would be a command string of 4 bytes. However, the PROTOCOL MANUAL, specifies a completely different command structure of 7 bytes: STX, Command, Mask, Parameter 1, parameter 2, checksum, ETX.

With all these uncertainties the trial end error method of getting this to work is going to take a long time! Can anybody give some advice?

In the meantime I have solved the problems. It is possible to control the relays with elementary RS232 commands. You do not need the Velleman dll file.

For the RS232 traffic I use a VB6 module downloaded from internet. This can also used in Excel VBA.

If anyone is interested send me an email at frans.westendorp@kpnmail.nl

I had some trouble with the checksum, the following may be helpful.

In the Velleman documentation the checksum is introduced as:

-(STX + CMD + MASK + PARAM1 + PARAM2) + 1

In VBA a correct function is:

Function Checksum(Commando As Byte, Mask As Byte) As Byte
Dim deSom As Integer
deSom = 4 + Commando + Mask
Checksum = ((deSom Mod 256) Xor 255) + 1
End Function

An interesting alternative function is:

Checksum=256-(deSom MOD 256)

Note that the MOD function is necessary for command values> 255. These occur in the relay module for instance when all relays are switched together