Data Loading...

arduino robotics automation Flipbook PDF

arduino robotics automation


115 Views
71 Downloads
FLIP PDF 1.75MB

DOWNLOAD FLIP

REPORT DMCA

Robotics, Electronics and Automation using Arduino By Sanjin Dedić

Contents The Arduino microcontroller

2

Installing Arduino Software

3

How to connect the Arduino board to the computer

5

Safety considerations

6

Uploading your sketch (code) to the Arudino

7

Installing mBlock

8

Uploading Programs VS Controling Robot from IDE?

10

Connecting VIA USB, Bluetooth or 2.4G Wireless

13

mBot Online Resources

16

Arduino Fundamentals Course

17

Assessment Options with Arduino

18

Assessment Type 1: Students following Schematics and pre-produced code:

19

Assessment Type 2: Analysing Arduino Code

21

Assessment Type 3: General knowledge of Circuitry and Programming

23

Assessment Type 4: Arduino Based Projects:

27

Appendix 1: Equipment List

29

1

What is a microcontroller? A microcontroller is a programmable device that receives data from inputs in order to produce one or more outputs. A microcontroller is made up of small microchips that contain microscopic circuits called iintegrated circuits that can be programmed to carry out simple functions. Once programmed, there is no need to use a computer to operate them. Another name for a Microcontroller is a: P programmable L logic C controller (PLC)

How does it work? A microcontroller can only work if it has been programmed. The program (also called a sketch) is written on a computer in text editor. The program is then uploaded to the microcontroller chip via a USB cable connection. The microcontroller can then be disconnected from the computer and an alternate Power supply can be connected. This allows the microcontroller to be an Independent control technology system.

The Arduino microcontroller Arduino is a company that develops microcontrollers and the software required to program them (www.arduino.cc). During this unit you will be using Arduino software and a compatible microcontroller board to create your own control technology. Look at your microcontroller and discuss as a class the parts of the board and their function

2

Installing Arduino Software Install the Arduino Software (IDE) on Windows PCs Download the Arduino Software (IDE) Get the latest version from the https://www.arduino.cc/en/Main/Software You can choose between the Installer (.exe) and the Zip packages. The instructions below are the When the download finishes, proceed with the installation and please allow the driver installation process when you get a warning from the operating system.

Choose the components to install

Choose the installation directory (we suggest to keep the default one) 3

The process will extract and install all the required files to execute properly the Arduino Software (IDE)

How to connect the Arduino board to the computer 4

1. Using a USB cable, connect the Arduino Uno board to computer.

1. If successful, the power light will turn on.

Setting the Arduino board type You will need to make the Arduino board known to the application so you can upload the Blink sketch to the board. 2. Click on the ‘Tools’ drop down menu. 3. Click on ‘Board’ option. Another menu list appears. 4. Locate the Arduino board type and click on it. A blue button will appear in front of the selection you made and the menus will automatically disappear.

© ARDUINO LLC 2016 - CC-BY-SA 3.0

Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

5

Setting the port number 5. 6.

Again, click on the ‘Tools’ drop down menu. Click on the ‘Port’ option. a. On Windows: This is likely to be the COM with the highest number. As there is no harm in guessing wrong, if it doesn’t work, try the next one. However, to find out, you can disconnect your Arduino board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port.

b. On Mac: This should be something with /dev/tty.usbmodem in it. There are usually two of these; select either one. 7. Click on the ‘Port’ number the Arduino is connected to. A tick will appear in front of the selection made and the menus will automatically disappear.

© ARDUINO LLC 2016 - CC-BY-SA 3.0

Safety considerations List some general safety issues to consider when using a microcontroller. It runs on electricity so no drinks or other liquids, otherwise it may short circuit. You can create a “short” if you put it on conductive surfaces, so only put it down on nonconductive bench and table tops.

Uploading your sketch (code) to the Arudino Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

6

