I have a problem:
I use Arduino Ide and fees on STM32F103C8T6, you must establish a connection via the RS-485 between the Master (STM32F103) and slave (Arduino Uno). Use the library SimpleModbus NG (https://github.com/angeloc/simplemodbusng). Sketches are compiled without problems. To use an example from STM32F103 library (SimpleModbusMasterExample.ino) and use UART1 – Serial1 (PA9-TX1, PA10-PX1 and control of transmit / receive pin PA8 for the MAX485). For example UNO used SimpleModbusSlaveExample.ino and Serial (default TX, PX and pin 2 – transmit / receive control).
So, the problem is that the UNO does not respond to requests STM32. Master returns a timeout error. But the fact is that if the master flash sketch in Arduino Mega 2560 is a problem in the communication between master and slave is not there, everything works, and the data is transmitted, and even tried to slave (UNO) to connect to a PC using an app for Windows “Modbus Master”- problems with this too does not arise.
Please answer, what could be the problem?
You could post here your sketch.
So, I would be really interested to find solution to make Maple Mini work as Modbus Master. Otherwise I will have to add something like Attiny85 between Modbus slave device and Maple mini to play role of translator.
The possible problem you can have is that the oroginal RS485 adapters use chips that are working with 4.5V and above. So it will most probably not work with 3.3V from the F103 board. I solved the problem by replacing the onboard RS485 chip with the 3.3V working ADM3485.
I’ve already figured out in his problemme, it appears in the source code of the library Modbus Master function of sending the package: void sendPacket (unsigned char bufferSize). So pay attention to this code:
void sendPacket(unsigned char bufferSize)
{
digitalWrite(TxEnablePin, HIGH);
for (unsigned char i = 0; i < bufferSize; i++)
Serial2.write(frame[i]);
Serial2.flush();
// allow a frame delay to indicate end of transmission
delayMicroseconds(T3_5);
digitalWrite(TxEnablePin, LOW);
previousTimeout = millis(); // initialize timeout delay
}
I suppose you know how many bytes or words do you want to send.
So just cast the passed parameters/constants like:
send( (uint8_t)0x5a );void ModbusMaster::send(uint8_t data)
{
send(word(data));
}better to use uint16_t etc
Probably you already know, but the stm32 uses 3.3v IO, while the uno uses 5V. Are you connecting the boards directly during testing? if so, you probably need a level converter.
If using RS485 chips, make sure the one used in the stm32 end can work with 3.3V in the MCU side.
Arduino2560 Serial call look like:
AA 20 00 04 57 FA
Can you show us your code?
Mega2560 train is wrong, it does not contain 0x03. Maple mini looks good.
Check if you can find a version of the library tested in the DUE or the Teensy 3.x, there may be some problems with the types and the endianness as Steve pointed out, and anyone using them in Due or Teensy should have worked those out already.
Check if you can find a version of the library tested in the DUE or the Teensy 3.x, there may be some problems with the types and the endianness as Steve pointed out, and anyone using them in Due or Teensy should have worked those out already.
I added a little library for working with STM32F103 (Library :: ModbusMaster Author :: Doc Walker), I hope he will not swear.
Everything is working very well now. I checked on two boards Arduino (slave) and Blue Pill Stm32F103 (master). Here are links to files:
ModbusMaster_STM32_RS-485
ModbusSlave_ArduinoUNO_RS-485
I added a little library for working with STM32F103 (Library :: ModbusMaster Author :: Doc Walker), I hope he will not swear.
Everything is working very well now. I checked on two boards Arduino (slave) and Blue Pill Stm32F103 (master). Here are links to files:
ModbusMaster_STM32_RS-485
ModbusSlave_ArduinoUNO_RS-485
i am doing f103 with enc28j60 to become modbus tcp.
do u have any library for modbus tcp for stm32.
with regards
zouk
stop multiple-posting, your issue will not be solved if you post in every possible thread.
If you have already Enc26 working on F103, then ModbusIP (link from your other post) should work out of the box.
Just try one of those examples.
is there any way to do uno as master and stm32 f103 as slave??? ![]()
A useful work. I am getting the following error in Arduino 1.8.2
sketch\ModbusMaster.h:54:53: fatal error: libmaple/usart.h: No such file or directory
#include <libmaple/usart.h> // Modified Egor Orlenok
is there ModBus RTU library for use between STM32s? I tried SimpleModbus with no luck.


