4:03 pm
August 9, 2016
Hello.
This question might be dumb so sorry in advance if that is too stupid...
Well, I'm making a translator on arduino between and old motor driver to a new one. Long story short, the host submitting serial messages cannot be chaned or adapted to use the new "language" used by the new drivers. So I have to "translate" the old format messages to the new format.
Quickly: I'm getting serial data incoming (array of bytes)
I do manipulation on data etc.
Then I need to calculate a CRC16 (modbus type) on the generated message.
Problem is: each data inside my "message" array are 1-Byte type.
A CRC16 calculator is making calculation on all of these bytes and gives a 2-Bytes number
But as Arduino compatible compiler cannot re-cast the 8-bit into 16-bits I get compiler error. This is pretty basic in Labview and works properly but here I cannot get it right...
Do you guys have any idea how I could do it? I already tried to copy my array of 8-bits data into a 16-bits data array but also the compiler is failing... I even tried with the native "join numbers" which outputs a 16-bits number from 2 8-bits numbers (1 is 0 the other one is the element from my 8-bit array) to copy my 8-bits data array to a local 16-bits data array without success.
---EDIT---
I actually managed to compose a 16 bits data using the join function. However, if I run the CRC16 calculation using labview, I always get the good result, if I run it with Arduino, it is always false (but gives always the same result, despite false). There must be something wrong with the memory allocation... need to investigate...
Thanks for your help and sorry for the silly question...
Cheers!
Catlan
15
1 Guest(s)