LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Modbus RTU to access a loadcell converter and PLC

 Hi, I am trying to set up a system with LabVIEW and modbus RTU to do the following;

 

1. Tell aPLC to operate a motor until one of two sensors (call them a or b) is activated,

2. get three readings from a modbus digital loadcell converter at intervals of about 1 minute,

3. Bundle the readings and the status of the sensors as well as several other sensors from

     the PLC and output them along with time and date to a csv file.

4.  go to the start and repeat forever ( I want this thing to run for at least a year)

I will need to be able to interupt for maintenance.

It would be good to be able to take the data off the master (a laptop) for analysis without interupting the process. Also file size might eventually cause a problem.

It would be nice if an alert could be made if the difference between the average of readings associated with sensor "a" and "b" went over a constant, but I want to implement this as soon as possible so I should only include this option if it is relatively easy.

 

A few pointers as to the best way to set about this would be greatly appreciated. I dont have the DSC or RT platforms only the latest modbus library and library from Plasmionique inc.

 

The PLC is a Barth STG680 MODbus which has its own graphical programming language so I will have to do those processes separately and report the status to registers for reading by the LabVIEW master.

The LabVIEW modbus examples I have seen mostly have a VISA function, I dont think my server devices will be compatible with VISA and I dont really understand what the start and termination blocks represent/what VISA is for?

Any answers greatly appreciated

Ed

 

0 Kudos
Message 1 of 4
(3,535 Views)

Just to clarify - you're connecting the MODBUS port on the PLC to the loadcell converter, and the PLC to the laptop using the USB port?

 

The VISA nodes are used for (amongst other things) communication with serial ports. The USB port from the PLC is connected to as far as I can tell a virtual serial port. It also claims to have a RS232 programming interface but I haven't worked out how/where.

 

If I understand your problem correctly (which possibly I don't) then there are a few separate steps that you need to solve (or possibly, already have).

  • You want to be able to make a load cell measurement and transfer the result to the computer.
  • You need to be able to start this measurement from the computer (or on a clock via the PLC?)
  • Have the PLC read two (different?) sensors and stop a motor when one is activated.
  • Store data in a CSV file that shouldn't exceed some reasonable file size?
  • Measure the difference between the average of readings from "a" and "b" - I'm not sure what you mean here, since you made them sound fairly boolean with the first condition, but perhaps you want the fraction of time that "a" or "b" is active? Some more explanation would be helpful here.

Some of these problems are very simple - you can set a maximum number of writes to the CSV file and create a new file with a start date in the filename, for example, when the number of lines exceeds that value.

 

Having your code repeat should be fairly simple, and having it be able to stop/start for maintenance also should be an issue with any reasonable design.

 

Taking the data off without interrupting the process might require a control to trigger an early file change (so that the current output CSV file can be closed) - this isn't a very complicated problem either but needs to be considered.

 

String formatting for outputting the data to CSV is also fairly straightforward. You can create a subVI to do this very easily and just call it each time you have new data. If some data might change and other values are not updated simultaneously, you might want a way to indicate which columns are "old" data and which are new.

 

I hope the project is already going well - perhaps you've already finished. If not, maybe you can elucidate how it's going and what you need help with.


GCentral
Message 2 of 4
(3,380 Views)

Thanks for your reply,

I had given up looking at my post and then took a week to respond myself.

The project is progressing slowly I have just managed to communicate with the PLC by modbus RTU and write three single coils. To do this I modified the MB_simple serial example with a write single coil VI because I couldnt make the Plasmionique comm tester do anything but give error messages. I was able to discover the function of VISA in this simple situation because the VI didnt recognise the serial ports if I deleted the visa block. In the end I discovered my problem was with the RS232 -485 converter - due to the very good advice of brillenbar in his post "A solution to avoid error 56 on RTU Modbus" and that is to use a budget converter!

 

Your clarification is correct except that both the plc and loadcell are both modbus so I could poll them alternately.

 

I was thinking of having the motor run cycle started by a write to a coil by the labview master, but how and when to reset this ready for the next trigger? I have not found a way to make the slave reset the trigger coil so am thinking along the lines of making the master do that. At the moment I am having trouble with reading or writing multiple coils with this modified MB simple serial example. The errors are usually time out errors, so I probably have to introduce some timing? I increased the time out on the front panel and it still timed out after re delay.

 

labview modbus.png

 

 I need to get down to trying out some method of controlling the following sequence - read input register of the load cell three times at 2 minute intervals, write coil of the plc to start motor, wait or poll for motor stop sensor 1, read a couple of other coils of the plc and write all to .csv file including time and date.  repeat that except with motor stop sensor 2, return to the start, would you use a case structure or some kind of event structure?

 

0 Kudos
Message 3 of 4
(3,332 Views)

It sounds like what you want could be expressed as a State Machine.

 

An Event Structure can be used in an Idle case of a State Machine, if you have buttons and so on that you want to respond to.


GCentral
0 Kudos
Message 4 of 4
(3,309 Views)