Reply by October 5, 20192019-10-05
On Fri, 4 Oct 2019 16:14:11 +0000 (UTC), Grant Edwards
<invalid@invalid.invalid> wrote:

>On 2019-10-04, upsidedown@downunder.com <upsidedown@downunder.com> wrote: > >> On the slave side, each slave must be able to detect when a response >> from an other slave has ended and when the master is sending a new >> request to you. This requires accurate timing. > >I've seen it done without timing by using a state machine (including >running CRC) to keep track of the response from the other slave and >detect its end even without a gap.
One way of doing this is to have a 270 byte history buffer. Immediately after a new byte is received, assume it is the last byte of the CRC. Assume the 4th newest byte is the start of a frame and calculate the CRC heck for this frame. If it fails, start one byte position older and calculate new CRC for this longer frame. Repeat this towards the end of the history buffer. However, if there is a CRC match before reaching the end of the history buffer, make a heuristic validity check (function code, count etc.). If this check is OK, synchronization has been obtained and lighter framing can be done in the future. If the heuristic fails, this was a premature CRC mach, continue searching towards the older starting points. However, if no match has been found, the most recent received byte was not the second byte of the CRC. Wait for next character and repeat the processing with the history buffer.
Reply by Grant Edwards October 4, 20192019-10-04
On 2019-10-04, upsidedown@downunder.com <upsidedown@downunder.com> wrote:

> On the slave side, each slave must be able to detect when a response > from an other slave has ended and when the master is sending a new > request to you. This requires accurate timing.
I've seen it done without timing by using a state machine (including running CRC) to keep track of the response from the other slave and detect its end even without a gap. -- Grant
Reply by David Brown October 4, 20192019-10-04
On 04/10/2019 15:40, upsidedown@downunder.com wrote:
> On Fri, 4 Oct 2019 15:13:24 +0200, David Brown > <david.brown@hesbynett.no> wrote: > >> >>>>> On the slave side, each slave must be able to detect when a response >>>>> from an other slave has ended and when the master is sending a new >>>>> request to you. This requires accurate timing. Otherwise the slave >>>>> will concatenate the two requests and the CRC will hopefully fail and >>>>> after timeout, the master have to do a resend. >>>>> >>>> >>>> It does not need to be done by accurate time - often approximate timing >>>> is sufficient. And slaves can happily read and check telegrams that are >>>> not addressed to them (such as replies to the master) and use that for >>>> synchronisation. >>> >>> If the master sends the next request within 1.5 character times after >>> the previous slave response has ended, all slaves will combine the >>> previous response and next request to a single frame. >>> >> >> No, they won't - not if they parse and check the telegrams as they come >> in (as some slaves do). > > Yes, some do it. It is easy in a point to point system, in which you > know if master only or slave only frames are expected. The same > applies to a multidrop master. > > However, a multidrop slave has to determine if it is a response from > an other slave or a request from the master and hence know when the > end of telegram is expected. Can you do it for all function codes ? > Some ad hoc code is sufficient for the most common function codes, but > is it possible for all. >
Yes - at least, for all standard function codes. In most Modbus systems, only a very few function codes are ever used, which makes it all a little easier.
Reply by October 4, 20192019-10-04
On Fri, 4 Oct 2019 15:13:24 +0200, David Brown
<david.brown@hesbynett.no> wrote:

