I already posted this in the PXI forum but someone suggested I might get more results here. Sorry in advance if I am not abusing the forum.
I have PXI system with a RT OS. It was working pretty well until I upgraded to LabWindows/CVI 2013. It seems to be a context switching problem; I will describe it the best I can and see if there have been others with a simular problem.
The section of my code which has the problem is where I am trying to measure the effect of a RC filter by injecting a DC signal to a external device which has its own signal acquisition system. The external device is communicated to via CAN. The DC signal is generated by a DAC in my PXI system. My PXI system also has a CAN device I control in my application.
Here is the steps of my software.
1.) a CAN message to my external signal acquisition system to start acquiring a waveform of 100 samples at a sample rate of 150us. The waveform is 15ms long.
2.) p for 5 ms
3.) the DAC to a voltage
4.) load signal from external device and record to a file.
So by Sleeping for a bit before setting the DAC I will see the effect of my RC filter in the external acqusition system's generated waveform.
When I had LabWinodws/CVI 2012 this worked just fine but now it seems that the DAC output changes before my external device receives the CAN message to start acquisition.
Here are some of the complexities of the system.
The CAN message is sent on a separted thread so use the function PostDeferredCallToThread() to post this.
Right after that I go to sleep so the RTmain() function can allow this lower priority thread (the CAN message) to execute.
Then I set the DAC output.
Here is the code which Posts the CAN and sets theAC.
PostDeferredCallToThread( ActOnStartAbsorptionMeasurement, &g_InputVoltage[g_InputVoltageptr], g_mainThreadID); // send CAN message
// 5 ms delay
timerTracker = GetTimeUS();
timerTracker += 5000;
SleepUntilUS((unsigned long)timerTracker);
// set the DAC
(void) SetDACoutput(VoltageLevel);
Here is what I do in the RTmain()
while (!RTIsShuttingDown () && !gDone)
{
/* Your code. */
/* Sleep for some amount of time to give the desired loop rate */
/* and to allow lower priority threads to run. */
timerTracker = GetTimeUS();
timerTracker += RT_MAIN_SLEEP_TIME; // RT_MAIN_SLEEP_TIME == 400us
SleepUntilUS((unsigned long)timerTracker);
ProcessSystemEvents ();
}
I appreciate any help. Thanks in advance