Before you upload the sketch look at the code/sketch, for every ‘13’ you see, replace it with ‘12’. Be careful to only change 13s to 12s; don’t accidently change or delete any other part of the code or your program will not compile. 1. Press the ‘Upload’ toggle button on the toolbar (the top left corner of the window).

© ARDUINO LLC 2016 - CC-BY-SA 3.0

8. You should see a bar indicating the progress of the upload near the lower right corner of the Arduino IDE.

© ARDUINO LLC 2016 - CC-BY-SA 3.0

9. The lights labelled TX and RX on the Arduino board will be blinking while the data transfer takes place.

© ARDUINO LLC 2016 - CC-BY-SA 3.0

10. If the upload is successful, the IDE will display the message ‘DONE UPLOADING’.

© ARDUINO LLC 2016 - CC-BY-SA 3.0

Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

Installing mBlock 7

Downloading mBlock, installing drivers and connecting Once you have your robot built and running, we encourage you to dive into the world of programming with mBlock. The following is an introduction in how to get setup. 1. Download from http://learn.makeblock.com/en/software/ 2. Install and open the software. 3. Get the Arduino drivers. For PC users, go to the Connect menu in mBlock:

For Mac users, download the driver. Unfortunately, the latest update for the Mac OSX introduced an issue with this driver. Find out about the solution to this issue. 4. Connect your robot to your computer via USB cable, turn your robot on, and open mBlock. Go to Connect-> Serial Port -> (port ID). (TIP: If you don’t know the port ID you are connected to, make a note of the available ports, disconnect your robot, and see which port disappears.) Once you have successfully connected, the title bar will say you are connected and the red dot in the “Robots” Scripts will turn green:

NOTE: To upgrade firmware, to reset the default program and to upload a program onto the robot board, you MUST be connected via USB. 5. Next, make sure you have the appropriate board selected in the Board menu: 8

o

Starter / Ultimate – Orion

o

mBot – mCore

o

mBot Ranger – Auriga

o

Ultimate 2.0 – Mega Pi

Here, I am using mBot, so the mCore board is selected:

Now you are ready to start programming. Construct Your Dreams!

Uploading Programs VS Controling Robot from IDE? 9

If you haven’t yet downloaded mBlock, installed Arduino drivers or connected your board, you might want to take a look at this lesson first. mBlock programs can be run from 2 places: the mBlock interface or the robot board. The following talks about the differences. mBlock IDE When running a program in the mBlock IDE, the commands are sent from the computer to the robot board, where they are interpreted and then executed. This means that users can use their computers in conjunction with the robot. For example, you can use the keyboard to control the robot:

Or you can use the timer provided in the mBlock software:

You can also use your webcam, the stage in the mBlock IDE, and much more. One of the drawbacks about using the mBlock IDE is that because the computer and robot are passing messages to each other, there is a slight lag as these messages take some time to go back and forth. In many programs, this won’t have a big effect on how the robot runs, but on others, for example a line following program, it will mean the program does not run how we would like. Another thing to consider is that if you are running from the mBlock IDE, you will of course need a computer, and a connection to the computer. If you have a Bluetooth or 2.4G module you can go wireless, but if you don’t, do you really want the robot to always be attached to the computer via USB cable? When you want to run programs through the mBlock IDE, “Upgrade Firmware” before you begin. Select Connect -> Upgrade Firmware:

10

This will overwrite any programs currently on the robot board with firmware that makes sure the computer and robot can communicate properly. If you are using the mBot Ranger you also need to select “Bluetooth mode”:

Once the firmware is upgraded, you are ready to start programming from the mBlock IDE. Robot Board When uploading to the robot board the program runs as a standalone. This means that all the programming scripts that were only relevant to the mBlock environment programming (such as “Motion” and “Looks”) are unavailable. On the plus side, because the code is uploaded to the board, there is no lag between, for example, reading sensors and acting accordingly. When you want to upload a program to the Arduino board, you should go into Arduino mode. You can do that either by selecting it from the menu:

Or by dragging and dropping the “(Board Name) Program” block into the programming area and clicking on it (here are the common header blocks):

