MODBUS RTU mode read/write ASCII value

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.

I have a project with modbus. ( it is my first modbus device).

Customer want Modbus RTU and some Holding register has "ascii value" 

Holding register have 16 bit and will use / set "2  ASCII char" per register.

ok but it is the right way? if not

what is the data format for read/write  ASCII value in RTU mode ?

the value the customer want is some "ID name" ++++

 

MODBUS RTU mode fast choice.

ASCII value fast choice. 

Make a no standard protocol way can be my choice but if it is a "right way" I will see.

Thank you

Thierry

 

 

 

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, it is a bit tricky to sort out.  I have a number of Modbus RTU systems.  An e.g. 8-character name is stored in four consecutive 16-bit Modbus "registers".

 

On the decode end, it takes a bit of fussing as Modbus is big-endian.  But the brute-force approach is often the easiest.  If the name is "ABCDEFGH" and the receiver decodes it as "BADCFEHG" then a swap is needed of each pair.  If it is interpreted as 32-bit or 64-bit little-endian values, than more swapping is needed.

 

Once known, you could do the swapping on the AVR side to make it easier for the host side.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you.. well more compact 4 bit directly! yes.... 

yes easy to swapping from AVR but most direct if I use 8 bit / ascii from the holding.

will place all holding with ascii value from a fast address , easy to make the "4 bit ascii x 4  to 16 bit register".

 

Thierry

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What are you talking about -- "4-bit ASCII"?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes first 4 bit is 0x3X data are the last 4 bit...

4 bit is enough to store.. not to use

 

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Suit yourself.  That is not what you said earlier...

TPE wrote:
the value the customer want is some "ID name"

What does that have to do with packed-BCD digits?  Very little, IMO.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

not for my application I must have full ascii but for "Theusch" case need only number... 

I must use 8 bit .

Thierry

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think something got lost in the translation - the suggestion was you needed two swap the bytes in the 16 bit 'register' word. 

I too used the same scheme many years ago and I was working with the 90's modbus spec from Schneider and it didn't have a means of representing strings.

 

It might be worth reading the latest modbus specs to see if there is an 'official' way of doing it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you "Kartman" 

not realy found the way by "official" but a lot of example than make 2 ascii byte in one int 

I will just place right way when the com from "SMS source" and naturell place if com from RTU master.

 

Thierry 

Thierry Pottier