Arduino for Radon Measurement System

advertisement
Arduino Programming
for
Radon Measurement System
By:
Mazhar Hussain
Muhammad Amir Yousaf
mazhar.hussain @miun.se
amir.yousaf@miun.se
mazhar.hussain@miun.se
amir.yousaf@miun.se
2011-11-02
1
Outline
 Background
 Introduction to Arduino
 What is Arduino Platform?
 What can it do?




Arduino Hardware
Development Environment
Programming Arduino
Objectives
 Live Demonstration
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
2
Background
Measurement system for Radon.
Ventilation
reset
Charge
Sensitive
Amplifier
Particle Sensor
Shaping
Amplifier
Amplitude
Measurement
Detector-bias
200V
U-controller
Presentation
Storage of data
Temp. Moisture
Make alarm in
critical situations
http://apachepersonal.miun.se/~go
rthu/ass/
amir.yousaf@miun.se
mazhar.hussain@miun.se
Present on my
Computer
2011-11-02
3
Programming Background
Read datasheets
Microcontroller
Do you have experience with Microcontroller
programming with C
/ C++ ?
DDRB =
(1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0);
Programming at
register level
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
4
What is Arduino Platform?
•
Arduino is an open-source electronics prototyping platform based on flexible, easy-touse hardware and software. It brings simplicity to developer.
–
Simplicity in Hardware, Development Environment and Language.
•
It can sense the environment by receiving input from a variety of sensors and can affect
its surroundings by controlling lights, motors, and other actuators.
•
Arduino projects can be stand-alone or linked with software running on computers.
Arduino
UNO
Arduino
MEGA
Arduino
NANO
http://www.arduino.cc/
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
5
What can it do?
Smell Pollutants:
Arduino interfaced with gas sensors. It can smell
ethanol, methane and a bunch of voilatile organic
compounds.
http://www.instructables.com/id/How-To-SmellPollutants/
Mini Segway Using the Arduino:
A self balancing segway-like robot is build by using
arduino, a couple of LEGO motors and sensors.
http://hacknmod.com/hack/make-a-mini-segway-usingthe-arduino/
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
6
Arduino NANO Hardware
Specifications:
•
Based on Atmega 328
•
Operating Voltage 5V
•
32 KB Flash Memory
•
2 KB SRAM
•
16 MHz clock speed
•
Dimensions 0.73" x 1.70"
http://www.arduino.cc/en/Main/A
rduinoBoardNano
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
7
Arduino NANO Hardware
Arduino Peripherals
•
•
•
•
•
•
•
14 Digital I/O Pins
8 Analog Input Pins
External Interrupts (on
D2 and D3)
PWM (D3, 5, 6, 9, 10,
and 11)
Serial port & FTDI
USART to USB
converter.
SPI, I2C
Buttons and LEDs
http://www.arduino.cc/en/Main/A
rduinoBoardNano
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
8
Development Environment
•
Download from:
http://www.arduino.cc
/en/Main/software
•
Double click the file
from the folder to
open IDE.
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
9
Development Environment
Install USB driver
System Properties  Hardware  Device Manager  Ports
http://arduino.cc/en/Guide/Arduin
oNano
Mini-B USB
Your computer
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
10
Development Environment
Steps to Program
1a
1
1. Configure
3
2. Write Program
4
3. Compile Program
4. Upload and Execute
2:Write program
here.
amir.yousaf@miun.se
mazhar.hussain@miun.se
1b
2011-11-02
11
Programming Arduino
•
Open example program:
File  Examples  Basics
 Blink
• Arduino Sketch
o Setup()
Initialization (run once at
beginning )
o Loop()
Run repeatedly
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
12
Programming Arduino
•
No need to write Hardware Abstraction Library (HAL) for accessing microcontroller‟s
peripherals. That make it extremely simpler to program in Arduino.
•
All peripherals are in access with provided libraries e.g.
To configure pin as output or input:
pinMode()
To set a digital pin high/low:
digitalWrite()
To read a digital pin‟s state:
digitalRead()
To read an analog pin:
analogRead()
To write an “analog” PWM value:
analogWrite()
Wait an amount of time
delay()
•
Complete library references:
http://arduino.cc/en/Reference/HomePage
http://www.arduino.cc/playground/Code/HardwareAbstraction
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
13
Programming Arduino
• Arduino Refernce Homepage
http://arduino.cc/en/Reference/Home
Page
has every thing you need to create a
program from scratch.
http://arduino.cc/en/Reference/Ho
mePage
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
14
Programming Arduino
• Creating a program to write message on serial port.
–
–
–
–
Visit „Arduino Refernce Homepage‟.
Click over „Serial‟ link and find a list of functions as shown.
Use function to implement your requirement.
Clicking over the function name gives the details with examples.
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
15
Programming Arduino
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
16
Objectives
Measurement system for Radon.
reset
Particle Sensor
Charge
Sensitive
Amplifier
Shaping
Amplifier
Amplitude
Measurement
Detector-bias
200V
U-controller
Presentation
Storage of data
Temp. Moisture
http://apachepersonal.miun.se/~go
rthu/ass/
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
17
Objectives
Reset
Measurement system for Radon.
ADC
read
reset
Amplitude
Measurement
amir.yousaf@miun.se
U-controller
mazhar.hussain@miun.se
2011-11-02
18
Objectives
Measurement system for Radon.
DHT11 is a temperature
and Humidity Sensor
with single data line.
Community
Contributions
U-controller
A DHT11 Class for Arduino.
http://arduino.cc/playground/Main/D
HT11Lib
Temp. Moisture
int chk = DHT11.read(DHT11PIN);
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
19
Live Demonstration
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
20
Data Storage and Presentation(1)
•
U-controller
Presentation
Storage of data
•
•
Temp. Moisture
•
•
amir.yousaf@miun.se
mazhar.hussain@miun.se
For representing data in an intuitive way,
LabView provide a powerful user interface
along with its Microsoft Office toolkit for Data
storage.
Through LabView you can control Ardiuno
based Radon Measurement device via serial
link.
Post processing could be done in LabView to
avoid long code inside Processor.
Report generation in Excel..
Go to HELP in LabView and have a look on
“Find Examples”….
2011-11-02
21
Data Storage and Presentation(2)
amir.yousaf@miun.se
mazhar.hussain@miun.se
2011-11-02
22
Data Storage and Presentation(3)
•
amir.yousaf@miun.se
mazhar.hussain@miun.se
By using MS office toolkit in
LabView, you can generate detail
report of your measurements
including tables and graphs.
2011-11-02
23
Download