I have a piece of VB6 code that sends command to a Picaxe 28X1. Those commands consist of 3 bytes in a row - first one is the command code, the next two are parameters. I'm running the 28X1 at 16 MHz (external resonator) and the serial speed is 19200 baud.
My intial VB6 code was this (command, param1 and param2 are byte variables):
My problem was - about 20% of the transmission attempts failed because the Picaxe received corrupted data (I can tell it did receive something - but corrupted - because the Picaxe responds with a checksum - a single byte that is all three data byte xor'ed together.
Now after a lot of troubleshooting (with the side benefit that I made the communication code much more failure tolerant so it wouldn't get stuck when a transmission did not go through) I discovered that if I insert short pauses (1 msec) between the transmission, it suddenly starts to work flawlessly, no more corrupted data at all:
Has anybody experienced similar problems? Also, I did not yet check if serin behaves the same, but suspect it will (since both are software serial routines). It may also explain why on a previous project I couldn't get it to work at all when sending all three commands in a row:
which was the reason that I split it up into three commands in the first place.
I tried several different computers (laptops as well as desktops, all running Windows XP), with the same outcome.
As an additional question, it looks like sertxd automatically does a "reconnect" after it receives data, is that true?
My intial VB6 code was this (command, param1 and param2 are byte variables):
Code:
.Output = Chr(Command)
.Output = Chr(Param1)
.Output = Chr(Param2)
Now after a lot of troubleshooting (with the side benefit that I made the communication code much more failure tolerant so it wouldn't get stuck when a transmission did not go through) I discovered that if I insert short pauses (1 msec) between the transmission, it suddenly starts to work flawlessly, no more corrupted data at all:
Code:
.Output = Chr(Command)
Sleep 1
.Output = Chr(Param1)
Sleep 1
.Output = Chr(Param2)
Sleep 1
Code:
.Output = Chr(Command) & Chr(Param1) & Chr(Param2)
I tried several different computers (laptops as well as desktops, all running Windows XP), with the same outcome.
As an additional question, it looks like sertxd automatically does a "reconnect" after it receives data, is that true?
Last edited: