annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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
Messaggio 1 di 8
3.738Visualizzazioni

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
Messaggio 2 di 8
3.715Visualizzazioni

Hello Knight of NI,

 

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

0 Kudos
Messaggio 3 di 8
3.689Visualizzazioni

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
Messaggio 4 di 8
3.685Visualizzazioni

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
Messaggio 5 di 8
3.671Visualizzazioni

@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
Messaggio 6 di 8
3.657Visualizzazioni

What have you tried? Please pose your code.

0 Kudos
Messaggio 7 di 8
3.640Visualizzazioni

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
Messaggio 8 di 8
3.635Visualizzazioni