> >>>> On the slave side, each slave must be able to detect when a response >>>> from an other slave has ended and when the master is sending a new >>>> request to you. This requires accurate timing. Otherwise the slave >>>> will concatenate the two requests and the CRC will hopefully fail and >>>> after timeout, the master have to do a resend. >>>> >>> >>> It does not need to be done by accurate time - often approximate timing >>> is sufficient. And slaves can happily read and check telegrams that are >>> not addressed to them (such as replies to the master) and use that for >>> synchronisation. >> >> If the master sends the next request within 1.5 character times after >> the previous slave response has ended, all slaves will combine the >> previous response and next request to a single frame. >> > >No, they won't - not if they parse and check the telegrams as they come >in (as some slaves do).
Yes, some do it. It is easy in a point to point system, in which you know if master only or slave only frames are expected. The same applies to a multidrop master. However, a multidrop slave has to determine if it is a response from an other slave or a request from the master and hence know when the end of telegram is expected. Can you do it for all function codes ? Some ad hoc code is sufficient for the most common function codes, but is it possible for all.
Reply by David Brown October 4, 20192019-10-04
On 04/10/2019 14:54, upsidedown@downunder.com wrote:
> On Fri, 4 Oct 2019 13:00:30 +0200, David Brown > <david.brown@hesbynett.no> wrote: > >> On 04/10/2019 11:44, upsidedown@downunder.com wrote: >>> On Fri, 4 Oct 2019 08:54:18 +0200, David Brown >>> <david.brown@hesbynett.no> wrote: >>> >>>> On 03/10/2019 08:10, upsidedown@downunder.com wrote:
>> There are no timing requirements for when a master sends a request, or >> for when the slave replies, other than the minimum 3.5 character delay. >> These pauses are not part of the protocol specification. > > Of course not. A fixed delay of say 10 ms is sufficient to produce > _at_least_ a 3.5 character pause.at speeds above 9600 bit/s. While in > principle, a single 10 ms pause would be sufficient also at 4800 > bit/s, the OS delay is not synchronized with the character stream. >
So you put in two ticks of pause, giving you 10-20 ms delay. Or you synchronise, or use some other timer system. Or you accept that if you need low-latency, low-jitter, high speed communications, then Modbus RTU was not the ideal choice.
>> >>> This will ensure that all slaves can reliably detect a pause between >>> frames (even if not addressed to your slave). You could even skip the >>> extra delay when sending multiple requests to the same slave, >> >> You can't skip the 3.5 character delay - whether you are sending to the >> same or a different device. Any delay beyond that is entirely up to the >> device sending. (This is the same for masters and slaves.) > > In practice, most slaves after sending the response go _immediately_ > into Rx mode, so the master could send the next request immediately. > This works very well in practice.
It is likely that a slave will go into receive mode quite quickly after finishing transmission - agreed. I don't know about you, but when I write code for a Modbus master, I still have a brief delay before sending the next telegram.
> > Modbus point to point connections work well, without observing > accurate timing. >
Yes, that usually makes things very simple.
>> >>> but it >>> definitively needed when first accessing one slave and then send next >>> request to a new slave, so that the new slave will reliably separate >>> the response from the old slave and the next request addressed to your >>> slave. >>> >>> After sending the request, the master should disable the transmitter >>> and let the fail-safe termination drive the bus into idle state. There >>> is a timing window up to 70 bit times (3.5 master character times + >>> 3.5 character slave preamble) for the master to go from Tx to Rx. In >>> practice, this window may have to be limited to 10-20 bit times for >>> more or less standard slave implementations. >> >> Slaves are not allowed to reply before the 3.5 character time break. >> There is no protocol-specified maximum delay time. > > How many of those thousands of different Modbus slave devices actually > follow this ? >
A good many, I expect, have some delay. If nothing else, it is common to get in the telegram, crc-check it, parse it, the figure out how to handle it. In many cases this can take time (though in some cases it is just a read or write to memory). A good slave implementation will probably create the reply telegram in a memory buffer before starting the reply at all - you want to make sure your reads and writes are atomic, and mess with creating replies on the fly. All this will naturally cause a delay on the small, cheap devices usually used on Modbus slaves.
> >>> OTOH the master Tx should not be turned off more than 1 bit time >>> before the end of last stop bit of last character, so that the last >>> stop bit will actively drive the line to mark "1" state and then let >>> the fail-safe termination passively take over the idle "1" state. >> >> That is obvious. >> >>> >>> On the slave side, each slave must be able to detect when a response >>> from an other slave has ended and when the master is sending a new >>> request to you. This requires accurate timing. Otherwise the slave >>> will concatenate the two requests and the CRC will hopefully fail and >>> after timeout, the master have to do a resend. >>> >> >> It does not need to be done by accurate time - often approximate timing >> is sufficient. And slaves can happily read and check telegrams that are >> not addressed to them (such as replies to the master) and use that for >> synchronisation. > > If the master sends the next request within 1.5 character times after > the previous slave response has ended, all slaves will combine the > previous response and next request to a single frame. >
No, they won't - not if they parse and check the telegrams as they come in (as some slaves do). Look, if you are going to use a standardised protocol, follow the standard. Assume that any other devices on the bus also follow the standard. Otherwise the whole exercise is pointless.
> >>> Agreed that implementing Modbus RTU timing accurately is hard, >>> especially at high speeds. >> >> It can be a bit fiddly, and would be easier with a concrete >> start-of-telegram character, but it is not /that/ hard. >> >>> With the QUICC I/O coprocessor (on MC68360 >>> and some PPC), this can be done relatively accurately. >> >> People do it all the time on all sorts of microcontrollers. There is no >> need for overkill on the processor power. These might be good choices >> of processor for other reasons, but for common baud rates (19.2 kbaud is >> standard, above 115.2 kbaud is very rare) you can work happily with a >> little 8-bit microcontroller. > > With any half duplex protocols, watching for the latencies is critical > to get a reasonable scan rate with multiple slaves. I once had nearly > one hundred actuators on each 230k lines (due to slew rate limited 250 > kbit/s transceiver chips on both master as well as slave) to get a few > cycles every second. The processor also handled generating controls > for all these actuators. After trimming out most latencies, it become > obvious that hundreds of amps drawn by the actuators at once would > kill the power supplies, so the control signals had to be > staggered:-).
In my experience it is usually easier to have tight control of your latencies with a small microcontroller than with a big one. My comment still stands - people do this all the time, on small microcontrollers.
> >>> Multiple >>> segments can be chained and sent out in sequence and when last segment >>> is sent, this will then interrupt the main processors. In the first >>> segment send 4 dummy characters with Tx driver disabled, in the second >>> send actual message with Tx ON and in the third segment send 3 dummy >>> characters with Tx OFF. On Rx, set the Idle timeout to 2 character >>> times. >>> >>> This will produce a 4 character preamble with 3 character trailing and >>> 2 character Rx end detection, compared to 3.5 character preample, 3.5 >>> trailer and Rx 1.5 pause detection as specified in the standard. >>> >> >> I don't know if I have ever heard of a Modbus implementation being done >> in such a complex manner. > > While some code is required on QUICC to set up the system, sending a > master frame is very simple. Just update the actual length to segment > 2 and enable transmission. The next time the master program needs to > react is when the 2 character time idle timeout of the slave response > has expired. > >> >> You turn on your driver, send out the telegram, and turn off the driver >> again. If you are trying to do this on an ancient Windows system, it is >> a bit of a pain - fortunately, that hasn't been needed for decades. > > Why would anyone try to do such tricks on brain dead IBM PC hardware.
Look at the title of the thread.
> >> When the slave receives the telegram, it interprets it, figures out the >> reply telegram, waits if necessary (and who cares if it is 3.5 character >> times or 10 ms?), turns on its driver, sends out the telegram, turns of >> the driver. > > For multidrop master, the critical thing is when the transmitter is > turned off. For a slave, the how easily the 1.5 character (or more) > time pause is detected. > >> There is no need to make a mountain out of a molehill, or use high-end >> communication controllers that are designed for things like Profibus >> (with 12 MBaud on RS-485, and hideously complicated timing and processing). > > Profibus-DP at 12 Mbit/s is nasty even electrically in a multidrop > system with frequency compensated T-connectors :-). At 1.5 Mbit/s even > barbed wire works reasonably. > > Agreed that the timing requirement is nasty, but would be quite hard > to achieve for instance 4 ms bus cycle times with multiple slaves in > software only. >
Agreed.
Reply by October 4, 20192019-10-04
On Fri, 4 Oct 2019 13:00:30 +0200, David Brown
<david.brown@hesbynett.no> wrote:

