Modbus Slave Starting Addresses
Moderator: Benj
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Modbus Slave Starting Addresses
Hi All,
This is my first time posting so please forgive me if I am posting in the wrong place or way. I have hunted through the posts and help pages but can find no help or instructions on this. I am making a device that uses 10 identical PCB's that collect data and using Modbus RTU over RS422 send the data to a PLC for distribution on to a company network. I am using MAX 491 RS422 transceivers and I have the hardware side working. Come to my problem, as each of the PCBs are the same really didn't want to flash each PIC separately, the idea being that there is an ID DIP switch that sets the slave ID / address of each PCB, this way a spare can be held and substituted easily if required. It appears that I need to change the starting addresses, in my case for the coils and the registers from the program as the Slave ID changes. So, if Slave ID is 1 then starting address might be 0 and number of addresses 10, then when the slave ID is changed to 3, say, the starting addresses need to be increased to 20. I have tried every way I can think of to change these property variables from the program, they don't appear as Macros in the components explorer, I have right clicked the property and set the "expose to top level" which has added them to the explorer tree in the calculation component, but if I try to set those variables it just brings up an error about the variable being on the wrong side of the equals sign. Please help, this one has got me and I have spent hours researching and trying all manor of things, none that have worked. Any help or ideas would be much appreciated.
Simon.
This is my first time posting so please forgive me if I am posting in the wrong place or way. I have hunted through the posts and help pages but can find no help or instructions on this. I am making a device that uses 10 identical PCB's that collect data and using Modbus RTU over RS422 send the data to a PLC for distribution on to a company network. I am using MAX 491 RS422 transceivers and I have the hardware side working. Come to my problem, as each of the PCBs are the same really didn't want to flash each PIC separately, the idea being that there is an ID DIP switch that sets the slave ID / address of each PCB, this way a spare can be held and substituted easily if required. It appears that I need to change the starting addresses, in my case for the coils and the registers from the program as the Slave ID changes. So, if Slave ID is 1 then starting address might be 0 and number of addresses 10, then when the slave ID is changed to 3, say, the starting addresses need to be increased to 20. I have tried every way I can think of to change these property variables from the program, they don't appear as Macros in the components explorer, I have right clicked the property and set the "expose to top level" which has added them to the explorer tree in the calculation component, but if I try to set those variables it just brings up an error about the variable being on the wrong side of the equals sign. Please help, this one has got me and I have spent hours researching and trying all manor of things, none that have worked. Any help or ideas would be much appreciated.
Simon.
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Modbus Slave Starting Addresses
Hello! Simon
Is it possible for you to post the chart to understand better, i have worked on RS485 slave, i will try my best to help/explain.
Abhi
Is it possible for you to post the chart to understand better, i have worked on RS485 slave, i will try my best to help/explain.
Abhi
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Re: Modbus Slave Starting Addresses
Hi Abhi,
I appreciate your help with this. I have attached the code I have working as a master- single slave setup, not that there is much of it at the moment, the Modbus part is the bit that's new to me, so I thought I would get that working first. I know that the code isn't quite correct to eliminate time out errors etc. I just haven't gone there yet. The problem came when I tried to add a second or more devices to the mix. I had assumed that each slave ID would create a new set of registers that started from 0 (or 40001), it would appear I was wrong and that the starting address needs to be incremented with the slave ID by the number of registers I am using. I am testing using Modbus Poll on a laptop at the moment. It's changing the starting address from the program that I am having the issue with. Presumably this is possible, actually it's probably quite simple and I have looked at it so long I have become blind to it!!
Many Thanks.
Simon
I appreciate your help with this. I have attached the code I have working as a master- single slave setup, not that there is much of it at the moment, the Modbus part is the bit that's new to me, so I thought I would get that working first. I know that the code isn't quite correct to eliminate time out errors etc. I just haven't gone there yet. The problem came when I tried to add a second or more devices to the mix. I had assumed that each slave ID would create a new set of registers that started from 0 (or 40001), it would appear I was wrong and that the starting address needs to be incremented with the slave ID by the number of registers I am using. I am testing using Modbus Poll on a laptop at the moment. It's changing the starting address from the program that I am having the issue with. Presumably this is possible, actually it's probably quite simple and I have looked at it so long I have become blind to it!!
Many Thanks.
Simon
- Attachments
-
- Modbus Dev V1_0.fcfx
- (21.72 KiB) Downloaded 129 times
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Modbus Slave Starting Addresses
Hello! Simon
I will check your chat once i get free, can you check the below link, if it is of any help.
viewtopic.php?p=101424#p101424
Abhi
I will check your chat once i get free, can you check the below link, if it is of any help.
viewtopic.php?p=101424#p101424
Abhi
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Re: Modbus Slave Starting Addresses
Hi Abhi,
Thanks for this, I have already seen this link, but it appears that this is just a master talking to one slave. I have that working fine, it's adding additional slaves to the mix that is causing me the issue. Modbus Poll flags up an error if you re-use the same addresses for additional slaves. I am sure that if I can change the starting addresses from the Flowcode program, proportionate to the slave ID it will solve my problem, I just can't find a way of doing it.
Simon.
Thanks for this, I have already seen this link, but it appears that this is just a master talking to one slave. I have that working fine, it's adding additional slaves to the mix that is causing me the issue. Modbus Poll flags up an error if you re-use the same addresses for additional slaves. I am sure that if I can change the starting addresses from the Flowcode program, proportionate to the slave ID it will solve my problem, I just can't find a way of doing it.
Simon.
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Modbus Slave Starting Addresses
Hello! Simon
If you are able to work correctly with a master and one of the slaves then you are doing okay, do not worry about the starting addresses of the input, coil, analog and registers, let them start with zero only that is not a problem.
Just make sure when you change the address of the slaves (from 1-10) on all the PCB (if i have not mistaken you are using DIP switch) make sure that is happening correctly, if the slave address remain same by mistake then the master do some error in reading the values from 2 same slave address.
I always use the ADAM -4561 to test the modbus slave working on computer, i use MODSCAN-32 on computer.
I notice in your chart, you have mentioned 8 addresses for input and coil 1 for analog and 5 for registers, try to keep this counts same for all, if you do not have memory issues on your chip, or else you need to mention the length for what you are reading on the computer software, i mean if you are reading coils then you need to mention length=8 on computer if analog then length=1 in computer, likewise, so i always keep the addresses count same for all so i need not change the length in computer always.
When you read the slave one by one on the computer by changing the slave address you will automatically notice the values changing for input or coil etc even if you keep the starting address zero for all.
I hope i was able to explain my observations, if you still find it difficult do ping.
Abhi
If you are able to work correctly with a master and one of the slaves then you are doing okay, do not worry about the starting addresses of the input, coil, analog and registers, let them start with zero only that is not a problem.
Just make sure when you change the address of the slaves (from 1-10) on all the PCB (if i have not mistaken you are using DIP switch) make sure that is happening correctly, if the slave address remain same by mistake then the master do some error in reading the values from 2 same slave address.
I always use the ADAM -4561 to test the modbus slave working on computer, i use MODSCAN-32 on computer.
I notice in your chart, you have mentioned 8 addresses for input and coil 1 for analog and 5 for registers, try to keep this counts same for all, if you do not have memory issues on your chip, or else you need to mention the length for what you are reading on the computer software, i mean if you are reading coils then you need to mention length=8 on computer if analog then length=1 in computer, likewise, so i always keep the addresses count same for all so i need not change the length in computer always.
When you read the slave one by one on the computer by changing the slave address you will automatically notice the values changing for input or coil etc even if you keep the starting address zero for all.
I hope i was able to explain my observations, if you still find it difficult do ping.
Abhi
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Re: Modbus Slave Starting Addresses
Hi Abhi,
Thanks very much for your reply, OK on the start addresses, I will give that another go, I have brought a Modbus Poll licence and I am wondering if thats whats causing my problem, it seems that I should be able to open several windows in it and look at different registers on different slaves at the same time. It's when I try this that it all fails, that's when I assumed that I was having address issues. However I have been working on this again this afternoon and I tried loading different versions with different start addresses into 2 devices, still got the errors.
Yes you are quite correct, I have 4 DIP switches for the address, that does appear to work as with a single slave I can change the address on both the PC and the PIC and get them to talk.
I have to confess I don't have a decent converter like the Adams unit, its a cheaper version, however it does seem to work OK. But I will keep an eye on that in case it's struggling to drive multiple slaves.
OK on the address quantities, I have actually set them all back to 10 as I wondered if that was a problem, yes in Modbus Poll you have to set the quantities up correctly as well, I discovered that early on!!!
Very annoyingly I have been called out tomorrow morning, I will have another go when I get back and see what happens. I will let you know how I get on. I think i might try MODSCAN as well.
Thanks again.
Simon.
Thanks very much for your reply, OK on the start addresses, I will give that another go, I have brought a Modbus Poll licence and I am wondering if thats whats causing my problem, it seems that I should be able to open several windows in it and look at different registers on different slaves at the same time. It's when I try this that it all fails, that's when I assumed that I was having address issues. However I have been working on this again this afternoon and I tried loading different versions with different start addresses into 2 devices, still got the errors.
Yes you are quite correct, I have 4 DIP switches for the address, that does appear to work as with a single slave I can change the address on both the PC and the PIC and get them to talk.
I have to confess I don't have a decent converter like the Adams unit, its a cheaper version, however it does seem to work OK. But I will keep an eye on that in case it's struggling to drive multiple slaves.
OK on the address quantities, I have actually set them all back to 10 as I wondered if that was a problem, yes in Modbus Poll you have to set the quantities up correctly as well, I discovered that early on!!!
Very annoyingly I have been called out tomorrow morning, I will have another go when I get back and see what happens. I will let you know how I get on. I think i might try MODSCAN as well.
Thanks again.
Simon.
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Re: Modbus Slave Starting Addresses
Thanks again for your help Abhi,
I have this working now. I can't display all of the slaves on the PC screen, using Modbus Poll, at the same time, but I can look at each slave individually, which I think will work with the PLC as the program can just call each slave individually. There is nothing fast in this project so should work fine.
Much appreciated.
SImon.
I have this working now. I can't display all of the slaves on the PC screen, using Modbus Poll, at the same time, but I can look at each slave individually, which I think will work with the PLC as the program can just call each slave individually. There is nothing fast in this project so should work fine.
Much appreciated.
SImon.
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Modbus Slave Starting Addresses
Hello! Simon
I am happy to hear your project is working, thank you.
Abhi
I am happy to hear your project is working, thank you.
Abhi
-
- Posts: 12
- Joined: Thu Aug 19, 2021 12:43 pm
- Has thanked: 1 time
- Been thanked: 1 time
- Contact:
Re: Modbus Slave Starting Addresses
Hi Viktor,
Modbus Poll is $129, I purchased Poll and Slave together and it was £167.40 UK all in.
The website is https://www.modbustools.com/order.html
As I said, I have it working now but I can't set it up so that I can look at multiple Slaves together, I can only look at one at a time, although it indicates I should be able to. I am not sure if this is a problem with Poll or how I have it set up.
Simon.
Modbus Poll is $129, I purchased Poll and Slave together and it was £167.40 UK all in.
The website is https://www.modbustools.com/order.html
As I said, I have it working now but I can't set it up so that I can look at multiple Slaves together, I can only look at one at a time, although it indicates I should be able to. I am not sure if this is a problem with Poll or how I have it set up.
Simon.