K8055, thermal resistor and doing the math (voltage divider)

read a dozen of tutorials how to built this but i don’t get it right…

Here is my setup:

GND is connected to GND on my K8055, next to the A2 analog input.
Vout is connectet to A1 (and SK2 is not in place)
Vin is connected to A2 (and SK3 is in place)
Potentiometers are both set to maximum.

The formula is from here:
en.wikipedia.org/wiki/Voltage_di … _divider_2

and here is the Code (AutoIT, a Basic like language)

(text version is here: pastebin.com/qTC0tR8P )

My problem is that r2 is always calculated wrong.
I think its just a math problem because Vout seems pretty right to me…
Its probably something obvious that i am missing :slight_smile:

Thanks for looking into it!

By placing jumper SK3, and using A2 as a voltage source, you are neglecting to consider the internal 1 kΩ resistor (R4 in the clip of the K8055 diagram below) in the +5 V “back feed” to the A2 terminal:

This makes the total “R1” resistance 4.3 kΩ, nor 3.3 kΩ (R1 + R99) in the equivalent circuit below:

Use 4300 as your $r1 constant and the calculation should come close…

ok, i would never have found that out on my own…

Thank you very much!

Now its working but the precision is pretty low, i found out that if i just remove the 3.3K resistor and use 1000 as r1 for calculation precision increased.
Any idea on how to increase it further?

And that may be a stupid question but… why does R4 (the 1k Resistor on the k8055) count but others don’t?
I mean there are probably resistors somewhere between the Power plant and my USB outlet, right?

[quote=“piccaso”]ok, i would never have found that out on my own…

Thank you very much!

Now its working but the precision is pretty low, i found out that if i just remove the 3.3K resistor and use 1000 as r1 for calculation precision increased.
Any idea on how to increase it further?[/quote]

Part of the problem is that you are using a PT1000 RTD (Resistance Temperature Device) you are using has, like all the PT RTDs, a very narrow resistance range–for the PT1000 the resistance varies only by 1000Ω from -50°C (800Ω) to 200°C (1800Ω)–this obviously is only a 2.25:1 ratio over its entire range. If you are attempting to monitor a narrower range, let’s say 18°C to 30°C (65°F to 85°F), then the resistance would only vary from 1060Ω to 1115Ω–this is only a 1.05:1 range. Observing this using passive voltage divider, and assuming that 65°F has been scaled to be 2.5V, then 85°F would provide only 2.63V. This is just a difference of 6-bits (an input count range of 128 to 134) when read via the K8055’s analog input.

RTDs like the PT1000 are usually wired as one leg of a Wheatstone Bridge, with the bridge’s output amplified and scaled–here’s a good Wikipedia article explaining this further.

What temperature range do you anticipate needing to read? If it’s a relatively narrow band, say 100°F (35°C) or so, then a NTC thermistor would be a much better sensor choice.

[quote]

And that may be a stupid question but… why does R4 (the 1k Resistor on the k8055) count but others don’t?
I mean there are probably resistors somewhere between the Power plant and my USB outlet, right?[/quote]

This is because the 1kΩ resistor in the K8055, with SK3 in place, is between (in series with) it’s +5V supply and your test circuit–the others you speak of are on the “other side” of the K8055…

That was the only water prof thermal sensor i could buy… (and i need it to be water proof)
But my area of interest is between 0 °C and 30 °C…

About that Wheatstone Bridge: is it possible to build one having only a single power source for the K8055 and the Wheatstone Bridge?
When i look at this article:
en.wikipedia.org/wiki/Wheatstone_bridge
To measure Vg i would have to connect D to GND and that would make R2 useless, right?

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?

Nice work piccaso !
I’m happy to see you got the K8055 working well and made this application software.

I think you may connect the Wheatstone Bridge outputs to the inputs A1 and A2 of the K8055.
Connect the Wheatstone Bridge power supply minus pole to the GND terminal of the K8055.

I am very happy as well :slight_smile:
And i hope that i can improve this example to use a Wheatstone Bridge some Day… and Draw a nice circuit :slight_smile:

Do you mean something like: Calculate the difference by using both values (A1 and A2) ?
I’ll try that.
Also i’ve worked out a formula:
R4=-R3(R1Vb+R2Vb+R2V)/(R1Vb+R2Vb-R1V)
But i didn’t have the Time to test it jet.

