8/16/2010 3:14 PM | |
Joined: 1/17/2007 Last visit: 3/10/2025 Posts: 1557 Rating:
|
I assume that the 3 meters are on the same RS485 bus. If that is the case, then each meter (modbus slave device) must have its own unique slave address. It would be logical to assume that you will be acessing the same data registers from each slave device (is this the case?). The customer will have provided you with a register map of the slave. This usually takes the form of a list that has address and data columns (plus some possible additional columns such as min/max ranges). The addresses will dictate which function code you will need to use to access the data from the slave devices:- Adresses in the range 00001 to 09998 are coils and are read using function code 01 Adresses in the range 10001 to 19998 are discrete inputs and are read using function code 02 Adresses in the range 30001 to 39998 are input registers and are read using function code 04 Adresses in the range 40001 upwards are holding registers and are read using function code 03 The source DB holds the data for each telegram request. A request consists of:- Slave address, function code, data start address, number of data points to receive and a CRC. You will need to setup the slave address, function code, start address and number of data points to receive in your source DB. The dest DB is where the recieved data is stored. It is usual to store the data in the DB starting at address 0. This will be fine. You just have to make sure that your dest DB is large enough to accomodate the recieved data (note: modbus registers are 16-bit values so you will need twice as many bytes in your dest DB to store the data - coils and discrete inputs are booleans so you can fit 8 of these to one byte in the dest DB). Now assuming that I am correct that each meter is a seprate slave device, you will need to repeat this telegram request for each slave in turn. Now you can either put the data from each slave in the same dest DB or in different dest DB's. The former requires you to change the recieve address pointer (the DBB) such that the data from each slave does not overlap in the dest DB. The latter you can leave the DB address 0, but you will need to change the DB value for each request so that it loads the data to another DB. It is explained here at the top of page three of this thread. |
Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
8/20/2010 2:28 PM | |
Posts: 152 Rating:
|
hi all i am back again, after doing some research how to start with MODBUS program. Now I have 5 salves 3 pqm meters, 2 multiin meters from GE: One master CP341 the CFC to send-receive the data, is attached here in pdf. ; I write the code only for 3 for testing purpose .I have few question now, to know whether I am in right direction or not, 1) Is it ok to use same DB for SEND-RECIVE data, (I used same DB by giving OFFSET at DBB_NO) 2) the customer want to the data from registers 0240,0241;0242;0243 and 0288 028A;028C;028E;0290;02F0; 02F2,03D0; 03DA; and 0440.etc… in PQM meter. And in PQM meter memory map (refer page no 18 to 60 ), these are not in consecutive registers but scattered. so while reading in the DB, is it ok to keep so much spares (which are not required to read). Then DB will be very big at the end !!! (PS; in the DB block, all spare registers are not defined, I want to do after taking your value advices Thanks in advance for your advices. sun Attachmentcfc&db.pdf (216 Downloads) |
Last edited by: sun7 at: 8/20/2010 2:30 PM |
|
8/20/2010 2:31 PM | |
Posts: 152 Rating:
|
PQM meter memory map start frompage 18 AttachmentGEK-113532.pdf (206 Downloads) |
Follow us on