Skip to main content

Reply to "Sending TMCC Commands to Legacy Base over Serial Connections"

Chris, your code would not work.  Remember, the TMCC addresses are NOT aligned on the byte boundaries.  As shown on page 36 of the TMCC manual, a switch command is:

01AAAAAAACCDDDDD  (where AAAAAAA is the TMCC id)

splitting that into two bytes gets you

01AAAAAA ACCDDDDD

so part of the TMCC id is in the third byte.  As in my code fragment above, what you want to do is shift and OR the bits to assemble the bytes:

Byte2 = B01000000 | (TMCC_SwitchID[3] >> 1);
Byte3 = (TMCC_SwitchID[3] << 7) | TMCC_Out;

Serial.write(0xFE);
Serial.write(Byte2);
Serial.write(Byte3);



I would look at the Arduino Reference page, specifically the parts about bitwise OR and bitwise shifting, to understand how the byte assembly works.

Last edited by Professor Chaos

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×