• No results found

Programming with the Arduino: open-source hardware in an introductory programming laboratory. Paul Cruickshank

N/A
N/A
Protected

Academic year: 2021

Share "Programming with the Arduino: open-source hardware in an introductory programming laboratory. Paul Cruickshank"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

School of Physics & AstronomySchool of Physics & Astronomy

Programming with the

Arduino: open-source

hardware in an introductory

programming laboratory

Paul Cruickshank [email protected]

(2)

Motivation

Prior to 2013, no formal programming for St Andrews physics students until 3rd year

Earlier programming experience thought desirable

Aims to introduce 3 key concepts:

loops, decision making and functions Available time: 7.5 hours over three weeks

(3)

School of Physics & AstronomySchool of Physics & Astronomy

Context: computing in the St

Andrews physics degree

2nd year: some Python in modules taught by School of Maths

2nd year: 7.5 hours of C in Arduino lab (all physics/astrophysics students)

3rd year: Computational Physics module,10 credits, Mathematica (all physics/astrophysics students)

3rd year: Computational Astrophysics, 15 credits,

Fortran

3rd year: 15 hours of LabView as part of physics

(4)

The Arduino (UNO R3)

Atmel ATmega328 8-bit microcontroller, 16MHz

14 digital I/O pins

6 analogue input pins (10-bit)

5V supply via USB, 7-12V external, on-board 5V and 3.3V regulators

HUGE community of users

£21.66 inc VAT (Farnell)

(5)

School of Physics & AstronomySchool of Physics & Astronomy

The Arduino IDE

Java based, so platform agnostic*

Programs written in C/C++ Hardware functions

abstracted away from hardware pretty well Core function set pretty minimal, but easy to learn

(6)

The Arduino IDE

All Arduino programs MUST contain TWO functions,

called ‘setup’ and ‘loop’ When program compiled, IDE adds these and other code to generate a ‘proper’ C++ file, then compiles that

(7)

School of Physics & AstronomySchool of Physics & Astronomy

Why use Arduino?

Replaced part of an electronics

practical, so wanted to retain practical feel

Very easy to interface to

Built-in analogue to digital converter Digital input/output