When entering Arduino mode, the stage layout (where the panda is on the left) is hidden and Arduino code is shown on the right. As well as this, all the programming scripts that were only relevant to the mBlock environment programming (such as “Motion” and “Looks”) are greyed out. As you write your mBlock program, Arduino code will automatically be generated in the Arduino editing window. 11

Once you have finished writing your program, click on the “Upload to Arduino” button and the program will start running as soon as it has successfully uploaded.

NOTE: Once you have uploaded a program to the robot board, whether it be the firmware upgrade or one that you have written yourself, it will have overwritten the preloaded program. If you need to get this program back onto the robot board, go to Connect -> Reset Default Program -> (Robot Name):

Connecting VIA USB, Bluetooth or 2.4G Wireless 12

NOTE: To upgrade firmware, to reset the default program and to upload a program onto the robot board, you MUST be connected via USB. If you want to run programs from the mBlock IDE you can connect via Bluteooth or 2.4GHz (or USB). Here is how to connect in each of the 3 ways: USB cable Connect your robot to your computer via USB cable, turn your robot on, and open mBlock. The title bar should say you are disconnected.

Go to Connect-> Serial Port -> (port ID). (TIP: If you don’t know the port ID you are connected to, make a note of the available ports, disconnect your robot, and see which port disappears.) Windows:

Mac:

2.4GHz Module 13

If you are using the 2.4GHz module for the first time, you need to pair the dongle and the electronic module: Insert the 2.4GHz module into the robot board. Turn on your robot. Press the button on top of the 2.4GHz module. Plug the dongle into your computer. When the LED on the module stops blinking, it means the components have been successfully paired. Once you have been successfully paired, open mBlock. The title bar will still show you are disconnected:

You need to select Connect -> 2.4G Serial -> Connect.

Bluetooth Make sure your robot is turned on, the Bluetooth module is properly inserted into the board and the blue LED is flashing. The title bar should say you are disconnected.

Then you are ready to connect: Windows: 14

Mac: Pair and connect to “Makeblock” in the Bluetooth menu of your system. Then find your robot in the Serial Port menu.

mBot Online Resources 15

1. Kids Maker Rocks with the Robots goo.gl/QhzwPH

2. Series of Video Tutorials in mBot, start here http://www.mblock.cc/edu/1-the-light-sensor/

3. The Light Sensor http://learn.makeblock.com/en/robot-kits/mbot/the-light-sensor/

4. The Ultrasonic Sensor

http://learn.makeblock.com/en/robot-kits/mbot/the-ultrasonic-sensor/

5. The Line Follower http://learn.makeblock.com/en/robot-kits/mbot/the-line-follower/

6. The Ultrasonic Theremin http://learn.makeblock.com/en/robot-kits/mbot/the-ultrasonic-theremin/

7. The Sumo mBot http://learn.makeblock.com/en/robot-kits/mbot/sumo-mbot/

Arduino Fundamentals Course 16

The PD includes free access to this Online Course which consists of video tutorials that cover the fundamental concepts of Arduino as well as the Accelerometer and Reaction Time circuits central to this session. While mastering the pedagogical aspects of this PD will require classroom experience, you can master the technical aspects of Arduino by completing courses such as this one. Course content below, free course access here: goo.gl/An962W Breadboards and Electronic Circuits 1. Using a push button to turn on an LED 2. Using a potentiometer to vary LED brightness 3. Using a transistor in conjunction with human skill conductivity 4. Glow in the dark circuit Programmable Circuits Programmable Circuit 1. Controlling LED Blink rates 2. Controlling a buzzer with a button 3. Voltage divider circuit 4. Light sensor voltage divider (intensity control via PWM) 5. Light theremin 6. Microphone clap switch 7. Microphone double clap switch 8. Laser Tripwire Circuit 9. Multi Sensor Alarm Circuit Reaction Time Analysis 1. Reaction time analysis 2. Reaction time Arrays Visualising Accelerometer and Reaction Time Results 1. Processing and turning on LED's with a mouse 2. Mouse LED Boolean 3. Sending Message to Processing 4. Visualising Accelerometer Values 5. Smoothing accelerometer graphs in processing 6. Saving Reaction Time Results to SD Card 7. Creating Graphs from Data on SD Card

