Close
0%
0%

Micro-PID Module

This is a small PID Temperature controller, designed to be a drop-in module on a parent board.

Public Chat
Similar projects worth following
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.

To Do

 [Hardware]

- Complete Simulations of Output Stage

- Test Power Supply

- Finish Prototype with MCU

[Software]

- 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.

Changelog:

[Misc]

- Fixed broken GitHub Link

- V 0.1 of PID Library on GitHub [10/21/1019]

-----------------------------------------------------------------------------------------------------------------------------------

Useful Links

http://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-DataSheet-DS40001995B.pdf

http://ww1.microchip.com/downloads/en/Appnotes/TB3210-Getting-Started-with-DAC-90003210A.pdf

http://ww1.microchip.com/downloads/en/Appnotes/TB3209-Getting-Started-with-ADC-90003209A.pdf

-----------------------------------------------------------------------------------------------------------------------------------

Source Code:

[GitHub]

https://github.com/ZTStrohm/micro-pid/

Adobe Portable Document Format - 68.79 kB - 10/17/2019 at 01:28

Preview
Download

  • 1 × ATtiny 1614 SS Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers, SOIC
  • 1 × TLV 2372 Rail to Rail Opamp, SOIC
  • 1 × I/O Connector 1x8 2.54mm Header
  • 1 × uA7805 Power Management ICs / Linear Voltage Regulators and LDOs, SOT 223
  • 1 × NTC Thermistor Temperature Sensor, Value TBD

View all 11 components

  • Project Log # 5: A Few Hard Lessons, But Progress In the End

    Zach Strohm10/29/2019 at 05:05 0 comments

    Hello everyone!

    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.

    Unfortunately, the DAC can only go up to 4.3 V, so I will have to include some sort of compensation if I want true 0-5V output.

    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.

  • Project Log #4: Major Update

    Zach Strohm10/16/2019 at 05:11 0 comments

    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.

  • Project Log # 3

    Zach Strohm10/01/2019 at 22:55 0 comments

    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.

  • Quick Update #1

    Zach Strohm09/30/2019 at 23:57 0 comments

    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.

  • Project Log #2

    Zach Strohm09/28/2019 at 15:43 0 comments

    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:

    previous_error = 0
    integral = 0
    loop:
        error = setpoint – measured_value
        integral = current_error + cumulative_error*dt
        derivative = (current_error-previous_error)/dt
        output = Kp + Ki*integral + Kd*derivative
        previous_error = error
        delay(dt)
        return to loop
    

    There will be more updates in the future. I should be getting some hardware to work on soon. As always, feel free to ask questions, and make suggestions.

  • Project Log #1

    Zach Strohm09/28/2019 at 04:07 0 comments

    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.

    So, what exactly is a PID controller?

    From Wikipedia:

    A PID controller is control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control.

    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:

    Read more »

View all 6 project logs

Enjoy this project?

Share

Discussions

Dan Maloney wrote 09/24/2019 at 15:43 point

I like the idea of plug-and-play PID. How will you provide for loop tuning? Directly on this board, or through whatever host you wire it into?

  Are you sure? yes | no

Zach Strohm wrote 09/25/2019 at 02:47 point

Tuning is intended to be provided primarily through the host. However, I plan on including tools for setting controller modes, parameter adjustment, and for tuning on the board itself via a serial connection to a PC.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates