Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Delay before sending a message via Visa Write

Hi everyone,

 

I want to enable communication between a microcontroller (dsPIC33E) and the cRIO using RS-485 serial communication in the half-duplex mode. For that purpose, I use NI 9871 module.

 

To see what happens when I send a message via the Visa Write function, I recorded the message via an oscilloscope. Please find attached the trace. For easier referencing, let's say that the far left line denotes t=0 ms, and the time step is 1 ms.

 

It is clearly visible that the NI 9871 module switches to the transmit mode at t=1 ms, and that it releases, i.e. switches to the receive mode at t=10.2 ms. However, what I don't get is the delay before sending a first start bit, and after the last stop bit.

 

Should I implement these delays on my microcontroller as well? If yes, is there any general formula for a duration of these delays?

 

Thank you in advance!

 

Best, Marko

0 Kudos
Message 1 of 8
(5,237 Views)

Hi,

 

What is the model of the cRIO that you are using? Could you also post the code that you are using to send the command?

Matt G.
Product Manager
National Instruments
0 Kudos
Message 2 of 8
(5,199 Views)

Hi,

 

I use a cRIO-9076.

 

Please find the code attached.

 

Thanks!

 

Download All
0 Kudos
Message 3 of 8
(5,195 Views)

So you are opening and closing your port each time you send something?  Initializing your port can take some time.  In a real application, you should only initialize your port at startup and then close it when you are completely done with it (shutdown of application).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 8
(5,188 Views)

crossrulz, I know I should open/close a Visa session only once, this was just for testing.

 

It appears that these "delays" are indeed caused by opening and closing of a VISA session. I tried to send two messages, the second message immediately after the first message. On the oscilloscope, they look like a single message which means that the module is not introducing any delays.

 

Thanks for the help!

0 Kudos
Message 5 of 8
(5,163 Views)

I have another question.I tried to send a message that consists of the following characters:

 

1. 0x01 (device address)

2. 0x78 (character 'x')

3. 0x79 (character 'y')

 

As for the serial communication settings, I use a half-duplex transmission at the baud rate of 9600 bps, 8-bit data transfer, no parity, and with 2 stop bits. Keeping in mind that a start bit is also added to the beginning of each character, a character consists of 11 bits. It should be noted that an 8-bit data byte is transmitted backwards.

 

Please find attached the waveform. It can be seen that the first two characters (0x01 and 0x78) are completely normal, i.e., they consist of 11 bits each: 1 start bit + 8 data bits + 2 stop bits

 

However, the last character in a message consists of 9.5 bits: 1 start bit + 8 data bits + 0.5 stop bits. My question is: is there any reason why the last character has only 0.5 stop bits? I know that only first stop bit in a character is sampled, but if the baud rate of a slave is somewhat "slower" (in my case it is approx. 0.5% too slow), then the stop bit is not going to be sampled exactly at its center, but rather on its 60-70% bit-time. In other words, I get the frame error on my microcontroller (UART) for each last character of a message I receive.

 

Thanks!

0 Kudos
Message 6 of 8
(5,122 Views)

I will speak to some colleagues about this and find out why this could be happening.

Matt G.
Product Manager
National Instruments
0 Kudos
Message 7 of 8
(5,082 Views)

Do you have an issue if you send each message separately? What does that data look like?

Matt G.
Product Manager
National Instruments
0 Kudos
Message 8 of 8
(5,075 Views)