adding two 8bits digit into a 16bit one | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
adding two 8bits digit into a 16bit one
August 9, 2016
4:03 pm
Avatar
Catlan
New Member
Members
Forum Posts: 1
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

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

August 9, 2016
9:00 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

You should be able to just use join numbers.  You can do a serial print of the CRC calculation to see where it has gone wrong.  Or you can post a simplified version of your code if you think everything looks correct on your end.

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
15
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356