Page 1 of 1

ECIO 40 and comms

Posted: Sat Apr 24, 2010 8:14 am
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.

Re: ECIO 40 and comms

Posted: Mon Apr 26, 2010 10:51 am
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.