17

Assessment Options with Arduino You will be assessing four main categories of knowledge: circuit building, programming, terminology and applications. Below are some elaborations on each category and an example assessment. 1.

Building electric circuits on breadboards: Assess how well their prototype on a breadboard functions With their prototype see if they can explain what Summative Assessment: students create logic gates from schematic and function description

2.

Writing programs in Arduino: Assess the functionality of the programs Ask your students to explain how their programs work Formative Assessment: ask students to identify and correct errors in Arduino programs (and / or add functionality). This type of assessment tests the higher order computational thinking of your students.

3.

General knowledge in electronics and programming In order to communicate with others about the subject students need to speak the technical vocabulary Many students will achieve understanding before being able to put the understanding into words Summative Assessment: Vocabulary or labelling exercises that demonstrate that students are familiar with the technical terminology and functionality of basic Arduino commands

4.

Applied Knowledge: Arduino based Projects : Students will apply everything they learned into an Arduino based project, the project will include a working prototype and a report Prioritise the Q&A session when assessing presentations Formative Assessment: Assess the student report and presentation, make sure to give both written and in person feedback which the students will clearly understand.

18

Assessment Type 1: Students following Schematics and preproduced code: The schematic below will build a circuit with a button input and an LED output. The goals for this assessment is as follows: 1. Students receive just two pieces of information: circuit schematic and code 2. Students build the circuit using the schematic alone and upload the code 3. Students demonstrate that the circuit works correctly 4. Students complete some higher order extension activities Creating circuits from schematics and implementing provided code is a core skill in electronics. Without this skill your students will not be able to effectively use technical manuals or educational resources in the field of electronics.

Schematic for button LED circuit:

19

Code for button LED circuit:

Skills Demonstrated: 1. Students understand how schematics translate to breadboard circuits 2. Students understand how to wire breadboard circuits 3. Students can accurately copy and upload Arduino code

Extension Questions and suggestions: 1. Students can add two more LED’s 2. Students can print the state of the LED in the serial monitor 3. HARD: Students can alter a program that makes LED’s come on one at a time when a button is pressed so that you need to press a button 3 times to turn on 3 LED’s

20

Assessment Type 2: Analysing Arduino Code This assessment is all about code, the circuit will use an on-board LED as well as the one on the breadboard. So the students can chose whether or not to wire the LED on the breadboard, this is not assessable. The goals for this assessment are as follows: 1. Students will identify and correct syntax errors. 2. Students will identify and correct functional errors. 3. Students will understand the overall program logic and can modify it to improve functionality.

The circuit schematic:

21

Code below:

Questions for students: 1. Can you find and correct the two syntax errors in the code? 2. Can you identify why the circuit does not work properly even after fixing syntax errors? 3. HARD: Can you write a program which increases the blink rate and prints that blink rate at the serial monitor in such a way that you can precisely say at which rate the blinking became imperceptible?

22

Assessment Type 3: General knowledge of Circuitry and Programming Below are 3 pages of terms and code snippets, each of which comes with a definition. These make great assessment material to make sure that your students understand the basics. Previous assessments have dealt with code and schematics, this one deals with knowledge of terminology and basic functionality.

Word

Definition

actuator

A component that will move in your circuit. For example a servo motor in a remote control car controls the steering wheel direction.

analogue input

Allows an input voltage on Arduino anywhere between 0 and 5 volts, as opposed to digital which is off or on (0 or 5 only).

analogue output

Allows an output voltage on Arduino anywhere between 0 and 5 volts, as opposed to digital which is off or on (0 or 5 only).

analogRead

Command converts the input voltage range, 0 to 5 volts, to a digital value between 0 and 1023. This is done by a circuit inside the microcontroller called an analog-todigital converter or ADC

analogWrite