Libraries and examples for most things you can think of (not always a good

(8)

Good things about the Arduino

Programmed in C/C++

Low barrier to entry (cost, availability, computer requirements)

Exercises have a good practical feel:

easy to write programs that interact with outside world

(9)

School of Physics & AstronomySchool of Physics & Astronomy

Less good things about the

Arduino

(Deliberately) not designed for teaching programming

Programmed in C/C++

Compiler error messages less than transparent

Development environment can be restrictive Occasional driver issues

No console (although serial monitor works out ok)

(10)

Development

Spring 2012: final-year student project devising trial script (Adam Hollan)

Single afternoon trial run with 9

volunteers from intended target group All student questions to demonstrators recorded

Spring 2013: final-year student project evaluating first live run (Duncan

(11)

School of Physics & AstronomySchool of Physics & Astronomy

Lab structure

Three 2.5 hr afternoon sessions

Before starting, students answer pre-lab questions based on content of lab script

(12)

Lab afternoon one

Introduction to environment Introduction to syntax

Analogue input: start with a potentiometer (dull but straightforward), on to thermistor, LDR and analogue accelerometer

(13)

School of Physics & AstronomySchool of Physics & Astronomy

Lab afternoon two

Analogue output (using external DAC, with pre-written library functions)

Decision making (i.e. if and if…else statements)

Introduction to flowcharts Loops: for and while

Resistive touchscreen sensor (with pre-written library functions)

(14)

Lab afternoon three

Write and use program to measure the IV characteristic of a diode

Develops the automation of an experiment students will already have done by hand

Designed to link in with previous work and make use of experience of first two

afternoons

Also shows utility of automation of measurement tasks

(15)

School of Physics & AstronomySchool of Physics & Astronomy

Lab supporting materials

Script entirely self-contained

Include text of sample programs so that students can read in advance

Extensively footnoted to point out

parallels and differences with standard C

(16)

Lab supporting materials

Try hard to separate programming aspect from electronics aspect Provide suggested

breadboard layouts for exercises: found some students get bogged down in assembling circuits, leaving less

time for the main point of the lab

(17)

School of Physics & AstronomySchool of Physics & Astronomy

Demonstrator training and

support

Demonstrators work independently through lab few weeks before start

Deliberate move to develop familiarity Also uncovers errors in script/libraries and ensures manageable load for lab time (7.5 hours)

Typically ~3.5hrs for no C/C++ prior experience

(18)

Demonstrator support

4 demonstrators for ~30 students

Demonstrators encouraged to be pro-active

More than half required no time outside scheduled periods

Of those who did, an hour was adequate

(19)

School of Physics & AstronomySchool of Physics & Astronomy

Approx. costs for 40 sets (inc.

VAT)

Arduino boards & cables: £880 Touchscreens: £330 Accelerometers: £330 PCBs: £400 Other components: £400

Most of these one-offs, less than £100 per year

(20)

Difficulties

Mark distribution is poor, and marks generally high (~80%)

Tension between teaching a skill and having to put a number on the end

result

Lab doesn’t discriminate amongst the most capable students effectively

(21)

School of Physics & AstronomySchool of Physics & Astronomy

Evaluation (2013)

Comprehensive questionnaire

Recruited volunteers to record audio of their lab experience along with their

written text, using LiveScribe pens Most surprising sources of difficulty

related to experimental technique rather than programming

(22)

Student reception (2013

evaluation)

Overall, pretty positive: they didn’t hate it, and no-one died

Asked students to respond to a series of questions or statements on a five-point Likert scale

(23)

School of Physics & AstronomySchool of Physics & Astronomy

Feedback

How difficult did you find this lab compared to other second year labs?

(N=79)

(24)

Feedback

How enjoyable did you find the Arduino lab? (N=79)

(25)

School of Physics & AstronomySchool of Physics & Astronomy

Feedback

This lab opened up a whole new area of physics to me

(N=77)

(26)

Feedback

Overall impression: (N=78)

(27)

School of Physics & AstronomySchool of Physics & Astronomy

Feedback

Overall impression: perceived gain from the lab

(N=78)

(28)

Example applications from

elsewhere

10 by 10 temperature sensor array Eric Ayars, California State

University, Chico

(Very instructive blog, http://hacks.ayars.org/)

used with permission

(29)

School of Physics & AstronomySchool of Physics & Astronomy

Example applications from

elsewhere

used with permission

Orthopaedic rehab studies using Arduino based data acquisition systems of

accelerometer and goniometer data

obtained from the knee Graham Brooker, AFCR, University of Sydney

(30)

Our plans for Arduino

From spring next year: take-home lab Give all students a box with necessary kit

Keep same amount of available contact time

If successful, consider adding extra content

(31)

School of Physics & AstronomySchool of Physics & Astronomy

References

Related documents

Monday 1st March 2021 LO:To Locate Europe on a world map and.. identify some of

If you have a good idea for the improvement of the OpenCIT project, please feel free to contact us on the developer mailing list. The guidelines for the development of the

Because the RF switch position is included in the presets, Specmaster is able to cycle automatically through multiple antennas and provide specific spectrum analyzer settings for

The study on physical support like connecting smartphone to personal virtual system on cloud and using computing resources unlimitedly is quite active, but the study

Passage, 2012, video stills, duration: 4:47, HD (16:9), stereo audio vimeo.com/janszewczyk/passage (portfolio)... Workshop, 2012, video stills, duration: 8:32, HD (16:9), stereo

To the extent permitted by relevant privacy laws, companies should also look to take advantage of external data sources to enhance their fraud detection and management

The three alternatives I will use in this file are called guilty but mentally ill, voluntary commitment, and involuntary commitment. I have discussed how the guilty but

Apart from some mild issue about viewing q as a parameter (not the case for the standard construction), this mainly consists of some observations about the spherical algebra