05-30-2022 03:54 PM
Hello, I am trying to fix a robot which was originally made on Matlab, and to control the speed of a spinning drum, there is a gain equation to convert mm/s into a number which should be assigned to a 32bit unsigned integer and then sent to the serial port following the character V. For Example, if I wanted 30mm/s, the number would be 71213, so on MatLab, I would send...
write(SR, 'V', "uint8");
write(SR, 71213 , "int32");
This would make the drum spin at the appropriate speed.
On LabVIEW, the Write function only accepts strings, and when I try converting my int32 number to a string and then give that to the write buffer, it does not work the same. I am assuming that MatLab and LabVIEW handle the number differently.
If anyone could help me try to get the same results on LabVIEW as I am on MatLab, that would be awesome. Or even if someone has a good understanding of how MatLab's write function works, so I could try to replicate it on LabVIEW.
Thanks
05-30-2022 04:18 PM
@Accid3nts900 wrote:write(SR, 71213 , "int32");
Well, int32 is NOT an unsigned integer, so you probably should have specified uint32. I assume it wants binary data (i.e. 4 bytes for U32) but you probably also need to know the required byte order (LabVIEW is big endian by default).
Take your U32 and try flatten to string and pick the correct byte order and see how far you get.
05-30-2022 08:45 PM
Matlab defaults to Little Endian while LabVIEW defaults to Big Endian. So use the Flatten To String (one of my favorite functions) and set the byte order to Little Endian to convert to a I32.