So much fun stuff and so little time…

[quote]Do you mean something like: Calculate the difference by using both values (A1 and A2) ?[/quote]Yes. I hope success.

That worked!

ReadAllAnalog(&a1, &a2);
vb = v/255*a1 - v/255*a2;

vb has the same value as displayed on the multimeter :slight_smile:
And the formula seems to be correct too.

So if i did the Math right i can now mesure with a precision of 0.98 °C
Which would be sufficient for this Project (a Cooling system which should keep the temperature between 10 and 25 °C) but i have to go to a shop and buy Resistors so i will try to get a cheap amplifier…

And using averaging, as in your first code example, you’ll get very stable reading…

Please note:
The K8055 card is using the USB +5V supply voltage as a reference for the analog-to-digital converter.
If you move the K8055 to other PC, you may get slightly different result depending on the supply voltage.
You may check the supply voltage easily between the pin header SK2 or SK3 and any GND terminal of the card.

Please see also this case: viewtopic.php?f=3&t=2342

Great to see that you have it up and running, I had to be away on a business trip for a couple days and was unable to find time to log on…

I’m not giving up jet fixing this on the hardware side :slight_smile:
But you are right, the averaged values are already pretty clear.

[quote=“VEL255”]
Please note:
The K8055 card is using the USB +5V supply voltage as a reference for the analog-to-digital converter.
If you move the K8055 to other PC, you may get slightly different result depending on the supply voltage.
You may check the supply voltage easily between the pin header SK2 or SK3 and any GND terminal of the card.

Please see also this case: viewtopic.php?f=3&t=2342[/quote]
Do i get this right: I could stabilize the read value with a capacitor?
I dont really understand what can be done with capacitors jet, the only thing i know is that polarity matters and that they work similar to rechargeable batteries.
Is it save to just try some out without damaging the board?
Some of them have Voltages printed on them but its always > 5, but does it matter?
And i guess it does not make sense to stabilize Vb (output from the bridge) unless its amplified, right?

You pointed me in the right direction, thank you very much!
I really appreciate your help and input - from both of you, of course.

The capacitor mentioned in the other post is to put between A1 and/or A2 and GND to reject input noise.
There is no need to put any additional capacitor between the USB +5V and GND.

  • Indeed, adding this capacitor can damage your PC.

no i ment like this:

Capacitors pass AC signals, but block DC. Because of this what you propose would not work as the output of the bridge is a DC signal.

The voltage rating of a capacitor it its maximum working voltage, however it is not good design to use capacitors of too high a rating–for instanace using a 100V rated cap in a 5V circuit due to a number of issues, ESR (Equivalent Series Resistance) being one such issue.

Here is a good beginner’s tutorial on capacitors, and here is a next step

Your solution to put the capacitor between A1 and A2 should stabilize the difference between A1 and A2 inputs.
Anyhow, I recommend some filtering for the absolute value of the analog inputs A1 and A2.
You may connect capacitors (e.g. 470nF) between A1 and GND and between A2 and GND.
By doing this you’ll stabilize the analog input values.

I apologize, I just jumped on for a quick peek and had mis-interpreted the diagram–the cap will of course filter the output placed in parallel as shown…

I thought that there are 2 types of capacitors, but there are… many!
To much for today, have to get going… :frowning:

Can you please help me find an operational amplifier in any shop or wherever, i tried to but i’m not sure what to look for…

Here is a simulation i made and i really would like to test it in real but i cant get all parts…

Rx (1000-1200 Ohm) is simulated with a potentiometer, thats why it looks so funny…)

Last time i was at the shop and asked for an amplifier, but they had no idea what i was talking about.
i would like to try it for real and the only part i dont have is the triangle thing.
In the emulator it feels like its something normal, just ad an op-amp and set it to 0-5 V…

Btw, the simulator i found is nice for sharing stuff over the web.
If the circuit is not to large you can link it :slight_smile:

Nice simulator indeed!

I think you can connect the bridge outputs directly to the A1 and A2 inputs of the K8055, without external amplifier.
If you need more gain, you can add resistors R8 and R9 on the board.
Please see the manual p. 10 how to calculate the values for R8 and R9.