I am not new to Arduino specifically (I backed the first Teensy Kickstarter and have been using the Arduino platform for a good while now) but I am somewhat new to Modbus and RU485 as it was not possible to do it natively with an Arduino until fairly recently when the SERCOM support was FINALLY implemented.
As usual, Teensy is leading the way with this. We have been considering using a ATSAMD21 or ATSAMD51 (ARM Cortex-M0 or ARM Cortex-M4) based board now that they are starting to be reasonable in price.
Looks like the M0, the Zero and now the M4 and the LC (?), 3.2 and now 3.5 and 3.6 should all support this (though unclear if it is just the 3.2 and beyond as those are based on the Cortex M4).
Anyway, my question is more related to is there any actual code for using RS485 and more specifically Modbus RTU over it using the Teensy (or for that matter any M4 based chip?)
I am trying to use an Arduino as a Master to speak to an actuator that, well, requires you to speak to it through half duplex Modbus RTU only (not ASCII). I asked around and was told that it was not supported at all, which does not appear to be the case and then when I looked into Section 34.6.3.6 of the roughly 2000 page manual (
http://ww1.microchip.com/downloads/en/DeviceDoc/SAM-D5xE5x-Family-Datasheet-01507B.pdf) that does specify that it is possible, I was told it was possible but there is no code for it. The Zero has been out for 3+ years now so surely somebody has written something that, well, functions at least? I do see some software drivers out there but those are more for MEGAs and other hardware that does not support this natively which I would like to be able to do.
Looking around the forum, I do see a few references to serial though I cannot tell if there is any Modbus RTU code over RS485 out there or not.
So I guess I was wondering if anybody has any specific code that just works with regards to being able to send commands to a Modbus RTU slave over RS485? I know what I want to send to it, I just have no idea (not the current skill set) to create a RS485 link as well as a Modbus RTU framework.
https://forum.arduino.cc/index.php?topic=401006.0
This speaks to this a bit and has some example code regarding an Arduino Zero to Arduino Zero communication.
http://ww1.microchip.com/downloads/...S-485-Xplained-Pro_ApplicationNote_AT8547.pdf
Both the ATSAMD21 and the ATSAMC21 support hardware RS-485.
Ideally I would be looking for some method of being able to just send specific commands from within the sketch directly to the RS485 / Modbus RTU slave as if the Teensy or Zero / M4 was a terminal console and not have to create an entire protocol to make that work. Is this already built into the Teensy from around LC or 3.2 and beyond? Has this already been done? Even the documentation about it on the ATSAMD21 doesn't seem terribly comprehensive but it seems to be a selling point of the ATSAMD51 and newer 3.5 and 3.6 style of Arduinos. Except I have tried for several hours to actually locate, well, actual usable code without much success.
Am I misunderstanding the state of the new 6 port SERCOM hardware that enables RS485 and Modbus RTU on the Arduino or Teensy or is there really no usable code except for software implementations? I am more of a hardware person unfortunately and I do not think I would be able to (within a reasonable timeframe) write something like this.
A few extra resources:
https://www.arduino.cc/en/Tutorial/SamdSercom
Youtube video from Adafruit that goes over ATSAMD21 that talks about SERCOM.
https://www.youtube.com/watch?v=L2edpBP3AWE
Adafruit talks about this a bit more in depth but more from the SERCOM level rather than the RS485 level and from the perspective of the ATSAMD21 in their Zero line.
https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/muxing-it-up
Lastly, it is worth mentioning that there is a bit written about this here already. Though I am not quite sure that quite gets us there just yet, though it is helpful.
https://www.pjrc.com/teensy/td_uart.html
Except when you click on the link to learn more about "Modbus RTU (see RS-485 transmitter Enable function)", it literally takes you to this forum thread.