ECIO 40 and comms

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
User avatar
goldwingers
Posts: 118
Joined: Wed Sep 06, 2006 1:22 pm
Location: London
Been thanked: 1 time
Contact:

ECIO 40 and comms

Post by goldwingers »

I have set up an analog port to read as int ( 0-1024). I am trying to send the hex value of any given point through the com port.
The issue is when my VB2008 program reads the byte it comes back with 4 series of 0 - 255.

The ECIO is outputting hex values and the conversion is done in VB.
ie. turn pot from min to max. When 255 is reached the value returns to 0 and starts again to 255

The input routine in VB is as follows

TextBox1.AppendText(SerialPort1.ReadByte().ToString("x3"))
TextBox2.Text = Microsoft.VisualBasic.Right(TextBox1.Text, 3)
ana0.Text = Convert.ToInt32(Microsoft.VisualBasic.Mid(TextBox2.Text, 1, 3), 16)
Analogview.Analog2.AdvancedThermometer1.Value = ana0.Text

Any ideas would be helpful

Cheers Ian.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO 40 and comms

Post by Benj »

Hello Ian,

You are probably being limited by the communications method you are using. If this is USB, RS232 etc then you are probably dealing in 8-bit bytes. eg 0- 255.

To get around this you could instead convert the number to a string using the string manipulation functions this will allow you to send numbers larger then 255 but you will have to use VB to convert the value back into numeric data from a string of characters. eg in a string each byte is a character so "123" would be 3 bytes rather then a single byte with the value 123.

Otherwise you will have to send each byte seperatley from the ADC eg

ADCreading = SampleADC
ADCreadHigh = ADCreading >> 8
ADCreadLow = ADCreading & 0xff

Then transmit the bytes ADCreadLow and ADCreadHigh and use VB to recombine the values into one 16-bit variable.

Post Reply