+ All Categories
Home > Documents > BFY-2012 Wkshp Robinson

BFY-2012 Wkshp Robinson

Date post: 03-Apr-2018
Category:
Upload: uma-mageshwari
View: 221 times
Download: 0 times
Share this document with a friend

of 13

Transcript
  • 7/28/2019 BFY-2012 Wkshp Robinson

    1/13

    Arduino: PID-controlled thermostat

    or, how to do things with Arduino without everbecoming an expert

    Sean P. [email protected]

    Massachusetts Institute of TechnologyDepartment of Physics

    BFY 2012 Workshop July 26, 2012

    1 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    2/13

    Outline

    1 Introductions (You, Me, and Arduino)

    2 Microcontrollers, microcontroller projects,and how they can help you run your physicsteaching lab

    3 How to make a project

    4 An Exercise, if we have time(or Homework if we dont)

    2 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    3/13

    What we did, and why we did it

    WHAT: We used an Arduino microcontroller tobuild a fancy thermostat.

    Several experiments use heating ovens with temperature control bysetting variac voltage supply to a resistive heating element.

    Requires trial and error to establish voltage-temperature relationSlow to stabilize (10s of minutes) trial and error is tedious!!

    Use a thermostat (negative feedback towards set point) instead!

    This exercise: lets add challenge by using the PID control algorithminstead of simple (threshold model) thermostat.

    WHY: we were looking for a simple project to

    practice using Arduino in a full buildEveryones doing it! (Large user community, including local friends.)Inexpensive (open source). Hardware $2530, software free.

    They say its easy. (Much of the user community is nontechnical.)

    Street cred with the cool kids.

    3 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    4/13

    xkcd.com/730/

    4 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    5/13

    Microcontrollers: What are they?

    DefinitionMicrocontroller: a small computer, often consisting of a single boardrunning whatever program has been uploaded to it, whose inputs andoutputs are analog and/or digital voltage ports. (Usually includes apower input and some kind of serial connection for receiving uploadedprograms from some other computer.)

    Can be used like a data acquisition device (eg LabJack orNI-DAQ), for low resolution (10-bit 5 mV resolution) and lowbandwidth (250 samples/sec, or up to 1050 kHz with tricks).

    Can be used as part of a feedback/control system between inputsand outputs.

    Can be used as a programmable voltage source.

    . . . and more!

    Examples include BASIC Stamp, Arduino, Cypress (kind of) and others.

    5 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    6/13

    Why Arduino?

    Arduino is a relatively new but massively popular player amongmicrocontrollers.

    Open Source: an appealing moral sthetic like Linux, Firefox,etc

    low cost! And, ample resources on the web.

    Popular among artists and the DIY/maker crowd so, you dont need a degree in CS/EE to use Arduino. and, theres a huge online menu of project ideas and problemsolutions. . . . and that includes a lot of my students.

    Extendable hardware: daughter boards (called shields) extend thehardware capability, just like software libraries extend the software.

    6 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    7/13

    What does a working project with amicrocontroller look like?

    Well, look at what we have here. . .

    This is a feedback-controlled piece of lab equipment. Ingredients:

    an Arduino Uno ($26) for overall control

    a TC4 shield ($30, surface mount components already soldered) for

    better resolution in reading thermocouple. Developed and sold bygourmet coffee roasting hobbyists, homeroasters.org(http://code.google.com/p/tc4-shield/)

    solid state relay ($22) to switch power on and off

    LCD display ($6) so we can see what were doing

    a 12V DC power supply, a type-T thermocouple, bits of wire, aknob, some power cord, and other minor bits from around the lab

    an aluminum box and a plastic cover from around the lab

    the equipment to be controlled

    7 / 13

    http://localhost/var/www/apps/conversion/tmp/scratch_3/homeroasters.orghttp://code.google.com/p/tc4-shield/http://code.google.com/p/tc4-shield/http://localhost/var/www/apps/conversion/tmp/scratch_3/homeroasters.org
  • 7/28/2019 BFY-2012 Wkshp Robinson

    8/13

    How to start a projectAssuming you have an idea of something to build . . .

    Get Arduino software

    (free) and hardware (cheap)Download the Arduino IDEdevelopment environment:arduino.cc/en/Main/Software

    Buy Arduino hardware. Manysuppliers, but we like these guys:www.adafruit.com/category/17

    Dont get confused by the varieties ofArduino boards. Unless your project is

    high-performance, you probably want theArduino Uno.

    Check out tutorials!!Getting Started with

    Arduino is what it sounds like:arduino.cc/en/Guide/

    HomePage

    Lady Adas tutorial is the best:www.ladyada.net/learn/

    arduino/

    Take a glance at the Arduinoplayground:arduino.cc/playground/

    projects/ideas

    Someone has probably done this before. . . or least parts of it. Break problem into constituent parts and then

    . . . to the INTERNET!8 / 13

    http://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Main/Softwarehttp://www.adafruit.com/category/17http://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Guide/HomePagehttp://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Guide/HomePagehttp://www.ladyada.net/learn/arduino/http://www.ladyada.net/learn/arduino/http://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/playground/projects/ideashttp://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/playground/projects/ideashttp://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/playground/projects/ideashttp://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/playground/projects/ideashttp://www.ladyada.net/learn/arduino/http://www.ladyada.net/learn/arduino/http://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Guide/HomePagehttp://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Guide/HomePagehttp://www.adafruit.com/category/17http://localhost/var/www/apps/conversion/tmp/scratch_3/arduino.cc/en/Main/Software
  • 7/28/2019 BFY-2012 Wkshp Robinson

    9/13

    The joy of open source

    Things to search forWhole projects

    Shields that extend hardware capability

    Software librariesCode examples

    Circuit diagrams

    Better ideas

    The Arduino programming language is basically C++, so programminghelp is also widely available on the internet and in your neighbors office.

    9 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    10/13

    Use other peoples code!Every Arduino program needs a function named void setup() andone named void loop().

    10 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    11/13

    About our temperature controllerproject: two goals

    1 An excuse to learn Arduino2 Build a cheap, useful temperature controller.

    The first goal outweighs the second, so we may make some odd choices.

    The PID control loop

    Image source: Wikipedia

    11 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    12/13

    Performance

    No regulation rapid overheating

    A poor choice of PID constants,(Kp, Ki,Kd) = (2, 1/1 ms, 1 ms).

    (Kp, Ki,Kd) =(2.5, 1/1.6 min, 4 min). Very stable,little overshoot, but 5C of droop.

    Tuning PID constants is difficult.

    Not every system is a goodcandidate for PID control.

    Our system happens to be one ofthem.

    12 / 13

  • 7/28/2019 BFY-2012 Wkshp Robinson

    13/13

    Lets think of a project . . .

    13 / 13


Recommended