Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCC_TURNTABLE and <I id DCC 0> provides incorrect address. #407

Open
Rosscoetrain opened this issue May 6, 2024 · 3 comments
Open

DCC_TURNTABLE and <I id DCC 0> provides incorrect address. #407

Rosscoetrain opened this issue May 6, 2024 · 3 comments

Comments

@Rosscoetrain
Copy link

I'm working on my DCC turntable decoder.
Decoder works fine and responds correctly.
However using the examples from here:

https://dcc-ex.com/ex-commandstation/accessories/turntables/dcc-turntables.html#defining-dcc-turntables-traversers

The address sent from the command station is not correct with either the DCC-EX native or EX-Rail example the address 201 gives address 97 at the decoder and on up to address 210 gives address 106 at the decoder.

The ROTATE_DCC command works correctly as does the command at a serial prompt.

It is only the address that is set incorrectly.

@Rosscoetrain
Copy link
Author

Git diff to correct this added below.

@Rosscoetrain
Copy link
Author

diff --git a/Turntables.cpp b/Turntables.cpp
index f75005c..bb9cd38 100644
--- a/Turntables.cpp
+++ b/Turntables.cpp
@@ -254,8 +254,8 @@ bool DCCTurntable::setPositionInternal(uint8_t position, uint8_t activity) {
int16_t value = getPositionValue(position);
if (position == 0 || !value) return false; // Return false if it's not a valid position
// Set position via device driver

  • int16_t addr=value>>3;
  • int16_t subaddr=(value>>1) & 0x03;
  • int16_t addr=(value - 1) / 4 + 1;;
  • int16_t subaddr=(value - 1) % 4;
    bool active=value & 0x01;
    _previousPosition = _turntableData.position;
    _turntableData.position = position;

@Rosscoetrain
Copy link
Author

I'd also suggest that line 259 be changed from:

bool active=value & 0x01;

to

bool active=0;

This makes all the commands sent to the turntable be thrown. The turntable decoder should then be able to calculate which way to go (clockwise or anticlockwise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant