Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:46 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Modbus

     Page 1 of 2    
Author Message
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 09:29am 16 Jan 2024
Copy link to clipboard 
Print this post

Does anyone have a copy of the code that was on FoTS?

I have downloaded Daniel's HTTRACK (thanks Daniel ) and I see the CRC stuff but not the actual protocol.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4234
Posted: 10:11am 16 Jan 2024
Copy link to clipboard 
Print this post

Hi Phenix,

The CRC calculation is currently build into PicoMite (MATH CRC16). It is a generic CRC calculation, you just need to provide the seed and poly.

Modbus uses CRC16-IBM (a variant of CRC16)

CRC overview
and
Python CRC overview   

Volhout
Edited 2024-01-16 20:29 by Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 10:26am 16 Jan 2024
Copy link to clipboard 
Print this post

  Volhout said  Hi Phenix,

The CRC calculation is currently build into PicoMite (MATH CRC16). It is a generic CRC calculation, you just need to provide the seed and poly.

Modbus uses CRC16-IBM (a variant of CRC16)

CRC overview  

Volhout


Ah, misunderstanding  

CRC is not the problem; the actual Modbus comm's protocol was posted on FoTS but I can no-longer find it.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 896
Posted: 11:47am 16 Jan 2024
Copy link to clipboard 
Print this post

Temporary static copy of FotS

Look here under M for MODBUS
Latest F4 Latest H7
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 12:05pm 16 Jan 2024
Copy link to clipboard 
Print this post

  disco4now said  Temporary static copy of FotS

Look here under M for MODBUS


Thanks Gerry but already have this....it's just the CRC stuff.
I remember that the Cap'n published actual Modbus comm's protocol (coils, registers, etc.)

Did i dream it?  
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 12:20pm 16 Jan 2024
Copy link to clipboard 
Print this post

Modicon Modbus protocol
Not 'Mite specific, this is general.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 01:27pm 16 Jan 2024
Copy link to clipboard 
Print this post

Thanks Mick,

This was my first plan but I was certain that an MMBasic sample was already on FoTS.

I'll create it when I actually need it.  
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 07:16pm 16 Jan 2024
Copy link to clipboard 
Print this post

I put the Modbus CRC stuff on FoTS but their is no other reference to Modbus in there.

The reference guide is slanted towards Modicon PLCs and the reference to coils, holding registers and register addresses don't make understanding the protocol easier. Most of it is irrelevant to most modern implementation. The Modbus protocol is fairly simple really, you only need to implement the commands you need.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 07:51pm 16 Jan 2024
Copy link to clipboard 
Print this post

I think most of the PLCs that use Modbus tend to use a similar concept of coils, contacts and registers - at least as an option. The main thing is to keep with the same header and packaging system if possible. The data is up to you. The detail in the Modicon document is specific, but the basic info near the beginning is relevant to all Modbus systems, I think. You have to remember that it's designed as a high reliability industrial system so keeping close to the spec is an advantage.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 07:59pm 16 Jan 2024
Copy link to clipboard 
Print this post

If I understand this correctly, this waveshare module will convert to/from Modbus TCP.

 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 08:11pm 16 Jan 2024
Copy link to clipboard 
Print this post

It Looks like it but I have no experience with Modbus TCP. All our applications used Modbus RTU and were not PLCs.

Bill
Keep safe. Live long and prosper.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 896
Posted: 09:41pm 16 Jan 2024
Copy link to clipboard 
Print this post

Is this post helpfull
Latest F4 Latest H7
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 11:10am 17 Jan 2024
Copy link to clipboard 
Print this post

Many thanks, guys. Yeah this stuff is no big deal...KISS principle.
 
SimpleSafeName

Guru

Joined: 28/07/2019
Location: United States
Posts: 319
Posted: 12:49am 18 Jan 2024
Copy link to clipboard 
Print this post

  Turbo46 said  It Looks like it but I have no experience with Modbus TCP. All our applications used Modbus RTU and were not PLCs.

Bill


It's my understanding that Modbus TCP is actually Modbus RTU encapsulated in a TCP packet. And because of the encapsulation, there are a couple of quirks that come with it.

1) The CRC16 checksum is no longer necessary, since the TCP packet will take care of that.

2) It opens up the possibility of multiple masters.

But it's been a hot minute since I messed with Modbus.

When I worked for Schneider we saw plenty of interesting adaptations of the Modbus specs. :)
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 06:06am 18 Jan 2024
Copy link to clipboard 
Print this post

  Quote  
1) The CRC16 checksum is no longer necessary, since the TCP packet will take care of that.


Ah-ha, I was wondering about this very thing.  
Edited 2024-01-18 16:07 by PhenixRising
 
SimpleSafeName

Guru

Joined: 28/07/2019
Location: United States
Posts: 319
Posted: 11:26pm 18 Jan 2024
Copy link to clipboard 
Print this post

  PhenixRising said  
  Quote  
1) The CRC16 checksum is no longer necessary, since the TCP packet will take care of that.


Ah-ha, I was wondering about this very thing.  


Yeah, but...

To a certain extent, Modbus is an example of an open protocol that has descended into chaos. So while it might not be necessary to include the checksum, the "wrapper" that encapsulates the packet takes what has been given to it, which surely came with a CRC already calculated.

And while it is one thing for you to ignore the CRC on your end when receiving a packet, I'm going to guess that the target for your packets on the other end won't be as forgiving.


And were you aware that the CRC16 result needs to have the bytes swapped? Usually.

I created a CRC16 routine in VB and PowerBasic many moons ago, and VB gave me nothing but trouble when I swapped the bytes. Finally I converted the result to Hex$, and swapped those character pairs around and then converted it back to decimal.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 09:02am 19 Jan 2024
Copy link to clipboard 
Print this post

Yeah - Modbus is a "standard" of which everyone uses their own version.  

To appreciate its true beauty you have to go back to the days of hardware UARTs and logic chips. That's how it was designed to be used. Forget what people have done to it when they've emulated it in firmware / software because they are usually in the wrong!
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
SimpleSafeName

Guru

Joined: 28/07/2019
Location: United States
Posts: 319
Posted: 12:58am 20 Jan 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  Yeah - Modbus is a "standard" of which everyone uses their own version.  

To appreciate its true beauty you have to go back to the days of hardware UARTs and logic chips. That's how it was designed to be used. Forget what people have done to it when they've emulated it in firmware / software because they are usually in the wrong!


It's still very effective, and at the heat death of the universe it will be cockroaches and Modbus as the last two standing.

I'm helping out on a project destined for Antarctica, and since it's an upgrade from a Rockwell PLC to a Turck TBEN PLC we may have to use Modbus to communicate to the HMI.

But while working for Schneider I can recall three instances of outside vendors telling us that we had it wrong. :)
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 01:30am 20 Jan 2024
Copy link to clipboard 
Print this post

  Quote  Yeah - Modbus is a "standard" of which everyone uses their own version.

Surely if you implement the commands as defined in the Modicon Modbus Protocol Reference Guide systems must be compatible with each other.

Bill
Keep safe. Live long and prosper.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 859
Posted: 02:03am 20 Jan 2024
Copy link to clipboard 
Print this post

  SimpleSafeName said  it's an upgrade from a Rockwell PLC to a Turck TBEN PLC


That's some nice looking hardware  

Switching away from Rockwell is always an "upgrade"  

If I never use that stuff ever again, it will still be too soon  
 
     Page 1 of 2    
Print this page
© JAQ Software 2024