This is a multi-function PID controller designed to be a drop-in module for use in larger projects. It is compatible with the Arduino Nano footprint and may be used as a shield or as a standalone module. The Micro-PID is compatible with various sensors, including analog and digital sensors for position, speed, and temperature. Control is accomplished using an ATTiny 1614, using its internal ADC and DAC, with a buffered output. The intention of this device is to easily add PID control to a project. I will likely include accessory boards in the future for driving larger loads, motors, and more.
- Complete Simulations of Output Stage
- Test Power Supply
- Finish Prototype with MCU
- Write PID loop software
- V0.1 of PID Library Uploaded
- Add mode selection for PID, PI, P controller types.
- Write interface library for display, buttons, encoders etc.
It has been a bit longer than I wanted between project logs, but I have managed to make some progress, while learning some important lessons. Upon trying to program the ATtiny 1614, I realized that the old ICSP programming method was not going to work. The ATtiny 1614 is a tinyAVR-1 series MCU. This means that they use a new proprietary method called UPDI. It is nice because it uses fewer pins, but I did not own a programmer for UPDI, and was not going to pay for an expensive Atmel ICE programmer.
Instead of buying a programmer, I made one using an Arduino Nano clone using jtag2UPDI, a piece of firmware that essentially turns an Arduino Uno, or any ATMega 328 MCU into a UPDI programmer. It was pretty simple to set up, both software and hardware.
As seen above, the breadboard layout is pretty simple. I connected D6 on the Nano to Pin 10 on the ATtiny 1614 through a 4.7 KΩ resistor. Then I connected VCC and Ground on pins 1 and 14 on the ATtiny 1614 respectively to +5v and GND on the Arduino. Last, I added a decoupling capacitor (0.22uF), and a 120Ω between RST and +5v to disable the reset. I followed the setup instructions to load the jtag2UPDI firmware, and was ready to program. I might post a tutorial on this later, to take you though all of the steps in detail. There is a schematic view of this below.
For uploading code, I opted to use the megaTinyCore for speeding up development by allowing me to use Arduino code to write the programs. This greatly simplifies things, as the documentation for the ATtiny 1614 is a bit hard to understand, and most importantly, rather disorganized at the moment.
Here is the setup that I am currently using for programming. I had it soldered to perfboard initially, but messed up, and haven't had time to fix it yet, so it remains on the breadboard for now.
So far, I have been learning how to work with the ATtiny 1614, I have so far been able to program via Arduino, as well as Atmel Studio, and am just working on basic tasks. I have GPIO working, and with some mild frustration, have the DAC working as well. I was able to get the DAC to generate the waveform seen below. Seen here at (1V/DIV) at a frequency of about 2.13 kHz.
I hope this update was not too long, but it contained a lot of information. I can now focus more on the program side of things, now that I have some working hardware. As always, feel free to comment if you have any questions, comments, or suggestions.
Hey everyone, a lot has happened since I released my last project log. I have completely redesigned the board, and have shifted the scope of this project somewhat. The new design will be compatible with Arduino Nano, and can either be utilized as a shield, or as a standalone drop-in module. The reason, I redesigned with Arduino compatibility is to give users an easy way to interface with the module, and to allow for easier project integration.
As for software, the μPID will communicate with Arduino, or other interfaces with SPI. The microcontroller itself will be running Arduino-based software, which will be programmed using the megaTinyCore bootloader. I have also included options to switch between PWM and Analog outputs, as well as included programmable high and low alarm pins.
You will also soon be able to follow my projects, as well as tutorials, and subject guides on a new website I have been working on: setpointlabs.com. I have a couple of items published, with more soon to follow. However, my hackaday.io page will be the best way to stay up to date with my projects.
As always, feel free to comment and share your thoughts and suggestions.
Hey everyone. After a frustrating day, I have finally been able to get the ATtiny 817 Xplained to program, however, I am having problems getting the DAC to work. In the mean time, while I try to get the DAC figured out, I implemented a PID algorithim in Arduino. I am taking measurements from a GY-521 IMU/Temperature Sensor, and outputting to PWM. At the moment, I do not really have a system to control, so I have just been changing the temperature with my finger, to warm the sensor up, and blasting it with an upside-down can of electronics duster to cool it down.
I should have an actual system to control soon, and will hopefully be able to use the Xplained board.
In this image, the blue line is the measured variable (PV), and the red is the PWM value (CV). As always, if anyone has any questions, suggestions or critique, please feel free to comment.
Hey everyone, I finally have some hardware to start testing things on. I am using the ATtiny817 Xplained Mini evaluation board from Microchip. The ATtiny 817 has the same architecture and assembly language as the ATtiny 1617, just with 24 pins, instead of 14. This board has included programming, debugging, and a serial com port over micro USB.
I am hoping that this evaluation board will allow me to implement the system on it, before being uploaded to the Micro PID controller. You can check out the board here. As soon as I can get Atmel Studio to behave, I will try implementing a PID loop on the board.
In my previous project log, we discussed what a PID controller is, and the basics of how the project works. In this post, we will look at how to implement a PID controller in a microcontroller. In order to use the PID equation in a digital environment, we first must make a discrete-time model.
We will first look at the integral operator.
This is saying that the integral is equal to the sum of all previous error with respect to a sampling time.
Next, we will look at the derivative operator.
Using an approximation method known as backwards finite differences, the derivative can be approximated as the current error minus the previous error divided by the sampling time.
But how do we implement this in code? This algorithm is surprisingly simple, as can be seen below:
Hey everyone, I have decided to give a more detailed rundown of my project, and some underlying theory.
The goal of this project is to create a PID temperature controller module for use in other projects. This board contains a sensor interface, control processor, and output interface. There are no physical user interfaces on this board, however control via serial, as well as options to interface with displays and buttons for programming will be available.
It attempts to rectify the difference between the user's desired value (the setpoint) and a measured value (the process variable) by applying a correlation based on Proportional, Integral, and Derivative values (this is where the term, PID comes from). The PID controller can be modeled by the following equation: