Mimic a thermistor with a digital potentiometer?

hippy

Technical Support
Staff member
It would be useful if you can determine exactly what the actual input to the controller is. If that is basically an ADC input with thermistor between that and 0V, a pull-up to +5V then you possibly would not need isolation and can inject a voltage directly into the controller using a simple RC as previously suggested. You can then have a fully closed-loop system by monitoring what the voltage being injected is.

If it is not a thermistor ADC arrangement as above then it gets more complicated; you need the signal isolation, and may only have access to the voltage used to drive the LED-LDR coupler. You could add a second LED-LDR coupler and feed that back via a PICAXE ADC. That signal should reflect any self-heating and illumination related drift back to the PICAXE.
 

rmeldo

Senior Member
New reading this morning and yet more drift, albeit it is slowing down.

ime, ---- Voltage ------ Equivalent Temperature (as displayed on the commercial controller)
14/09/2016 07:29 3.941 16.9

supply voltage 5.039V

Chart attached.

forForum 14Sep2016 morning.png

I haven't replaced the capacitor yet so there is still hope but close loop seems to be the way to go.

from the readings I have a temperature drift read by the commercial controller of 8 degC (24.9-16.9) and a voltage difference of 0.368 V. The controller has a resolution of 0.1 degC so 80 steps. So 0.368/80 = 0.0046 volts/step.

With a 5.038V supply and 10 bit ADC i get 0.0049 V/step. It should work.

Riccardo
 

rmeldo

Senior Member
To answer Hippy I tried to use the measurements I have got to calculate the other resistance of the hypothetical voltage divider used by the DC1100 ADC circuit.

The results are shown in the attached figure:

voltage divider.jpg

I don't know if this is enough evidence to support the voltage divider theory. What do you think? I do not have access to the DC1100 schematic.

Riccardo
 

rmeldo

Senior Member
An update and some questions:

I have swapped the two electrolytic capacitors for a ~10uF ceramic. I am in the process of taking measurements. Data to follow.

In the meantime I have had a go at drawing a circuit which controls the resistance "seen" by the DC1100 and implements a close loop using a 08M2 (pending feedback on my input to Hippy's suggestion to just inject a voltage in the post directly above this).

I am attaching it hoping for comments, before I try it on a breadboard.

drawn circuit.JPG

I have added a feature to power cycle the broadband router (they lose connection to the internet from time to time and need rebooting). The idea is to use the pin voltage (when high) to cut the power to the router. Any advice on what I should use to do this? Would a solid state relay do the job? I haven't looked into this yet.

Also attached is the circuit implemented on a stripboard to be placed directly on top of the raspberry pi B 2 in a "shield" fashion. Comments welcome too (disregard the colors of the resistors as they are still wrong).


circuit on stripboard.JPG

Thanks in advance
Riccardo
 

rmeldo

Senior Member
PID code snippets?

Hi,

I am making progress.
The system seems more stable now that I have replaced the capacitor. I might be able to go in open loop.

I am working on the breadboard in parallel whuile calibrating the sistem in situ.

I also implemented the RC filter at the input of the optocoupler. It requires shifting to higher PWM seetings, as suggested in previous posts. I have ended up with ~100 ohm resistors and 100 uF capacitor.


Now I am trying to implement the close loop control so that I can compensate the drifts.

I am struggling on how to implement the PID control without floating point math. Would somenone be so kind to post some code snippets to get me started?

Many Thanks
Riccardo
 

hippy

Technical Support
Staff member
Never done proper PID but for a slow moving system which this appears to be with no sudden or large changes it should be good enough to set an initial PWM duty, read back the voltage, if too low then bump duty up one, if too high, bump it down one.

You can get more PID like such that if it's a lot too low, bump it up by more than one, etc.

It's probably worth trying a simpler scheme like that and seeing how well it does before getting more complicated.
 

AllyCat

Senior Member
Hi,

Yes, I was going to propose much the same: IF required > actual THEN : INC pwm : ELSE IF required < actual THEN DEC pwm ... etc. seems to work much better than might be expected.

However, for a heating system it's probably essential to also include quite a long PAUSE (or equivalent) in the loop. If the program has background tasks, then something like: IF time > 300 THEN : time = 0 :.....etc. (as above).

It might be refined with "proportional" control, e.g.: pwm = pwm + required - actual , but for faster response without excessive overshoot, you might want to add a "phase advance" or "feedforward" method such as: IF present_tempretaure > last_temperature THEN : DEC pwm etc..

Cheers, Alan.
 

hippy

Technical Support
Staff member
However, for a heating system it's probably essential to also include quite a long PAUSE (or equivalent) in the loop.
For a true heating system you are probably right, but this seems more a DS18B20 to voltage converter to deliver the temperature for the actual heating system, so the faster the response the better to keep the voltage tracking the temperature. Though it will inevitably be slowed by the time it takes to do the READTEMP.
 

rmeldo

Senior Member
Hi,

I implemented the close loop control last night. I used a combination of a feed forward "open loop" starting PWM value and then changed the duty cycle dy INC or DEC. In the final code I will also keep track of the last ofset between open and close loop PWM values to achieve the target ADC reading.
 

rmeldo

Senior Member
update and a question please.

The system is now deployed and working. I had to run in open loop though. I had to adjust the calibration over several days to correct the drift from the VTL5C6. Now however it seems stable.

However I couldn't make the close loop work. It performed perfectly during testing on its own. I was simulating the commercial controller as a voltage divider, where one of the two resistors was the VTL.

I don't know for sure that the commercial controller reads the thermistor resistance with a voltage divider but from previous tests I had worked out the value of the other resistor internal to the commercial controller.

To do this I 1) used the table of resistance vs temperature of the thermistor to replicate 2)the voltage drop across the VTL measured with the multimeter and 3) read the temperature on the display of the commercial controller. By Curve fitting the data I got a value of 12kOhm for the internal resistance.

