Hi,
I have a PCI-7342 board connected to a MID-7652 box that is being used to control a servo motor on a rotary axis with an encoder. I also have a PCIe-6323 board that is used to read a quadrature linear encoder on the counter using DAQmx and I am programming in C. As the axis rotates, it passes breakpoints and sends a trigger signal in order for the counter to latch a reading from the quadrature encoder. I have also posted this in the Counter/Timer message boards.
The DAQmx is set up using the following functions:
DAQmxCreateTask(, &thHandle);
DAQmxCreateCILinEncoderChan(thHandle, "Dev1/ctr0", , , , , , , , , );
DAQmxCfgSampClkTiming(thHandle, "/Dev1/PFI0", , , , );
DAQmxStartTask(thHandle);
This sets up the counter to be latched every time a signal arrives at the PFI0 terminal. I have connected the breakpoint output from the MID-7652 box to PFI0.
The rotary axis is configured with modulo breakpoints using the following functions:
flex_configure_breakpoint(, , NIMC_MODULO_BREAKPOINT, NIMC_RESET_BREAKPOINT, );
flex_load_bp_modulus(, , 250, );
flex_load_pos_bp(, , 0, );
flex_enable_breakpoint(, , NIMC_TRUE);
Due to modulo breakpoints, I have to call flex_enable_breakpoint(, , NIMC_TRUE); every time a breakpoint occurs in order for the next breakpoint to be able to trigger.
The problem I have lies in the next stage. I want to call the read function which will wait for incoming trigger on PFI0. So I call the function:
DAQmxReadCounterF64(thHandle, -1, dTimeOut, , , , );
Next in my code I start the motion of the rotary axis
flex_start(, , );
do
{
flex_read_axis_status_rtn(, , &usAxisStatus);
usBPStatus = !((usAxisStatus & NIMC_POS_BREAKPOINT_BIT)==0);
if (usBPStatus)
{
flex_enable_breakpoint(, , NIMC_TRUE);
}
} while ( !(usAxisStatus & (NIMC_MOVE_COMPLETE_BIT | NIMC_AXIS_OFF_BIT )));
But this line is never reached because the DAQmxReadCounterF64() function keeps waiting for an input at the PFI0 terminal and blocks the program from running and times out, returning an error.
I have tried rearranging the order of the functions by calling flex_start(); first and then DAQmxReadCounterF64() before the do-while loop.
The problem with this method is that the DAQmxReadCounterF64() function blocks the runtime and so the second breakpoint is never enabled. The function again times out and returns an error.
I don't want to set it to indefinite or my program will wait forever and not do anything. Is there a way around the DAQmxReadCounterF64() timeout? Or a way to re-enable the breakpoints?