Hi All
Just got another ECIO40, put in a simple input portB (all) to give a Byte output.
as
loop
input port B
sendbyte
endloop
I am inputting the byte into VB2008 but the returned byte is not as expected in such....
Sw 1 return 1
sw 2 returns 2
sw 3 returns 4
sw 4 returns 8
sw 5 returns 10 - expected 16
sw 6 returns 20 - expcted 32
sw 7 returns 40 - expected 64
sw 8 returns 80 - expected 128
Any ideas?.
Is it me or am i going crazy
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
- 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: Is it me or am i going crazy
Hello it looks like you are getting a hexadecimal output.
0x10 = 16
0x20 = 32
0x40 = 64
0x80 = 128
So the values you are getting are indeed correct.
Try holding down switches 3 and 4 and you will notice that the value changes from 4 or 8 to C which is 4 + 8.
0x10 = 16
0x20 = 32
0x40 = 64
0x80 = 128
So the values you are getting are indeed correct.
Try holding down switches 3 and 4 and you will notice that the value changes from 4 or 8 to C which is 4 + 8.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
Re: Is it me or am i going crazy
Hi Benj
OK but I am sendibg this out as a byte, why does it change to hex.
I will try this against a program I wrote for hex numbers and see what happens
Cheers
Ian
OK but I am sendibg this out as a byte, why does it change to hex.
I will try this against a program I wrote for hex numbers and see what happens
Cheers
Ian
- 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: Is it me or am i going crazy
Hello Ian,
It must be that VB is doing something strange when outputting the numbers. That is if you are simply sending the number as a byte. As far as I know you should be able to print out the number directly without modification to allow it to be printed out as decimal. Post up your VB code for the collection and outputting of the value if you like and I will see if I can spot the problem.
It must be that VB is doing something strange when outputting the numbers. That is if you are simply sending the number as a byte. As far as I know you should be able to print out the number directly without modification to allow it to be printed out as decimal. Post up your VB code for the collection and outputting of the value if you like and I will see if I can spot the problem.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
Re: Is it me or am i going crazy
Hi Benj,
'Data breakout
Public Sub DataRx()
While (SerialPort1.BytesToRead > 0)
TextBox1.AppendText(SerialPort1.ReadByte().ToString("x3"))
porta.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 1, 3)
portb.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 4, 3)
portc.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 7, 3)
Portd.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 10, 3)
Porte.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 13, 3)
'A0.Text = porta.Text
'a1.Text = portb.Text
'a2.Text = portc.Text
'a3.Text = Portd.Text
'a4.Text = Porte.Text
'a5.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 31, 3)
End While
End Sub
'Data breakout
Public Sub DataRx()
While (SerialPort1.BytesToRead > 0)
TextBox1.AppendText(SerialPort1.ReadByte().ToString("x3"))
porta.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 1, 3)
portb.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 4, 3)
portc.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 7, 3)
Portd.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 10, 3)
Porte.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 13, 3)
'A0.Text = porta.Text
'a1.Text = portb.Text
'a2.Text = portc.Text
'a3.Text = Portd.Text
'a4.Text = Porte.Text
'a5.Text = Microsoft.VisualBasic.Mid(TextBox1.Text, 31, 3)
End While
End Sub
- 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: Is it me or am i going crazy
Hello,
Im not sure if this will work in your version of VB but this command should convert a hexadecimal value into a decimal value ready for printing out.
Variable = Format$(Variable)
Im not sure if this will work in your version of VB but this command should convert a hexadecimal value into a decimal value ready for printing out.
Variable = Format$(Variable)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
Re: Is it me or am i going crazy
Thanks Benj
Sorted it out, The ECIO is sending Hex rather ascii. changed code to suit and now i can extract all 5 ports.
Now more coding
Sorted it out, The ECIO is sending Hex rather ascii. changed code to suit and now i can extract all 5 ports.
Now more coding