>On 04/10/2019 11:44, upsidedown@downunder.com wrote: >> On Fri, 4 Oct 2019 08:54:18 +0200, David Brown >> <david.brown@hesbynett.no> wrote: >> >>> On 03/10/2019 08:10, upsidedown@downunder.com wrote: >>>> On Wed, 2 Oct 2019 22:16:36 -0700 (PDT), Rick C >>>> <gnuarm.deletethisbit@gmail.com> wrote: >>>> >>>>> On Thursday, October 3, 2019 at 12:39:47 AM UTC-4, >>>>> upsid...@downunder.com wrote: >>>>>> On Wed, 2 Oct 2019 19:06:22 -0700 (PDT), Rick C >>>>>> <gnuarm.deletethisbit@gmail.com> wrote: >>>>>> >>>> There are dozens PLC serial protocols that supports multidrop and >>>> the timing issue may effect them all. >>>> >>> >>> I have worked with several different PLC serial protocols. Modbus RTU >>> is the only one I know of that does not have a specific start character >>> in the telegrams - for all others, "noise" characters at the start of a >>> telegram will be happily ignored. >>> >>>> The most common PLC serial protocol these days is Modbus RTU. While >>>> it has some nasty timing requirements, the master side can take some >>>> slack in timing, but this doesn't apply to Modbus slave, which needs >>>> to handle timing correctly. >>>> >>> >>> That is not true. If you want to be able to communicate with the >>> fussiest of devices on either side, you need to match the timings. That >>> means the master can't have breaks inside a telegram, or send out a new >>> request too soon before the end of the last reply. (Those are the only >>> two timings of relevance to Modbus RTU.) Equally, most Modbus masters >>> and slaves are quite relaxed about their checks and in practice lax >>> timings on a slave will not often be a problem. I simply don't see the >>> asymmetry you mention. >> >> Apart for reduced troughput, the master can safely insert a crude >> delay (such as 10 ms OS tick) before sending out the request, so there >> is at least a 3.5 character time silent period ahead of the request. > >There are no timing requirements for when a master sends a request, or >for when the slave replies, other than the minimum 3.5 character delay. > These pauses are not part of the protocol specification.
Of course not. A fixed delay of say 10 ms is sufficient to produce _at_least_ a 3.5 character pause.at speeds above 9600 bit/s. While in principle, a single 10 ms pause would be sufficient also at 4800 bit/s, the OS delay is not synchronized with the character stream.
> >> This will ensure that all slaves can reliably detect a pause between >> frames (even if not addressed to your slave). You could even skip the >> extra delay when sending multiple requests to the same slave, > >You can't skip the 3.5 character delay - whether you are sending to the >same or a different device. Any delay beyond that is entirely up to the >device sending. (This is the same for masters and slaves.)
In practice, most slaves after sending the response go _immediately_ into Rx mode, so the master could send the next request immediately. This works very well in practice. Modbus point to point connections work well, without observing accurate timing.
> >> but it >> definitively needed when first accessing one slave and then send next >> request to a new slave, so that the new slave will reliably separate >> the response from the old slave and the next request addressed to your >> slave. >> >> After sending the request, the master should disable the transmitter >> and let the fail-safe termination drive the bus into idle state. There >> is a timing window up to 70 bit times (3.5 master character times + >> 3.5 character slave preamble) for the master to go from Tx to Rx. In >> practice, this window may have to be limited to 10-20 bit times for >> more or less standard slave implementations. > >Slaves are not allowed to reply before the 3.5 character time break. >There is no protocol-specified maximum delay time.
How many of those thousands of different Modbus slave devices actually follow this ?
>> OTOH the master Tx should not be turned off more than 1 bit time >> before the end of last stop bit of last character, so that the last >> stop bit will actively drive the line to mark "1" state and then let >> the fail-safe termination passively take over the idle "1" state. > >That is obvious. > >> >> On the slave side, each slave must be able to detect when a response >> from an other slave has ended and when the master is sending a new >> request to you. This requires accurate timing. Otherwise the slave >> will concatenate the two requests and the CRC will hopefully fail and >> after timeout, the master have to do a resend. >> > >It does not need to be done by accurate time - often approximate timing >is sufficient. And slaves can happily read and check telegrams that are >not addressed to them (such as replies to the master) and use that for >synchronisation.
If the master sends the next request within 1.5 character times after the previous slave response has ended, all slaves will combine the previous response and next request to a single frame.
>> Agreed that implementing Modbus RTU timing accurately is hard, >> especially at high speeds. > >It can be a bit fiddly, and would be easier with a concrete >start-of-telegram character, but it is not /that/ hard. > >> With the QUICC I/O coprocessor (on MC68360 >> and some PPC), this can be done relatively accurately. > >People do it all the time on all sorts of microcontrollers. There is no >need for overkill on the processor power. These might be good choices >of processor for other reasons, but for common baud rates (19.2 kbaud is >standard, above 115.2 kbaud is very rare) you can work happily with a >little 8-bit microcontroller.
With any half duplex protocols, watching for the latencies is critical to get a reasonable scan rate with multiple slaves. I once had nearly one hundred actuators on each 230k lines (due to slew rate limited 250 kbit/s transceiver chips on both master as well as slave) to get a few cycles every second. The processor also handled generating controls for all these actuators. After trimming out most latencies, it become obvious that hundreds of amps drawn by the actuators at once would kill the power supplies, so the control signals had to be staggered:-).
>> Multiple >> segments can be chained and sent out in sequence and when last segment >> is sent, this will then interrupt the main processors. In the first >> segment send 4 dummy characters with Tx driver disabled, in the second >> send actual message with Tx ON and in the third segment send 3 dummy >> characters with Tx OFF. On Rx, set the Idle timeout to 2 character >> times. >> >> This will produce a 4 character preamble with 3 character trailing and >> 2 character Rx end detection, compared to 3.5 character preample, 3.5 >> trailer and Rx 1.5 pause detection as specified in the standard. >> > >I don't know if I have ever heard of a Modbus implementation being done >in such a complex manner.
While some code is required on QUICC to set up the system, sending a master frame is very simple. Just update the actual length to segment 2 and enable transmission. The next time the master program needs to react is when the 2 character time idle timeout of the slave response has expired.
> >You turn on your driver, send out the telegram, and turn off the driver >again. If you are trying to do this on an ancient Windows system, it is >a bit of a pain - fortunately, that hasn't been needed for decades.
Why would anyone try to do such tricks on brain dead IBM PC hardware.
>When the slave receives the telegram, it interprets it, figures out the >reply telegram, waits if necessary (and who cares if it is 3.5 character >times or 10 ms?), turns on its driver, sends out the telegram, turns of >the driver.
For multidrop master, the critical thing is when the transmitter is turned off. For a slave, the how easily the 1.5 character (or more) time pause is detected.
>There is no need to make a mountain out of a molehill, or use high-end >communication controllers that are designed for things like Profibus >(with 12 MBaud on RS-485, and hideously complicated timing and processing).
Profibus-DP at 12 Mbit/s is nasty even electrically in a multidrop system with frequency compensated T-connectors :-). At 1.5 Mbit/s even barbed wire works reasonably. Agreed that the timing requirement is nasty, but would be quite hard to achieve for instance 4 ms bus cycle times with multiple slaves in software only.
Reply by David Brown October 4, 20192019-10-04
On 04/10/2019 12:16, Rick C wrote:
> On Friday, October 4, 2019 at 3:43:41 AM UTC-4, David Brown wrote: >> On 03/10/2019 17:04, Rick C wrote: >>> On Thursday, October 3, 2019 at 3:35:31 AM UTC-4, David Brown >>> wrote: >>>> On 03/10/2019 04:06, Rick C wrote: >>>>> On Wednesday, October 2, 2019 at 6:11:58 PM UTC-4, >>>>> upsid...@downunder.com wrote: >>> >>>>>> These days I prefer ethernet to serial converters with >>>>>> proper Rx/Tx hardware switching. These work fine and you >>>>>> get 100 m range and galvanic isolation for 'free'. >>>>> >>>>> It's great if your device has an Ethernet port. I don't >>>>> know what it takes to set up the connection, but I know it >>>>> was a bear to get two Windows 10 PCs to talk to each other >>>>> over Ethernet, things like fill sharing. Years before I use >>>>> a web site WOW.com (World of Windows networking) or maybe it >>>>> was WOWN.com, I forget. It had the straight skinny on getting >>>>> Win2k working and made it easy. After Win2k MS seems to have >>>>> made Ethernet harder and harder with each new generation. >>>>> Meanwhile WOWN.com was sold and the new guys didn't care >>>>> about content, they just milked the traffic for advertising. >>>> >>>> How are you trying to connect the PC's ? Just a single >>>> Ethernet cable between them, or putting them on an existing >>>> network? >>>> >>>> (You are right that MS seems to make many tasks, like >>>> networking, harder for each generation of Windows.) >>> >>> Single cable between them. I think I also tried using my home >>> network but got zero traction with that. The old system I used >>> was a cable between two Win2k desktops. >>> >> >> You might, perhaps, need a cross-over cable for a direct >> connection. > > Lol, I would have been able to tell pretty easily if that were the > trouble.
I expect so. But I thought I'd better mention it just in case - maybe others are reading these posts.
> > >> Otherwise it is a matter of giving the two machines fixed IP >> addresses on the same network. Then IP networking should work. I >> haven't tried this with Windows machines, but I don't see any >> reason why you should have trouble. I certainly don't see any need >> for third-party software. > > Yes, Windows always makes things so easy.
Sarcasm, I assume? Windows makes /some/ things easy - but then the next version will complete change the way it is done.
> Parts would work and then > stop working. At one time I was able to run either laptop from the > other using the remote console feature or whatever they call it when > your screen, keyboard and mouse operate the remote machine. Then it > wouldn't work in one direction. File sharing wouldn't work. I spent > hours digging around on the Internet but most web sites just give the > same, lame first level instructions on how to set it up and nothing > on trouble shooting. > > >> If you prefer, any cheap router will do the job. Just connect both >> PC's to LAN ports on the router - you don't need anything connected >> to the "Internet" port on the router, or any setup. Each PC will >> get an IP address by DHCP and they can communicate. > > Didn't work any better.
Are the laptops going into low-power modes, or something like that? (Yes, I know that may be another silly question.)
> > >> (You might need to partially disable the local firewall junk on >> the Windows PC's to let them listen to each other. And if you have >> any third-party "security" crapware, it's best to get rid of it.) > > Totally off. > > That was months ago when I was setting up some PCs for work and the > easy way to copy stuff would have been by Ethernet. Instead I ended > up using USB memory sticks. Windows sucks. >
It sounds like you have tried most of the things I can think of for now. Have you tried VNC rather than RDP? And of course, you can always switch to Linux.
Reply by David Brown October 4, 20192019-10-04
On 04/10/2019 11:44, upsidedown@downunder.com wrote:
> On Fri, 4 Oct 2019 08:54:18 +0200, David Brown > <david.brown@hesbynett.no> wrote: > >> On 03/10/2019 08:10, upsidedown@downunder.com wrote: >>> On Wed, 2 Oct 2019 22:16:36 -0700 (PDT), Rick C >>> <gnuarm.deletethisbit@gmail.com> wrote: >>> >>>> On Thursday, October 3, 2019 at 12:39:47 AM UTC-4, >>>> upsid...@downunder.com wrote: >>>>> On Wed, 2 Oct 2019 19:06:22 -0700 (PDT), Rick C >>>>> <gnuarm.deletethisbit@gmail.com> wrote: >>>>> >>> There are dozens PLC serial protocols that supports multidrop and >>> the timing issue may effect them all. >>> >> >> I have worked with several different PLC serial protocols. Modbus RTU >> is the only one I know of that does not have a specific start character >> in the telegrams - for all others, "noise" characters at the start of a >> telegram will be happily ignored. >> >>> The most common PLC serial protocol these days is Modbus RTU. While >>> it has some nasty timing requirements, the master side can take some >>> slack in timing, but this doesn't apply to Modbus slave, which needs >>> to handle timing correctly. >>> >> >> That is not true. If you want to be able to communicate with the >> fussiest of devices on either side, you need to match the timings. That >> means the master can't have breaks inside a telegram, or send out a new >> request too soon before the end of the last reply. (Those are the only >> two timings of relevance to Modbus RTU.) Equally, most Modbus masters >> and slaves are quite relaxed about their checks and in practice lax >> timings on a slave will not often be a problem. I simply don't see the >> asymmetry you mention. > > Apart for reduced troughput, the master can safely insert a crude > delay (such as 10 ms OS tick) before sending out the request, so there > is at least a 3.5 character time silent period ahead of the request.
There are no timing requirements for when a master sends a request, or for when the slave replies, other than the minimum 3.5 character delay. These pauses are not part of the protocol specification.
> This will ensure that all slaves can reliably detect a pause between > frames (even if not addressed to your slave). You could even skip the > extra delay when sending multiple requests to the same slave,
You can't skip the 3.5 character delay - whether you are sending to the same or a different device. Any delay beyond that is entirely up to the device sending. (This is the same for masters and slaves.)
> but it > definitively needed when first accessing one slave and then send next > request to a new slave, so that the new slave will reliably separate > the response from the old slave and the next request addressed to your > slave. > > After sending the request, the master should disable the transmitter > and let the fail-safe termination drive the bus into idle state. There > is a timing window up to 70 bit times (3.5 master character times + > 3.5 character slave preamble) for the master to go from Tx to Rx. In > practice, this window may have to be limited to 10-20 bit times for > more or less standard slave implementations.
Slaves are not allowed to reply before the 3.5 character time break. There is no protocol-specified maximum delay time.
> > OTOH the master Tx should not be turned off more than 1 bit time > before the end of last stop bit of last character, so that the last > stop bit will actively drive the line to mark "1" state and then let > the fail-safe termination passively take over the idle "1" state.
That is obvious.
> > On the slave side, each slave must be able to detect when a response > from an other slave has ended and when the master is sending a new > request to you. This requires accurate timing. Otherwise the slave > will concatenate the two requests and the CRC will hopefully fail and > after timeout, the master have to do a resend. >
It does not need to be done by accurate time - often approximate timing is sufficient. And slaves can happily read and check telegrams that are not addressed to them (such as replies to the master) and use that for synchronisation.
> > Agreed that implementing Modbus RTU timing accurately is hard, > especially at high speeds.
It can be a bit fiddly, and would be easier with a concrete start-of-telegram character, but it is not /that/ hard.
> With the QUICC I/O coprocessor (on MC68360 > and some PPC), this can be done relatively accurately.
People do it all the time on all sorts of microcontrollers. There is no need for overkill on the processor power. These might be good choices of processor for other reasons, but for common baud rates (19.2 kbaud is standard, above 115.2 kbaud is very rare) you can work happily with a little 8-bit microcontroller.
> Multiple > segments can be chained and sent out in sequence and when last segment > is sent, this will then interrupt the main processors. In the first > segment send 4 dummy characters with Tx driver disabled, in the second > send actual message with Tx ON and in the third segment send 3 dummy > characters with Tx OFF. On Rx, set the Idle timeout to 2 character > times. > > This will produce a 4 character preamble with 3 character trailing and > 2 character Rx end detection, compared to 3.5 character preample, 3.5 > trailer and Rx 1.5 pause detection as specified in the standard. >
I don't know if I have ever heard of a Modbus implementation being done in such a complex manner. You turn on your driver, send out the telegram, and turn off the driver again. If you are trying to do this on an ancient Windows system, it is a bit of a pain - fortunately, that hasn't been needed for decades. When the slave receives the telegram, it interprets it, figures out the reply telegram, waits if necessary (and who cares if it is 3.5 character times or 10 ms?), turns on its driver, sends out the telegram, turns of the driver. There is no need to make a mountain out of a molehill, or use high-end communication controllers that are designed for things like Profibus (with 12 MBaud on RS-485, and hideously complicated timing and processing).
>> It /is/ the case that an 0xff character could be the start of a Modbus >> RTU telegram, and therefore you need to be careful about using one as an >> extra interrupt-generator for switching the RS-485 bus. >> >
Reply by Rick C October 4, 20192019-10-04
On Friday, October 4, 2019 at 3:43:41 AM UTC-4, David Brown wrote:
> On 03/10/2019 17:04, Rick C wrote: > > On Thursday, October 3, 2019 at 3:35:31 AM UTC-4, David Brown wrote: > >> On 03/10/2019 04:06, Rick C wrote: > >>> On Wednesday, October 2, 2019 at 6:11:58 PM UTC-4, > >>> upsid...@downunder.com wrote: > > > >>>> These days I prefer ethernet to serial converters with proper > >>>> Rx/Tx hardware switching. These work fine and you get 100 m > >>>> range and galvanic isolation for 'free'. > >>> > >>> It's great if your device has an Ethernet port. I don't know > >>> what it takes to set up the connection, but I know it was a bear > >>> to get two Windows 10 PCs to talk to each other over Ethernet, > >>> things like fill sharing. Years before I use a web site WOW.com > >>> (World of Windows networking) or maybe it was WOWN.com, I forget. > >>> It had the straight skinny on getting Win2k working and made it > >>> easy. After Win2k MS seems to have made Ethernet harder and > >>> harder with each new generation. Meanwhile WOWN.com was sold and > >>> the new guys didn't care about content, they just milked the > >>> traffic for advertising. > >> > >> How are you trying to connect the PC's ? Just a single Ethernet > >> cable between them, or putting them on an existing network? > >> > >> (You are right that MS seems to make many tasks, like networking, > >> harder for each generation of Windows.) > > > > Single cable between them. I think I also tried using my home > > network but got zero traction with that. The old system I used was a > > cable between two Win2k desktops. > > > > You might, perhaps, need a cross-over cable for a direct connection.
Lol, I would have been able to tell pretty easily if that were the trouble.
> Otherwise it is a matter of giving the two machines fixed IP addresses > on the same network. Then IP networking should work. I haven't tried > this with Windows machines, but I don't see any reason why you should > have trouble. I certainly don't see any need for third-party software.
Yes, Windows always makes things so easy. Parts would work and then stop working. At one time I was able to run either laptop from the other using the remote console feature or whatever they call it when your screen, keyboard and mouse operate the remote machine. Then it wouldn't work in one direction. File sharing wouldn't work. I spent hours digging around on the Internet but most web sites just give the same, lame first level instructions on how to set it up and nothing on trouble shooting.
> If you prefer, any cheap router will do the job. Just connect both PC's > to LAN ports on the router - you don't need anything connected to the > "Internet" port on the router, or any setup. Each PC will get an IP > address by DHCP and they can communicate.
Didn't work any better.
> (You might need to partially disable the local firewall junk on the > Windows PC's to let them listen to each other. And if you have any > third-party "security" crapware, it's best to get rid of it.)
Totally off. That was months ago when I was setting up some PCs for work and the easy way to copy stuff would have been by Ethernet. Instead I ended up using USB memory sticks. Windows sucks. -- Rick C. -+ Get 2,000 miles of free Supercharging -+ Tesla referral code - https://ts.la/richard11209
Reply by October 4, 20192019-10-04
On Fri, 4 Oct 2019 09:45:38 +0200, David Brown
<david.brown@hesbynett.no> wrote:

