LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read more than 100 registers using modbus

Hello Everyone, 
 

I downloaded modbus library and try to use modbus ethernet query to communicate with PLC. I found modbus can only read about 100 register one command but I need to read way more than 100 registers and record the data to a spreadsheet and export the final result as a csv file. I am really new to this field and wondering how can this be done ?(my guess is using while loop?)

0 Kudos
Message 1 of 8
(3,720 Views)

Do multiple reads in series with each.  The first 100 registers, then the next 100, then so on.  Then you can combine the results to write to your CSV file.

0 Kudos
Message 2 of 8
(3,697 Views)

Hello Knight of NI,

 

Thank you for replying. I am wondering why cannot use a while or for loop?

0 Kudos
Message 3 of 8
(3,671 Views)

I don't understand your question.  You'll have to show me an example of how you are thinking that a while loop is going to help you read more than 100 registers at a time.

0 Kudos
Message 4 of 8
(3,667 Views)

Hi Sophia,

actually RavensFan is implicitly suggesting to use a while/for loop.

 

Do you need to read 10000 registers?

Run a for loop 100 times placing a modbus read of 100 registers inside.

 

Regards,

Marco

0 Kudos
Message 5 of 8
(3,653 Views)

@MarcoMauri wrote:

Hi Sophia,

actually RavensFan is implicitly suggesting to use a while/for loop.

 

Do you need to read 10000 registers?

Run a for loop 100 times placing a modbus read of 100 registers inside.

 

Regards,

Marco



Not exactly.

 

You use a while loop to do repetitive readings of the same registers for an unspecified number of times.  You use a For loop to do repetitive readings of the same registers for a known number of times.

 

You can use a for loop for different registers, but you have to set it up correctly.  You'd need to use arrays that would define each group of registers that you can auto-index on that array so that each iteration of the For Loop will handle the different groups.  Of course modbus is returning data, so you need to figure out a way to send that data to different places since each group represents different data.

0 Kudos
Message 6 of 8
(3,639 Views)

What have you tried? Please pose your code.

0 Kudos
Message 7 of 8
(3,622 Views)

Hi ,

 

Thank you so much for your advice. I am still working on the program. Since it's the first time I ever use labview, I did lots of readings for the past few days try to understand better. I will post my code as soon as I am done.

 

Sophia

0 Kudos
Message 8 of 8
(3,617 Views)