It seems to make sense. Could the sensing have been implemented in a different way in the commercial controller?

The problem I got when i connected my board, with the close loop circuit, to the controller was a constant voltage (and temperature reading in the controller) regardless of the value of the PWM to the VTL from 0 to 100%.

I think the problem might be in my connections.

I tapped one of the two wires of the VTL output and connected it to the ground of my board. The other wire I tapped and connected to the ADC of my microcontroller.

Have I broken a "ground" rule, pun intended? Any suggestions?

I really want to make the close loop control work because it makes calibration so much easier.

IF there is no solution to the problem of implementing close loop by making an electrical connection, are there contactless methods of closing the loop by measuring the current/voltage across the VTL? The current levels are about 0.1 mA and 4V.

Thanks again

Riccardo
 

AllyCat

Senior Member
Hi,

I didn't mention this before, because you appeared to be getting satisfactory results, but it's quite common for a system to measure the value of a Thermistor by including it in a ramp generator or oscillator circuit. Some microcontrollers don't have ADCs and also this "oscillator" method can resolve a time period (and corresponding resistance) to 16 bits resolution (i.e. a 16-bit timer/counter like PULSIN) which is better than most low-cost ADCs can achieve.

So you need to determine if the commercial controller is using such a "dynamic" measurement method. That really needs a 'scope but you might be able to discover if anything "unexpected" is happening by connecting the signal to an audio amplifier, e.g. a PC "soundcard". Such a method might not make closed loop operation impossible, but certainly more difficult.

I don't know about "contactless" but it's possible to measure the V and I with two PICaxe ADC inputs. However, it would be necessary to choose a suitable resistor value to put in series with the Thermistor to measure current (via Ohms Law). The voltage drop across the resistor must not be too much, so for this case it's probably reasonable to use the FVR1024 volt reference for the ADC to resolve to 1 mV steps with READADC10.

Isolated closed loop control probably needs a second processor (08M2) to measure the I and V, then convert to digital values and transmit via an optocoupler.

Cheers, Alan.
 

rmeldo

Senior Member
Possible brute force approach?

Thanks for the advice.

I have a scope so I will take the measurement. One thing that makes me think however is the fact that I have a 10 uF capacitor in parallel with the resistive output of the VTL and the commercial controller is fine with it. Wouldn't it affect the dynamic measurement?

Also I was reflecting on the options for a contactless close loop and I dreamed up the attached method (see figure).

double relay.jpg

This is how I envisage it working:

1) use two VTLs, one in open loop connected to the commercial controller and the other in close loop system connected to the microcontroller to calibrate the current needed to maintain the required output resistance.
2) periodically (say every 6 hours or so) swap the connections using two double throw relays to bring the one which was in open loop back into the calibration loop.

I was thinking of using latching relays probably make before you break.

The opportunity is the fact that the drift happens slowly and there is plenty of time to correct for it.

It is too heavy handed?

Thanks
Riccardo
 

stan74

Senior Member
You can often 'fake' a device like a thermistor by simply using pwmout onto a resistor to capacitor to ground, the connection between the resistor/capacitor is connected where the thermistor would have been.

Varying the pwmout frequency will alter the voltage measured at the r/c junction.
I remember using that with LDRs on a light seeking robot :)
 

AllyCat

Senior Member
Hi,

Wouldn't it [10 uF] affect the dynamic measurement?
Not necessarily. I've been working with such as system (a commercial radio-linked thermometer) which actually has 10uF connected to the thermistor. In operation, it first charges the capacitor via an accurate 10k resistor (measuring the time until Vdd/2 is reached) as a "calibration stage". Then it discharges the capacitor, charges it again via the thermistor and calculates the ratio of the two times. Therefore the actual value of the (non-precision) electrolytic capacitor has no influence on the result, and even doubling the value (by adding another capacitor) might not have much effect.

The "dynamic" operation can even have advantages because it's possible to "see" when the commercial controller is making a measurement. A system I've been developing uses just one PICaxe pin (on an 08M2) and no other components (except a couple of optional resistors to "improve the user experience") but it can "read" the calibration and thermistor ADC pulses, or even "fake" a different temperature by "pulling" the voltage on the timing capacitor. It's part of a much larger project that I'm not ready to document yet, but if you do find any "waveforms" on your thermistor, then post them here and we'll see what can be suggested.

Your relay method is probably "overkill" but not ridiculously so. A single (two-pole) relay might be sufficient; either by not switching the earths, or even by making a quick measurement "whilst the commercial controller isn't looking". A latching relay may be good if you're using an "occasional change-over" method, but I think make-before-break contacts are rather rare and probably not a good/necessary idea.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Could the sensing have been implemented in a different way in the commercial controller?
Possibly. If there are self-heating effects from passing current through a thermistor a controller could be designed to take those into account, either to reduce them or try to keep them constant. That might be done electronically rather than in software.

It might be possible to have a scheme trying to keep a constant current through the thermistor-resistor divider rather than using a voltage.
 

rmeldo

Senior Member
A long overdue thanks to everyone who has helped me on this project.

A quick status update:

I am still using the optocoupler in open loop, as the drift stops after about a day. I decided to leave any improvements until the time the heating is turned off next spring. At that time I should be able to take more measurements and decide how to implement close loop control.

Thanks again
Riccardo
 
Top