Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus serial

Hi,
 
I am attempting to communicate with an air pump that is Modbus RTU, and is on RS485 with an RS 232/485 converter into the COM port of my computer. According to the memory map, the address is 8 and the register is 40029. The query I am using is as follows:
 
0803 001C 0001 4555
 
1st block: device address is 8 and since the register is in the 40k range, I assumed to use the "read analog output holding register" function, 03.
 
2nd block: Since the address is 40029 and the offset is 40001, the difference is 28, which converts into 1C in hexadecimal
 
3rd block: Assumption that the data I wish to retrieve is held within in one register
 
4th block: I had difficulty following documentation explaining the calculation of CRC, so I used the modbusVIEW NG/TCP demo from Saphir to calculate. http://www.saphir.fr/GB/products/downloads/index.htm
 
Is my line of thinking correct?
 
Also, I have successfully communicated with another pump which is on RS232 and responds to ASCII control characters, such as <enq>, <stx>, etc. Prior to asking for any information from it, the first necessary step was to send out a generally inquiry command, "is anybody out there?"--which was the <ENQ> command. The pump responded, identifying itself, then I could assign in a name and issue commands. Does a similar general inquiry exist that I could try for the modbus air pump? Thanks.
 
Adam
0 Kudos
Message 1 of 14
(5,092 Views)
Also, the VI I am using to communicate in Labview is "Basic Serial read/write."
0 Kudos
Message 2 of 14
(5,086 Views)
Hi,

Seems right to me. Is it not working?

I am attaching a VI which computes the CRC (I didn't write it, and don't remember where exactly I downloaded it from). You will pass in your bytes from the message as an array of U8s. E.g., if you pass in 08, 03, 00, 1C, 00, and 01, the CRC will be computed as x45CC.

Regards,

-Khalid
0 Kudos
Message 3 of 14
(5,084 Views)

Khalid,

Thanks for the help. I tried out the CRC calculator program but received x3937 for the calculated CRC for the sequence 08, 03, 00, 1C, 00, 01. However, I tried your calculation of x45CC and Labview read back a sequence from the serial port. However, when I tried it again, it would not read anything from the serial port as before. Any ideas? Thanks,

Adam

0 Kudos
Message 4 of 14
(5,081 Views)

Hi Adam,

I use a Modbus protocol for a solid state PC we use. My CRC calculator comes up with the same result as you have. So that could be right, but I saw a lot of different ways of CRC calculation with different results.

Did the manufacturer of the device you use specified the type of CRC to use ?

Can you post the VI you use ?

0 Kudos
Message 5 of 14
(5,070 Views)
You would be better off using a Modbus driver.  This makes things so much easier.  Check out this message: http://forums.ni.com/ni/board/message?board.id=170&message.id=151337&requireLogin=False
0 Kudos
Message 6 of 14
(5,066 Views)
Hi Adam,

I apparently made a mistake, the CRC computed is indeed 4555. Sorry about that.

I agree with Brian, you may want to use the NI Modbus library rather trying to build the message frames yourself.

Regards,

-Khalid
0 Kudos
Message 7 of 14
(5,058 Views)

Thanks for the suggestions! I looked played around with the modbus library for a bit and am confused on how to set up a VI to perform the query originally listed, 0803 001C 0001 4555. Could you show me how to construct a simple VI using the sub-VIs of the library? Thank you

Adam

0 Kudos
Message 8 of 14
(5,047 Views)
Adam,

You can use the 'MB Serial Master Query.vi' to test the communication. Here's the screenshot of this VI. For the result, you will have to parse the third element from the return message, and convert to decimal.

MBQuery.png>

To look at the actual message that is being sent out to the device, you will have to look at the 'MB Serial Transmit.vi'. This is where they get written to the serial port.

Note that most subVIs are reentrant and have debugging turned-off. So, you may want to make a copy of these and change the settings to allow debugging temporarily.

Hope this helps.

Regards,

-Khalid

Message Edited by Khalid on 10-06-2006 03:51 PM

0 Kudos
Message 9 of 14
(5,039 Views)

Khalid,

Thanks for your help! Unfortunately, I still cannot seem to get a response from the air pump. I have attached a screen shot of the way I set up the MB serial mastery query. As circled, the field "Modbus Data Unit Out" is NOT set by the user, correct? Rather, it is the response from the slave device. In your screenshot, I notice that you have four fields in the data section, with the numbers "0 2 0 26" in consecutive boxes, and the function code read holding registers is the same as the modbus command (which I assume that it should). Compare yours to mine. Am I missing something? Thanks!

 

Adam  

0 Kudos
Message 10 of 14
(5,018 Views)