>On 03/10/2019 19:15, upsidedown@downunder.com wrote: >> On Thu, 3 Oct 2019 11:12:15 +0200, David Brown >> <david.brown@hesbynett.no> wrote: >> >>> On 03/10/2019 09:59, upsidedown@downunder.com wrote: >>>> On Thu, 3 Oct 2019 09:19:41 +0200, David Brown >>>> <david.brown@hesbynett.no> wrote: >>>> >>>>> On 03/10/2019 00:11, upsidedown@downunder.com wrote: >>>>>> On Wed, 2 Oct 2019 12:12:06 +0200, David Brown >>>>>> <david.brown@hesbynett.no> wrote: >>>>>> >>> >>>>> There was a common trick of sending an extra 0xff character beyond the >>>>> telegram you wanted to send, and when you got the interrupt as that >>>>> moved into the transmit register, you turned off the RS-485 driver. >>>>> This had a risk of letting a start bit, or part of a start bit, get >>>>> through - but for most protocols that was not an issue as it would be >>>>> ignored by the receiver. >>>> >>>> This is true for most protocols, but not with Modbus RTU, since if the >>>> start bit gets trough, it calculates the frame length incorrectly and >>>> tries to locate the CRC from the wrong position. >>> >>> Modbus requires a break before the start of the telegram - at least 3.5 >>> character times. A slave that checks this will not be bothered by the >>> noise. >>> >>> Failing that, it is not uncommon to avoid address 255 and consider a >>> start address of 255 as noise. >> >> Is this the reason why Modbus RTU documentation defines slave address >> range 1 .. 247 (oxF7) ? > >That could be the case. Or they might have other reasons - sometimes I >wonder what the Modbus designers were thinking for some of their rather >arbitrary decisions.
The strange is that I saw this limitation only quite recently (maybe a decade or so) ago. Modbus/TCP Unit number (=slave address) field can be 0 - 255. This is useful especially for Modbus/TCP to Modbus RTU gateways. For native Modbus/TCP devices, which is essentially point to point, the recommended unit number is 255.
>> >>> But it certainly /can/ be an issue, and should be considered when >>> designing a system. >>