10-11-2015 08:32 AM
Hello,
I'm new to NI and DAQ. Just posted this question before http://forums.ni.com/t5/Signal-Conditioning/usb-6211-DAQ-frequency-question/td-p/3202422 and found out that the signal can't be locked on a hardware level.
Can anyone provide an example in C / C++ to lock a 400 hz signal. I've used the ContAcq-IntClk.c example to read data from one resolver (sind and cosine) and a reference signal. However since the signal shifts to the right (in this case) it becomes difficult to determine the resolver's position.
Thank you in advance.
Regards,
Gerhard
Solved! Go to Solution.
10-11-2015 10:36 AM
Looks like I can self solve another of my posts 😉 lonely here in this forum... kind of... 😉
Well since I asked for a code example, I'll provide my solution here. It's probably by far not perfect, but works. So improvement suggestions are welcome.
DAQmxErrChk(DAQmxReadAnalogF64(taskHandle, 1000, 10.0, DAQmx_Val_GroupByChannel, data, 3000, &read, NULL)); if( read>0 ) { for (int loopa = 2001; loopa < 2999; loopa++) { if (data[loopa] > highestRef) { highestRef = data[loopa]; highestPos = loopa; } } referenceS = data[highestPos]; lsine = data[highestPos-1999]; cosine = data[highestPos-999]; radians = atan2(cosine, lsine); angle = radians * (180 / M_PI); if (cosine < 0) angle += 360; printf("D: %f %f ref: %f refH: %f Pos: %i angle: %f\r", lsine, cosine, referenceS, highestRef,highestPos, angle); fflush(stdout); }