Messaging between multiple Maple Mini clones

What are you developing?
bubulindo
Posts: 33
Joined: Fri Sep 11, 2015 10:51 am

Re: Messaging between multiple Maple Mini clones

Post by bubulindo » Thu Sep 08, 2016 7:35 am

This may be a stupid question, but wouldn't the CRC unit on the STM32F103 be ideal for this calculation??

User avatar
Slammer
Posts: 242
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Messaging between multiple Maple Mini clones

Post by Slammer » Thu Sep 08, 2016 11:04 am

While it is possible to connect MCUs with TX and RX (with some diodes and resistors) the modbus RTU protocol is designed to work with RS485 networks (it is very easy to use a RS485 tranceiver like ADM485 or SN75176, on TX/RX lines)
It is very common in industrial systems ( for connecting PLCs with Sensors, Remote IOs, etc) as the total wire length of network can be up to 1600m and data rates up to 10Mbit.
The limitation of the protocol is that there is only one master and slaves can't initiate a transmission without master's request.

PS: Many very low priced UART<>RS485 modules exist in Ebay/Aliexpress : http://www.ebay.com/sch/i.html?_nkw=RS485&_sop=15

User avatar
RogerClark
Posts: 6877
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Messaging between multiple Maple Mini clones

Post by RogerClark » Thu Sep 08, 2016 11:30 am

bubulindo wrote:This may be a stupid question, but wouldn't the CRC unit on the STM32F103 be ideal for this calculation??
Possibly, but Modbus has its own special CRC calculation. I don't know enough about the STM32F103 to know if it supports the same CRC type.

bubulindo
Posts: 33
Joined: Fri Sep 11, 2015 10:51 am

Re: Messaging between multiple Maple Mini clones

Post by bubulindo » Thu Sep 08, 2016 6:31 pm

I just had a look and no. It's not compatible on the F1 or F4 as these are fixed to 0x4C11DB7 which apparently is mostly used in TCP/IP.

F3, however... with the programmable polynomial and n bit data size seems to be possible.

I thought there was a library for CRC already implemented... do you know anything about this?

User avatar
RogerClark
Posts: 6877
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Messaging between multiple Maple Mini clones

Post by RogerClark » Thu Sep 08, 2016 9:16 pm

The CRC code is well documented, and @slammer posted it.

HW CRC is interesting, but its a sledgehammer to crack a nut in this case

User avatar
Slammer
Posts: 242
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Messaging between multiple Maple Mini clones

Post by Slammer » Thu Sep 08, 2016 10:13 pm

The discussion about hardware CRC calculation for Modbus, while it is interesting has no practical value, the frames are very small and the computational method is very fast on ARM, the time needed is on microseconds range. Even on 8051, many years ago, I was using both methods (computational method is smaller and sometimes every byte counts in small MCUs) and there was no problem.

User avatar
RogerClark
Posts: 6877
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Messaging between multiple Maple Mini clones

Post by RogerClark » Thu Sep 08, 2016 10:29 pm

Slammer wrote:The discussion about hardware CRC calculation for Modbus, while it is interesting has no practical value, the frames are very small and the computational method is very fast on ARM, the time needed is on microseconds range. Even on 8051, many years ago, I was using both methods (computational method is smaller and sometimes every byte counts in small MCUs) and there was no problem.
+1 ;-)

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Messaging between multiple Maple Mini clones

Post by Pito » Sat Sep 10, 2016 4:30 pm

To the schematics - I would add a 100ohm resistor to each slave's rx, to avoid ringing (wired between master's rx and slave's rx).
To the physical layer - you are using voltage driven layer (high impedance one), for 30cm lengths it is ok, for 500m it will not work, however.
The industrial one use ie. a "current loop" (low impedance one, ie 20mA current loop), good for long distances, usually isolated with opto-couplers.
RS485 is low impedance one too.
Pukao Hats Cleaning Services Ltd.

joevpt
Posts: 12
Joined: Sat Aug 27, 2016 6:38 pm

Re: Messaging between multiple Maple Mini clones

Post by joevpt » Fri Sep 23, 2016 6:07 pm

Hi All,

I finally have this working as suggested by Pito and Simonf by daisy-chaining all the boards together just on the RX port and locally tying the TX port to the RX port via a diode. The benefit as the guys have said is that all boards receive the message on the RX port (including the current speaker) and there is no bus Master board (even one is equal). You can control how this works entirely in software, so you might have in your program that some boards only speak when spoken to while other boards are allowing to initiate communications.

The circuit is quite simple and while I used two resistors (one at each end each was 20k ) it did work with just one resistor.

Very many thanks to all who offered advice and especially to Pito and Simonf

Regards,

Joe
pict1.png
pict1.png (4.8 KiB) Viewed 614 times

simonf
Posts: 180
Joined: Sun Jul 26, 2015 4:03 pm

Re: Messaging between multiple Maple Mini clones

Post by simonf » Fri Sep 23, 2016 6:42 pm

Your welcome to the help. Glad you got it going its about the easiest and most flexible way to connect a bunch of uPs you can even get away with a mix of 3/5V devices.

Post Reply