48
MPC-385 SERIES OPERATION MANUAL – REV. 3.21K (20201120)
long cpxus, cpyus, cpzus;
cpxus = cpyus = cpzus = 0;
Copy 24-bit (3-byte) position for each axis to 32-bit (4-byte) equivalents. Use the byte position
offsets shown in the diagram above. (“le” means Little Endian; “be” means Big Endian bit/byte
order.)
If in Little-Endian environment (e.g., Windows, Intel-MacOSX), copy all 3 U24 bytes for each axis
to the respective U32 variables.
memcpy(&cpxus[1], &pos[3], 3); // X
memcpy(&cpyus[1], &pos[6], 3); // Y
memcpy(&cpzus[1], &pos[9], 3); // Z
If in Big-Endian environment (e.g., legacy MacOS, LabVIEW), copy U24 to U32 byte at a time (1
st
to 3
rd
, 2
nd
to 2
nd
, & 3
rd
to 1
st
). Note that “pos” is always in Little-Endian bit/byte order.
memcpy(&cpxus[2], &pos[3], 1); // X
memcpy(&cpxus[1], &pos[4], 1);
memcpy(&cpxus[0], &pos[5], 1);
memcpy(&cpyus[2], &pos[6], 1); // Y
memcpy(&cpyus[1], &pos[7], 1);
memcpy(&cpyus[0], &pos[8], 1);
memcpy(&cpzus[2], &pos[9], 1); // Z
memcpy(&cpzus[1], &pos[10], 1);
memcpy(&cpzus[0], &pos[11], 1);
Ready to update UI with current position in microsteps using 32-bit integer values.
Convert microsteps to microns. Use double-precision variables for current position in microns;
initialize each to 0.
double cpxum, cpyum, cpzum;
cpxum = cpyum = cpzum = 0;
Microsteps-to-microns conversion factor (see “Microns / microsteps conversion” table for
appropriate factor)
double us2umCF = 0.0625;
Get microns from microsteps for each axis
cpxum = cpxus * us2umCF;
cpyum = cpyus * us2umCF;
cpzum = cpzus * us2umCF;
Ready to update UI with current position in microns using double-precision values. Loop for next
data block as desired until streaming ends.
For LabVIEW, a 3-byte positional value for an axis can be transferred into a byte array, and then
into a U32 data type via a byte-swap function to ensure 24-bit to 32-bit conversion while making
sure that no high-order value is misinterpreted as a sign bit (there should never be a negative
positional value in the MPC-200). LabVIEW data types (e.g., U16, U32, I32) are always in Big-
Endian bit/byte order, while MPC-200 multibyte values are always transcieved in Little-Endian
bit/byte order.
A single completion indicator byte (ASCII CR) is returned when streaming ends and
target position has been reached.