Hello, MIT community. I have a robot sending me lots of data, and I want to use some and graph it. Currently, the data I receive is in decimals, and I try to transform it in HEX to combine it then since I am receiving it in a 1byte ID - 2-bytes data structure. Overall I received 48 bytes. The issue is in Screen2 of the .aia file.
An example of the data is shown at the bottom of the screen.
Post the robot code.
You might be transmitting faster than AI2 can receive and process.
The robot code is needed also to see how data formats match up on the transmitting and receiving ends of the link.
The after 5 - I mean the first column is the data ID, which is constant until there is the shift after about 5 seconds. Each row is a different type of data that comes in two bites (decimals) that I have to convert in HEX and then join to reconvert into decimal.
As mentioned the negative conversion code I have works.
The positive using only convert number base 10 to hex doesn't. For example, if I have a decimal 162 I should get A2, but I get A3 instead similar goes with the second digit where I would get a correct conversion with a added 1infront of it. Weird things like this.
It could be..What is the max speed I can read in AI2? Unfortunately, I cannot post the code for reference. In the picgui in Matlab my baudrate is at 115200.
Do you mean adding an if statement that says if the number is higher than 0, multiply by -1?
Honestly, I think it is genius, and it should solve the issue in the short term. Although I still wonder why the convert number base 10 to hex does not work correctly.
1Mbit/s (1000000bit/s), 8N1, No HW-Flow Control
The main node sends at 100Hz.
The message contains 16 signals separated by a signal ID.
Each signal is sent as UINT16 (after being converted accordingly), and the LSB is sent first.
Note how I switched to Unsigned bytes, and I eliminated the double list-text conversion you had on the way into the Data list. (ReceiveUnsignedBytes returns a list).
Sorry for the late reply and thank you for all the help @ABG .
P.S. the first number I am receiving is time. Do you think there is a way to store the first value I receive and subtracted from it. Such as I receive 200 and I desplay it as a 1. Number - First received number? This way I use it as my X value for the graph
You are correct; I was doing the conversion in reverse. Because as the data moves, the first byte changes fast but the second changes once the first value makes a complete revolution.
After the ID, each value I am receiving needs to be converted following its specific conversion. For example, the value in row 1 needs to be divided by 1000 before storing it, whereas the value in row 2 is multiplied by 3.7 and so on for each row.
Using global pairs, how do I achieve this without indexing as I was doing before?
Considering that I want to store the values and plot them singularly
I haven't seen any usage of that column 1 value (5,21,37,...(n*16 - 11),...,245) in this thread, other than their constancy.
Do you expect any other values than those 16 values?
If not, you might as well just accumulate your 16 bit values in a 16 column table (list of lists), one row per 48 byte packet.
On the other hand, this is getting ahead of yourself. You have no packet wrappers to stay in sync.
The alternative is to add your (id, value) pairs to a long two column log table as they arrive, and filter the table by column 1 value later when you want to graph your data by arrival order.
Regarding your normalization problem, I suggest keeping a constant lookup table of multiplication factors
(5, 0.001),
(21, 3.7),
...
to be used in conjunction with the LOOKUP IN PAIRS list block.