
mtiberia
There is an issue when sending ASCII code through the UART ports.
For some reason the ASCII code is getting lost in the translation.
It is hit or miss, some codes make it through fine and some don't get sent at all. Error saying that the expression is not in quotes.
If the code is sent the received transmission shows a question mark.
I have included an example with the ASCII code 255, it gets sent but RX is a ? and not the y with two dots above it.
If you can correct this issue with the scripting you would have me sold on the EZ B.
Great platform and fun to use.
Thanks DJ
Start
1: UARTInit(0,1,1000000)
7: $handshake=GetAsByte(255) # ASCII code 255
8: UARTWrite(0,1,$handshake) # not all codes will be TX
10: Print($handshake)
> ΓΏ # symbol that code represents
14: Sleep(1000)
16: $x = UartAvailable(0, 1)
18: print("Bytes in buffer: " + $x)
> Bytes in buffer: 1
20: $TX_DATA = UARTRead(0, 1, $x)
22: print("Received: " + $TX_DATA)
> Received: ? # RX Issue or TX issue
25: Print ("done")
> done
Code:
Tell me what you expect to see in $data?
Do you expect to see many bytes? Or do you expect to see the values of each variable added together?
It just saves typing a separate line for each value and sending it.
Even if I send the data one at a time a still don't RX the proper value.
I'm sorry I used python to send data to the Dynamixel servos and Arduino nano.
and it is working.
String example
Code:
Math example...
Code:
What do you think $z would equal in each example?
What values are you RX in your console ?
Would you like me to give you the solution or would you prefer if I helped point you in the right direction so you can feel the achievement of discovering the answer yourself?
The issue that you have been experiencing is writing and reading from the UART too quickly. This is because you are testing by connecting the TX and RX together of a UART. The EZ-B and it's connection to the controlling device is multi threaded. This means that commands are sent in another thread of the CPU. You will need to sleep() before reading from the UART.
Normally, you would always need to sleep() a little to wait for the other device to respond. The other device that you are connecting too over the UART will have a small fraction of thinking time. It will then respond over it's connection speed. The sleep() should not be significant, but it is something you will need to practice.
A smarter programming model is to wait until the desired number of bytes have been received before processing the packet.
I have attached an example you can preview. Here it is
auart.EZB
I keep forgetting how fast things really happen in the scripting.
Maybe instead of sleeping a bit I can read a bunch of sensors or run a motion for my robot?
Use that extra time to do something else.
Thanks DJ I'm learning a lot.
Here's what I got.
All unsigned byte value to 127 are TX and RX correctly
Start
1: uartInit(0, 1, 1000000)
5: uartwrite(0, 1, "127")
7: sleep(100)
9: $x = uartavailable(0, 1)
11: $y = uartRead(0, 1, $x)
13: print("Bytes Read: " + $x)
> Bytes Read: 1
15: $test=GetByte($y)
17: print("Read: " + $test)
> Read: 127
Done (00:00:00.2496069)
All unsigned byte values from 128 to 255 are TX and RX incorrectly
Start
1: uartInit(0, 1, 1000000)
5: uartwrite(0, 1, "255")
7: sleep(100)
9: $x = uartavailable(0, 1)
11: $y = uartRead(0, 1, $x)
13: print("Bytes Read: " + $x)
> Bytes Read: 1
15: $test=GetByte($y)
17: print("Read: " + $test)
> Read: 63
Done (00:00:00.2183817
All unsigned byte values greater than 255 will get an error, which is correct
Start
1: uartInit(0, 1, 1000000)
5: uartwrite(0, 1, "256")
> Error on line 5: Value was either too large or too small for an unsigned byte.
Done (00:00:00.0311750)
Sorry to be a pain.
What do you think about the new Variable Watcher? Now that you can view Hex values?
Here is my Test Bed.
This is my results
I hope this can help.
Could the issue have to do with 7bit and 8bit as 7bit can count only to 0-127
and 8bit can store 0-255? <- Just thinking....
It's only when using the UART through the EZ script because EZ B can communicate with the dynamical servos that need the 8 bits to represent values from 0 to 255.
Awseome thanks DJ !
Now you can give Masimo Banzi a run for his money.
I'm surprised he hasn't made you offer you can't refuse.
Forget about it.
Thanks