Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using...

19
1 Using Arduinos to Teach Engineering Concepts Andrew G. Bell October 27, 2016

Transcript of Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using...

Page 1: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

1

Using Arduinos to Teach Engineering Concepts

Andrew G. Bell

October 27, 2016

Page 2: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

2

Ivy Tech Community College is Indiana’s largest public postsecondary institution and the nation’s largest singly accredited statewide community college system. 

Background

We offer Associates of Science degrees in:

Electrical Engineering TechnologyMechanical Engineering TechnologyEngineering TechnologyPre‐ EngineeringNanotechnologyDesign Technology

over 40 degree programs

2

Page 3: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

3

Arduino is a inexpensive Microcontroller CCA that interface to your PC via USB

They typically cost ~ 20 to 25 and are available many places online

Software to program them is free, open source. https://www.arduino.cc/

Arduino Uno (and other models) have daughter boards call “shields” that you can stack

Shields include Motor Drives, Prototype boards, Displays, etc.

Arduino microcontrollers have become very popular with hobbyist, students and colleges. 

What is an Arduino?

http://www.jameco.com/https://www.adafruit.com/http://www.elexp.com

3

Page 4: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

4

What is an Arduino?

Specification

Microcontroller  ATmega328P 

Operating Voltage 5V

Input Voltage  7‐12V

Digital I/O Pins  14

Analog Input Pins 6

Flash Memory 32 KB

SRAM 2 KB 

EEPROM 1 KB 

Clock Speed  16 MHz 

PC Interface USB

https://www.arduino.cc/en/Main/ArduinoBoardUno

Arduino Uno

Prototype Shield

4

Page 5: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

5

Our Approach - Using Arduino & LabView for Teaching MEMS Devices

1.) Give students general idea and requirements for design2.) Provide students with resources to design, build and test3.) Provide feedback as needed but don’t micromanage4.) Allow students time to learn, fail and succeed5.) Provide positive feedback and recognition6.) Step back and let them learn …

5

Page 6: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

6

Our Results - Using Arduino & LabView for Teaching MEMS Devices

Multisim schematic Utliboard PWB

6

Page 7: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

7

SCME Pressure Sensor KitIncludes – Arduino Uno based DAK interface module, instruction manual, Executable LabView Data acquisition software, USB cable, and pressuresensor interface cable.

Arduinos are key to our program

7

Page 8: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

8

SCME Cantilever KitIncludes ‐ Arduino Uno based DAK interface module,  instruction manual, executable LabView Data acquisition software,  USB cable, and Cantilever beam Strain gauge interface – Discovered “How to make a Strain Gauge”

Strain Gauge with Custom Shield and Arduino

8

Page 9: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

9

Using Arduino to position Solar Panel - Global

9

Page 10: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

10

Using Arduino to position Solar Panel

10

https://www.youtube.com/watch?v=ibURmCctnWk

Page 11: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

11

• Ultrasonic Sensor (Adam Beauchot)• Photo Diode (Adam Beauchot)• LCD Examples (Ryan Noyes)• Two direction Solar Tracker (Ryan Noyes)

Student Work

11

Page 12: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

12

This project used two sensors together, a light sensing diode and a range finding sonic eye.  The objective was to get the sonic eye to determine the range of an object and or determine if their was movement in a room only at night time, similar to a type of burglar alarm.

Arduino Project 1 and 2

12

Page 13: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

13

Arduino Project 1 and 2

13

https://www.youtube.com/watch?v=aQlpAhh8WyI

Page 14: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

14

Arduino Project 3

// include the library code:#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {// set up the LCD's number of columns and rows:lcd.begin(16, 2);// Print a message to the LCD.lcd.print("hello, world!");}

