Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus frame

Hi everyone,
 
I'm still new in labview and I really hope that I can get some hints for our project. Thanks in advance.
 
I already manage to communicate with some instruments using modbus protocol in Labview but with a 200ms delay. However, I have a doubt that the modbus string that I send from labview through the port is giving us unrecognized signal in between modbus frame. And maybe this is the cause why I get a long delay. Currently, we are going to implement modbus protocol in our micro controller for controlling valves purposes. In order to program the micro controller, we only need to identify the modbus frame. So we tried to identify the frame from the port using a software called Logic Port. However, we get a long "0" and "1" before we can actually get the frame. Is this suppose to be happening? Because of this unrecognized signal, we are having some trouble to program the micro controller. Do anyone have any idea or any suggestions for us? We are very glad to hear about it.
 
Attaced is the snapshot of the signal that we get from the port when we send a simple modbus frame: 01040000000071CB
 
0 Kudos
Message 1 of 39
(5,540 Views)
Hi,
 
There are serial ports that set the data signal in a '1' state and switch this to a '0' state when you configure the port. It got me into trouble once.
The '1' at the end is not normal I think, but this is from a software tool if I understand correctly.
That can be different from the real world.
 
If you have a microcontroller with a serial port it should be no problem reading the data from a serial interface. No matter if it is Modbus or something else. ModBus is just the protocol that is used.
 
 
 
0 Kudos
Message 2 of 39
(5,519 Views)
Hi KC,
 
Thanks for replying. I really appreciate it.
 
If you said is true, then how can I be sure that mine is also like that? Is there any other way to test or manipulate this signal to high in between modbus frames. Actually our micro controller detects "0" as a start bit and "1" as a stop bit between 8 bits data. So if we get a falling edge, it will consider the rest of 8 bits as a data.
 
Any advise would be great :womanhappy:
0 Kudos
Message 3 of 39
(5,508 Views)

Hi,

If you want to know what the signal is you should measure it with a oscilloscope. But if it is a normal COM port there should be no problem at the PC side.

When you say a '0' as a start bit you are talking about the level at TTL level at the microcontroller ? (and not at the RS-232 side)

When you see a start bit and this takes longer as 1 byte it should be seen as a break. So even if the signal looks like you showed a normal UART would have no problem.

What microcontroller are you using ?

0 Kudos
Message 4 of 39
(5,493 Views)

hi,

i want to use atmega16 with labview using modbus,

i tried to get frame but i couldn't get valid data i think it is because the speed is different, baud rate i set 9.6 for labview and micro.

what do u think the problem is?

0 Kudos
Message 5 of 39
(5,477 Views)

Hi again KC,

Thanks for your advise. I came up with something after that.

Pooria is the one who works on micro controller in our team. Like he said, he's using atmega16. I manage to remove "0" signal in previous signal but a new problem occur. We found that the length of the modbus frame is different between labview and micro C even we set the same baudrate. Are we miss anything here? Can you please take a look at the attached file and suggest us anything.

Thanks.

Download All
0 Kudos
Message 6 of 39
(5,471 Views)

Hi,

 

Well if there is really a difference in timing like the picture shows it’s never gonna work.

 

Forget the ModBus protocol. Try to get your micro so far that it echoes everything that it receives at the RxD input back to the TxD output. That way you can test it with LV or Hyperterminal.

When the communication works OK you can start working on the ModBus protocol.

 

I don’t know anything about the Atmega but I see in a datasheet that is has a programmable USART. Do you use this? If so, you probably are using the wrong baudrate or something like that.

 

Can you try this echo thing ?

 

 

btw: don't let you colleague post something that looks like a new issue.



Message Edited by K C on 11-05-2007 12:34 PM
0 Kudos
Message 7 of 39
(5,461 Views)
Hi again,
 
Thanks KC. Now we can get the same data length between labview and micro.
 
Our current issue here, how the code from micro should be so that labview can read it back? At the moment, micro can respond to the labview code but unable to read anything from micro. We just simply sending the code (modbus frame)  from micro to the port. Is it really matter if we use RS 232 or RS 485? I mean the signal should be the same right?
 
Thanks.
 
0 Kudos
Message 8 of 39
(5,436 Views)
Hi,
 
Is doesn't matter which hardware layer you use (RS-232 or RS-485) as long as it is the same on both sides  Smiley Very Happy
 
If I understand you correctly you cannot read any data in LV from the microcontroller. Can you show the VI you use ?
0 Kudos
Message 9 of 39
(5,431 Views)

Haha... sorry for ABC question there. I guess my head is spinning here and I don't really know what else should I ask to make it work. hehe... Please take a look at my VI and tell me if it's wrong somewhere.

 

 

0 Kudos
Message 10 of 39
(5,427 Views)