Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus frame

It depends how you want to handle your data. As long as you know it is not ascii and you know.

I was wondered about the spaces (0x20) in the ModBus frame. I would not expect it at these positions. Can you show me what you send or are you using the ModBus lib from NI to create the ModBus frames

0 Kudos
Message 21 of 39
(1,933 Views)
Now that you mentioned it, I guess there's something wrong with the data. When we run our modbus program as attached before (modbus serial query1.vi) requesting value at the first register...0104000071CB.. it shows 01040400000000FB84..as expected. If I run your program (Mon232.vi) at the same time ..then I looked at the file it shows 01040420202020FB84. I guess the log data became different from what it showed at our program.
0 Kudos
Message 22 of 39
(1,930 Views)

It's a bit strange that the 0x00 are changed into 0x20 and that the CRC bytes at the end are correct for 0x00 data.

If the software in your micro is a ModBus slave then you will not get an answer because the CRC is wrong because the 0x00 bytes are changed into 0x20.

Even if you get the data OK the command I don't think the command frame is OK. At least for the ModBus things I know.

I think the data is 1 byte to long. Beside that the length of the requested data is zero (two bytes before the CRC)

I never used the ModBus lib from NI because I use my own (dedicated) VI's for the ModBus communication.

Do you think you can get any further at this moment ? If not you can always try to make a simple com VI that send 1 command and displays the return data. 

0 Kudos
Message 23 of 39
(1,917 Views)
Hi,
 
I know that actually we can use modbus by write to visa directly without using any library. Unfortunately, if I use that..I get long "0" value like my first problem before. Most probably because my program itself. That's why we worked on the modbus library.  But somehow, either we still have "0" or not, micro doesn't even longer have the problem to read the data anymore. Anyway, I figured something strange. I tried to save repeated string generated by string control in labview. How come when I open the file .. doesn't show the actual string that I typed? Please look at the attached file.
Download All
0 Kudos
Message 24 of 39
(1,899 Views)

It’s not clear to me want you want to do with this VI.

It appends the ‘cheat modbus string’ to the value of the shift register and displays it in the ‘string display’ indicator. So the string in your indicator gets longer and longer until you stop the loop.

You don’t see it because the indicator is too small !!

 

I think to get further we are going to try something else.  Do you know if your micro supports the ModBus loop-back command ?

Or do you have a file with the supported ModBus commands ?

0 Kudos
Message 25 of 39
(1,881 Views)
KC. That's not what I'm trying to show you. The problem is not about long string that I can't see at the small indicator but after I write to txt file...I should get the same string that I send right? Instead of getting 0104 00000000 71CB..the txt file shows 0104 20202020 71CB. For your info, the response that I get from other device, a power meter, is also the same. We already did the loopback test using micro and it echoes back everything that we send from LV. Actually, we do the programming in micro ourselves.
0 Kudos
Message 26 of 39
(1,878 Views)

OK, I understand. From what you show me I cannot understand why the 0x00 are changed into 0x20 while the other bytes remain the same.

I need to know more about what is done with the received data.

0 Kudos
Message 27 of 39
(1,872 Views)

Me as well. I can't understand either why 0x20 keep showing up. Right now I'm testing the modbus program with a power meter. There's no point if I can display a correct modbus response at the front panel but after write to txt file..it shows something else. I must log every received data anyhow in my application. Where do you think the problem is? If there's something wrong with modbus frame that I send or receive, then why still I get 0x20 even just sending a simple string (display in HEX) from LV?? Is this only happen in my labview or something else...

I'm confused...Let me know what you think ok...  Smiley Wink

0 Kudos
Message 28 of 39
(1,865 Views)

Is possible that some VI's are set to ASCII where it should be RTU ?

Just to get things clear, in the last VI you showed you write 0x00 and read back 0x20 ?

 



Message Edited by K C on 11-13-2007 12:18 PM
0 Kudos
Message 29 of 39
(1,857 Views)
Yes. I send 0x00 but read back 0x20. I don't think that it's about RTU or ASCII mode for modbus anymore because that was just a simple test to save any HEX string
0 Kudos
Message 30 of 39
(1,837 Views)