Page 1 of 1

Variables in Bridge Program

Posted: Fri Jan 27, 2017 12:24 pm
by kaleenee
Hi!

I'm trying to add in my calibration equation to the example Bridge program code, and am running into some issues.

One, I'm not sure I know where the variable 'lf' comes from. I've figured out that 'd' is the port on the bridge (0-3), and the only thing that 'lf' makes sense as is the voltage output. But it isn't defined anywhere, and if I try and use it in my equation it is underlined in red and hover-over says "identifier 'lf' is undefined"... so how is it using it in the printf?

Maybe I just don't know how the handles are supposed to work...

Any input is super appreciated!
Thanks!

Code: Select all

#define FREQS_SIZE 20
double bridges[FREQS_SIZE] = {0};
int CCONV data(CPhidgetBridgeHandle phid, void *userPtr, int index, double val)
{
	CPhidgetBridgeHandle bridge = (CPhidgetBridgeHandle)phid;
	double f, x, ms;
	int i;

	x = -147.2022*f - 2.1602;

	printf("Load Reading (%d) %lf,\n",index,val);
	/*if(val < 0)
		printf("Data Event (%d) - -0x%06x\n",index,(int)-val);
	else
		printf("Data Event (%d) - +0x%06x\n",index,(int)val);*/

	return 0;
}

Re: Variables in Bridge Program

Posted: Sun Jan 29, 2017 2:44 am
by frodegill
See the printf documentation. %d is a decimal integer, %1f is a floating-point with one decimal. The placeholders are replaced by values from the variables index and val.

Re: Variables in Bridge Program

Posted: Fri Feb 10, 2017 2:15 pm
by kaleenee
Thank you! Got me pointed in the right direction!