s7 & Modbus

ThePortLion

Member
Join Date
Oct 2007
Location
Ireland
Posts
58
Guys, I have been handed a flow meter with an RS485 interface
and asked to get it talking to a Siemens S7-317 PLC.
I happen to have a CP341 (341-1CH01-0AE0) card. I dont know
where it came from but basically I just need to know where
to start with this. I've never used modbus before so this is
new to me. I'm not looking for the solution, just any helpful
pointers to get me started.

Thanks
 
Hi,

A little more info would help, but i'll kick it off anyway...

Yes, you should be good with the CP341 module, but you will need to obtain the necessary software drivers to enable communication to your flow meter. This will depend on the type of configuration of your meter. If the meter is a Modbus MASTER, you'll need to set your CP341 as a SLAVE, and obviously, if it's the other way round, the opposite drivers apply.

Most i've used are RS485 2-wire, which should be fine for the Siemens card. If the meter is the MASTER then there's not too much you'll need to write code side (map required memory to READ the Modbus Data). If the CP341 needs to be the MASTER, then it's a bit more involved, and you'll need to create some sort of communication sequence to poll the various registers in the meter.

Hopefully this will help start you off...!

Regards,

Rob
 
There is a standard program in the S7 library which I modified and used to poll data from 6 different modbus stations.

Basically there were 12 sets of data per station being read into a temporary register and I just "Block moved" it to somewhere else. If you only have 1 flowmeter, you might not have to do this.

I think my card had a dongle plugged in the back which Siemens called "Firmware" and charged £800 for!
 
Last edited:
a flow meter with an RS485 interface
RS-485 is like a mule. It carries data. It doesn't pack the data, it doesn't unload the data, it doesn't care what format or set of rules (protocol) are used to transfer data, just like a mule.

So you need to confirm which protocol the flow meter uses for access to the data. It is likely Modbus RTU or Modbus ASCII, but it could be a proprietary protocol.

Every flowmeter I have ever run into is a Modbus slave. Modbus Slaves always have a register map that shows which register(s) have which data. The manufacturer is responsible for supply the Modbus map for its devices.
 
Thanks fellas

The meter will be set up as a modbus slave. It supports
RS485 (half duplex). In the Cp341 settings in hardware
I have set up Half duplex RS485 in ASCII protocol and
also set the meter up for Modbus ASCII.

As far as I know I will only be reading 3 values from the meter
and maybe writing 3 values back to the meter at certain times.

I'm reading up on the addressing map for the meter but I'm
not sure how I will read and write to this meter in half
duplex mode. Do i need to code it that a read operation has
completed before I can commence a write command?
 
Last edited:
... set the meter up for Modbus ASCII.

As far as I know I will only be reading 3 values from the meter
and maybe writing 3 values back to the meter at certain times.

I'm reading up on the addressing map for the meter but I'm
not sure how I will read and write to this meter in half
duplex mode. Do i need to code it that a read operation has
completed before I can commence a write command?

Yes.

I have only used RTU slaves before, but with ASCII on the CP441-card. I'd do it more or less like this:

- Build the request/command telegram
- Calculate the LRC
- Activate sending
- Preset timeout

- If timeout, try resending x times
- If no of retries is reached, set error, increase timeout error cunter.

- When telegram is received,
- calculate and check the LRC. If it does not correspond with the telegram tail, show an error, increase a LRC error counter.
- Check if the telegram header is as expected.
- Copy the received tlg data part from the mailbox to this slave node's data area.
- Clear the mailbox, or at least the first bytes.
- Increase valid data counter for this node.
- Release for new request.

If there are errors or timeouts, one must have a strategy how to act. If a tank level reading has failed, perhaps it is wise to stop pumping.


For comparization; If this was Profi IO that had timeout, the data area would be zeroed.

Here is a link that can be worth reading:
http://www.simplymodbus.ca/ASCII.htm

Good luck!

Kalle
 

Similar Topics

Hi Everyone, i was hoping for a little help with this module. i have data that needs to be read from a different plc through the Modbus plus...
Replies
11
Views
151
I have a PH meter that I am trying to bring its data into 1756-L81. I have downloaded the Rockwell MODBUS AOI kit, but I am not sure if I need to...
Replies
5
Views
151
Dear All, i am trying to connect Danfoss inverter with s7 200 cpu 226.but microwin shows following error at DATA Ptr.i assigned different VB...
Replies
1
Views
46
I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
7
Views
221
Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
252
Back
Top Bottom