Unstable reading of SMC 24v23 on daisy-chain configuration

Hi, guys!

We are working with 3 Pololu Simple Motor Controller 24v23,
Connected in daisy-chain configuration,
Addresses: 3, 4 and 10.

Using the Pololu protocol
at 19200 bps, manually setted.

Our microcontroller is a ST NUCLEO F401RE which have 3 Hardware Serial ports, we are using one to communicate with the computer at 115200 bps and other to communicate with the Pololu Drivers at 19200 bps.

At writing every 30 ms to set the speed of the 3 drivers we have no problem, but at reading we are having a unstable response (as you can see in the GIF), even if we only read every 1000 ms.

Readings_every1s

When we read the drivers over USB using the smcCenter program we get a stable ~13.6V and ~25.6 °C, but when we read over UART port the correct values appear every now and then.

We are using the function getVariable, included in the user’s guide.
We just modify it to work with the pololu protocol, like this:

int MotorDriver::getVariable_Protocol(byte address, unsigned char variableID)
{
    // Read a variable defined by variableID from the Driver with address.

    smcSerial.write(0xAA); // Using Pololu Protocol Command Byte.
    smcSerial.write(address);

    smcSerial.write(0xA1); // Get Variable Command Byte
    smcSerial.write(variableID);

    //delayMicroseconds(10);

    return readByte() +  256 * readByte();

                 // Response Format:|
    // Response Byte 1      |   Response Byte 2|
    // variable low byte    |   variable high byte|
}

As you can see, we tried making a small delay before reading the response, but even a delay as big 100 ms doesn’t appear to have an effect in stabilizing the readings.

The problem appears even if we only read one of the drivers.

Any recommendations?

It looks like you are still trying to use 0xA1 as the command byte. Please note that when using the Pololu protocol, the command byte must have it’s most significant bit cleared. So, 0xA1 becomes 0x21, and the correct series of bytes for the get variable command becomes: 0xAA, device number, 0x21, variable ID.

Could you try making that change and see if that fixes the issue?

Brandon

1 Like

Yes, that was it!

I implemented writing to the drivers so long ago that I forgot the detail of clearing the MSB.

You are a champion, you are a hero without a cape!

There are some erratic readings at startup (I guess that’s normal) and then it runs like a breeze.

Testing_Working1

Thanks alot!

2 Likes