05-16-2009 05:13 AM
Hello
I'm using a NI USB 6221 DAQ to measure the angular postion of a maxxon encoder working with Visual Studio 2008 using visual C++ as the platform. I created task with the DAQ and initalised the angle of the CIAngularEncoder channel at the start, however, i need to change the inital angle in some later process. I've tried using DAQmxSetCIAngEncoderInitialAngle to reset the inital angle to my current desire values, however, it does not seem to be able to reset the angle and the read out values persit as the original inital value.
I initailised the DAQ with the following lines
if (DAQmxCreateTask(" ", &AO_TaskHandle) != 0) { return -1;}
if (DAQmxCreateAOVoltageChan(AO_TaskHandle, "Dev1/ao0", "", MIN_VAL, MAX_VAL, DAQmx_Val_Volts,
"") != 0) { return -2;}
if (DAQmxCreateTask(" ", &DI_TaskHandle) != 0) {
return -3;}
if (DAQmxCreateTask(" ", &AI_TaskHandle) != 0) { return -5;}
if (DAQmxCreateAIVoltageChan(AI_TaskHandle, "Dev1/ai1", " ", DAQmx_Val_RSE, MIN_VAL /2.0, MAX_VAL /2.0, DAQmx_Val_Volts,
"") != 0) { return -6;}
if (DAQmxCreateCIAngEncoderChan(DI_TaskHandle, "Dev1/ctr0", "right", DAQmx_Val_X4,
0, 0.0, DAQmx_Val_AHighBHigh, DAQmx_Val_Degrees, 1000, 135.00, "") != 0) {
return -4;}
and tried to change the inital angle using
DAQmxSetCIAngEncoderInitialAngle(DI_TaskHandle2, "Dev1/ctr0", 90);
DAQmxSetCIAngEncoderInitialAngle(DI_TaskHandle2, "right", 90);
of which both methods failed.
Can someone assist or perhaps suggest a different method to which i would be able to change the starting angle after the inital setting?
Thanks in advance!
05-28-2009 07:03 AM
Hi,
I´m not that familar with C++ and Visual Studio, but I know most of the DAQmx-Functions and as far as I know, it`s not possible reinitialize to a new angle at the running process. The only chance is to stop and restart with a new init-value. But perhaps you can use simple arithmetic and use the encoder more relative. This means if you want to re-init, use a second variable to the value you need and calculate the new coming angles relative to the one you need.
Hope this helps
Alex Rudolph
NI Switzerland