Is it me or am i going crazy

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

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:

Is it me or am i going crazy

Post by goldwingers »

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?.

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: Is it me or am i going crazy

Post by Benj »

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.

User avatar
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

Post by goldwingers »

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

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: Is it me or am i going crazy

Post by Benj »

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.

User avatar
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

Post by goldwingers »

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

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: Is it me or am i going crazy

Post by Benj »

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)

User avatar
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

Post by goldwingers »

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 :-)

Post Reply