Page 1 of 1

MDDS30 Reset and Dummy Byte

PostPosted: Wed May 05, 2021 6:49 am
by drannex42

I am having a minor problem with the MDDS30 in serial packet mode.

I can control everything, and everything works but: Upon start of the MDDS30 I need to need to send a dummy byte (0x80, or 127) as the first byte to initialize autobaud for the device. I know this is required.

The issue is that the dummy byte only works after clicking the reset button after power up. Every time. Is this expected? Or is there something odd going on?

To rephrase, when I start my system (power-up) sending the dummy byte doesn't work (two led blinks per second) until I click the 'reset' button on the device. Is there anyway to not require pressing the reset button on every power up?

Re: MDDS30 Reset and Dummy Byte

PostPosted: Fri May 07, 2021 2:29 pm
by waiweng83
This is really strange. Did you try to put in some delay after power up the motor driver before sending in the autobaud byte?
This is for the MCU on the motor driver to finish its initialization process.

I do not have data of how long the delay it should be for now. Maybe just start with some pretty long delay like 500ms and gradually reduce it.

Re: MDDS30 Reset and Dummy Byte

PostPosted: Sun May 09, 2021 4:58 am
by drannex42
Yes.I've even tried:
- opening the port, adding a delay, and then sending a write command.
- opening the port, sending the command, and then adding a delay.
- opening the port, adding a delay, sending the command, closing the port, opening the port, and then sending the other values.

All of this do not work as thought, until I press the reset button.I've tried delays from 500msec to 5 seconds, and still all the same issues.

Re: MDDS30 Reset and Dummy Byte

PostPosted: Sun May 09, 2021 5:59 am
by drannex42
I have somewhat spotted the error, this does not seem to be a MDDS30 issue, but rather a serial port config issue with some onboard drivers when using a USB -> TTY converter.

When i wrote this in C I was using the built in open() function that writes to a 'file' called USB/ttyUSB0, where my device is connected. When I ported this code to Julia, and finally to Rust, I decided to use built in 'serialport' libraries. Writing to the file seems to work, but when writing via a serialport library it corrupts data outside of a few bytes and when instantiating with autobaud it confuses the MDDS30 when the handshake occurs. This does not appear to be an issue on Windows, but on Linux.

After I wrote my last comment I decided to start looking through my port() functons, and replace with a
operator instead of the
std::boxed::Box<dyn serialport::SerialPort>
that I was given.

I appear to have solved the issue, and will see if the MDDS30 has any issues with the way autobaud detects when using other types of serialport libraries.

tl;dr: When using a USB to TTY converter to communicate, be sure to use a file writer instead of more standard serial port libraries.

Re: MDDS30 Reset and Dummy Byte

PostPosted: Mon Apr 25, 2022 11:10 am
by gh9st
Thanks for your response. I have been having issues using 2 MDDS30 at the same time using 2 CP2102 USB to ttl converters. I am using the Pyserial library for python, and at first was using packet serial mode, but got tired of trying to figure it out and now I am having a hard time getting serial simplified to work right. The devices only receive the first command that is written to the serial port. This is my first time using UART for communications on a pi, so I am new to serial in python. When I get back to my shop I will share my code, but if someone could tell me how to send the packets, I would appreciate it. Im using 2 MDDS30 with 4 motors, and have mapped my mecanum drive speed control to 0-63, and back motor controllers are ttyUSB0, front ones are ttyUSB1, direction is passed as 0 for reverse and 1 for forward, speed is converted to binary, filled with zeros until the length is 5 bits, and then converted to string, and then my packet is concatenated, then encoded to bytes. Output written to serial is b'0110000 for front right motor at 0 speed, and b'01111111 for speed at 63. Any quick ideas on what im not grasping?

I got the controllers working great using:
Adafruit servo hat, connected to RC pins, and using the continuous servo library to set the throttle (-1 to 1). This works great, but I wanted to see if serial was more efficient, as my joystick inputs are sent over MQTT remotely. Now, I haven't really got lag, but I also havent added anything else but the motor controllers and servo hat on the PI. I also think I am not getting full speed output this way.