18f4550 and usb slave component
Moderator: Benj
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
18f4550 and usb slave component
I am currently using flowcode 4 ,and it has served me well,
I have a problem , when using usb slave component and serial , if you send a "0" (zero) it sops sending the rest of the string.
I am told to use the byte method,
I don't understand the byte method, I send 40 bytes every time I scan the chip.
questions
1) does version 6 behave this way, I am hoping it does not then a simple upgrade will resolve my problem.
I have a problem , when using usb slave component and serial , if you send a "0" (zero) it sops sending the rest of the string.
I am told to use the byte method,
I don't understand the byte method, I send 40 bytes every time I scan the chip.
questions
1) does version 6 behave this way, I am hoping it does not then a simple upgrade will resolve my problem.
- 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: 18f4550 and usb slave component
Hello,
In a string a value of 0 represents a null byte and indicates the end of the string.
A string is simply a sequence of bytes so if you can use the byte method instead to send the data from the string a byte at a time then it should work as expected.
As far as I know v6 will also have this issue with strings to allow actual string data to work correctly.
In a string a value of 0 represents a null byte and indicates the end of the string.
A string is simply a sequence of bytes so if you can use the byte method instead to send the data from the string a byte at a time then it should work as expected.
As far as I know v6 will also have this issue with strings to allow actual string data to work correctly.
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
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
Re: 18f4550 and usb slave component
thank you,
have no idea on how send 40 bytes across at one time.
have no idea on how send 40 bytes across at one time.
- 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: 18f4550 and usb slave component
Hello,
Create a byte array variable called data[40]
Create a byte variable called count.
Then the code should look something like this.
Create a byte array variable called data[40]
Create a byte variable called count.
Then the code should look something like this.
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
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
Re: 18f4550 and usb slave component
Thank you,
my problem is setting up the usb parameters,
must it have a slave service macro name,
what must the slave service macro parameters be set as.
must I initialize the slave
must I run the slave.
thanks
Roy
my problem is setting up the usb parameters,
must it have a slave service macro name,
what must the slave service macro parameters be set as.
must I initialize the slave
must I run the slave.
thanks
Roy
- 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: 18f4550 and usb slave component
Hi Roy,
The service macro is recommended, the component help file should details what the slave service macro will do for you.
If your sending data then you can simply do it at the end of the slave service macro and then on the PC side you simply send then receive to allow the slave macro to fire and return data.
The service macro is recommended, the component help file should details what the slave service macro will do for you.
Yes it won't compile without this.must it have a slave service macro name,
Depends what format the data is in that your sending from the PC and what you want to do with that data.what must the slave service macro parameters be set as.
Yes this starts up the USBmust I initialize the slave
Up to you but it's recommended.must I run the slave.
If your sending data then you can simply do it at the end of the slave service macro and then on the PC side you simply send then receive to allow the slave macro to fire and return data.
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
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
Re: 18f4550 and usb slave component
I don't think I am calling it from vb properly, this is my subroutine.
Private Sub Command605_Click()
Dim lRetVal As Long
Dim bDataOut(0 To 40) As Byte
Dim bDataIn(0 To 40) As Byte
Dim nTxDataCnt As Long
Dim nRxDataCnt As Long
Dim sID(0 To 20) As Byte
sID(0) = Asc("v")
sID(1) = Asc("i")
sID(2) = Asc("d")
sID(3) = Asc("_")
sID(4) = Asc("1")
sID(5) = Asc("2")
sID(6) = Asc("b")
sID(7) = Asc("f")
sID(8) = Asc("&")
sID(9) = Asc("p")
sID(10) = Asc("i")
sID(11) = Asc("d")
sID(12) = Asc("_")
sID(13) = Asc("f")
sID(14) = Asc("f")
sID(15) = Asc("0")
sID(16) = Asc("5")
sID(17) = 0
bDataOut(0) = 10
bDataOut(1) = 220
lRetVal = ECIO_Open(0, sID(0))
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 2, nRxDataCnt, 500)
ECIO_Close
Me.Borehole_refill_rate_confirmed = bDataIn(0)
Me.Maximun_water_per_hour_confirmed = bDataIn(1)
End Sub
Private Sub Command605_Click()
Dim lRetVal As Long
Dim bDataOut(0 To 40) As Byte
Dim bDataIn(0 To 40) As Byte
Dim nTxDataCnt As Long
Dim nRxDataCnt As Long
Dim sID(0 To 20) As Byte
sID(0) = Asc("v")
sID(1) = Asc("i")
sID(2) = Asc("d")
sID(3) = Asc("_")
sID(4) = Asc("1")
sID(5) = Asc("2")
sID(6) = Asc("b")
sID(7) = Asc("f")
sID(8) = Asc("&")
sID(9) = Asc("p")
sID(10) = Asc("i")
sID(11) = Asc("d")
sID(12) = Asc("_")
sID(13) = Asc("f")
sID(14) = Asc("f")
sID(15) = Asc("0")
sID(16) = Asc("5")
sID(17) = 0
bDataOut(0) = 10
bDataOut(1) = 220
lRetVal = ECIO_Open(0, sID(0))
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 2, nRxDataCnt, 500)
ECIO_Close
Me.Borehole_refill_rate_confirmed = bDataIn(0)
Me.Maximun_water_per_hour_confirmed = bDataIn(1)
End Sub
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
Re: 18f4550 and usb slave component
I have another idea and not sure if I am correct,
do I have to run the command. lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 2, nRxDataCnt, 500)
for every byte I want to send and receive.
in other words a subroutine that will loop through 40 times until all data is sent/received.
do I have to run the command. lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 2, nRxDataCnt, 500)
for every byte I want to send and receive.
in other words a subroutine that will loop through 40 times until all data is sent/received.
- 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: 18f4550 and usb slave component
Hello,
Looking at the code yes it sends off the byte in individual transactions so that's a bit annoying but you could have 40 transactions for each slave service macro and this should work.
Looking back at the string routines, there is nothing I can see that would say to specifically bail out on a 0 but there could be something lurking or at the PC end which is truncating the string at the null byte.
Looking at the code yes it sends off the byte in individual transactions so that's a bit annoying but you could have 40 transactions for each slave service macro and this should work.
Looking back at the string routines, there is nothing I can see that would say to specifically bail out on a 0 but there could be something lurking or at the PC end which is truncating the string at the null byte.
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
-
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- Contact:
Re: 18f4550 and usb slave component
right I have done it, it works.
maybe not the most efficient way, but I cannot see any other way to do it.
what I did was use the two bite method, a command byte and a data byte.
the command I first reset the counters and read the inputs into a variable.,
then I write to the chip ,
and finally I read from the chip.
all by changing the command byte.
maybe someone can tell me if this is the most efficient way of doing it
here is my vb code.
bDataOut(0) = 3 ' a value of 3 is to reset counters to 0
lRetVal = ECIO_Open(0, sID(0))
lRetVal = ECIO_Transmit(bDataOut(0), 1, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
For i = 1 To 11
bDataOut(0) = 1 ' a 1 is to write values to board
bDataOut(1) = bDataOutc(i)
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
Next i
For i = 1 To 8
bDataOut(0) = 2 ' a 1 is to read values from board
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
bDataInc(i) = bDataIn(0)
Next I
maybe not the most efficient way, but I cannot see any other way to do it.
what I did was use the two bite method, a command byte and a data byte.
the command I first reset the counters and read the inputs into a variable.,
then I write to the chip ,
and finally I read from the chip.
all by changing the command byte.
maybe someone can tell me if this is the most efficient way of doing it
here is my vb code.
bDataOut(0) = 3 ' a value of 3 is to reset counters to 0
lRetVal = ECIO_Open(0, sID(0))
lRetVal = ECIO_Transmit(bDataOut(0), 1, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
For i = 1 To 11
bDataOut(0) = 1 ' a 1 is to write values to board
bDataOut(1) = bDataOutc(i)
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
Next i
For i = 1 To 8
bDataOut(0) = 2 ' a 1 is to read values from board
lRetVal = ECIO_Transmit(bDataOut(0), 2, nTxDataCnt, bDataIn(0), 1, nRxDataCnt, 10)
bDataInc(i) = bDataIn(0)
Next I
- Attachments
-
- borehole controller standalone tester byte.fcf
- (18.87 KiB) Downloaded 230 times