void loop() {// set the cursor to column 0, line 1// (note: line 1 is the second row, since counting begins with 0):lcd.setCursor(0, 1);// print the number of seconds since reset:lcd.print(millis() / 1000);}

14

Page 15: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

15

6VDC

To Servos

HV

Vertical Servo

Horizontal Servo

Arduino Project 4

15

Page 16: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

16

Arduino Project 4

16

https://www.youtube.com/watch?v=baPeL3r8GSg

Page 17: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

17

The future

Andy BellDepartment Chair – EngineeringIvy Tech Community College – NortheastPhone: 260-481-2288 : Fax: 260-480-2052 : [email protected] Technology Center, Room TC1240R, 3800 N. Anthony Blvd.,Fort Wayne, IN 46805

17

https://www.youtube.com/watch?v=0nQ‐1o1mHpI

Page 18: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

18

const int pingPin = 7;int sensePin = 0;int ledPin = 9;int lastDist = 0;int currentDist = 0;

int thresh = 200;

void setup() {// initialize serial communication:Serial.begin(9600);pinMode(ledPin, OUTPUT);}

void loop(){// establish variables for duration of the ping,// and the distance result in inches and centimeters:long duration, inches, cm;

// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:pinMode(pingPin, OUTPUT);digitalWrite(pingPin, LOW);delayMicroseconds(2);digitalWrite(pingPin, HIGH);delayMicroseconds(5);digitalWrite(pingPin, LOW);

// The same pin is used to read the signal from the PING))): a HIGH// pulse whose duration is the time (in microseconds) from the sending// of the ping to the reception of its echo off of an object.pinMode(pingPin, INPUT);duration = pulseIn(pingPin, HIGH);

// convert the time into a distanceinches = microsecondsToInches(duration);cm = microsecondsToCentimeters(duration);

Serial.print(inches);Serial.print("in, ");Serial.print(cm);Serial.print("cm");Serial.println();

delay(100);int val = analogRead(sensePin);

if (inches >9 && val < 700){digitalWrite(ledPin, HIGH);delay(900);digitalWrite(ledPin, LOW);}else if (inches >3 && inches <=9 && val <700){digitalWrite(ledPin, HIGH);delay(300);digitalWrite(ledPin, LOW);}else if (inches >0 && inches <=3 && val <700){digitalWrite(ledPin, HIGH);delay(100);digitalWrite(ledPin, LOW);}

else{digitalWrite(ledPin, LOW);

}}long microsecondsToInches(long microseconds){// According to Parallax's datasheet for the PING))), there are// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per// second).  This gives the distance travelled by the ping, outbound// and return, so we divide by 2 to get the distance of the obstacle.// See: http://www.parallax.com/dl/docs/prod/acc/28015‐PING‐v1.3.pdfreturn microseconds / 74 / 2;}long microsecondsToCentimeters(long microseconds){// The speed of sound is 340 m/s or 29 microseconds per centimeter.// The ping travels out and back, so to find the distance of the// object we take half of the distance travelled.return microseconds / 29 / 2;}

This is the code required for the Arduino to control the Light sensing diode and the sonic eye in conjunction with one another.

Arduino Project 1 and 2

18

Page 19: Using Arduinos to Teach Engineering Concepts Revfaculty.ivytech.edu/~abell118/files/Using Arduinos...Our Approach -Using Arduino & LabView for Teaching MEMS Devices 1.) ... // The

19

#include <Servo.h>

Servo horizontalServo; Servo verticalServo;int posh = 10;    // variable to store the horizontal servo positionint posv = 10;   // variable to store vertical servo position

#define OFFlight 13

void setup() {pinMode(OFFlight,OUTPUT);

horizontalServo.attach(9);   // attaches the servo on pin 10 to the servo objectverticalServo.attach(10);Serial.begin(9600); // initialize serial communication at 9600 bits per second: 

horizontalServo.write(10); verticalServo.write(10); }

void loop() {

int topLeft = analogRead(A5);int topRight = analogRead(A4); int botRight = analogRead(A3);

int botLeft = analogRead(A2); 

int resetButton = analogRead(A1); 

// Convert the analog reading (which goes from 0 ‐ 1023) to a voltage (0 ‐ 5V):float VtopLeft  = topLeft  * (5.0 / 1023.0);float VtopRight = topRight * (5.0 / 1023.0); float VbotLeft = botLeft * (5.0 / 1023.0); float VbotRight = botRight * (5.0 / 1023.0); 

Serial.println(botRight); 

// ‐ IS CLOCKWISE // + IS COUNTERCLOCKWISE 

// horizontal Servo 

////////////////////////////////   BOTTOM SENSORS ‐ HORIZONTALif (botRight > botLeft ) {posh = posh + 1;if(posh >= 179){posh = 179; }// if

horizontalServo.write(posh); delay (300); 

}// if 

if ( botLeft > botRight) {posh = posh ‐1; if(posh <= 0){posh = 0; }// ifhorizontalServo.write(posh); delay ( 300); }

/////////////////////////////// TOP SENSORS ‐ HORIZONTAL if (topRight > topLeft ) {posh = posh + 1;if(posh >= 179){posh = 179; }// if

horizontalServo.write(posh); delay (300); 

}// if 

if ( topLeft > topRight) {posh = posh ‐1; if(posh <= 0){posh = 0; }// ifhorizontalServo.write(posh); delay ( 300); }

/////////////////////////////// LEFT SENSORS ‐ VERTICAL if (topLeft > botLeft ) {

posv = posv + 1;if(posv >= 179){posv = 179; }// if

verticalServo.write(posv); delay (300); 

}// if 

if ( botLeft > topLeft) {posv = posv ‐1; if(posv <= 0){posv = 0; }// ifverticalServo.write(posv); delay ( 300); }// if

///////////////////////////////// RIGHT SENSORS ‐ VERTICAL if (topRight > botRight ) {posv = posv + 1;if(posv >= 179){posv = 179; }// if

verticalServo.write(posv); delay (300); 

}// if 

if ( botRight > topRight) {posv = posv ‐ 1; if(posv <= 0){posv = 0; }// ifverticalServo.write(posv); 

delay ( 300); }// if

if(resetButton >= 900 ) {horizontalServo.write(10);posh = 10;  verticalServo.write(10);posv = 10;digitalWrite(OFFlight,HIGH); delay (500);digitalWrite(OFFlight,LOW); delay ( 500); digitalWrite(OFFlight,HIGH); delay (500);digitalWrite(OFFlight,LOW); delay ( 500); digitalWrite(OFFlight,HIGH); 

delay (500);digitalWrite(OFFlight,LOW); delay ( 500); digitalWrite(OFFlight,HIGH); delay (500);digitalWrite(OFFlight,LOW); delay ( 500); 

delay (3000); }

} // void loop

Arduino Project 4

19