geoland:
The switch mode power supply to the Arduino is the culprit. No noise when Arduino is powered by a wall adapter. Not inconvenient because I would like to keep adapters / leads to a minimum.
Are you using the default voltage reference, i.e. Arduino +5v?
Is the switched mode supply feeding 5v direct to the +5v pin (as opposed to providing more than 5v into Vin or the barrel jack)?
If the answer to both is yes, then the solution is to use a more stable voltage reference. e.g. the +3.3v pin. if there is no load on that pin currently, you may need to add a 10K resistor between it and ground to get a stable voltage there.
The mosfet source pin should be connected to power supply ground and a single wire run from that junction to the Arduino ground pin.
You shouldn't need a capacitor across the temp sensor, but if you do have one, you should connect the ground side of it to the ground side of the temp sensor (i.e. analog ground), not to any other ground. Depending on the temp sensor, you may need a resistor between the temp sensor output and the capacitor (check the data sheet for the temp sensor).
Thank you. Power supply is 12v to Vin. Reference voltage is 3.3 for the temp sensors, otherwise 5v. I followed your earlier advice and separated the GND's, but need to connect to power supply GND also.
Caps have improved the stability of readings. But noisy in the -ve range. Need to loooy a resistor use.
geoland:
Thank you. Power supply is 12v to Vin. Reference voltage is 3.3 for the temp sensors, otherwise 5v.
How are you using more than one ADC reference voltage?
geoland:
I followed your earlier advice and separated the GND's, but need to connect to power supply GND also.
See attached for my recommendation on how to connect the power supply. The resistor between the power supply +ve and Vin is optional but may help reduce PSU ripple feeding through to the Arduino. About 47 ohms should do provided that you aren't drawing much power from the +5v line.
[EDIT: I just looked up the TMP36 and I see it is a 3-terminal device, so connect its supply pin to +5v and ignore the resistor from output to +5v on my diagram. According to the datasheet, if you are driving a capacitive load, you need to put a resistor in series with the output pin.]
Thanks again. That clears up the few remaining issues. I had the cap across +ve GND, which might explain erratic readings in the lower temperature range - not sure - using 3.3 aref for the TMP 36, which increases its accuracy from what I have read.
So I need to add A 47R to the power supply line and tie the FET source to power supply GND, which will tidy things up and eliminate the use of wall adapters. There are enough leads to trip over as it is.
Power supply is a 12v 12.5 amp switchmode to supply the Peltier and Arduino board and Equatorial mount. Off the Arduino I am using 5v to power a stepper through an L293D and camera shutter release through an optoisolator, tapping 12v Vin to power an LED array via a power transistor.
Does the temperature reading only fluctuate when the Peltier is operating with PWM, and not when it is turned fully on by doing a digitalWrite(pin, HIGH)? If so:
It's occurred to me that the high pulsed current through the Peltier device may be inducing current elsewhere. See attached for my latest take on the wiring. Try to keep the area of the loop comprising Mosfet source/drain, capacitors, and cables to the Peltier as small as possible (e.g. use a twin cable to connect the Peltier as my diagram infers, or two wires twisted around each other). The inductor between the Peltier/capacitor junction and +ve supply will help stop the switching transients getting outside this loop (use a few turns of wire on a ferrite toroid).
Similarly, keep the area of the loop comprising TMP036 ground and output, Arduino input and analog ground, and the cable between them small. However, if that loop does pick up noise, the resistor and capacitor should reduce it provided the capacitor is close to the Arduino.
geoland:
using 3.3 aref for the TMP 36, which increases its accuracy from what I have read.
Using 3.3v as the reference voltage reduces the range of the input that can be measured from 0->5v to 0->3.3v, but improves the resolution from (5/1024)V to (3.3/1024)V. You may need to load the 3.3v pin a little to get a stable voltage (try between 1K and 10K from 3.3v to ground).
geoland:
Off the Arduino I am using 5v to power a stepper through an L293D ...
That's another reason to use 3.3v as the reference. Powering the stepper from the Arduino +5v will cause the 5v to fluctuate a little as the stepper is driven.
I am still having problems with interference / ripple when powering the Arduino from the switch mode supply. I have followed your advice and placed a 47R in series with +ve supply to the Arduino and it works great until the temperature of the cold finger is ~11C. Today it's ~33C outside. A delta of ~22, conveniently
I'm not sure whether the interference at 11C is representative of the temperature delta between ambient and cold finger or an absolute temperature of ~11 degrees. That is, on a cold day the same delta might produce a temperature of 0C. I have bonded the switch mode supply case to GND, just to be sure.
If I disconnect the PWM pin from the Arduino there is no interference. I have tried a capacitor across the PWM pin to GND after the 100R series resistor without success.
As it stands the circuit is as described in your earlier post, which was very helpful indeed.
Can you answer my earlier question: if you drive the PWM pin permanently high (or alternatively short the source and drain terminals of the mosfet) so that the Peltier is operating continuously, do you get the interference then? In other words, is the problem caused by putting a load on the switched mode supply, or is it caused by the PWM? I'm not sure what the significance of 11C is - perhaps the temperature at which the PWM kicks in?
If the problem is caused by the PWM, add the capacitors between mosfet source and Peltier +ve side as shown in my most recent diagram. If that isn't sufficient, add the inductor. Also make sure you have the grounds arranged as in my diagram, i.e. PSU negative goes to the junction of the mosfet source and capacitors, and a separate wire goes from that point (or very near it) to the Arduino ground. There should be no other connection between Arduino ground and PSU -ve.
If interference from the PWM is still a problem after doing all that, then I guess an alternative solution would be to do software PWM and synchronise the temperature readings with it, i.e. only take a temperature reading just before switching the mosfet. But is really shouldn't be necessary to go that far.
I missed your latest posts. Somehow crossed over. Will get back to your request soon. The PWM value is 255 during cool down from start to achieving set point temperature. So PWMing throughout. Power cable to Arduino gets warm, not hot, over the cool down time.
Since my last post the interference has disappeared. Which is strange. I did rewire the the camera temp sensor, shutter at the camera end and crimped the power cable to the Arduino - although it is soldered. I don't have much confidence in the reliability because there is no identifiable difference to the repair. Perhaps a dodgy connection...
Many thanks again. As requested, digitalWrite(pin10, HIGH); temp readings stable - no interference.
analogWrite(pin10, 255); no interference, but temp readings more erratic.
EDIT: It seems that the power supply problems are not completely fixed. The 12v LED array, switched through a power transistor, repeatedly flashes 2 x 1 second, pauses 2 or 3 seconds and flashes as before. Using a wall adapter the array remains on, as designed.
geoland:
Many thanks again. As requested, digitalWrite(pin10, HIGH); temp readings stable - no interference.
analogWrite(pin10, 255); no interference, but temp readings more erratic.
That indicates that the pwm is causing the temp readings to be erratic (a pwm value of 255 turns the Peltier off for 1/256th of the time). Add the capacitors i suggested, and if necessary, the indictor.
geoland:
EDIT: It seems that the power supply problems are not completely fixed. The 12v LED array, switched through a power transistor, repeatedly flashes 2 x 1 second, pauses 2 or 3 seconds and flashes as before. Using a wall adapter the array remains on, as designed.
I can think of a few possibilities:
Is that power transistor switched by the Arduino? If so, what is supposed to cause it to turn on and off? Posting your code might help.
Is the the power supply adequately rated for the Peltier device?
The switching on/off of the Peltier device at a low PWM frequency may be too much for the power supply to respond to and it may be dropping out. If so, the capacitor I suggested will help, although you may need to use a larger value and/or increase the PWM frequency. How much current is drawn by the Peltier?
[EDIT: is it possible that the Arduino is resetting during those 2 or 3 seconds?]
The power supply is rated at 12.5 amps. The Peltier is 8 amps. I disconnected the power lead to the Peltier, observing the same behaviour with the LEDs, cooling on or off. I will rebuild the cooling control circuit according to your latest diagram.
If the power supply is a switching supply try just the arduino on linear regulated supply. The EMI artifacts from the switching supply may be interfering via ground loops between camera frame and the Arduino's power supply 3rd wire ground.
Personnally I would use this approach I had intended to post here but accidentally posted elsewhere...
Your filtering needs to be an LC filter with suitable flyback diode on the mosfet, secondly petlier devices hate ripple, they work best with smooth dc not chopped. Control the fet with a suitable pwm controller for power supplies such as a LM494, then use the analog write to control the pwm's reference for its feedback loop via a very low pass rc filter. At the ~400Hz rate the analogWrite generates PWM output your inductor would be huge, the approach I suggested gets your inductor requirements down into the millihenry range as opposed to several henry. If you wanted to be really anal about it you could even snoop the petlier drive voltage with an analogRead port and make a software based global feedback loop. But it brings me full circle, why use the cpu at all when the temp sensor could reference the LM494 directly and be a done deal on 3 sqin of pcb?
geoland:
The power supply is rated at 12.5 amps. The Peltier is 8 amps. I disconnected the power lead to the Peltier, observing the same behaviour with the LEDs, cooling on or off. I will rebuild the cooling control circuit according to your latest diagram.
Rebuilding the cooling circuit according to my diagram should help stop the Peltier PWM interfering with the temp reading, but will do nothing about the LEDs. What code do you use to control the power transistor that switches the LEDs?
ajofscott has mentioned the possibility of ground loops, and this is certainly a possible source of problems. The switching PSU probably has the negative output connected to mains ground, so if the Arduino is controlling anything that also has a connection to mains ground, you will have a ground loop. If this is the case, it's probably not safe to disconnect either the PSU or the equipment from mains ground, so the best solution would be to use optical isolation between the two.
If I have an available power source which exceeds VMax, can I pulse-width modulate it to reduce the effective DC level?
No! No! No! Because this sort of approach usually works with resistive heaters, a significant number of designers seize upon this idea to avoid having to translate their available DC supply voltage to a more suitable level. The only problem is that it doesn't work with thermoelectrics. Why not? Let's say that we want to apply a pulsed DC at twice VMax with a duty cycle of 50%. If this was powering a conventional resistor, we would simply look at the effective power dissipation over the full cycle of the pulsed DC and proceed accordingly. Unfortunately, Peltier devices present some extra complexities which cannot be overlooked. The crux of the matter is that the Peltier device can only pump heat when current is flowing. We thus have to look at what is happening in each separate phase of the cycle.
When power is on (voltage high), we are driving the TE device at twice its rated VMax; what happens during this interval is no different than what happens when powering a module at twice VMax continuously. With so much power dissipated (V2/R) within the device, there is no capacity left for pumping any heat from the thermal load—in fact, some of the excessive heat within the module will flow back into the load. When power is turned off in the other part of the cycle, it is true that no power is being dissipated within the Peltier device, but without current flow, it's not pumping any heat either. Thus when power is on, you are operating a bad thermoelectric system which creates heat rather than removing it from the load; when power is off, no active cooling work is being done. Nothing good is achieved in the process.
The afore mentioned ripple figure is in line 39. It all arises to available heat transfer capacity vs I2R losses. as does puled overdrive current.
Well, thanks again. I would prefer to stick with the PSU and resolve the issues at hand rather than add another wall adapter to the tangle of cables that I have worked hard to minimize. This is an important aspect of working essentially in dark conditions where feet and hands easily get caught in a web of cables.
I understand the PWM implications - I began with the Tellurex FAQ when I started the project, but skill level just makes PWM easier all round for me, though it is not optimal. Perhaps I need to revisit the cooling control system again and redesign from the ground up. The essentials are there. With a better system the present losses may translate into increased cooling delta, which provides more flexibility and control.
Where do I start? Add a LM494 and optoisolate the GNDs from what I understand of your comments, and understanding the ground loop issue that I have created.
Does adding a LM494 fix the power loss issues associated with PWM. Not sure I understand the principle. And I might be guessing at the circuit design.
The 494 will resolve the efficiency issues as the circuit will provide an adjustable regulated and filtered dc, no PWM as far as the load sees. In fact i just recieved 10 of them from an ebay auction for about a buck per there is excellent example application in the datasheet. http://www.ceia.uns.edu.ar/integrados/datos/PWM/LM494_National.pdf
Sadly this version does not have the application circuit I'm checking for other manufacturer's datasheets, as all '494' are the same in pinout form and function.
Almost every AT powersupply I have ever scrapped has used a 494 as a controller. So you could recycle everything needed from an old power supply.
At last the app notes:
The schematics have apparent breaks where the component labels hid lines.
From your description, you have two separate issues:
LED chain not behaving as it should, even when the Peltier is disconnected. As you haven't said what controls the power transistor that switches the LED, it's hard to say why, although if it only occurs with the switching PSU connected then ground loops may have something to do with it.
Peltier PWM affecting the temperature reading.
I suggest you sort out (1) first. When you have done that, careful attention to the Peltier drive circuit decoupling and wiring along the lines I suggested should resolve (2).
Note the 0.1 ?F bypass capacitor on the input. This capacitor should be a ceramic type, have very short leads (surface-mount is preferable), and be located as close as possible in physical proximity to the temperature sensor supply pin. Because these temperature sensors operate on very little supply current and may be exposed to very hostile electrical environments, it is important to minimize the effects of radio frequency interference (RFI) on these devices. The effect of RFI on these temperature sensors specifically and on analog ICs in general is manifested as abnormal dc shifts in the output voltage due to the rectification of the high frequency ambient noise by the IC. When the devices are operated in the presence of high frequency radiated or conducted noise, a large value tantalum capacitor (±2.2 ?F) placed across the 0.1 ?F ceramic capacitor may offer additional noise immunity.
Taken straight from the sensor datasheet.
I saw no decoupling at the sensor in the camera. The camera its self is an EMI generator. Probably most of your random readings are from the camera's electronics, the probe cable should be a shielded cable such as a 2 conductor microphone cable. If you used unshielded wire your arduino is hearing "hum" from every powerline in the house. Decouple the analog signal on the Arduino end, 15K between Arduino and sensor Vout pin with 100uF on the analog input pin to gnd. I downloaded your code and noticed you have no equasions correlating Q to voltage, nor any establishing a linear line to setpoint error.
Summary: Sensor issues are installation related, decoupling will resolve these, better math will resolve control efficiencies of the TEC along with true DC drive of the TEC.