NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU RS-485 Help

Hi,

i am new member on this forum,

i want ask about how to use modbus RTU RS-485 on labview, i have plan to monitoring Volt,Ampere and Power meter on this metering,

CVM NRG.jpg

that device support Modbus RTU RS-485, this is manual of this metering,

http://circutor.com/docs/M98172501-03.pdf

anyone can help me how to integrate that device to LabView using modbus ? i already download NI VISA ana ni modbus library. please give me example so i can develop it by my self.

Many Thanks

0 Kudos
Message 1 of 17
(33,739 Views)

Hi, rhiesnand. If you do not familiar with RS-485 Bus and Modbus RTU Protocol, I think the best way to start is NI Serial Quick Reference Guide http://digital.ni.com/manuals.nsf/websearch/38D274565C6ED65186257B58007663FC?OpenDocument&seen=1 and Basic Serial Write and Read.vi (find it in LabVIEW Examples). Make connections of wares as for loopback RS-485 test in Guide and test line (send something in port and receive the same 🙂 . When it work it’s not big problem to make Modbus transactions. Is it what you need?

0 Kudos
Message 2 of 17
(19,294 Views)

OK, Mihalis. i'll try later, im still looking for converter RS-485 that support on LabView 2010 ? is all kind of converter RS-485 to USB is support on LabView ? i have plan to buy this converter.

Converter+Rs-485+USB.jpg

http://www.produkimport.com/c-003-computers--networking/c-039-cables--converters/c-446-converters/p-...

is that converter support for communication modbus RTU on LabView ?

Thanks

0 Kudos
Message 3 of 17
(19,294 Views)

rhiesnand, this one converter support by LabVIEW, moreover for LabVIEW converter is absolutely transparent, you just see COM1 or COM2 (don't forget install drivers for converter). You connecting converter to USB port at one side and on another side you connect converter to your Power Analyzer (PA). And like in Basic Serial Write and Read.vi you send a command to PA wait some milliseconds and receive respond from PA. Master-Slave architecture. In Basic Serial Write and Read.vi "string to write" control - it's Modbus RTU command to slave than pause and after respond in "read string" indicator. You have to put all you Modbus RTU request (any command) in "string to write" (including CRC). At p. 34 of PA manual great example absolutely ready to be done. Just copy and place it in "string to write" control.

0 Kudos
Message 4 of 17
(19,294 Views)

Mihalis, i did it but no response, something wrong ? please correct me, this my labview program below :

CVM.jpg

my set up of baud rate, stop bit, data bit, parity is already corrected on hardware & software, whats wrong ?

Thanks~

Message 5 of 17
(19,294 Views)

Hi Mihalis, this is my update, i wanna ask how to pick them one by one (Volt,Ampere,Watt,kVar,Cosphi) ? i wanna convert it to decimal and make it to Meter display on labview.

HASIL.jpg

Thanks~

Message 6 of 17
(19,294 Views)

hi, rhiesnd, firstly you have to fix one problem in you code - there no pause in you VI between Serial Write and Serial Read functions, so you must put pause between this functions, because in you vi LabVIEW send request to PM (Serial Write)  and right after it you acquire respond (Serial Read), and you do not give to ypur PM process data. So put pause inside Sequence Structure (see Basic Serial Write and Read.vi from LabVIEW examples). The value of pause in ms depend on speed of serial (100 ms is quit enough for 9600). You do not need pause inside the loop, like in your vi (your pause influence only how often you acquire data from PM).

So put in ypu code like in Basic Serial Write and Read.vi property node (Instr)  for count amount of byte in each transaction.

And about how to take data from Modbus string – see the block diagram below. Like this..

code.png

Best!

0 Kudos
Message 7 of 17
(19,294 Views)

Mihalis, i did it, but i have problem again, sometimes this communication cannot read data from my Power Analyzer, i dont know why this is happened, whether due on my Labview program or the Hardware ? look at my screenshot. sometimes lose some data. what your suggestion ?

FLAT SEQUENCE.jpg

0 Kudos
Message 8 of 17
(19,294 Views)

Hi, rhiesnand, in your code now you have no pause after reading values from PA. Put in while loop just 10-30 ms pause function. It's a first reason, why your data don't being read. Another reason may be deal with different amount of bytes which being read from PA. In case to know exactly how much bytes came from PA you have to use Property Node, like in Serial Write and Read.vi and use it for manipulations with data. May be reason deal with it...

0 Kudos
Message 9 of 17
(19,294 Views)

i've tried that Mihalis, but still not work correctly,

Property Node 2.jpg

any suggestion ? or you want to check my NI files ?

https://www.dropbox.com/s/ggyhu50l1fx6l4o/Modbus%20CVM%20NRG.vi

i attach my video, please see

https://www.dropbox.com/s/st6qs1cbtr72m0m/bandicam%202014-05-05%2015-06-09-546.avi

Thanks~

0 Kudos
Message 10 of 17
(19,294 Views)