LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SetCtrlVal error

I'm writing a program to control a test station, and one of the things which i am trying to do is update an on screen display. I have a numeric indicator on my UIR called OLDTEMP and it is set up as type double. I'm trying to set the value of it using SetCtrlVal. The data type I'm trying to put into the indicator is of type double. A code snippet looks like this:

char lasttemp[1024];
double tempdub=57;

kei2182id=ibdev(0,kei2182, 0, TIMEOUT, EOTMODE, EOSMODE);
ibclr(kei2182id);


Fmt(command, ":SENS:TEMP:RTEM?"); //Gets the internal Temperature
ibwrt(kei2182id, command, strlen(command)); //writes command to the keithley
ibrd (kei2182id, lasttemp, 1024); //gets the result
Scan(lasttemp, "%s>%f", &tempdub); //converts from char to
double
SetCtrlVal(kei2182, KEI2182_TEMPNOW, tempdub); //updates the display . . . this is also the line where the error occurs.

When I try to run the program, the error I get back says: "ProbeStation.c", line 1423, col 42, thread id 0x0000049C Invalid argument type: found 'double', expected 'pointer to char'.

Line 1423 is the line containing SetCtrlVal(xxx), and the output "tempdub" is the argument the debugger doesn't like.

I'm still fairly new at this, but I don't understand what I'm doing wrong. If anyone has any suggestions, I would greatly appreciate it.

Thanks in advance,

john Nordling
0 Kudos
Message 1 of 4
(4,310 Views)
A problem like you describe with SetCtrlVal is usually because you are using the wrong panel handle or control ID. CVI doesn't know whether or not the control you specified is on the panel whose handle you specified.
You said you have a numeric indicator called OLDTEMP, but the SetCtrlVal statement uses KEI2182_TEMPNOW. What's TEMPNOW?
Check to make sure that TEMPNOW is the numeric you want to write to, and that KEI2182 is the constant for the panel given the handle kei2182 by LoadPanel(). Also, make sure that the function in which you're calling SetCtrlVal has access to kei2182 and that nobody else changed its value. Using breakpoints, check the value of kei2182 immediately after LoadPanel() and again right before SetCtrlVal.
Message 2 of 4
(4,310 Views)
That was exactly it, I was using the wrong handle. Sometimes I wonder about myself. FYI, TEMPNOW is the other indicator. The program shows both the current temperature and the temperature at the last calibration, I cut the wrong code snippet for my question. They're identical, except for the command sent to the voltmeter and the name of the numeric indicator.

It's always the stupid little mistakes that get me.

thanks again,

John
0 Kudos
Message 3 of 4
(4,310 Views)

I was doing the same stupid thing.  Solved my problem, too!  Kudos.

0 Kudos
Message 4 of 4
(2,336 Views)