DIY PID Controller
This is the first of a series of posts about the Arduino PID controller shield:
A PID controller is like a kind of fancy thermostat, but can be used to control pretty much any kind of process, not just heating and cooling. This project was inspired by the osPID (open source PID) and its design is greatly indebted to that pioneering device.
The goal of this project was to make a PID controller from scratch with minimal skill and know-how. It was an easy call to design the controller as an Arduino shield. This would make the project accessible to hobbyists and enable reuse of the tried-and-tested osPID firmware and GUI. The shield had to be easy to build using minimal tools, with components that were easy to order. Fortunately, it proved possible to recreate most of the functionality of the osPID on hand-soldered prototype board using through-hole components. With the exception of the Arduino all the components can be ordered directly from Tayda.
Although intended as a DIY project this device is very capable. With the addition of an SSR module and suitable cookware, the stripboard PID shield could be used directly in applications such as sous vide food preparation, brewing, and making the best espresso this side of Milan.
Hardware Design
The original osPID hardware was adapted to fit the constraints I had chosen. There wasn't space for an output relay, the op-amp buffer and low pass filter for the thermistor were omitted, and the thermocouple interface chip was not available as a through hole component. On plus side, it was easy to add the ability to use 1-wire temperature sensors like my favorite DS18B20. A 16x2 LCD module was preferred to the osPID's 8x2 on the basis that it used the standard connector for HD44780 equivalent displays.
The stripboard layout was created using the freeware version of Eagle, following this useful guide. It would have been nice to spaced things out a little more, but I chose to constrain the board to a standard size so that the the shield would not dwarf the Arduino underneath.
This project implements different temperature sensors: the digital DS18B20, and an analogue thermistor. These options limit the maximum temperature to 125°C or so, but don't despair if you need to measure higher temperatures. It's easy to interface a K-type thermocouple using a MAX31855 breakout board.
To keep things simple, all the materials (apart from the Arduino itself) can all be sourced from Tayda. I have never been let down by the quality of Tayda components, despite their low prices, and shipping is quick and cheap from a location in the USA.
The PID shield was developed and tested using an Arduino Uno R3. It should work on other 5 V boards with the standard dimensions. The firmware requires at least 32 kB of flash memory and was developed for the Arduino Uno. It does not fit on the Leonardo due to its larger bootloader. Low voltage models like the Arduino Due will need a 3.3V display and lower values for resistors R1, R2, and R8. The PID controller shield will have to be adapted considerably to work with small-format Arduinos such as the Nano or Pro Mini 328.
Build
- Clean the stripboard with isopropyl alcohol to remove grease and tarnish. Orient the board with one long side to the front and the copper tracks on the top. Cut tracks in the positions shown on the diagram below using a 1/8" drill bit or craft knife. It's a good idea to check with the continuity tester setting on your multimeter. Check the locations carefully — I made a couple of extra holes by mistake which I had to correct later on by bridging the holes with the cut-off leg from a LED.
- Now flip the stripboard over the long axis. The short edges on the left and right should stay on the same side, but what was the front edge should now be at the back and the copper tracks should now be on the bottom. Prepare the male headers by cutting lengths from the strip: one each with 8, 6, and 4 pins. For each male header, press down using needle-nose pliers to slide to the pins to the end of the plastic retainer. Put the headers in the positions marked "M" below, with the plastic part flush with the top of the board, and solder the pins to the copper strips on the reverse. Then cut the female pin headers, two with 6 holes and two with 3 holes, and solder them in the positions marked "F" below. A good trick for lining up the female headers straight is to fix them to a male header strip. Make doubly sure the headers are in the right place. Once all the pins are soldered they are devilishly difficult to remove.
- Cut wire jumpers to size and solder in place. Solid core wire is preferable for stripboard because it is easier to poke through the holes, and the corners can be bent nicely so it lies flat: flat nose jewelry pliers are useful for this. It is helpful to colour code the wires. I suggest using black wire for anything connecting the GND, red wire for connecting to 5V, and yellow or white wire for everything else. Use flush cutters to trim the wires after soldering.
- Solder the axial resistors in place. This should be easy after the practice you have had soldering the jumpers! The resistor values are: R1, R2, R4, R7: 1 KΩ. R3: 10 KΩ. R5, R8: 330 Ω. R6: 470 Ω.
- Solder in the larger components. Be sure to orient the symmetrical components correctly. Make sure the positive and negative terminals of the LEDs and buzzer are in the correct holes, and that the transistor is facing the right way. The terminal blocks should have the screw clamps facing outward.
- Now make the temperature probes. Solder red and black stranded wires to the thermistor pins. (These can be twisted if desired to reduce noise on the input). Solder red, black, and yellow stranded wires to the DS18B20 VDD, GND, and DATA pins, respectively. Insert the chosen temperature probe into the appropriate terminals of the 3-position input terminal block. The thermistor goes between VDD and DATA, forming a voltage divider with a 10 KΩ 1% resistor whose legs are clamped in DATA and GND. (Select the reference resistor that measures 10 KΩ most exactly on your multimeter.) Alternatively, connect all 3 wires from the DS18B20 to the appropriate terminals, and a 4.7 KΩ resistor between DATA and VDD acting as a pull-up on the DATA line. It's a good idea to insulate the legs of the probe with heat shrink or electrical tape. And if the temperature probe is going to go somewhere wet, it is probably advisable to put it in some kind of thermowell. For a visual indication of the output, we can clamp the legs of a LED in the terminals of the 2-way output block.
- Check the board over one last time, then clean off any residual flux. Label the switches. Fit the LCD display into the female headers. Stuff a decoupling capacitor between AREF and GND on the Arduino — something around 0.1 μF helps reduce noise on the ADC, which is used to measure the resistance of the thermistor, as well as reading the pushbuttons. Finally, mount the shield to your Arduino. The hardware is complete. The next step is to upload the firmware to the Arduino and test out your new PID controller.
Materials
For ease of ordering, all these components are sourced from Tayda. To make sure you get the exact components that are specified, please order through the clickable links on the Taydakits page.
- 93x53mm stripboard (copper)
- 16x2 character LCD display with blue backlight
- PCB mount piezoelectric buzzer
- 4 x tactile switch
- DS18B20 digital temperature sensor
- 10 KΩ NTC thermistor
- screw terminal block 5mm pitch, 3 positions
- screw terminal block 5mm pitch, 2 positions
- 0.1" pitch male pin header strip
- 0.1" pitch female pin header strip
- 2N3904 transistor
- 10 KΩ trimpot
- 2x 5mm red LED
- 5mm yellow LED
- 10 x 10 KΩ resistor 1%
- 10 x 330 Ω resistor 5%
- 10 x 470 Ω resistor 5%
- 10 x 1 KΩ resistor 5%
- 10 x 4.7 KΩ resistor 5%
- 10 x 0.1 uF ceramic capacitor
- 1' black 22 AWG solid hook-up wire
- 1' red 22 AWG solid hook-up wire
- 1' yellow 22 AWG solid hook-up wire
- 6' red 22 AWG stranded hook-up wire
- 6' black 22 AWG stranded hook-up wire
- 3' yellow 22 AWG stranded hook-up wire
Recommended Tools
Soldering is much easier with a temperature controlled soldering station. For safety reasons, I recommend using lead free solder.
Resources
- Github repository containing schematics, parts list, and other documentation
- osPID resources
4 comments:
would it be possible to get these pics showing the grid for placement of parts please.
Great share thanks for writing this
nice
Your post is very nice. useful information. Thanks for sharing.
How Many Pennies Are In A Roll
Post a Comment