UART Communication to and from closed loop stepper

I have a BigTreeTech closed loop stepper (S42C v1.0) and it apparently allows UART communication to read and write settings. I have two questions based on the following information from the "manual":


and

The first question is - can anyone help me with a resource on how to communicate using this protocol? Some light reading would be helpful.

Second Question (probably not for here): Does anyone know what pins on the S42C driver are used for communications?

Thank you.

You are best off with an Arduino with multiple UARTs for your device and debugging on PC, like an Arduino Mega. Else you need some SoftwareSerial for the second serial connection.

For the protocol you should learn to use logic OR '|', AND '&' and shifts '<<' and '>>' - see the Arduino Reference.

A link to the complete datasheet were nice for answering your other question(s).

1 Like

not very helpful doc

there is this mention

so wondering if you actually can access to the UART or SPI at all

Me2. Redirect all questions to the person that ordered the device.

@DrDiettrich, here is the link:

I posted this doc (post 3) 7 hours ago.. Have you read what I highlighted?

Thanks. Yes. I don't believe it is interpreting what I'm talking about.

how do you understand that?

In terms of the interface, this is what I think may be useful:

According to the STM32G031xx datasheet PA2/PA3 is one of the USART options. The configuration of these pins between 3.3v and GND looks suspiciously like the kind of interface I need.

When I get a chance, I'll see if I can at least communicate with these pins via my PC.

The note that the device uses a "uart mode" tells me they are using bit-banging instead of a real UART. The software method was cheaper than using a real UART in the device. Perhaps space on the circuit board was the reason.

In any event you need to write to the device using a regular Arduino UART or use software serial.

The document identifies exactly how to format you message. The sync bits at the start of each message is there so the device software can discover that a message is arriving and begin to decode it.

worth trying indeed with those pins

UhOh! DO you see the pin identified as SWCLK???? Does that mean the communication is actually synchronous with an external clock? If so, your async will not work.

@Paul_KD7HB i'm in no way an expert in this, but I think there is a separate interface for flashing the firmware to the processor. I think that might be what those additional pins are for? J-Link?

You will be if you get this project done!

Okay. A bit of an update.

I've connected the Stepper motor pins PA2 and PA3 through an ESP32 onto my Arduino IDE serial monitor and plotter. I used this basic code to spit out what was happening on those two pins:

HardwareSerial StepperSerial(2);

void setup() 
  {
  Serial.begin(9600);
  StepperSerial.begin(9600,SERIAL_8N1,16,17);
  }

void loop() 
  {
  while (StepperSerial.available() > 0) 
    {
    Serial.println(byte(StepperSerial.read()));
    }
}

I was getting a succession of values between 0 and 255 being pushed out. This is the serial plotter example:

Not what I was immediately hoping for, but wondering if anyone might have an idea of what i've tapped into.

you would need to print in binary or hexadecimal and check against the protocol in the doc.

I've not been able to resolve this.

Better yet, there is a closed loop stepper that definitely does have serial communications and comes with a bunch of tutorial videos and resources.

I'll be working with this new driver and maybe someone can work out how the BigTreeTech unit works.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.