LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

need help on modbus RTU: don't know the meaning of other output registers

Solved!
Go to solution

to ravens fan,

 

 

the first NI-spy data has two execution, my mistake. here are the portmon files. 1st is single register, 2nd is multiple registers (timeout error 6101). i convert the files into pdf becoz i cannot attached using .log files.

 

thanks for the time analyzing my problem.

Ivel R. | CLAD
Download All
0 Kudos
Message 11 of 17
(3,684 Views)
Solution
Accepted by ivelson

AH HA!

 

I know what it is.

 

You are getting an echo of the command you sent out.  See if there is some sort of setting either in the instrument.  Or are you using some sort of RS-232/RS-485 converter?  It may have a switch or jumper that enables or disables echoing.

 

Looking at your single register pdf at line 33, bottom of the first page.  You are sending FE 03 00 5F 00 01 A0 17.  That is slave address 254 ( I thought you were working with slave address 1?)  Function code 3.  00 5F means starting at register 95,  00 01 is 1 register, then A0 17 is the checksum.

 

You are getting back, FE 03 00 5F 00 01 A0 17 FE 03 02 00 03 EC 51.  The underlined part is the echo of what you sent.  After that is FE, slave address, 03, function code, 02 2 bytes, 00 03 is 512 decimal.  EC 51 is the return checksum.

 

I see the same thing occurring in the multiple registers.  It looks like you are trying to read 2 also starting at 95 and getting back 512 and 0 in the two registers.

 

If you aren't able to fix the echoing issue either by way of your serial hardware or by way of the instrument you are talking to, then what you will need to do is modify your modbus code so that it will read the number of bytes that were send out in the write command.  Then the remaing bytes will go through just fine with the modbus decoding subVI's.

 

Are you running this VI on a PC or on something like a compact Fieldpoint?  Are you using RS-232 or RS-485?  Is it 2-wire or 4-wire RS-485?  Any converters, isolators or anything else on the serial connection?

Message 12 of 17
(3,677 Views)

To ravens fan,

 

 

you are absolutely right!!

 

i am using usb/485 converter and just becoz this device is localized and have no manual, i wired my converter like the 2-wire config told by NI in this link: http://digital.ni.com/public.nsf/allkb/5FFDF323C35C1B5386256F1C00622596. yes im using laptop as my master, i shorted the USB/485 converter like this:T/R+ & RXD+, T/R- & RXD- and proceed to 2-wire config taught by the link (connect A to T/R+... connect B to T/R-... ). i just rely if i passed the loopback test (hyperterminal) using this config before i connect to the power meter devices.

 

btw, the data i gave to you is from my 2nd power meter device. here it goes : (CPM-50 model = slave address 1, MWH-10 = slave address 254).

now i tried to remove the shorted wires in the USB/485 converter but the same connection (A to T/R+: B to T/R-) and it works!..i got the CORRECT data, single data register for single quantity, and multiple data for multple quantity i requested. as a proof, i attached the portmon data with correct output register (single & multiple).

 

you are right, my problem is in the converter and i create my own mess in my wiring (its hard to identify correct wirings w/o manual):smileyindifferent:. you shot two birds at a time! (coz you solved both of my problems: single registers & multiple registers):smileyvery-happy: now i have no problem reading multiple registers using rs-485 cable. whew...  and its time for me to go to the 2nd part of communication "using 485 - ethernet converter". more programming works to do. for now, this case is closed.

 

you're such as genius man.

 

thanks a million!

 

 

Ivel R. | CLAD
Download All
Message 13 of 17
(3,671 Views)

Great!  I'm glad it is working for you now.

 

I remember reading for the compact fieldpoint RS-485 port that NI says it is only set up for 4 wire communication, and they didn't recommend using a 2-wire setup.  It could work, and you'd have to do those jumpers like your link shows, but you'd have to deal with the echoed outgoing message.  I am communicating with a 2-wire device, but I never had this particular problem because I have an isolator in between that does the 4-wire to 2-wire conversion automatically.

Message 14 of 17
(3,668 Views)

I think echoed message is quite hard to deal with in making LVmodbus software rather than in hardware (or just becoz im novice?Smiley Very Happy). anyway, very nice info, maybe i may encountered that in the future so i will try to do that later on. btw, i do not need to use my revised MB program now, original MB serial query.vi is both working in my power meters. now i will start to use my serial/ethernet converters to communicate. after that, use NI-OPC server to monitor all (quite hard for a beginner,tsk tsk...). i may open a new MB topic in the future if i can't find solutions for my upcoming problems (hope none!).

 

thanks a lot...

Ivel R. | CLAD
0 Kudos
Message 15 of 17
(3,658 Views)

Attached is the code for the CRC calculation block diagram. What should go in the input string for CRC16 calculation for Eurotherm 2404 series PID controller? In the 2000 Eurotherm controller manual, I see code in crc16& = 65535. I keep reading on the NI forums about Calc-CRC.vi for checksums. They say checksums are usually calculated by adding the byte values and then performing an AND between the sum and OxFF. And then the forums talk about, if your data is a string, you can use the String to Byte Array function and then the Add Array Elements function to get the sum. I see the CRC Calculation in the 2000 Eurotherm controller manual in Chapter 3.11 of this manual (which I have attached). If you have any suggestions for me, that would be great.

Download All
0 Kudos
Message 16 of 17
(3,359 Views)

I've taken a look at section 3.11 in the manual you linked. Although there is a function or 2 in BASIC of which I don't know the meaning, you should be able to implement that in a VI. You can use substring functions in Programming->String or String to Byte Array. The rest should be mathematical steps. There will be many possible implementations so do whatever you feel most comfortable with (unless speed is a huge factor, in which case it will take some more research to find the most efficient method). You seem to be on the right track! Refer to http://en.wikipedia.org/wiki/Cyclic_redundancy_check if you need to know more about the purpose of the function. If this isn't what you're looking for, please clarify and I'll be happy to help you further!

0 Kudos
Message 17 of 17
(3,313 Views)