Detroit_Aristo
Well-known member
So, I have an equation that I need to satisfy to convert a 2 byte message into the formula to properly display a variable via a serial stream.
The formula is such that:
I create three uint8_t variables (d1, d2, d3)
For example. The message is 00000111 11010000 (7 208) (int 2,000)
I can't seem to get a bitshift pattern that satisfies this equation.
For example. Where var = 2000, what would the byte1, byte2, and byte3 be to satisfy the equation? I know as n approaches infinity, var approaches 0, but I just can't seem to satisfy this algorithm.
The serial message is as such:
Any advice would be greatly appreciated!
*snippets are posted as they are just thoughts and nothing tangible is coded.
The formula is such that:
uint32_t var = 1/((Data1 * 0x10000 + Data2 * 0x100 + Data3) * 1.66666666666667E-07)
I create three uint8_t variables (d1, d2, d3)
Code:
d1 = incoming16BitVar >> 8;
d2 = incoming16BitVar;
d3 = 0;
I can't seem to get a bitshift pattern that satisfies this equation.
For example. Where var = 2000, what would the byte1, byte2, and byte3 be to satisfy the equation? I know as n approaches infinity, var approaches 0, but I just can't seem to satisfy this algorithm.
The serial message is as such:
Code:
uint8_t msg[5];
msg[0] = 18;
msg[1] = d1;
msg[2] = d2;
msg[3] = d3;
msg[4] = (18 + d1 + d2 + d3) & 0xFF;
Any advice would be greatly appreciated!
*snippets are posted as they are just thoughts and nothing tangible is coded.