Writes an analog value to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. Range is between 0 and 255.

Arduino

A small and easy to use computer board. A programmable microcontroller board.

board

A surface that electronic components and parts are attached to. Can be made of various materials but they must not conduct.

camel case

Using capital letters to join words that have been joined together.

coding

Another word for computer programming.

component

Electronic parts that on their own generally have no function. When combined into a circuit they can perform a task such as being a night light.

conductive

Able to transfer electricity/electronic charge through itself. E.g. copper wire.

control technology

Electronic devices that use inputs to create outputs.

declaration

Means defining the type, and optionally, setting an initial value (initialising the variable) of a variable.

digital input

An input that is only on or off, it is not able to gradually turn on or off.

23 Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

Word

Definition

digital output

Can only be switched on and off, not able to be changed to a % of the full “on” value. Usually pins 0-13 on an Arduino Uno. Pins with PWM can simulate a % value by switching on and off really fast.

digitalRead

To receive a HIGH or LOW signal from a pin that has been made an input.

digitalWrite

To send a HIGH or LOW signal from a pin that has been made an output.

electrical circuit

A path that allows electricity to flow.

false

Not true. No electrical current present. Also known as OFF or LOW or 0.

hardware

The physical components of the electrical circuit and microcontroller (Arduino).

HIGH

Also known as ON or True or 1. It means that there is electrical current present (up to 5V for Arduino Uno).

Input, Processing and Output (IPO) Chart

A simple map of the input and output components of a control system. These make it easier to understand the control system you working with or building.

Integer

A whole number

Light dependant resistor (LDR)

A component that varies resistance depending on the amount of light on it.

Light emitting diode (LED)

Light Emitting Diode – a component that emits light and only lets electrical current pass in one direction. They are able to be purchased in a wide range of colours.

LOW

No electrical current present. Also known as OFF or False or 0.

microcontroller

A small programmable computer that is able to run code.

multimeter

A tool to measure a wide range of electrical values (including amps, continuity, resistance and volts) on circuits and components.

piezo buzzer

Makes a buzzing sound with electrical current applied, not a speaker.

port

A connection to the Arduino that is connected to sensors or actuators.

Source: https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

24

Word

Definition

potentiometer

A resistor that can have its resistance changed by turning a knob or moving a slide, just like on a car radio or home stereo system.

power supply

This supplies the electrical circuit with power. Comes in a large range of options from small batteries (like in watches/fitbits), to power packs that plug into power points.

pseudocode

Writing in plain English line by line (step by step) what you want the computer program to do.

resistor

A component that reduces the amount of current (amps) in a circuit.

sensor

A device that can be connected to the microcontroller that detects a change providing data to the microcontroller.

shield

A device that plugs into an Arduino that performs another function. The Thinkershield is an example.

sketch

This is the name Arduino give their code or programs.

tactile switch

A switch operated by a human.

true

Also known as ON or HIGH or 1. It means that there is electrical current present (up to 5V for Arduino Uno).

void loop

This section of code which runs after void setup runs forever or until the power runs out.

void setup

This section of code gets the Arduino prepared for the code that is going to run continuously and is always run before the void loop. Without this part being defined you will get errors as the Arduino board will not know how to execute the code.

Volts or voltage

The units of potential or “pressure or force” that electrical current wants to flow at.

Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

25

Component

Function

Commands

Are an instruction given in a program that tells the computer to do something specific. The main ones we will work with are keywords.

Semicolon ;

To tell Arduino it is at the end of that line of code.

Serial monitor

To allow you to see what the program is doing “in the background” even if your circuit doesn’t appear to be working. Serial monitor is a good way to check your code is correct/working.

Void setup

This section of code initially runs once when the program is run, and is used to tell Arduino what to expect its input/output pins to be doing or connected to.

Void loop

This section of code runs over and over until the power is switched off or the program has an ending statement.

Curly braces { }

These begin and end sections of code and Arduino needs them to recognise “paragraph structure” in your program.

Comments

Are put into the program to remind the programmer or tell someone else looking at the program what is happening in that line or section of code.

