07-27-2016 12:21 PM
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
07-28-2016 12:25 PM
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?
07-28-2016 12:33 PM
Hi,
I use a cRIO-9076.
Please find the code attached.
Thanks!
07-28-2016 08:17 PM
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).
07-31-2016 09:38 AM
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!
08-04-2016 09:54 AM
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!
08-08-2016 09:55 AM
I will speak to some colleagues about this and find out why this could be happening.
08-08-2016 12:47 PM
Do you have an issue if you send each message separately? What does that data look like?