I found a way to get cleaner readings, but this way the reaction time is longer.
Maybe someone has a use for it too…
R1 = 470 Ohm
Vin comes from SK3 Header to get around that built in Resistor. (Made a Plug out of an old floppy power cable)
SK2 and SK2 are open.
Vout goes to A1 and A2.
On the software side there is a thread running which constantly pulls A1 and A2 Readings and provides an average value of the last 64 read cycles.
Here is the relevant code (written in C):
[code]// change buffer size here when needed
#define buffer_size 64
float analog_buffer[buffer_size] = {0};
void __cdecl analog_reader (void* d){
int a1, a2;
while(1){
analog_cnt++;
if(analog_cnt == buffer_size) analog_cnt = 0;
ReadAllAnalog(&a1, &a2);
analog_buffer[analog_cnt] = (a1 + a2) / 2;
// maybe add a call to Sleep here…
}
}
float get_analog_value(void){
float rval = 0;
for(int i = 0; i < buffer_size; i++) rval += analog_buffer[i];
return rval / buffer_size;
}
int main(int argc, char *argv[])
{
if(init() != 0) return -1;
if(OpenDevice(0) != 0) return -2;
// Start Worker
_beginthread(&analog_reader,0,0);
// Make sure the analog_buffer is filled bevor using
Sleep(2000);
// set v_in in Volt and r1 in Ohm
float v_in = 5;
float r1 = 470;
while(1){
// Calculate Vout
float v_out = v_in / 255 * get_analog_value();
// Calculate R2
float r2 = r1 / ((v_in/v_out) -1) ;
// Translate R2 to Temperature [°C]
float t = GetPt1000Temperature(r2);
// Print temperature, rounded to 1 digit after the decimal point
printf("%.1f\n",t);
Sleep(1000);
}
}[/code]
Complete file: pastebin.com/57iq30rP
@cliffyk, i read deeper into the Wheatstone bridge and failed to solve this calculation:
[size=75]Rx = R2I2I3R3 / R1I1*Ix[/size]
Where do i get I2, I3, I1 and Ix from?
Could it be that its not possible to use a Wheatstone bridge on a K8055 or am just not ready for level 2 yet?