Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 310 → Rev 311

/cvi/apps/TempCtrl/TempCtrl.c
73,8 → 73,6
GetCtrlVal(pa,PA_CHANNEL, &ch);
iRet = TMI_TimeOut(TMI_DeviceId, 1);
iRet = TMI_Refresh(TMI_DeviceId);
 
 
iRet = TMI_MoniDataQ(TMI_DeviceId, ch+1, &Voltage, &Current, &cv_cc);
 
SetCtrlVal(panel, PA_VMON, Voltage);
97,10 → 95,9
GetCtrlVal(pa,PA_CHANNEL, &ch);
GetCtrlVal(pa,PA_PRESET, &preset);
 
 
 
TMI_VoltageQ(TMI_DeviceId, ch+1, preset, &Voltage);
TMI_CurrentQ(TMI_DeviceId, ch+1, preset, &Current);
SetCtrlVal(pa, PA_VSET, Voltage);
SetCtrlVal(pa, PA_ISET, Current);
 
109,6 → 106,11
return 0;
}
 
int SetCooling(char onoff){
int nb=0;
nb = ComWrt (COM_PORT, &onoff, 1);
return nb;
}
 
#define tcpChk(f) if ((g_TCPError=(f)) < 0) {ReportTCPError(); return -1; }
 
174,10 → 176,10
printf("Received %s\n", receiveBuf);
int cmd=0;
float arg;
sscanf("%d%f",&cmd,&arg);
sscanf(receiveBuf,"%d%f",&cmd,&arg);
switch (cmd){
case 1:
SetCtrlVal(ps.PA_TSET,arg);
SetCtrlVal(pa,PA_TSET,arg);
break;
default:
break;
285,7 → 287,19
return 0;
}
 
int CVICALLBACK SwitchCoolingOnOffCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int onoff=0;
 
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(pa,control,&onoff);
SetCooling(onoff);
break;
}
return 0;
}
 
int CVICALLBACK SwitchOnOffCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
313,8 → 327,13
int debug1;
GetCtrlVal(pa,PA_DEBUG_1, &debug1);
//printf("%f#%s#", temp, read_data);
// temp1 , temp2 , temp3 , temp4 , temp humidity sens, rel.humidity
if (bytes_read >0) {
SetCtrlVal(pa,PA_ARDUINO, read_data);
}
sscanf(read_data,"%lf %lf %lf %lf %lf %lf",&f[0],&f[1],&f[2],&f[3],&f[4],&f[5]);
double humidity = f[5];
double htemp = f[4];
// printf("%lf %lf %lf %lf %lf %lf",f[0],f[1],f[2],f[3],f[4],f[5]);
int RS232Error = ReturnRS232Err ();
if (ReturnRS232Err ()) {
338,7 → 357,7
 
double tdiff = temp - tset;
double retpid = UpdatePID(&pid, tdiff, temp);
const double troom = 20;
const double troom = htemp;
double Pheat= 0.2 * (temp - troom);
double Ptec = retpid - Pheat*2;
vset = (polar*Ptec>0) ? sqrt(fabs(Ptec)) : 0;
362,7 → 381,7
PlotStripChart (pa, PA_GRAPH_VMON, pgraph, 3, 0, 0, VAL_DOUBLE);
PlotStripChart (pa, PA_GRAPH_3, &humidity, 1, 0, 0, VAL_DOUBLE);
SetCtrlVal(pa,PA_TMON,temp);
 
SetCtrlVal(pa,PA_HTMON,htemp);
SetCtrlVal(pa,PA_HUMIDITY,humidity);
 
char transmitBuf[512]= {0};