Can I use hardware serial with Arduino STM32 and commander? I need to control driver with another Arduino board by UART. And because. Serial1 using for Arduino programming by stlink I need to use another serial.
Yes, you can do it.
Just declasse your hardware serial and add it to the commander constructor.
Yes, you can do that. Make sure you connect the correct serial pins on the stm32 and also if you use Arduino IDE, and call Serial1, Serial2, or Serial3, you need to include the
-DENABLE_HWSERIAL1 -DENABLE_HWSERIAL2 -DENABLE_HWSERIAL3
in a file named
you need to create in your Arduino project directory, else the project won’t build.
Which STM32 are you using?
Stm32 f446re I’m using
In second Arduino I need to use Serial.print() or Serial.write() for control driver by serial?
Depends on what information you pass. print() prints data to the serial port as human-readable ASCII text. write() writes binary data to the serial port.
So. I have 2 stm nucleo board. One for the driver motors and one to communicate with sensors (IMU) and algorithms control. I need to control driver from second board.
How can I do it?
I understand I need “M0.2” command. When “M” motor index and 0.2 float for voltage control. How can I transive it into serial ?
It does not work.
From the little I understand of your problem, you want to transmit “M0.2” ?
You need to construct the entire “M0.2” string first then transmit the string in a single atomic transaction, else the serial on the other side will first process “M” then “0.2”. Do you see the problem?
Yes. I don’t know how to do it
You need to concatenate the two strings. Could you please read this and see if you can do it?
Thank you. I will try