LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VFD Modbus Control - 1 works. 2 Does not !

Solved!
Go to solution

The attached project (done in LV17) is a simple check out tool for verifying if the connected VFD ( Bonfiglioli brand ) is working fine. 

 

I created simple sub VIs to generate the required Read and Write commands instead of using any library. Bonfiglioli uses some special function codes and 32 bit register commands and hence this is easier for me  

 

Apart from the VFD there is also a Oil Particle counter which only needs to be read once every minute. 

 

Right now the 45KW  VFD and the Particle counter are working fine. But If I try to also start the 65KW VFD then the loop hangs and both drives stop. 

 

There are enough comments on the BD to indicate the flow of Modbus commands  - I am sure there is something going wrong as with this code I am able to run either the 45KW or 65KW drive but not both. 

 

The cabling is a two core twisted type and with one termination resistor on the 65KW drive which is the last in the daisy chain. 

 

Any idea why it cannot control both VFDs at a time ? 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(1,275 Views)

Hi Mogaraghu,

 

thanks for attaching the whole project.

Please mark the mainVI in your project more clearly, I couldn't locate it just from its filename or location in the project…

 

On your mainVI:

  • It misses error handling completely! How do you want to handle errors when you forgot to implement that?
  • Please cleanup: left-to-right wiring! You have a heavy mix of right-to-left and top-todown…
  • What about implementing all the stuff spread over the blockdiagram in a nice and clean statemachine? This would also get rid of the sequence frames before and after the main WHILE loop…

Please don't maximize any windows of all (!) the subVIs to fullscreen: this is just annoying…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(1,247 Views)

Heloo GerdW

 

Sorry about not naming the main VI and the fact about maximized sub VIs. ( Never realized till you mentioned this !)

 

Now for the code itself ...

 

This snippet is part of a much larger code for a complete machine and I hence created this just for the sake of posting here. And also wanted to emphasize the flow of the Serial Task to see if there is any hiccup in that.  Otherwise it is part of a larger SM. 

 

Could you see any issue in the way the Serial interface code is implemented ?  I always get into knots when the project has a heavy dependence on serial comm. 

 

And the one other point I could not understand is the left - to right and top-down data flow. I thought that was the most natural way we implement ?? Maybe I am missing something here. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 8
(1,233 Views)
Solution
Accepted by topic author MogaRaghu

OK I have got it going now ! 

 

it all started with reading the Bonfig manual where one page it says : The VFD does not respond before 10ms after a command and if the CPU is busy, this can reach upto 500ms. 

 

So then got down to work and created two state machines - one for each drive - but this time around the RPM read cases also went inside the state machine. Created a data flow by threading the Error wire from the first state machine to second state machine. Ensured the required timing with properly placed delays. 

 

Even then it did not work. In fact the code crashed.

 

What made it work is this : Created a stacked sequence structure with two frames and in the first one kept the SM for the 45kw drive and in the second frame kept the 65kw drive.  Now there is no case of any fighting for the Serial port resource and the control is great.  Runs good with a 100ms timing. 

 

Thanks to all the inputs which set me thinking in the right direction !

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 8
(1,111 Views)

Also wanted to share the Modbus Read SUB VI that I had used in the code.  This just handles the VISA Write / read part over Serial. The required Modbus command is generated externally and fed to this ( CmdArray) .  The reason I cannot use a standard Modbus library is that I need to send some non standard functions ( 100 for 32 bit read and 101 for 32 bit write in this application )  So instead of taking a standard library and editing it,  I thought of creating my own for this. No problems so far. 

 

Also In the VISA Read I am using a fixed byte read. (10 in this case ) . Being a Modbus RTU  mode I cannot send a Termination Char  which is the preferred method instead of a fixed byte wait. 

 

ModbusRead.png

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 8
(1,074 Views)

@MogaRaghu wrote:

OK I have got it going now ! 

...

 Created a stacked sequence structure...


"stacked sequence structure" is *never* the answer 😱

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 6 of 8
(1,060 Views)

Wait... your are sending your command,

Frozen_0-1646432677953.png

 

then throwing away the answer,

Frozen_1-1646432693281.png

 

then waiting for a response?

Frozen_2-1646432716676.png

 

That just cannot end well!

BTW. the sequence structure is redundant.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 7 of 8
(1,059 Views)

@Frozen wrote:

Wait... your are sending your command,

Frozen_0-1646432677953.png

 

then throwing away the answer,

Frozen_1-1646432693281.png

 

then waiting for a response?

Frozen_2-1646432716676.png

 

That just cannot end well!

BTW. the sequence structure is redundant.



1. The sequence structure is part of development history when there were some fixed delays between Read / Write etc. You are right  -  now its redundant. 

 

2. The code works.  As I mentioned this whole code is to control more than one VFD over a single Serial Bus.  And  this particular VFD model has a 10ms (minimum ) delay before sending out the response.  So what is being is flushed from the Receive buffer is any leftover bytes ( if any ) from a previous transaction. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 8
(1,033 Views)