03-04-2010 12:52 PM
Hi.
I'm using LabVIEW and VISA to do a simple write and read operation for a LIN transceiver.
Every time I receive a byte from the master LIN node I have to reply with another byte as the slave LIN node.
The problem is that between the read and write of the bytes there's more than 2 ms of delay (i've seen this with an oscilloscope DPO 2014).
My VISA settings are 19 000 Bd, 8 data bits, 1 stop bit, no parity.
I have a Timed Loop and inside the timed loop I read and write emediatly.
I have no waits nor any other king of delays inside the loop.
Why is it taking so long to reply?
Is there a way to write to the serial port faster?
Is it possible to reduce these 2 ms to 1 ms or almost 0 ms?
I've made this with a microcontroler and the response/write is done emediatly after reading the expected byte.
I apreciate all help.
Regards.
Daniel Coelho
http://www.vistoolkit.com - Your Real Virtual Instrument Solution
03-04-2010 01:09 PM
03-04-2010
01:47 PM
- last edited on
10-29-2025
09:59 PM
by
Content Cleaner
How are you configured for Sync / Async?
Good KB that can improve VISA turnaround and explains in detail what Smercurio-FC alluded to
03-10-2010 10:32 AM
My VISA VIs are configured as Sync.
Changing to Async doesn't change a thing.
I'm not looking for a real time solution because I can do this with a PIC microcontroller with a simple code.
I just want to understand if it is really impossible to obtain the same result.
I understand that going up and down the layers takes time, but 2 ms seemed to much for me.
Since I'm "simulating" a LIN card with a LIN transceiver, reading one byte at a time and respond with 5 bytes if a specific byte is received seems a very quick and simple thing to do with LabVIEW.
When I use a NI USB LIN card with LabVIEW, the LIN messages are read and sent quickly, the only (big) difference is that the card is an usb card instead of serial port.
03-10-2010 10:37 AM
03-10-2010 10:45 AM
I took the Basic Serial Write and Read.vi example and changed it.
Please see the atached file.
03-18-2010 05:53 AM
Hi Mark.
Did you have the chance to see my VI?
Do you notice the same delays I do?
I apreciate your help.
Thanks in avance.
03-18-2010 08:10 AM - edited 03-18-2010 08:16 AM
Daniel: I took a look at your code and don't see any problem with it. However, doing the math:
19,200 BAUD = 19,200 BITS per second.
10 BITS per BYTE ( 1 BIT start + 8 BITS data + 1 BIT stop = 10)
19,200 BAUD = 19,200/10 BITS per BYTE = 1,920 BYTES per second
1,920 BYTES per second / 1000 milliseconds per second = 1.92 BYTES per millisecond (ms)
Now the above would not be a problem since you are only waiting for one character (which should only take 0.52 ms), however, you are sending 5 bytes. That's a total of 6 bytes round trip or 6 * 0.52 ms = 3.12 ms.
In addition, having "Enable Terminating Char" on your VISA Configure Serial Port can't be helping unless your serial LIN device requires it because having to wait for a teminating character on a read or write (in your case it appears you are using a 0x0A or line feed) increases the number of characters that need to be transmitted.
Another thought just came to me: If your serial device is sending a terminating character, it is possible you may have a second read operation each cycle due to the 0x0A (line feed) and the fact that your code only reads one byte at a time from the serial port. This may also add some time to your response.
I hope this helps.
03-18-2010 10:24 AM
04-09-2010 12:55 PM
I'm sorry for the delay answering.
Meanwhile, the hardware isn't available and I can't make tests just yet.
But, I understand your baud rate maths and, don't take me wrong, the problem can't be in the baud rate because a colleage of mine was able to do it with a PIC microcontroler with a simple code (read one byte, if byte found, reply) and I don't see any delays in the LIN bus.
As soon as I get the hardware back to me, I'll measure the time difference between RX and TX in the serial bus.
By the way, I noticed something, I can't read as fast as the bytes arrive. Every cycle I read the "bytes at port" number and read one byte per cycle, it increases until it reaches the maximum 4096. This may be an issue too.