LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically activate a MAX scale

Hi,
I d like to know if there's a function to programmatically activate or deactivate a scale define for a specified channel under MAX.

Thanks

Olivier
0 Kudos
Message 1 of 5
(3,830 Views)
Hi Olivier,

As far as I know there is no function to "activate or desactivate" a scale in MAX.
I believe that this is just a problem with semantics. What exactly do you wanna do ? You can actually programmatically create channels and specify a scale for them - that you can also create programmatically. It should be enough to match your needs.

Give us some more details and we might help.
Regards.
0 Kudos
Message 2 of 5
(3,815 Views)
HI,
here is the code I have tried to use

int32 CVICALLBACK SpeedTorqueAcquisition721 (TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)

{
   
    DisableBreakOnLibraryErrors();
   
    if(unit==1) DAQmxSetChanAttribute (AnalogInputsTask, "Torque Acquisition 721", DAQmx_AI_Voltage_Units, DAQmx_Val_FromCustomScale, "LB-In to N m");
    else if (unit == 0) DAQmxSetChanAttribute (AnalogInputsTask, "Torque Acquisition 721", DAQmx_AI_Voltage_Units, DAQmx_Val_FromCustomScale, "Torquescale");

   
    (DAQmxReadAnalogF64(AnalogInputsTask, 500, -1,DAQmx_Val_GroupByChannel, AnalogInputsArray,2500, &AnalogSamplesPerChan,NULL));

    EnableBreakOnLibraryErrors();
   
    Subset1D (AnalogInputsArray, 2000, 0, 500, SpeedArray);
   
    Mean(SpeedArray, 500, &SpeedVal);
   
    SpeedVal = SpeedVal*1500;
   
    SetCtrlVal(dvdxt, DVDXT_Speed_indicator, SpeedVal);   
   
    Subset1D (AnalogInputsArray, 2000, 500, 500, TorqueArray);
       
    Mean(TorqueArray, 500, &TorqueVal);

    SetCtrlVal(dvdxt, DVDXT_Torque_indicator, TorqueVal);
   
    Subset1D (AnalogInputsArray, 2000, 1000, 500, PressureArray);
   
    Mean(PressureArray, 500, &PressureVal);
   
    SetCtrlVal(dvdxt, DVDXT_Pressure_indicator, PressureVal);
   
    Subset1D (AnalogInputsArray, 2000, 1500, 500, AlternatorTemperatureArray);
   
    Mean(AlternatorTemperatureArray, 500, &AlternatorTemperatureVal);
   
    SetCtrlVal(dvdxt, DVDXT_Int_Temp_indicator, AlternatorTemperatureVal);
           
    return 0;
}

What I am trying to do is to convert value from lb-in to Nm using scales,on action of a button on the front panel called unit.
so I need to use the LB-in scale when unit = 1 and I need to use the lb-in to Nm scale when unit =0
lb in scale is y=40x+0, LB in to Nm scale is y=40*0.112984137 x+0, 40 is the converstion factor from voltage to lbin and 0.112984137  is the converstion factor from lbin to Nm
but using the code above the values does not change on unit button actuation.

0 Kudos
Message 3 of 5
(3,806 Views)
Hi Olivier,

Thanks for pointing this "Custom Scale Name" attribute. I missed it.
I think that what you do is right except on one point. You have to stop the task and start it again for the scale change to be effective.

This is worth trying but might no need your match... Stoppping and restarting the task actually takes some time

Did you try to do the choice in the software? I mean do the scale by yourself in the code.

Regards.
0 Kudos
Message 4 of 5
(3,800 Views)

Hi Olivier and Mathieu,

I think that Mathieu is right. Did the scale change if you switch your unit button before beginning the first acquisition?

And as Mathieu said, stopping and starting a task takes some time. Maybe you could use the DAQmxTaskControl function (NI-DAQmx Library>Task Configuration/Control>Advanced) With this function, you can abort a task and reserve again the resources before starting it. The different actions are well defined in the function panel help.

I hope this could help you to reach the behavior you're looking for.

Regards,

Olivier L. | Certified LabVIEW Developer


0 Kudos
Message 5 of 5
(3,746 Views)