Showing posts with label IOT. Show all posts
Showing posts with label IOT. Show all posts

Monday, 18 April 2016

Arduino-PID-Library online Trainer

PID seems to be a rather magical thing. I ported the Arduino-PID-Library to javascript so you can play with the constants in a simulator and and see the results immediately. Hopefully this will make people less scared about the tuning process.

In this simulator, you are Lara Croft driving a car. Using the sliders below you have to choose Kp, Ki and Kd to follow the green line as closely as possible, that is without overshooting or oscillating (so, not like now).

This PID controls the accelerator/decelerator of a car. There is some drag and the vehicle has a certain mass.

The X axis is time and the Y axis is the position of the car. Make sure she is at the right position at the right time

Can you help her? Good luck!



Position:

PID's output (accelerator):




Notes:


  • The car is simulated by using the following equations:
    • x(t) = v*t + 0.5*a*t^2
    • v(t) = a*t
  • The PID code is based in the Arduino PID Library by Brett Beauregard.

Lessons learnt:


There are 2 types of processes.
  • Processes that keep their last state (like in the level 1, a car on a flat road). These are called integrating processes, they don't need a Ki and the PID won't overshoot
  • Processes that feel an external force (car on a slope, something cooling down). These are called self regulating processes, they do need a Ki and they will overshoot when the external force changes

Credits go to Brett Beauregard for his excellent library and his great explanations in the diy-pid-control forum

Saturday, 20 February 2016

Monitor your fridge temperature

Ever wondered how efficient your fridge is?

Mine with a set point of 9 degrees needs to cool for 45 minutes(compressor on) and seems to keep the cold for another 45 minutes(compressor off). The temperature seems to oscillate ±1.5 degrees as you see in the pic.


I wonder how well other people's fridges perform. Should I change it? I wish everyone was posting their data! 


Here is a picture of my setup:


I am using a ESP8266 connected to an LM75 sensor. I am using a 5000mAh 3.7V battery connected through a step down voltage regulator to get 3.3V.

The device has been running for 37 hours thanks to using deep sleep. Every minute the ESP8266 was waking up, measuring the temperature, sending it to a server and then back to sleep. 

The consumption per wake up is: 5000mAh/37h/60 = 2.25mA

Just for laughs I'm going to elaborate on this server, it is just an old 'HTC Desire S' cellphone that is running Debian linux. This cellphone is now my cloud and it is running 24/7, it has installed PHP, nginx, mysql, samba, minidlna, ssh, avahi, and OpenVPN so I can connect remotely and have full access to everything. 

In order the deep sleep function I had to connect the XPD_DCDC with the reset pin, if you zoom into the ESP8266 you'll see the dirty hack (credits go to http://tim.jagenberg.info/2015/01/18/low-power-esp8266/ for the idea)



I find rather interesting what happened when the battery was running out of juice. The ESP seemed to work properly but the LM75 sensor was becoming more and more noisy


One would expect that the ESP would be the first one to notice the lack of power! The time stamps are generated in the server so this seems to imply that the ESP was doing its job at the right intervals.

If people show enough interest I will tidy up the code and upload it to github.