Verify program

This function checks your code for errors and highlights any errors in the code so you can fix them before uploading to your board.

Command

What does it mean?

pinMode(12, OUTPUT);

The mode or function of pin 12 is to be an output, it will send current out of the arduino board to what is connected to this pin. In this project it is an LED on pin 12 of the Thinkershield.

void loop() {

This is the start of the code that will run continuously in a “loop” until the power is turned off or other code is uploaded to the Arduino.

digitalWrite(12, HIGH);

Turn pin 12 to “low” or turn the electrical flow off.

delay(1000);

Delay means to wait for the time written in brackets. The unit for time is millisecond. E.g. (1000) = 1 second, (10000) = 10 seconds.

digitalWrite(12, LOW);

Turn pin 12 to “low” or turn the electrical flow off.

delay(1000);

Delay means to wait for the time written in brackets. The unit for time is millisecond.

Source : https://education.nsw.gov.au/teaching-andlearning/curriculum/key-learning-areas/tas/s4-5/resources

26

Assessment Type 4: Arduino Based Projects: This is the process that I found works really well in terms of running projects for students in years 7-10 with little to no experience with Arduino. 1. Define a goal! Ideally the goal should either be using technology to solve a problem or using technology to find out new facts about the world. Make sure you do the following before settling on a goal: Do the research to make sure the goal is achievable If similar projects exist then study them and aim to produce something different: a simpler more robust design or a design with more functionality Do some ‘market research’ to confirm that your project will solve a problem that really exists or answer questions which can be useful to someone

2. Develop a Conceptual Design This starts with a diagram of your product and a text description of how it works. This diagram should contain a parts list with all the key parts being labelled on the diagram. The conceptual design should also contain pseudo code which is a description of how the program will work

3. Develop a Minimum Viable Product So imagine the simplest design possible that accomplishes more than half of your goals. Once built it can be tested and modified. At this stage of the project the diagram, parts list and pseudo code should be revised taking into account the real world feedback from the minimum viable product. This stage of the process is also the best time for collaboration with other classmates who can suggest new testing methods and help with any hardware / software issues.

4. Project Plan At this point in your project you have both a conceptual design and a some real world feedback on the functioning of that design. This is where the following should take place Ordering of any remaining parts A step by step process for completing the project with due dates for each step

27

5. Execution and Documentation The final result will be a functioning project, which can be tested in several test cases. If students finish ahead of schedule, consider doing the following upgrades: Move the product from a breadboard to a soldered circuit board. Add an LCD display to display some of what the Arduino is doing. Add other functionality at recommendation of a teacher or students. The documentation should be BRIEF, ideally less than 10 pages. It should answer the following questions: What does their design do? How does the design accomplish this task? Why is their design important?

28

Appendix 1: Equipment List Part Resistor 0.25-220R-1%

Qt y20

Resistor 0.25-1K-1%

20

Resistor 0.25-10K-1%

20

Resistor 0.25-4.7K-1%

20

IR Receiver Diode IRM3638T

1

Ambient Light Sensor PT5I850AC-A4

1

Red LED 5mm

3

Yellow LED 5mm

3

Green LED 5mm

3

8-Segment LED LG5011BSR

1

Mini Push button 6*6*5

4

Jumper Cables M/M 20CM

36

Remote Control (with battery CR2025 inside)

1

Tilt Switch Sensor

2

LM35DZ Temperature Sensor

1

Buzzer

1

USB Cable A-B for Arduino

1

400 Tie Point Interlocking Solderless Breadboard

1

Prototyping Shield For Arduino

1

DFRduino UNO Rev3

1

10K Potentiometer

3

DFR0265 Gravity IO ExpansionShield for Arduino V7.1

1

DFR0034 Analog Sound sensor for Arduino

1

FIT0449 Speaker

1

Gravity PIR Sensor

1

SEN0142 Gyro Accelerometer MPU6050

1

2N3904 Transistor

1

Breadboard holder

1

GL5528

1

29