sertxd - receiving variable length data

Ramy

New Member
I'm making a control board that interfaces with Logicator software running on a desktop PC. When receiving commands from logicator, sometimes I need to receive one byte of data and sometimes it is necessary to receive two bytes of data and I may to need to receive more if I implement motor control.

As far as I know the picaxe will only receive a set number of bytes, so what is the best and most reliable way to solve this problem?
 

hippy

Ex-Staff (retired)
The simplest way is to always send a fixed numbr of bytes and ignore those not required; the first byte can indicate what the command / meaning / number of the other bytes is. A subroutine can send a number of variables, so set the varables to be sent and call the subroutine, it doesn't matter what the other bytes sent are set to as they'll be ignored.
 

Ramy

New Member
Unfortunately I'm not sending the data. The data is being sent by the Logicator software and I have no control over how many bytes are sent.
 

hippy

Ex-Staff (retired)
When you say the bytes are "sent by the Logicator software", what are those data bytes are you doing to make those bytes sent ?

I presume you are 'clicking on something' within the software and that sends the bytes, but I don't know what that would be.
 

Ramy

New Member
I'm going to write all the data being sent here as decimal values because that's how i'm sending/receiving them in picaxe.

The software automatically sends '90' every few milliseconds to for the status of the digital inputs. It also periodically sends '23' to get the type of analogue sensor attached, and then sends '41' to get the values of the analogue sensors attached.

When I turn on/off any of the digital outputs in the logicator software, it sends two byte '20' + number from 0-255 representing which outputs I have turned on in the software.
 

Technical

Technical Support
Staff member
For the clarity of others reading this thread you appear to be using 'Universal Logicator' by using a PICAXE chip to emulate one of the traditional buffer box interfaces.

This is completely different to what people on this forum would normally expect, ie programming a PICAXE chip by developing a 'Logicator for PICs' flowchart.

Which protocol (buffer box setting) are you trying to use? Some are much simpler than others.
 

Ramy

New Member
Sorry if there was any confusion. I'm using Universal Logicator 5 and I'm trying to emulate an economatics smartbox, purely because I have a smartbox here and I can log serial communication between the smartbox.

If there's any other boxes which might be better/easier to emulate, or any which might let me use more than 8 digital outputs in logicator, please let me know. Also if you have any documentation on any of these boxes, it would be really handy.
 
Top