LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NI MAX Affecting RS232 Performance

Solved!
Go to solution

Hi Everyone,

 

I'm having a really weird issue. I'm running LabWindows/CVI and I'm doing some communication via an RS232 serial port from my PC to a DUT and it's doing a full readout of the eeprom of the device through some microcontroller on the DUT. Every now and then one of the transmissions from the PC is bad and so the microcontroller sends a request for the PC to retransmit the message. I looked into it and found that the bad message had went high for an extended period of time (maybe 15ms) and that caused the microcontroller to timeout and ask for a retransmission. Now it gets weird, when I run the NI MAX application I never have this issue. The RS232 communication runs fine and I don't see any high periods with the comm signals. If NI MAX is off then the issue comes back. Does anyone know what could be causing this? Does NI MAX change any settings of any ports when it's ran?

 

Thanks,

Dave

0 Kudos
Message 1 of 6
(2,179 Views)
Solution
Accepted by topic author Dave89

My guess is the system is running with a 16ms clock resolution by default.

 

MAX configures the system clock resolution to 1ms. Is your application requesting the system to run with the 1ms clock?

 

I found some snippet CVI code to configure this:

#include "windows.h"

...

TIMECAPS timeCaps = {0,0};

timeGetDevCaps(&timeCaps, sizeof(timeCaps));

 

const uint32_t desiredTimerResolutionInMilliseconds = 1;

uint32_t timerResolutionInMilliseconds = min(max(timeCaps.wPeriodMin, desiredTimerResolutionInMilliseconds), timeCaps.wPeriodMax);

timeBeginPeriod(timerResolutionInMilliseconds);

 

[Insert Application Logic Here]

 

timeEndPeriod(timerResolutionInMilliseconds);

...

You could also look for an application called the "Windows System Timer Tool" to verify what timer the system is currently running against, and compare how this changes as you open/close different applications.
Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
Message 2 of 6
(2,157 Views)

I looked into this more and it gets even weirder. It seems that when I run examplefinder.exe and NI dsitributed system manager (SystemManager.exe) I get the same results as I did when running NI MAX. If I run any of those three applications then the RS232 communication is fixed. All of those are in the C:\Program Files (x86)\National Instruments... so maybe it's some kind of admin access issue? Has anyone seen anything like this or have any ideas? I also don't have admin access normally. I have to request it from IT each time I need it.

0 Kudos
Message 3 of 6
(2,093 Views)

All of these applications are likely build using LabVIEW, which by default applies the multimedia timer reprogramming on startup (unless a specific INI setting is present in its configuration file).

So that isn’t so strange but just confirms the earlier recommendation from Craig

 

Calling this meultimedia timer function early in your application isn’t quite like rocket science (and the according call to reset the timer before exciting neither). Rather than trying to find apps which make your serial port work I would have tried that recommendation already long ago.

 

it’s basically a bug in the virtual comm driver to rely on that timer being set to low latency and not take care of that somehow. In fact being a kernel device driver I would say there would be much better ways inside the Windows kernel to get accurate timing without relying on the very old (Windows 3.1) legacy timer that apps can reprogram at will!

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 6
(2,075 Views)

Thanks Craig! That did it! I tried it when you first mentioned it, but I couldn't get my program to compile with windows.h, so I moved on. Nothing else I tried worked or gave me any additional info, so I came back to this and worked on getting it to compile and that did it. Thank you so much!

Message 5 of 6
(2,058 Views)

This is Huge .... Thank You!! Craig for you help with this 🙂

0 Kudos
Message 6 of 6
(2,022 Views)