Sending data from a microcontroller to Duet3 (with SBC)
-
Hi,
I have an STM32F4 board running a custom pressure controller, with a melt pressure transducer connected to it. I can achieve basic functionalities with toggling IO pins on the Duet3, but my goal would be to establish a two-way communication with a custom protocol for future features. I am trying to setup an USART connection between IO0 and the STM32 pins, but seems like the Duet3 does not receive anything. I am sending this with the hopes of seeing something pop up in the DWC:
"M118 P3 S\"Hello from STM32!\"\n\r"
I lack the general understanding of how to wire things up - is the Raspberry Pi SBC setup 'overriding' the standalone functions of the Duet3 board? Maybe I should connect the STM32 to RPi, and then have a Python script that sends the commands to DWC?
I would greatly appreciate any info on how this should be done, ideally I would love to add many modules this way, so the communication method needs to be reliable.
TLDR: I need to send pressure readings to Duet3 from STM32, to have a macro which stops a print when the pressure is too low.
Thanks,
AW -
@awitc what are you ultimately going to use the STM32F4 based board for? Which specific STM32F4 processor does it run?
-
@jay_s_uk for now I have a STM32F411RE, will switch up to STM32F491RE in the following days. So it has Arm Cortex-M4. The STM is used to run a custom PID controller, which manipulates the speed of the extruder stepper motor, based on pressure.
EDIT: not extruder motor, but a drive which provides material to be extruded. I want to have the pressure in the extruder at a certain level.
-
@awitc ok. Just wanted to mention that theres a fork of the duet firmware which runs on an STM32F4 (only the STM32F407 and STM32F429) which can have an spi2can module added so it can talk directly over CAN-FD to the duet 3.
Although that probably won't help you with the control of the extruder.Have you added M575 in your config to enable the UART connector?
-
@awitc The UART channel on
io0
should be available no matter if the board is running in standalone or SBC mode but it has to be configured using M575 first (e.g.M575 P1 B57600 S2
). -
@jay_s_uk @chrishamm Yes, I have added the command, using 115200 as baudrate, but from what I see, I had the parameter S set to be default. I will try with the raw mode, that might have been the problem. Thanks!
-
In config.g:
; serial port enable M575 P1 B115200 S2
I have the following connections:
IO0.out (TX) -> STM32F411RE PA10 (USART1_RX)
IO0.in (RX) -> STM32F411RE PA9 (USART1_TX)USART1:
I send messages like this:
char message[] = "pleasework"; snprintf(buffer, 256, "M118 S\"%s\"\n\r", message); HAL_UART_Transmit_IT(&huart1, buffer, strlen(buffer)); HAL_UART_Transmit_IT(&huart2, buffer, strlen(buffer)); HAL_Delay(10000);
UART2 is transmitting to PC via USB, firstly I had it also sending data to the Duet3 (I connected the USART2_RX, USART2_TX to IO0 instead), but I tried this way to see if this might have caused the issue.
On DWC I enter:
M118 P2 S"WELCOME FROM DUET3!"
but still nothing happens, I have receiving configured on interrupts, and tested through PC and USART2, so I do not think the issue is there.
I am clueless as to what might be the problem, I would imagine this should work.