416
RockOn! 2008 1 Embedded System Overview RockOn! 2008

Embedded System Overview

  • Upload
    obelia

  • View
    49

  • Download
    0

Embed Size (px)

DESCRIPTION

Embedded System Overview. 1. RockOn! 2008. Why an Embedded System?. General Purpose computer Usually has a human in the loop Can be reconfigured to do any number of tasks (excel, email, music) Embedded Systems (RSW Board) Doesn’t require human input all the time Must meet real-time goals - PowerPoint PPT Presentation

Citation preview

Page 1: Embedded System Overview

RockOn! 2008

1

Embedded System

Overview

RockOn! 2008

Page 2: Embedded System Overview

RockOn! 2008

2

Why an Embedded System?

- General Purpose computer-Usually has a human in the loop-Can be reconfigured to do any number

of tasks (excel, email, music)

- Embedded Systems (RSW Board)-Doesn’t require human input all the

time-Must meet real-time goals- Heart monitor- Automatic braking systems (ABS)

- Takes specific inputs and computes outputs for a very specific application

Page 3: Embedded System Overview

RockOn! 2008

3

Why an Embedded System?

- General Purpose computer-Usually has a human in the loop-Can be reconfigured to do any number

of tasks (excel, email, music)

- Embedded Systems (RSW Board)-Doesn’t require human input all the

time-Must meet real-time goals- Heart monitor- Automatic braking systems (ABS)

- Takes specific inputs and computes outputs for a very specific application

Page 4: Embedded System Overview

RockOn! 2008

4

Signal Types - Analog

- Continuous function

- Measures real world value and represents it as a time varying voltage- voice, sun brightness and

temperature trends

- Can’t store Analog signal. Storage has to be represented as “0” and “1”s on a computer system

Page 5: Embedded System Overview

RockOn! 2008

5

Signal Types - Digital

- Non-continuous, discreet and quantized steps- 1V, 2V, 3V, 4V….90V

- Binary information- Individual bits, button push, “there or not there”

-Only method for storage of information with a computer system- Serial cables is an example of digital communication

Page 6: Embedded System Overview

RockOn! 2008

6

Accuracy v. Precision

- Accuracy-How close you are to the true value of the object

being measured-How often do you hit the bull’s eye?-Capable of accurately measuring the earth’s

gravity every time

- Precision- The smaller the division, the smaller change which

can be observed. The ruler.-Capable of sensing the change of .001g’s

High ALow P

High PLow A

Page 7: Embedded System Overview

RockOn! 2008

7

Precision and Recording Data

- A state is one unique combination of bits- 1 bit – 0 or 1 = 2 states = 21

- 2 bits – 00, 01, 10, 11 = 4 states = 22 - 4 bits – 0000, 0001….1111 = 16 States = 24

- 8bits = 28= 256 states- 16bits = 216 = 65,536 states

-More bits provides more precision over a given voltage range

- If it is necessary to record small changes, more precision (bits), is required

- 8 bits is a byte

Page 8: Embedded System Overview

RockOn! 2008

8

Sensor & Storage

- Item to be measured-Real world units -Degrees Celsius

- Temperature Sensor- Converts temp to Analog Voltage-42.0 C to 4.20V

- Analog to Digital Converter- Converts 4.20V to Digital value to be stored as binary- Input voltage range 0-5V- Output Count range 0-255 (8 bits)- Linearly scaled- 4.20V / 5.0V * 256counts = 215

42.0 C temp

4.20V

0C = 0V

5V = 255

0V = 0

215 counts = 11010111 binaryStorage for

later use

50C = 5V

Page 9: Embedded System Overview

RockOn! 2008

• Quantization of an Analog Signal into a Digital Signal

9

Analog to Digital Converter

Quantization of an Analog Signal into a Digital Signal.

Digitally converted signals

Black line – 4 bits more info

Red line – 2 bitsless info

321

Digital Conversion

Analog Signal (volts)

Page 10: Embedded System Overview

RockOn! 2008

10

What does this all look like on the AVR board?

- ATmega 32 FBD AVR Pinout

Page 11: Embedded System Overview

RockOn! 2008

11

Interfacing with the real world

- The ATmega 32 has four Ports which each has 8 pins.

- Each pin can be individually configured.-Analog in -Digital in or out

- Software sets up these pins, reads sensors, stores data

Ports A, B, C, DPins 0-7

Page 12: Embedded System Overview

RockOn! 2008

12

C Programming

Review

RockOn! 2008

Page 13: Embedded System Overview

RockOn! 2008

13

History of C

- C is a general purpose, block structured, procedural computer programming language

- Created in 1972 by Dennis Ritchie at the Bell Telephone Laboratories

- Standardized in the early 1980s

- The original C programming language is considered to be the language of choice for embedded systems

- C is used for the workshop

Page 14: Embedded System Overview

RockOn! 2008

14

History of C++

- C++ is a middle level programming language that supports the ability to create classes

- C++ was created by Bjarne Stroustrup to be a “better C”

- First standardized in 1998

- C++ is a spin on the usage of the ++ syntax in programming, and literally means “C + 1”, which implies a programming language a level above C

Page 15: Embedded System Overview

RockOn! 2008

15

Variables

- Variables are name-declared regions for storage

- Unlike real numbers, the values of a variable can change depending on the operations done on it

- For example, you can declare the letter ‘a’ to be a variable, and then later equate that letter with some value

Example a=4The value of ‘a’ has been equated to the number 4

- This value can change through an operationExample a=4;

a=a+2;The value of ‘a’ has been updated to a = 4+2, or 6

Page 16: Embedded System Overview

RockOn! 2008

16

Variables

- All variables must be declared before they are used

- General form for variable declaration:

<variable type> <name of variable>

- A variable name can be anything that is not already used by the c program

- Common variable types are int (integer), char (character), and float

Example int foo;

Page 17: Embedded System Overview

RockOn! 2008

17

Operators

- The values of a variable can change depending on the operation used on the variable.

- Basic Operators Example (using int a=4)+ (addition) a+2 = 6- (subtraction) a -3 = 1* (multiplication) a*2 = 8/ (division) a/4=1

- Uncommon Operators++ (increment) a++; a=5-- (decrement) a--; a=3

Page 18: Embedded System Overview

RockOn! 2008

18

Conditional Control

- The ability to control the flow of your code through decision-making

- Allows the program to skip or execute a section of code if some stated condition is met.

Page 19: Embedded System Overview

RockOn! 2008

19

Conditional Control

- Conditional statements are created using relational operators

> greater than< less than>= greater than or equal to <= less than or equal to!= not equal to== equal to

Page 20: Embedded System Overview

RockOn! 2008

20

If Statements

- General formif (conditional statement)

{execute all commands inside the bracketswhen above conditional statement is true}

- Exampleif(5>4)

{printf(“Five is greater than four.”)}

Page 21: Embedded System Overview

RockOn! 2008

21

Else Statements

- Used in order to force the program to execute a different section of code should the original IF statement prove false

- General formelse

{execute all commands inside the

brackets}

Page 22: Embedded System Overview

RockOn! 2008

22

If/Else Statements

- Exampleif(3>4)

{printf(“Three is greater than four.”)}

else{printf(“Three is less than four.”)}

- In this example, only the content of the else statement executes

Page 23: Embedded System Overview

RockOn! 2008

23

Else If Statements

- Used should more than 2 conditions be required.

- ELSE IF statements are placed between the initial IF statement and the final ELSE statement

- General formelse if(statement inside is true)

{execute all commands inside the

brackets}

Page 24: Embedded System Overview

RockOn! 2008

24

If / Else If / Else Statements

- Exampleint a = 3;if(a>3)

{printf(“a is greater than three.”)}

else if (a==3){printf(“a is equal to three.”) }

else{printf(“a is less than three.”)}

- In this case, only the ELSE IF statement will occur.

Page 25: Embedded System Overview

RockOn! 2008

25

For Loops

- For loops will execute a statement a defined number of times, and stop execution once the condition is declared false

- Used to avoid writing the same line of code multiple times

- General formfor ( variable initialization; condition; variable update )

{ code to execute while the condition is true

}

Page 26: Embedded System Overview

RockOn! 2008

26

For Loops

- Examplefor(int x = 0; x < 10; x++)

{printf(“Hello World!”)}

- The above example will print the phrase 10 times, from x = 0 being the first count, to x=9 being the last count

- x++ increments x by 1 after each execution of the loop, because x++ is a post increment

Page 27: Embedded System Overview

RockOn! 2008

27

While Loops

- While loops will execute a statement as long as the condition is met

- Used to avoid writing the same line of code multiple times

- General formwhile (condition)

{ code to execute while the condition is true

}

Page 28: Embedded System Overview

RockOn! 2008

28

While Loops

- Examplewhile(1)

{printf(“Infinite loop”)}

- The above example is an infinite loop that will print “Infinite loop” forever

- The “1” statement is equivalent to always TRUE, and so the condition is always met

Page 29: Embedded System Overview

RockOn! 2008

29

Functions

- A function is a block of code that, when called, executes a set of pre-defined commands

- Some functions come included in a library or in other reference codes, and some have to be written out from start

Page 30: Embedded System Overview

RockOn! 2008

30

Functions

- A function is a block of code that, when called, executes a set of pre-defined commands

- Some functions come included in a library or in other reference codes, and some have to be written out from start

Page 31: Embedded System Overview

RockOn! 2008

31

Function Advantages

- The main advantages of a function are:

- Organization; allows a programmer to organize different commands under different function names, thus making a program easier to follow

- Code Simplification; the programmer can call the same function repetitively in order to avoid repeating lines

- Flexibility; allows other programmers to use a set of commands without needing to recreate all the content within the function

Page 32: Embedded System Overview

RockOn! 2008

32

Function Format

- Functions have a two general forms: a return and non-return

- All functions must have a return-type, such as void (used for non-return functions), int, char, etc…

- Most functions have parameters or arguments - values of which the pre-defined code will work with; some functions do not

- There is no real limit to the number of parameters, but the smaller the amount the better

Page 33: Embedded System Overview

RockOn! 2008

33

Return Functions

- A function with a return command will output a value depending on the inputs, or parameters, given to the function

- Example int a = content(int x, int y)

- The output of the content function will be set to the variable a

- The output depends on the commands in the function content and the value of the parameters x and y – the inputs of the function

Page 34: Embedded System Overview

RockOn! 2008

34

Non-Return Functions

- A function without a return command will simply execute the pre-defined commands within its body without any output given

- Example greaterthanone(int x)

- The greaterthanone function may compare the value of its parameter, x, with 1, and execute a set of commands if the value of x is actually larger than 1

- It does not generate an output, or return value

Page 35: Embedded System Overview

RockOn! 2008

35

Creating a Function

- Define the return type

- Define the parameters and their variable types

- In order to return a value, include a return statement at the end of the code

- Example return foo

- The function will return the stored value of the variable foo

- Provide comments describing the function functionality

Page 36: Embedded System Overview

RockOn! 2008

36

Creating a Function

- General form

return-type function_name(arg_type1 arg1, arg_type2 arg2,…,arg_typen argn)

{commands to execute in the functionreturn statement if needed}

Page 37: Embedded System Overview

RockOn! 2008

37

Creating a Function

- Example of a Simple Function:

int checkequal(int x, int y) //function name and type{ //with 2 parametersif(x == y)

{return 1 //if parameters equal} //function returns

TRUEelse

{return 0 //else, functions

returns} //false

}

Page 38: Embedded System Overview

RockOn! 2008

38

Calling a Function

- Call the Function

int a = 5; //define one variable for functionint b = 4; //define another variable

int valid = checkequal(a,b) //call function and check

//if equal values

- The variable ‘valid’ will, in this case, hold the value 0, or FALSE, because variable a does not equal variable b

Page 39: Embedded System Overview

RockOn! 2008

39

#include

- The directive #include <file name> tells the C compiler to enter the contents of the specified file in that location

- This allows for a complicated program to spread on more than 1 .h or .c file, which allows better organization

- #include may be needed to access pre-defined values by the program

- Example #include <math.h>

- Allows access to the math library, which contains many important math functions and variables

Page 40: Embedded System Overview

RockOn! 2008

40

#define

- Can be used to declare values for constants

- Example #define MAXSIZE 256

- The value MAXSIZE always refers to the number 256

- Can be used for argument declarations, which is slightly similar to basic function declaration

- Example #define DOUBLE(x) 2*x

- Every time DOUBLE() is called with some number in its parenthesis, it will take that number or variable and multiply it by 2

Page 41: Embedded System Overview

RockOn! 2008

41

C Review Quiz – Question #1

Which of the following C statements declares an integer variable named my_int and assigns it a value of 42?

a) integer my_int(42);b) int my_int = 42;c) my_int = 42;d) my_int integer = 42;

EXPLANATION: all variables must be declared a type, and all declarations must occur before name assignments. To declare an integer, write ‘int’.

Page 42: Embedded System Overview

RockOn! 2008

42

C Review Quiz – Question #2

What is the value of output after the loop is executed?int i;int output;output = 1;for (i = 0; i < 30; i = i + 3){if (i < 15){

output = output * 2;}else{

output = output – 2;}}

a) 52b) 42c) 32d) 22

EXPLANATION: The output is effectively doubled 5 times, and then subtracted from 5 times. So, (2^5)-10 is the mathematical solution

Page 43: Embedded System Overview

RockOn! 2008

43

C Review Quiz – Question #3

- The next 2 questions refer to the function foo, defined below:int foo(double a, char b, long c);

 What is the return type of foo?a) intb) doublec) chard) long

EXPLANATION: The return type of a function is the type of the function, not the type of its parameters.

Page 44: Embedded System Overview

RockOn! 2008

44

C Review Quiz – Question #4

Which of the following statements correctly calls foo and assigns the return value to the variable x (ignore the type of x for this question)?

a) x = foo(1, 2.2, 5);b) x = foo(1.5, ‘a’, 1000);c) x.foo(1.5, ‘b’, 1000);d) x(foo(1, ‘c’, 0.25));

EXPLANATION: Return values must be written into an equal statement, and the function must have the correct parameter types for its inputs.

Page 45: Embedded System Overview

RockOn! 2008

45

C Review Quiz – Question #5

What value is contained in x[3] after the following code is executed?int x[10]; for (int i = 0; i < 10; ++i){

x[10-i] = i + 1;}

a) 5b) 6c) 7d) 8

EXPLANATION: The statement ++i is a pre increment. 1 is added to the value of i before i is used in the body. In this case, the first value of i used in the body of the loop is actually 1.

Page 46: Embedded System Overview

RockOn! 2008

46

C Review Quiz – Question #6

What is the value of output after the following code is executed?

int output;int a = 10, b = 1, c = 4, d = 7;if ((a < b) || ((b < c) && (d >= b))){

output = 1;}else{

output = 0;} 

EXPLANATION: And operations (&&) are analyzed first. Thus, d is greater than b and c is greater than b is true. If one condition of an or (||) statement is true, the entire or statement is true.

a) 0b) 1

Page 47: Embedded System Overview

RockOn! 2008

47

C Review Quiz – Question #7

Which of the following logical expressions evaluates to 1 for the given values?A = 2;B = 0;C = 0;D = 1;E = 3; a) !(D || (E < A))b) ((D < A) || (C == B) && E)c) ((E || F) && C)d) ((C == D) || ((D < E) && (A < B))) 

EXPLANATION: D<A in choice (b) evaluates to 1, which makes the entire statement evaluate to 1 because or statements are analyzed after and statements.

Page 48: Embedded System Overview

RockOn! 2008

48

C Review Quiz – Question #8

Given a function void foo(int x), which of the following correctly calls foo?

a) int x = 3; void foo(int x);b) void foo(3);c) foo(-3);d) int x = 3; foo(int x); 

EXPLANATION: The function only requires an integer declared parameter, or an integer placed inside the parenthesis. To call a function, simply write the name followed by filling the parameter positions.

Page 49: Embedded System Overview

RockOn! 2008

49

C Review Quiz – Question #9

Find the error in the following code:char test;

 scanf(test);

1. switch (test){

2. case a:printf(“Hello!”);break;

3. case ‘b’:printf(“Goodbye!”);break;

4. default: printf(“Input is not a or b”);

break;};

 

EXPLANATION: Test is defined as a character, and thus all values must be defined under quotes.

Page 50: Embedded System Overview

RockOn! 2008

50

C Review Quiz – Question #10

Which of the following is not a valid variable declaration?

a) int a[10];b) void b;c) long c;d) char d = 0;

 

EXPLANATION: To declare a variable void is not possible. Void is used for non-return functions

Page 51: Embedded System Overview

RockOn! 2008

51

Software Walkthrough

RockOn! 2008

Page 52: Embedded System Overview

RockOn! 2008

52

Brains…

- Now we will make your electronics come alive

- These steps are designed to teach you how to program your AVR and test its functionality

Page 53: Embedded System Overview

RockOn! 2008

53

Brains…

- Now we will make your electronics come alive

- These steps are designed to teach you how to program your AVR and test its functionality

Page 54: Embedded System Overview

RockOn! 2008

54

Materials

- All necessary coding files provided -Programs you will need- WinAVR (Version 20071221)- AVR Studio- RealTerm-Drivers for ISP and USB-to-Serial Converter-All installed on laptop and contained on DVD-ROM

- Utility suite to assist in development- Timer Setup Utility- In System Memory Programming Utility- Data Parser Utility

Page 55: Embedded System Overview

RockOn! 2008

55

AVR Studio

- Integrated Development Environment (IDE)

- Allows for easy interface to AVR from coding to device programming

- Allows all programming to be done within 1 program

- Provides framework for platform lessons and flight code

Page 56: Embedded System Overview

RockOn! 2008

56

AVR Studio

Page 57: Embedded System Overview

RockOn! 2008

57

AVR Studio Interface

Source Files

Header Files

Active File

Compiler Messages

Close Up

Page 58: Embedded System Overview

RockOn! 2008

58

Lesson 0:POST Test

RockOn! 2008

Page 59: Embedded System Overview

RockOn! 2008

59

Lesson 0: POST

- What is a POST?- Power-On System Test- Checks functionality of AVR board systems

- Objectives- Verify functionality of AVR board- Learn to load code onto the AVR

- What systems are checked?- EEPROM memory for data memory protection- Analog Sensors- Flash Memory

Page 60: Embedded System Overview

RockOn! 2008

60

Lesson 0: POST

- Open Atmel AVR Studio

- On the welcoming screen, press “Open”

Page 61: Embedded System Overview

RockOn! 2008

61

Lesson 0: POST

- In the RockOn! Workshop folder on the desktop, open the file POST/POST.aps , in the POST folder

Page 62: Embedded System Overview

RockOn! 2008

62

Lesson 0: POST

- During build, compiler warnings are okay, errors are not

- Build the code- Click Build -> Build (F7)

- If any errors occur, check your code for typos or errors- Ask for help if you cannot fix the error

Page 63: Embedded System Overview

RockOn! 2008

63

Lesson 0: POST

- Before making any connections to the AVR board, power to the board should be DISCONNECTED, either at the battery connection or at the connection pins on the board

- Be sure to take ESD precautions (put on your wrist strap)

Page 64: Embedded System Overview

RockOn! 2008

64

Lesson 0: POST

- Connect the AVRISP to the computer

- Connect the AVRISP to the AVR board

Page 65: Embedded System Overview

RockOn! 2008

65

Lesson 0: POST

Page 66: Embedded System Overview

RockOn! 2008

66

Lesson 0: POST

- NOTE: The programming header must be connected as shown. Flipping it around will cause programming to fail.

Page 67: Embedded System Overview

RockOn! 2008

67

Lesson 0: POST

- Create a serial connection between the AVR board and the computer by,- Connecting the USB to Serial Adapter to the computer

Page 68: Embedded System Overview

RockOn! 2008

68

Lesson 0: POST

- Connecting the USB to Serial Adapter to the data retrieval board

Page 69: Embedded System Overview

RockOn! 2008

69

Lesson 0: POST

- Connecting the data retrieval board to the AVR board

- NOTE: the orientation of the cables must match those shown below

Page 70: Embedded System Overview

RockOn! 2008

70

Lesson 0: POST

- Both the serial connection between board and computer and the ISP connection between board and computer will be needed

- The ISP connection is necessary for loading code onto the board

- The serial connection is necessary for analysis of the board by the computer

- For loading code or data retrieval and conversion, the AVR board needs to be powered on and activated

Page 71: Embedded System Overview

RockOn! 2008

71

Lesson 0: POST

- To use the USB-to-Serial Converter, the COM port it is connected to must be identified

- Click Start and right click on “My Computer”

- Left click on “Properties”

Page 72: Embedded System Overview

RockOn! 2008

72

Lesson 0: POST

- Click on “Hardware” - Click on “Device Manager”

Page 73: Embedded System Overview

RockOn! 2008

73

Lesson 0: POST

- Click on “Ports (COM & LPT)- Keyspan USB Serial Port = COM4

Page 74: Embedded System Overview

RockOn! 2008

74

Lesson 0: POST

- At this point, connect power to the AVR board

- RDY LED should be on if the RBF jumper is inserted

- Click the G-Switch (ON LED should be activated)

Page 75: Embedded System Overview

RockOn! 2008

75

Lesson 0: POST

- Now, go to the start menu and open up RealTerm

- RealTerm allows serial communication with the AVR board

- Will be used to collect results of POST

Page 76: Embedded System Overview

RockOn! 2008

76

Lesson 0: POST

-Click on the “Port” tab

Page 77: Embedded System Overview

RockOn! 2008

77

Lesson 0: POST

- Set the baud to 19200- Set the Port to the port for the USB-to-Serial cable- Make sure the Open button is depressed- Click the Change button to apply your changes - CTS(8) and DSR(6) “lights” should turn green

Page 78: Embedded System Overview

RockOn! 2008

78

Lesson 0: POST

- Click on the “Display” tab

Page 79: Embedded System Overview

RockOn! 2008

79

Lesson 0: POST

- Check the “newLine mode” box-Make sure the top bubble on the left, reading “Ascii”, is

selected- Check the “Scrollback” box

Page 80: Embedded System Overview

RockOn! 2008

80

Lesson 0: POST

- Go back to AVR Studio

- Click the “AVR” button on the bottom toolbar

Page 81: Embedded System Overview

RockOn! 2008

81

Lesson 0: POST

- This is the image you should have received.

- On the main tab, make sure that ATmega32 is the selected device, the programming mode is ISP, and the ISP Frequency is 125.0 kHz

Page 82: Embedded System Overview

RockOn! 2008

82

Lesson 0: POST

- If the program cannot connect to the AVRISP, make sure that the AVRISP mkII is selected in the left menu and try again

- If you did not get the pop-up box in the slide before, then you are most likely at this step.

Page 83: Embedded System Overview

RockOn! 2008

83

Lesson 0: POST

- The first time you program the AVR, you must set the fuses.

- Click on the “Fuses” tab

- Set your fuse settings as shown

Page 84: Embedded System Overview

RockOn! 2008

84

Lesson 0: POST

- On the “Program” tab, click the “…” in the FLASH section and select “POST/post/POST.hex” as the executable file, found in the RockOn folder.

Page 85: Embedded System Overview

RockOn! 2008

85

Lesson 0: POST

- Click “Program” in the FLASH section

-While this programs, go back to the RealTerm window

Page 86: Embedded System Overview

RockOn! 2008

86

Lesson 0: POST

- Once the code has been programmed, click on the black text section of the screen and press any key to begin the POST

Page 87: Embedded System Overview

RockOn! 2008

87

Lesson 0: POST

- Let the POST run (5 to 10 minutes)

- Results will be shown at the end of the POST

- If any tests fail ask for assistance from workshop personnel

Page 88: Embedded System Overview

RockOn! 2008

88

Lesson 0: POST

- Highlight text in the RealTerm window and select “CTRL C” on your keyboard.- Open Microsoft Word- Select “CTRL V” to paste text- Save file as “POST_KIT_XX.doc” to your desktop

Page 89: Embedded System Overview

RockOn! 2008

89

Lesson 0: POST

- Remove power from the AVR board

- Remove the Data Retrieval connector from the AVR board

- Close the RealTerm program

- Close the AVR Studio program

- You are now ready to start programming and testing your AVR board

Page 90: Embedded System Overview

RockOn! 2008

90

ENDLesson 0:

POST Test

RockOn! 2008

Page 91: Embedded System Overview

RockOn! 2008

91

Lesson 1:Blink an LED

RockOn! 2008

Page 92: Embedded System Overview

RockOn! 2008

92

Lesson 1: Blink an LED

- Objectives- Introduce fundamental library functions

- Introduce AVR Studio interface

- Create a simple program and load it onto the AVR board

Page 93: Embedded System Overview

RockOn! 2008

93

Lesson 1: Blink an LED

- Objectives- Introduce fundamental library functions

- Introduce AVR Studio interface

- Create a simple program and load it onto the AVR board

Page 94: Embedded System Overview

RockOn! 2008

94

Lesson 1: Blink an LED - Functions

- Upcoming Functions

cbi(register, pin)

sbi(register, pin)

_delay_ms(time)

Page 95: Embedded System Overview

RockOn! 2008

95

Lesson 1: Blink an LED - Functions

- cbi(register, pin)

- Clears a bit in a register

- Example: cbi(PORTB, 3) clears bit 3 in the PORTB register

-Uses- Set a pin as an input by clearing the corresponding bit in the Data Direction Register- cbi(DDRB, 3) sets pin B3 as an input- Turn on the status LED by calling cbi(PORTD, 6)- LED uses reverse logic, so clearing the pin activates the LED

Page 96: Embedded System Overview

RockOn! 2008

96

Lesson 1: Blink an LED - Functions

- Example cbi(PORTD, 6)

Page 97: Embedded System Overview

RockOn! 2008

97

Lesson 1: Blink an LED - Functions

- sbi(register, pin)

- Sets a bit in a register

- Example: sbi(PORTB,3) sets bit 3 in the PORTB register

- Uses- Set a pin as an output by setting the corresponding bit in the Data Direction Register- sbi(DDRD, 6) sets pin D6 as an output (status LED)- Turn off the status LED by calling sbi(PORTD, 6)

Page 98: Embedded System Overview

RockOn! 2008

98

Lesson 1: Blink an LED - Functions

- Example sbi(PORTD, 6)

Page 99: Embedded System Overview

RockOn! 2008

99

Lesson 1: Blink an LED - Functions

- delay_ms(time)- Delays the given amount of time in milliseconds- Example: _delay_ms(1);- Limitation: The function can only delay a small amount of time (about 2 ms) due to hardware limitations- In order to wait more you can call the function multiple times- Uses- Wait a certain amount of time between function calls- Can be used to blink an LED- Turn the LED on- Wait for a small amount of time- Turn off the LED- Wait again

Page 100: Embedded System Overview

RockOn! 2008

100

Opening the Project

- Open Atmel AVR Studio

- On the welcoming screen, press “Open”

Page 101: Embedded System Overview

RockOn! 2008

101

Opening the Project

- In the RockOn! Workshop folder on the desktop, open the file Code/Work/RocketSat.aps (file with bug icon)

Page 102: Embedded System Overview

RockOn! 2008

102

Lesson 1: Blink an LED

- Your Turn- In AVR Studio, right-click on “Source Files” on the left sidebar- Choose “Add Existing Source Files”- Add “led.c” to the project. Double click on “led.c” to open

Page 103: Embedded System Overview

RockOn! 2008

103

Lesson 1: Blink an LED

- The correct “led.c” file should only have comments in it

Page 104: Embedded System Overview

RockOn! 2008

104

Lesson 1: Blink an LED

- In led.c, write code to blink an LED

- Suggestions- Remember to delay after turning the LED on and off

- Remember that to repeat an action indefinitely, it can be put in a while (1) loop

- Use the comments in the file to guide you

Page 105: Embedded System Overview

RockOn! 2008

105

Lesson 1: Blink an LED - Code

sbi(DDRD, 6);

while (1) {

cbi(PORTD, 6); _delay_ms(2);_delay_ms(2); _delay_ms(2); sbi(PORTD, 6); _delay_ms(2);_delay_ms(2);_delay_ms(2);

}

Page 106: Embedded System Overview

RockOn! 2008

106

Lesson 1: Blink an LED

- Building Your Completed Code- Once code is written, you need to compile and link it to make an executable file

- Click Build->Build (F7)

Page 107: Embedded System Overview

RockOn! 2008

107

Lesson 1: Blink an LED

- Connecting the AVR Board to the Computer

Page 108: Embedded System Overview

RockOn! 2008

108

Lesson 1: Blink an LED

Page 109: Embedded System Overview

RockOn! 2008

109

Lesson 1: Blink an LED

- Connect the AVRISP to the programming header

- Make sure that all power connections have been DISCONNECTED before starting this process

Page 110: Embedded System Overview

RockOn! 2008

110

Lesson 1: Blink an LED

- NOTE: The programming header must be connected as shown. Flipping it around will cause programming to fail.

Page 111: Embedded System Overview

RockOn! 2008

111

Lesson 1: Blink an LED

- FINAL RESULT

Page 112: Embedded System Overview

RockOn! 2008

112

Lesson 1: Blink an LED

- Connect power to the AVR board before loading any code

- Install RBF jumper

- Install and activate G-Switch

Page 113: Embedded System Overview

RockOn! 2008

113

Lesson 1: Blink an LED

- Click the “AVR” button on the bottom toolbar to begin to load the code

Page 114: Embedded System Overview

RockOn! 2008

114

Lesson 1: Blink an LED

- This is the image you should have received.

- On the “Main” tab, make sure that ATmega32 is the selected device, the programming mode is ISP, and the ISP Frequency is 125.0 kHz

Page 115: Embedded System Overview

RockOn! 2008

115

Lesson 1: Blink an LED

- If the program cannot connect to the AVRISP, make sure that the AVRISP mkII is selected in the left menu and try again

- If you did not get the pop-up box in the slide before, then you are most likely at this step.

Page 116: Embedded System Overview

RockOn! 2008

116

Lesson 1: Blink an LED

- On the “Program” tab, click the “…” in the FLASH section and select “code/work/

default/RockOn.hex” as the executable file, found in the RockOn folder.

Page 117: Embedded System Overview

RockOn! 2008

117

Lesson 1: Blink an LED

- Click “Program” in the FLASH section

- After loading, your LED should begin blinking

- It is blinking so fast you it will appear to be only on

- Let’s reprogram with more delays

Page 118: Embedded System Overview

RockOn! 2008

118

Lesson 1: Blink an LED - Code

sbi(DDRD, 6); while (1) {

cbi(PORTD, 6); _delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);_delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);

Page 119: Embedded System Overview

RockOn! 2008

119

Lesson 1: Blink an LED - Code

sbi(PORTD, 6); _delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);_delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);

}

Page 120: Embedded System Overview

RockOn! 2008

120

Lesson 1: Blink an LED

- Building Your Completed Code- Once code is written, you need to compile and link it to make an executable file

- Click Build->Build (F7)

Page 121: Embedded System Overview

RockOn! 2008

121

Lesson 1: Blink an LED

- Click the “AVR” button on the bottom toolbar to begin to load the code

Page 122: Embedded System Overview

RockOn! 2008

122

Lesson 1: Blink an LED

- On the “Program” tab, click the “…” in the FLASH section and select “code/work/

default/RockOn.hex” as the executable file, found in the RockOn folder.

Page 123: Embedded System Overview

RockOn! 2008

123

Lesson 1: Blink an LED

- Click “Program” in the FLASH section

- After loading, your LED should NOW be noticeably blinking

- Disconnect power

- Leave AVR ISP connected

Page 124: Embedded System Overview

RockOn! 2008

124

Lesson 1: Blink an LED

- Challenge, if you have time before we go on, try:- changing the blink pattern of your LED- Example: Three delays on, five delays off-writing the code more efficiently

Page 125: Embedded System Overview

RockOn! 2008

125

ENDLesson 1:Blink an LED

RockOn! 2008

Page 126: Embedded System Overview

RockOn! 2008

126

Lesson 2:Flash Memory

RockOn! 2008

Page 127: Embedded System Overview

RockOn! 2008

127

Lesson 2: Flash Memory

- Objectives:- Learn about the RocketSat memory system

- Learn to write data to the flash memory

Page 128: Embedded System Overview

RockOn! 2008

128

Lesson 2: Flash Memory

- Objectives:- Learn about the RocketSat memory system

- Learn to write data to the flash memory

Page 129: Embedded System Overview

RockOn! 2008

129

Lesson 2: Flash Memory Overview

AVR CodeAVR Code

Memory BufferMemory Buffer

write( )

DataFlash16 Mbits = 2 MB

DataFlash16 Mbits = 2 MB

Atmega32

memFlush( )

Page 130: Embedded System Overview

RockOn! 2008

130

Lesson 2: Flash Memory Overview

Page 131: Embedded System Overview

RockOn! 2008

131

Lesson 2: Flash Memory - Functions

- Upcoming Functions

write(unsigned char data)

memFlush( )

ISMPCheck( )

RSInit( )

Page 132: Embedded System Overview

RockOn! 2008

132

Lesson 2: Flash Memory - Functions

- Important Functions From Previous Lessoncbi(register, pin)sbi(register, pin) _delay_ms(time)

Page 133: Embedded System Overview

RockOn! 2008

133

Lesson 2: Flash Memory - Functions

- write(unsigned char data)

- Writes a byte of data to the memory buffer on the AVR

- Example: write(‘R’);

- NOTE: Calling write( ) DOES NOT write data to flash memory. It adds the data to the buffer, which can then be flushed to memory later

- Uses- Store sensor data for retrieval later

Page 134: Embedded System Overview

RockOn! 2008

134

Lesson 2: Flash Memory - Functions

- memFlush( )

- Writes a single byte of data from the memory buffer on the AVR to the external flash memory

- Example: memFlush( );

- NOTE: Every time you call write(), you must call memFlush()

Page 135: Embedded System Overview

RockOn! 2008

135

Lesson 2: Flash Memory - Functions

- ISMPCheck( )

- Checks if the data retrieval board has been connected to the AVR board

- Example: ISMPCheck( );

- If the board is connected, the data retrieval interface is activated, and data can be read from the external flash memory

- Should always be called at the beginning of a program that uses the flash memory

Page 136: Embedded System Overview

RockOn! 2008

136

Lesson 2: Flash Memory - Functions

- RSInit( )

- Initializes the systems on the AVR board

- Example: RSInit();

- Should always be called at the beginning of a program

Page 137: Embedded System Overview

RockOn! 2008

137

Lesson 2: Flash Memory

- Your Turn

-Remove led.c from the project by right-clicking led.c in the “Source Files” section and choosing “Remove File from Project”

-Add flash.c to the project using the same method as in Lesson 1

Page 138: Embedded System Overview

RockOn! 2008

138

Lesson 2: Flash Memory

- Make sure that the correct file has been opened, “flash.c”

NEED NEW PICTURE WITH DELAY INCLUDE LINE

Page 139: Embedded System Overview

RockOn! 2008

139

Lesson 2: Flash Memory

- Your Turn (continued)-Write code in flash.c to write your name to external flash

memory- Build your program and upload it to the AVR board

- Hints-Remember that write only allows for one byte of data

(one character) to be sent to the buffer at a time

-Remember that memFlush( ) only sends one byte of data to be sent to flash memory at a time

-We will use the LED code in Lesson 1 as well

Page 140: Embedded System Overview

RockOn! 2008

140

Lesson 2: Flash Memory - Code

RSInit( );ISMPCheck( );sbi(DDRD, 6);

write('R'); memFlush( );

write('i'); memFlush( );

write(‘l’);memFlush( );

Code is case

sensitive

Page 141: Embedded System Overview

RockOn! 2008

141

Lesson 2: Flash Memory - Code

write('e'); memFlush( );

write('y'); memFlush( );

cbi(PORTD, 6); _delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);

Page 142: Embedded System Overview

RockOn! 2008

142

Lesson 2: Flash Memory - Code

sbi(PORTD, 6); _delay_ms(2);

_delay_ms(2);_delay_ms(2); _delay_ms(2); _delay_ms(2);_delay_ms(2);

while (1);

Page 143: Embedded System Overview

RockOn! 2008

143

Lesson 2: Flash Memory

- Building Your Complete Code-Once code is written, you need to compile and link it to

make an executable file

-Click Build->Build (F7)

Page 144: Embedded System Overview

RockOn! 2008

144

Lesson 2: Flash Memory

- Connecting the AVR Board to the Computer

Page 145: Embedded System Overview

RockOn! 2008

145

Lesson 2: Flash Memory

- Connect the AVRISP to the programming header

- Disconnect the board from power during this procedure

Page 146: Embedded System Overview

RockOn! 2008

146

Lesson 2: Flash Memory

- Connect power to the AVR board before loading any code

- Install RBF jumper

- Install and activate G-Switch

Page 147: Embedded System Overview

RockOn! 2008

147

Lesson 2: Flash Memory

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 148: Embedded System Overview

RockOn! 2008

148

Lesson 2: Flash Memory

- Since all details for the STK500 have been formatted, they should not have to be done again

- Click “Program” in the FLASH section

- Your LED should flash and your name written to the flash memory…now what?

-Welcome to Lesson 3

Page 149: Embedded System Overview

RockOn! 2008

149

ENDLesson 2:Flash Memory

RockOn! 2008

Page 150: Embedded System Overview

RockOn! 2008

150

Lesson 3:Data Retrieval Utility

RockOn! 2008

Page 151: Embedded System Overview

RockOn! 2008

151

Lesson 3: Data Retrieval Utility

- Objectives

- Introduce the In System Memory Programming (ISMP) Utility (more commonly known as the Data Retrieval Utility)

-Use the Data Retrieval Utility to retrieve data from flash memory

Page 152: Embedded System Overview

RockOn! 2008

152

Lesson 3: Data Retrieval Utility

- Objectives

- Introduce the In System Memory Programming (ISMP) Utility (more commonly known as the Data Retrieval Utility)

-Use the Data Retrieval Utility to retrieve data from flash memory

Page 153: Embedded System Overview

RockOn! 2008

153

Lesson 3: Data Retrieval Utility

- Right now, your name is in flash memory.

- Question: How do you read that data back?

- Answer: In the Data Retrieval Utility

- Utility has four functions- Read Entire Memory- Erase Memory- Read Portion of Memory- Software Arming

Page 154: Embedded System Overview

RockOn! 2008

154

Lesson 3: Data Retrieval Utility

- In the “RockOn! Workshop” folder on the desktop, open the “RocketSat Utilities” folder

Page 155: Embedded System Overview

RockOn! 2008

155

Lesson 3: Data Retrieval Utility

- Inside, open the “Data Retrieval Utility” folder and open data_util.exe

Page 156: Embedded System Overview

RockOn! 2008

156

Lesson 3: Data Retrieval Utility

- If Windows asks if you want to run the program, click “Run”

Page 157: Embedded System Overview

RockOn! 2008

157

Lesson 3: Data Retrieval Utility

- Read Entire Memory-Allows user to read the entire

2 MB memory of the external flash

-Use- Select the serial port

location on your computer (COM1) and the name of a file in which the data should be stored- Click “Retrieve Data”

Page 158: Embedded System Overview

RockOn! 2008

158

Lesson 3: Data Retrieval Utility

- Read Portion of Memory-Allows user to read a portion of

the external flash memory

-Use- Select the serial port location

on your computer (COM1) and the name of a file in which the data should be stored- Select the start address in

memory (usually 0) and the length of the data segment- Click “Retrieve Data”

Page 159: Embedded System Overview

RockOn! 2008

159

Lesson 3: Data Retrieval Utility

- Erase Memory-Allows user to erase the

external flash memory

-Use- Select the serial port

location on your computer (COM1)- Click “Erase Memory”

Page 160: Embedded System Overview

RockOn! 2008

160

Lesson 3: Data Retrieval Utility

- Software Arming-Allows user to enable or disable

write protection on the memory- The green circle will blink in the

same pattern as the status LED on the AVR board

-Use- Select the serial port location

on your computer (COM1)- Click “Check Armed Status”- To change the status of the

payload, click “Arm Payload” or “Disarm Payload”

Page 161: Embedded System Overview

RockOn! 2008

161

Lesson 3: Data Retrieval Utility

- Your Turn-Open the Data Retrieval

Utility-Disconnect power from the

AVR board-Connect the data retrieval

board to the data header on the AVR board

-Note: Same orientation must be maintained when connecting to both boards

Page 162: Embedded System Overview

RockOn! 2008

162

Lesson 3: Data Retrieval Utility

Page 163: Embedded System Overview

RockOn! 2008

163

Lesson 3: Data Retrieval Utility

- Connect the board to the computer using the data retrieval header, a serial cable, and the USB to Serial adapter

Page 164: Embedded System Overview

RockOn! 2008

164

Lesson 3: Data Retrieval Utility

Page 165: Embedded System Overview

RockOn! 2008

165

Lesson 3: Data Retrieval Utility

- Once all connections are completed, connect power to the AVR board

-Make sure RBF jumper is installed and activate G-Switch

- Does your LED blink? Why or why not?

- Power to the AVR board is required during usage of the RocketSat utilities

Page 166: Embedded System Overview

RockOn! 2008

166

Lesson 3: Data Retrieval Utility

- Verify Keyspan USB to Serial comm port as we did in Lesson 0

Page 167: Embedded System Overview

RockOn! 2008

167

Lesson 3: Data Retrieval Utility

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the “Check Armed Status” button of the correct COM port

-You want the green LED to flash for a successful connection

- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 168: Embedded System Overview

RockOn! 2008

168

Lesson 3: Data Retrieval Utility

- On the Data Retrieval Utility, select the “Read Portion of Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Less_3_Kit_XX.txt- Use a start address of 0 and a

length of 100-Click “Retrieve Data”

Page 169: Embedded System Overview

RockOn! 2008

169

Lesson 3: Data Retrieval Utility

-When the read operation is complete, open the output file and make sure that the name that you wrote to memory is at the beginning of the file

- Name more than once means payload activated more than once and extra characters after name is fine

Page 170: Embedded System Overview

RockOn! 2008

170

Lesson 3: Data Retrieval Utility

- Once data has been retrieved successfully, clear out memory by using the “Erase Memory” tab of the Data Retrieval Utility

- Select the Correct COM port-Click “Erase Memory”

- This will take ~13 seconds

Page 171: Embedded System Overview

RockOn! 2008

171

Lesson 3: Data Retrieval Utility

- To check if the memory erase was successful, complete the exact same process with the “Read Portion of Memory” tab as was done earlier.

- Data file should be Less_3b_KIT_XX.txt

-Click “Retrieve Data”-Open new and name

should be erased

Page 172: Embedded System Overview

RockOn! 2008

172

Lesson 3: Data Retrieval Utility

- Disconnect power from the AVR board

- Disconnect Data Retrieval Header from AVR board

- Prepare for Lesson 4

Page 173: Embedded System Overview

RockOn! 2008

173

ENDLesson 3:

Data Retrieval Utility

RockOn! 2008

Page 174: Embedded System Overview

RockOn! 2008

174

Lesson 4:Analog to Digital

Converter

RockOn! 2008

Page 175: Embedded System Overview

RockOn! 2008

175

Lesson 4: Analog to Digital Converter

- Objectives

- Learn to use the AVR’s internal analog to digital converters (ADCs)

- Learn to read 8-bit and 10-bit conversions and write them to memory

Page 176: Embedded System Overview

RockOn! 2008

176

Lesson 4: Analog to Digital Converter

- Objectives

- Learn to use the AVR’s internal analog to digital converters (ADCs)

- Learn to read 8-bit and 10-bit conversions and write them to memory

Page 177: Embedded System Overview

RockOn! 2008

177

Lesson 4: Analog to Digital Converter

-What is the difference between 8-bit and 10-bit conversions?

-An 8-bit conversion has 28 (0 to 255) possible values,

-Resolution is 1/(28 – 1) = 1/255 = 0.00392 V

Page 178: Embedded System Overview

RockOn! 2008

178

Lesson 4: Analog to Digital Converter

- A 10-bit conversion has 210 (0 to 1024) possible values

-Resolution is 1/(210 – 1) = 1/1023 = 0.000978 V

- For a device that is very precise, a 10-bit conversion allows for a higher resolution on the data (high-range accelerometers)

Page 179: Embedded System Overview

RockOn! 2008

179

Lesson 4: Analog to Digital Converter - Functions

- Upcoming Functions

adcGetChar(unsigned char ch)

adcGet16(unsigned char ch)

write16(unsigned short data)

Page 180: Embedded System Overview

RockOn! 2008

180

Lesson 4: Analog to Digital Converter - Functions

- Important Functions From Previous Lessonscbi(register, pin)sbi(register, pin)_delay_ms(time)write(unsigned char data)memFlush( )ISMPCheck()RSInit

Page 181: Embedded System Overview

RockOn! 2008

181

Lesson 4: Analog to Digital Converter - Functions

- adcGetChar(unsigned char ch)

-Reads an 8-bit conversion from the internal ADC on the channel given by ch-Returns an unsigned char

- Example: unsigned char value = adcGetChar(ACCEL_X_HIGH);

- Each sensor connected to the AVR has its own channel- The header file adc.h defines values that can be used for ch

Page 182: Embedded System Overview

RockOn! 2008

182

Lesson 4: Analog to Digital Converter - Functions

- adcGet16(unsigned char ch)

-Reads a 10-bit conversion from the internal ADC on the channel given by ch-Returns an unsigned short (16 bits) with the lower 6 bits

set as 0

- Example: unsigned short value = adcGet16(ACCEL_X_HIGH);

- The same values can be used for ch as is used in adcGetChar( )

Page 183: Embedded System Overview

RockOn! 2008

183

Lesson 4: Analog to Digital Converter - Functions

- write16(unsigned short data)

-Writes a 16-bit value to the memory buffer

- Example: write16(adcGet16(ACCEL_X_HIGH))

-Can be used to send 10-bit conversions to the memory buffer

-NOTE: memFlush( ) must be called TWICE when write16( ) is used, as two bytes must be sent to flash memory

Page 184: Embedded System Overview

RockOn! 2008

184

Lesson 4: Analog to Digital Converter

- Your turn-Remove flash.c from the project and add analog.c

Page 185: Embedded System Overview

RockOn! 2008

185

Lesson 4: Analog to Digital Converter

-Write code in analog.c that constantly samples all 8 sensors on the board and writes those values to memory

- Hints

- To write an analog sample to memory, you can do one of two things

1.unsigned char temp;temp = adcGetChar(ACCEL_X_HIGH);write(temp)

2.write(adcGetChar(ACCEL_X_HIGH));

Page 186: Embedded System Overview

RockOn! 2008

186

Lesson 4: Analog to Digital Converter

- Hints

- To write an analog sample to memory, you can do one of two things

1. unsigned char temp;temp = adcGetChar(ACCEL_X_HIGH);write(temp)

2. write(adcGetChar(ACCEL_X_HIGH));

Page 187: Embedded System Overview

RockOn! 2008

187

Lesson 4: Analog to Digital Converter - Code

RSInit( );ISMPCheck( );sbi(DDRD, 6);

while (1) {

write(adcGetChar(ACCEL_X_LOW)); memFlush( );

write(adcGetChar(ACCEL_Y_LOW)); memFlush( );

write(adcGetChar(ACCEL_Z_LOW));memFlush( );

Page 188: Embedded System Overview

RockOn! 2008

188

Lesson 4: Analog to Digital Converter - Code

write(adcGetChar(ACCEL_X_HIGH)); memFlush( );

write(adcGetChar(ACCEL_Y_HIGH)); memFlush( );write(adcGetChar(ACCEL_Z_HIGH)); memFlush( );

write(adcGetChar(TEMP)); memFlush( );

write(adcGetChar(PRESSURE));memFlush( );

Page 189: Embedded System Overview

RockOn! 2008

189

Lesson 4: Analog to Digital Converter - Code

cbi(PORTD, 6); _delay_ms(2); _delay_ms(2); _delay_ms(2);_delay_ms(2);

sbi(PORTD, 6); _delay_ms(2);_delay_ms(2);_delay_ms(2);_delay_ms(2);

}

}

Page 190: Embedded System Overview

RockOn! 2008

190

Lesson 4: Analog to Digital Converter

- Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 191: Embedded System Overview

RockOn! 2008

191

Lesson 4: Analog to Digital Converter

- Connecting the AVR Board to the Computer

Page 192: Embedded System Overview

RockOn! 2008

192

Lesson 4: Analog to Digital Converter

- Connect the AVRISP to the programming header

- Disconnect the board from power during this procedure

Page 193: Embedded System Overview

RockOn! 2008

193

- Connect power to the AVR board before loading any code

- Install RBF jumper

- Install and activate G-Switch

Lesson 4: Analog to Digital Converter

Page 194: Embedded System Overview

RockOn! 2008

194

Lesson 4: Analog to Digital Converter

- Give power to the AVR Board before loading any code

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 195: Embedded System Overview

RockOn! 2008

195

Lesson 4: Analog to Digital Converter

- Since all details for the STK500 have been formatted, they should not have to be done again

- Click “Program” in the FLASH section

- Let program run for a minute or two

- Disconnect power from AVR Board

Page 196: Embedded System Overview

RockOn! 2008

196

Lesson 4: Analog to Digital Converter

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 197: Embedded System Overview

RockOn! 2008

197

Lesson 4: Analog to Digital Converter

- Connect the board to the computer using the data retrieval header, a serial cable, and the USB to Serial adapter

Page 198: Embedded System Overview

RockOn! 2008

198

Lesson 4: Analog to Digital Converter

Page 199: Embedded System Overview

RockOn! 2008

199

Lesson 4: Analog to Digital Converter

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Page 200: Embedded System Overview

RockOn! 2008

200

Lesson 4: Analog to Digital Converter

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the check armed status button of the correct COM port

-You want the green LED to flash for a successful connection- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 201: Embedded System Overview

RockOn! 2008

201

Lesson 4: Analog to Digital Converter

- Read the data off of the external flash using the data retrieval board and Data Retrieval Utility and save it into a file

- choose an appropriately large address length to be able to gather sufficient data

Page 202: Embedded System Overview

RockOn! 2008

202

- On the Data Retrieval Utility, select the “Read Portion of Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Less_4_Kit_XX.txt- Use a start address of 0 and a

length of 10,000-Click “Retrieve Data”

Lesson 4: Analog to Digital Converter

Page 203: Embedded System Overview

RockOn! 2008

203

Lesson 4: Analog to Digital Converter

- Disconnect power from the AVR Board

- Leave Data Retrieval Connector attached for to the board

- If you have the time…

- Implement functions from previous lessons into this one to make the program code more efficient

- Implement an LED design that works in a more beneficial manner

Page 204: Embedded System Overview

RockOn! 2008

204

ENDLesson 4:

Analog to Digital Converter

RockOn! 2008

Page 205: Embedded System Overview

RockOn! 2008

205

Lesson 5:Data Parser Utility

RockOn! 2008

Page 206: Embedded System Overview

RockOn! 2008

206

Lesson 5: Data Parser Utility

- Objectives

-Modify the data in order to analyze it properly

- Learn how to use the Data Parser Utility

- Learn how to convert voltages to proper units

Page 207: Embedded System Overview

RockOn! 2008

207

Lesson 5: Data Parser Utility

- Objectives

-Modify the data in order to analyze it properly

- Learn how to use the Data Parser Utility

- Learn how to convert voltages to proper units

Page 208: Embedded System Overview

RockOn! 2008

208

Lesson 5: Data Parser Utility

- Open the data file on Desktop from the previous exerciseLess_4_Kit_XX.txt

- Can anyone tell me what these random characters actually mean?

- Problem: the data that we read is in binary, but our sensors output voltages

- Solution: parse the data file and convert back to voltages from binary

Page 209: Embedded System Overview

RockOn! 2008

209

Lesson 5: Data Parser Utility

- In the RocketSat Utilities folder, open the Data Parser Utility folder

- Run parser_util.exe (NOT Parser.exe)

Page 210: Embedded System Overview

RockOn! 2008

210

Lesson 5: Data Parser Utility

- This is the RocketSat Parser Utility that we will be using for this lesson.

Page 211: Embedded System Overview

RockOn! 2008

211

Lesson 5: Data Parser Utility

- In the “Data File” field, enter the name of the file from the last exercise Less_4_Kit_XX.txt- This is the file to be parsed

- In the “Output File” field, enter a filename with .csv as the ending- Less_4_Kit_XX.csv

Page 212: Embedded System Overview

RockOn! 2008

212

Lesson 5: Data Parser Utility

-Make sure that both of the boxes are checked

- The first one toggles whether the output file is opened once parsing is complete

- The second box ensures that the output file is compatible with Microsoft Excel

Page 213: Embedded System Overview

RockOn! 2008

213

Lesson 5: Data Parser Utility

- In the “Number of Columns” field, enter the number of sensors or inputs in the data file

- In this case, 8 sensors were read, so enter 8

- Press “Apply”

Page 214: Embedded System Overview

RockOn! 2008

214

Lesson 5: Data Parser Utility

- For each sensor (in the order you sampled them in your code)

-Name the sensor

- Enter the number of bytes per sample

-Check the box if the data is a count, not a voltage

- In this case, DO NOT check the boxes, as these values represent voltages

Page 215: Embedded System Overview

RockOn! 2008

215

Lesson 5: Data Parser Utility

- Press “Parse Data”-A black console window

should appear

- This is the actual parser process, DO NOT close the window, it will close on its own

-When the parsing is finished, wait for the output file to open in Excel

Page 216: Embedded System Overview

RockOn! 2008

216

Lesson 5: Data Parser Utility

- Excel should open something like this.

- The data shown in the spreadsheet is the voltage seen by the sensors each time they were sampled

- To do a more successful analysis of the spreadsheet, you can use the graphing program in excel to graph from 1 to all of your columns.

Page 217: Embedded System Overview

RockOn! 2008

217

Lesson 5: Data Parser Utility

- Highlight the rows that you wish to graph or compare.

- Click on a cell, and drag mouse until satisfied with selection of cells

- Select the Chart Wizard button on the Standard toolbar.

Page 218: Embedded System Overview

RockOn! 2008

218

Lesson 5: Data Parser Utility

- The Chart Wizard should show up.- Select the chart type

(Scatter with line-connected data points is recommended)

- To see a sample, click the Press and Hold button.

-Once satisfied, click Next

- For now, skip steps 2 and 3, which is mostly about labeling details on the graph, by pressing “Next” repetitively.

Page 219: Embedded System Overview

RockOn! 2008

219

Lesson 5: Data Parser Utility

- In step 4, select to place the chart ‘As new sheet:’ Name it whatever you like.

-When done, click Finish.

Page 220: Embedded System Overview

RockOn! 2008

220

Lesson 5: Data Parser Utility

- Your graph will now display in a new sheet of the excel notebook

Page 221: Embedded System Overview

RockOn! 2008

221

Lesson 5: Data Parser Utility

- Once the data has been properly collected and parsed, memory should be erased in order to prepare for the next memory write code

-Make sure that the serial connection between the AVR board, Data Retrieval Board, and computer is correctly connected

Page 222: Embedded System Overview

RockOn! 2008

222

Lesson 5: Data Parser Utility

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 223: Embedded System Overview

RockOn! 2008

223

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 5: Data Parser Utility

Page 224: Embedded System Overview

RockOn! 2008

224

Lesson 5: Data Parser Utility

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the check armed status button of the correct COM port

-You want the green LED to flash for a successful connection

- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 225: Embedded System Overview

RockOn! 2008

225

Lesson 5: Data Parser Utility

- Once connection verified, clear out memory by using the “Erase Memory” tab of the Data Retrieval Utility

- Select the Correct COM port

-Click “Erase Memory”

- Disconnect power but leave Data Retrieval Connector attached

Page 226: Embedded System Overview

RockOn! 2008

226

Lesson 5: Data Parser Utility

- Let’s try this again with 10 bit samples

- The high-range accelerometers can sense loads up to 35 g, which means that an acceleration of 1 g will cause a very low change in voltage

- The temperature and pressure sensors are also very sensitive

- To get better precision out of these devices, change your sampling code to take 10-bit samples from these devices

Page 227: Embedded System Overview

RockOn! 2008

227

Lesson 5: Data Parser Utility

- Hints-Don’t forget to call memFlush( ) twice for each

write16( ) call you make

-Remember that write() should be used with adcGetChar( ) and write16() should be used with adcGet16( )

- Try adding in a column in order to compare a 10-bit and an 8-bit set of data.

Page 228: Embedded System Overview

RockOn! 2008

228

Lesson 5: Data Parser Utility - Code

RSInit( );ISMPCheck( );sbi(DDRD, 6);

while (1) {

write16(adcGet16(ACCEL_X_LOW)); memFlush( );memFlush( );

write16(adcGet16(ACCEL_Y_LOW)); memFlush( ); memFlush( );

Page 229: Embedded System Overview

RockOn! 2008

229

Lesson 5: Data Parser Utility - Code

write16(adcGet16(ACCEL_Z_LOW));memFlush( );memFlush( );

write16(adcGet16(ACCEL_X_HIGH)); memFlush( );memFlush( );

write16(adcGet16(ACCEL_Y_HIGH)); memFlush( );memFlush( );

write16(adcGet16(ACCEL_Z_HIGH)); memFlush( ); memFlush( );

Page 230: Embedded System Overview

RockOn! 2008

230

Lesson 5: Data Parser Utility - Code

write16(adcGet16(TEMP)); memFlush( );memFlush( );

write16(adcGet16(PRESSURE));memFlush( );memFlush( );

cbi(PORTD, 6); _delay_ms(2); _delay_ms(2); _delay_ms(2); _delay_ms(2); _delay_ms(2); _delay_ms(2);

Page 231: Embedded System Overview

RockOn! 2008

231

Lesson 5: Data Parser Utility - Code

sbi(PORTD, 6); _delay_ms(2); _delay_ms(2);_delay_ms(2);_delay_ms(2); _delay_ms(2);_delay_ms(2);

}}

Page 232: Embedded System Overview

RockOn! 2008

232

Lesson 5: Data Parser Utility

- Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 233: Embedded System Overview

RockOn! 2008

233

Lesson 5: Data Parser Utility

-Connect the AVRISP to the programming header

-Disconnect the board from power during this procedure

Page 234: Embedded System Overview

RockOn! 2008

234

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

- Is your code running?

- Why?

Lesson 5: Data Parser Utility

Page 235: Embedded System Overview

RockOn! 2008

235

Lesson 5: Data Parser Utility

- Give power to the AVR Board before loading any code

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 236: Embedded System Overview

RockOn! 2008

236

Lesson 5: Data Parser Utility

- Click “Program” in the FLASH section

- Disconnect power and Data Retrieval Connector from AVR Board

- Connect power and activate G-Switch

- Let program run for a minute

- Disconnect power

Page 237: Embedded System Overview

RockOn! 2008

237

Lesson 5: Data Parser Utility

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 238: Embedded System Overview

RockOn! 2008

238

Lesson 5: Data Parser Utility

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 239: Embedded System Overview

RockOn! 2008

239

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 5: Data Parser Utility

Page 240: Embedded System Overview

RockOn! 2008

240

Lesson 5: Data Parser Utility

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the check armed status button of the correct COM port

-You want the green LED to flash for a successful connection

- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 241: Embedded System Overview

RockOn! 2008

241

- On the Data Retrieval Utility, select the “Read Portion of Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Less_5_Kit_XX.txt- Use a start address of 0 and a

length of 10,000-Click “Retrieve Data”

Lesson 4: Analog to Digital Converter

Page 242: Embedded System Overview

RockOn! 2008

242

Lesson 5: Data Parser Utility

- In the RocketSat Utilities folder, open the Data Parser Utility folder

- Run parser_util.exe (NOT Parser.exe)

Page 243: Embedded System Overview

RockOn! 2008

243

Lesson 5: Data Parser Utility

- In the “Data File” field, enter the name of the file from the last exercise Less_5_Kit_XX.txt- This is the file to be parsed

- In the “Output File” field, enter a filename with .csv as the ending- Less_5_Kit_XX.csv

Page 244: Embedded System Overview

RockOn! 2008

244

Lesson 5: Data Parser Utility

-Make sure that both of the boxes are checked

- The first one toggles whether the output file is opened once parsing is complete

- The second box ensures that the output file is compatible with Microsoft Excel

Page 245: Embedded System Overview

RockOn! 2008

245

Lesson 5: Data Parser Utility

- In the “Number of Columns” field, enter the number of sensors or inputs in the data file

- In this case, 8 sensors were read, so enter 8

- Press “Apply”

Page 246: Embedded System Overview

RockOn! 2008

246

Lesson 5: Data Parser Utility

- For each sensor (in the order you sampled them in your code)

-Name the sensor

- Enter the number of bytes per sample (in this case 2)

-Check the box if the data is a count, not a voltage

- In this case, DO NOT check the boxes, as these values represent voltages

Page 247: Embedded System Overview

RockOn! 2008

247

Lesson 5: Data Parser Utility

- Press “Parse Data”-A black console window

should appear

- This is the actual parser process, DO NOT close the window, it will close on its own

-When the parsing is finished, wait for the output file to open in Excel

Page 248: Embedded System Overview

RockOn! 2008

248

Lesson 5: Data Parser Utility

- Excel should open something like this.

- The data shown in the spreadsheet is the voltage seen by the sensors each time they were sampled

- To do a more successful analysis of the spreadsheet, you can use the graphing program in excel to graph from 1 to all of your columns.

Page 249: Embedded System Overview

RockOn! 2008

249

Lesson 5: Data Parser Utility

- Create graphs like you did previously to compare results.

- Here is a sample of ACCEL Y LOW (8 bit) and ACCEL Y LOW (10 bit)

2.38

2.39

2.4

2.41

2.42

2.43

2.44

2.45

2.46

2.47

2.48

0 20 40 60 80 100 120 140

Y Low (10)

Y Low (8)

Page 250: Embedded System Overview

RockOn! 2008

250

Lesson 5: Data Parser Utility

- Clear out memory by using the “Erase Memory” tab of the Data Retrieval Utility

- Select the Correct COM port

-Click “Erase Memory”

- Disconnect power but leave Data Retrieval Connector attached

Page 251: Embedded System Overview

RockOn! 2008

Converting Data

RockOn! 2008

Page 252: Embedded System Overview

RockOn! 2008

Converting Data - Overview

- You now have voltage data for each sensor.

- The next step is figuring out how to convert the voltages into useful units.

- Each type of sensor comes with a detailed datasheet filled with useful information, including how to convert the data.

- The datasheets for all the sensors are in the manual.

- If you are interested, the datasheets for the other integrated circuits used on the payload are available on the DVD.

Page 253: Embedded System Overview

RockOn! 2008

Converting Data - Overview

- You now have voltage data for each sensor.

- The next step is figuring out how to convert the voltages into useful units.

- Each type of sensor comes with a detailed datasheet filled with useful information, including how to convert the data.

- The datasheets for all the sensors are in the manual.

- If you are interested, the datasheets for the other integrated circuits used on the payload are available on the DVD.

Page 254: Embedded System Overview

RockOn! 2008

Converting Data - Process

- All the sensors are proportional to the actual value, but have an offset – that is, you can use a linear equation to convert from units to voltage.

- Each sensor can be characterized by its sensitivity and its zero output offset: VOUT = sensitivity * X + offset, where X is data in the appropriate units for the sensor in question.

- We want the converted data X in terms of VOUT, so we solve the equation for X as follows:

VOUT = sensitivity * X + offset

VOUT - offset = sensitivity * X

(VOUT - offset) / sensitivity = X

X = (1/sensitivity) * VOUT – (offset/sensitivity)

Page 255: Embedded System Overview

RockOn! 2008

Converting Data – Temperature Sensor 1

- Open the datasheet for the LM50c temperature sensor.

- The front page gives an overview of the sensor. Scan through the datasheet to see what other information it has, including detailed electronic and mechanical information.

Page 256: Embedded System Overview

RockOn! 2008

Converting Data – Temperature Sensor 2

- Scroll down to page 2, where you will see the image below, along with an equation which gives output voltage in terms of temperature: VOUT = 10mV/ °C * Temp °C + 500mV

- Notice that the sensitivity of the device is 10mV/C, while the zero temperature offset is 500mV.

Page 257: Embedded System Overview

RockOn! 2008

Converting Data – Temperature Sensor 3

- Solve the equation for temperature in terms of voltage. Be careful of units. The final equation should use volts rather than millivolts.

1.) 1000 mV = 1 V

2.) VOUT = 0.01 V/ °C * Temp °C + 0.5 V

3.) Temp °C/ (V / 100 °C) = VOUT – 0.5 V

4.) Temp °C = 100*(°C / V)* VOUT – 50 °C

Page 258: Embedded System Overview

RockOn! 2008

Converting Data – Pressure Sensor 1

- Open the datasheet for the ASDX015 pressure sensor.

- Notice that unlike the temperature sensor, this datasheet is for a whole series of pressure sensors.

-We use the ASDX015, which can measure pressures between 0PSI and 15PSI.

Page 259: Embedded System Overview

RockOn! 2008

Converting Data – Pressure Sensor 2

- Scroll down to page 3, where you will see these tables.

- Locate the sensitivity and zero pressure offset of the ASDX015

VOUT = 0.267*(V/PSI)*Press. + 0.5 V

Page 260: Embedded System Overview

RockOn! 2008

Converting Data – Pressure Sensor 3

- Solve the equation for pressure in terms of voltage.

1.) VOUT = 0.267*(V/PSI)*Press. + 0.5 V

2.) VOUT - 0.5 V = 0.267*(V/PSI)*Press.

3.) Pressure = 3.75*(PSI/V)*VOUT - 1.87 PSI

Page 261: Embedded System Overview

RockOn! 2008

Converting Data – Low Range Accelerometers 1

- Open the datasheet for the ADXL103/ADXL203 single/dual axis precision (low range) accelerometers.

- Notice the functional block diagram on the front page. Block diagrams are useful for understanding the basics behind a system without the overwhelming detail of a full schematic.

Page 262: Embedded System Overview

RockOn! 2008

Converting Data – Low Range Accelerometers 2

- Scroll down to the specifications table on page 3.

- Locate the sensitivity and the 0g offset, which is called the “0g Voltage at XOUT, YOUT” in this datasheet.

VOUT = 1*(V/g)*acc. + 2.5 V

1.0 V/g

2.5 V

Page 263: Embedded System Overview

RockOn! 2008

Converting Data – Low Range Accelerometers 2

- Solve the equation for g’s in terms of voltage.

1.) VOUT = 1*(V/g)*acc. + 2.5 V

2.) VOUT - 2.5 V = (V/g)*acc.

3.) Acceleration = VOUT *g – 2.5*g

Page 264: Embedded System Overview

RockOn! 2008

Converting Data – High Range Accelerometers 1

- Open the datasheets for the ADXL78 single axis high range accelerometer and the ADXL278 dual axis high range accelerometer.

- Notice that they are almost identical. If you want, you can look at a few pages to confirm that.

- The conversion is the same, so we will just use the ADXL78 datasheet. Again, you can cross-check with the ADXL278 datasheet to be sure.

Page 265: Embedded System Overview

RockOn! 2008

Converting Data – High Range Accelerometers 2

- Scroll down to the specifications table on page 3.

-We use the AD22279.

- Find the sensitivity, which determines how the output voltage changes based on acceleration.

- For some reason, the zero-g offset is omitted from this page.

55 mV/g

Page 266: Embedded System Overview

RockOn! 2008

Converting Data – High Range Accelerometers 3

- Scroll down to this chart on page 6. It shows the theory of how the accelerometers work.

- It also shows the output voltage at 0g (the zero-g offset)

VOUT = 55*(mV/g)*acc. + 2.5 V

Page 267: Embedded System Overview

RockOn! 2008

- Solve the equation for acceleration in terms of voltage. Be careful of units. The final equation should use volts rather than millivolts.

1.) 1000 mV = 1 V

2.) VOUT = 0.055*(V/g)*acc. + 2.5 V

3.) VOUT – 2.5 V = 0.055*(V/g)*acc.

4.) Acceleration = 18.18*(g/V)*VOUT – 45.45 g

Converting Data – High Range Accelerometers 3

Page 268: Embedded System Overview

RockOn! 2008

268

ENDLesson 5:

Data Parser Utility

RockOn! 2008

Page 269: Embedded System Overview

RockOn! 2008

269

Lesson 6:Geiger Counter

RockOn! 2008

Page 270: Embedded System Overview

RockOn! 2008

270

Lesson 6: Geiger Counter

- Objectives

- Learn to read the number of counts detected by the Geiger counter

Page 271: Embedded System Overview

RockOn! 2008

271

Lesson 6: Geiger Counter

- Objectives

- Learn to read the number of counts detected by the Geiger counter

Page 272: Embedded System Overview

RockOn! 2008

272

Lesson 6: Geiger Counter - Functions

- Upcoming Functions

getEXTo( )

setEXTo(unsigned char val)

Page 273: Embedded System Overview

RockOn! 2008

273

Lesson 6: Geiger Counter - Functions

-Important Functions From Previous Lessonscbi(register, pin)sbi(register, pin)_delay_ms(time)write(unsigned char data)memFlush( )ISMPCheck()RSInitadcGetChar(unsigned char ch)adcGet16(unsigned char ch)write16(unsigned short data)

Page 274: Embedded System Overview

RockOn! 2008

274

Lesson 6: Geiger Counter - Functions

- getEXT0( )

-Get the number of counts seen by the Geiger counter-Returns an unsigned char

- Example: getEXT0( );

-NOTE: The number of counts is stored in a single byte, so no more than 255 counts can be seen at a time

- It is important to clear the counts every time they are read with the next function

Page 275: Embedded System Overview

RockOn! 2008

275

Lesson 6: Geiger Counter - Functions

- setEXT0(unsigned char val)

- Sets the number of Geiger counts in memory

- Example: setEXT0(0);

- In most cases, this function will be used to clear the Geiger counts by passing 0 into the function

Page 276: Embedded System Overview

RockOn! 2008

276

Lesson 6: Geiger Counter

- Your Turn-Remove analog.c from the project and add geiger.c

Page 277: Embedded System Overview

RockOn! 2008

277

Lesson 6: Geiger Counter

-Write a program that continuously reads the Geiger counts and delays at least 1 ms between samples

- Hints-Don’t forget to clear the Geiger counts between reads

-Data Retrieval Connector should still be connected

Page 278: Embedded System Overview

RockOn! 2008

278

Lesson 6: Geiger Counter - Code

RSInit( );ISMPCheck( ); sbi(DDRD, 6);

while (1){

write(getEXT0( )); memFlush( );

setEXT0(0);

cbi(PORTD, 6); _delay_ms(2); _delay_ms(2);

Page 279: Embedded System Overview

RockOn! 2008

279

Lesson 6: Geiger Counter - Code

_delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);

sbi(PORTD, 6); _delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);_delay_ms(2); _delay_ms(2);

}}

Page 280: Embedded System Overview

RockOn! 2008

280

Lesson 6: Geiger Counter

- Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 281: Embedded System Overview

RockOn! 2008

281

Lesson 6: Geiger Counter

- Connect the AVRISP to the programming header

- Disconnect the board from power during this procedure

- Data Retrieval Connector should still be connected

Page 282: Embedded System Overview

RockOn! 2008

282

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 5: Data Parser Utility

Page 283: Embedded System Overview

RockOn! 2008

283

Lesson 6: Geiger Counter

- Give power to the AVR Board before loading any code

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 284: Embedded System Overview

RockOn! 2008

284

Lesson 6: Geiger Counter

- Click “Program” in the FLASH section

- Disconnect power and Data Retrieval Connector

- Connect power and activate G-Switch

- Let program run for a minute (use your radiation source)

- Disconnect power

Page 285: Embedded System Overview

RockOn! 2008

285

Lesson 6: Geiger Counter

-While running your code on the AVR board, bring a radiation source close to the Geiger counter and notice that the LED blinks rapidly

Page 286: Embedded System Overview

RockOn! 2008

286

Lesson 6: Geiger Counter

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 287: Embedded System Overview

RockOn! 2008

287

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 6: Geiger Counter

Page 288: Embedded System Overview

RockOn! 2008

288

Lesson 6: Geiger Counter

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the check armed status button of the correct COM port

-You want the green LED to flash for a successful connection

- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 289: Embedded System Overview

RockOn! 2008

289

- On the Data Retrieval Utility, select the “Read Portion of Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Less_6_Kit_XX.txt- Use a start address of 0 and a

length of 10,000-Click “Retrieve Data”

Lesson 6: Geiger Counter

Page 290: Embedded System Overview

RockOn! 2008

290

- Run parser_util.exe (NOT Parser.exe)

- Use the Data Parser Utility to convert your results to counts

- Note that you should only have 1 column this time

-Make sure that the check box in the count column is checked

Lesson 6: Geiger Counter

Page 291: Embedded System Overview

RockOn! 2008

291

Lesson 5: Data Parser Utility

- In the “Data File” field, enter the name of the file from the last exercise Less_6_Kit_XX.txt- This is the file to be parsed

- In the “Output File” field, enter a filename with .csv as the ending- Less_6_Kit_XX.csv

Page 292: Embedded System Overview

RockOn! 2008

292

Lesson 6: Geiger Counter

-Make sure that both of the boxes are checked

- The first one toggles whether the output file is opened once parsing is complete

- The second box ensures that the output file is compatible with Microsoft Excel

Page 293: Embedded System Overview

RockOn! 2008

293

Lesson 6: Geiger Counter

- In the “Number of Columns” field, enter the number of sensors or inputs in the data file

- In this case, 1 sensor was read, the Geiger Counter

- Press “Apply”

Page 294: Embedded System Overview

RockOn! 2008

294

Lesson 6: Geiger Counter

- For the sensor

-Name the sensor

- Enter the number of bytes per sample (1 byte)

-Check the box since the data is a count and NOT a voltage

Page 295: Embedded System Overview

RockOn! 2008

295

Lesson 6: Geiger Counter

- Press “Parse Data”-A black console window

should appear

- This is the actual parser process, DO NOT close the window, it will close on its own

-When the parsing is finished, wait for the output file to open

Page 296: Embedded System Overview

RockOn! 2008

296

Lesson 6: Geiger Counter

- Excel should open something like this

- Numbers will vary, depending on how the radiation source was used near the Geiger counter.

- Highlight the rows that you wish to graph or compare.

- Do not include cells that have 255

Page 297: Embedded System Overview

RockOn! 2008

297

Lesson 6: Geiger Counter

- The Chart Wizard should show up.

- Select the chart type (Scatter with line-connected data points is recommended)

- To see a sample, click the Press and Hold button.

-Once satisfied, click Next

Page 298: Embedded System Overview

RockOn! 2008

298

Lesson 6: Geiger Counter

- In step 4, select to place the chart ‘As new sheet:’ Name it whatever you like.-When done, click Finish.

Page 299: Embedded System Overview

RockOn! 2008

299

Lesson 6: Geiger Counter

-Your graph will now display in a new sheet of the excel notebook

Geiger

0

2

4

6

8

10

12

0 50 100 150 200 250 300

Geiger

Page 300: Embedded System Overview

RockOn! 2008

300

Lesson 6: Geiger Counter

- Once finished with lesson 6, clear out memory by using the “Erase Memory” tab of the Data Retrieval Utility

- Select the Correct COM port

-Click “Erase Memory”

- Disconnect power but leave the Data Retrieval Connector attached

Page 301: Embedded System Overview

RockOn! 2008

301

ENDLesson 6:Geiger Counter

RockOn! 2008

Page 302: Embedded System Overview

RockOn! 2008

302

Lesson 7:Timers

RockOn! 2008

Page 303: Embedded System Overview

RockOn! 2008

303

Lesson 7: Timers

- Objectives

- Learn how to use the AVR’s internal timers to perform tasks periodically

-Use the timers to sample sensors

Page 304: Embedded System Overview

RockOn! 2008

304

Lesson 7: Timers

- Objectives

- Learn how to use the AVR’s internal timers to perform tasks periodically

-Use the timers to sample sensors

Page 305: Embedded System Overview

RockOn! 2008

305

Lesson 7: Timers

- A timer is a device on the AVR that counts clock ticks and calls a function when that count reaches a value set in the Output Compare Register (OCR)

- The clock can also be divided by a prescale value before it is counted- Example: If a prescale of 64 is used, then 64 ticks of the

clock are a single count in the timer

- Allows a function to be called periodically at exact time intervals

Page 306: Embedded System Overview

RockOn! 2008

306

Lesson 7: Timers

- On this AVR, there are three timers- Timers 0 and 2 have 8-bit OCR registers, which means

they can count up to 255- Timer 1 has a 16-bit OCR register, so it can count up to

216 – 1 = 65,535

- For this project, we will be using timer 0

- All timer 0 functions have corresponding timer 1 and timer 2 functions that can be used in the same manner

Page 307: Embedded System Overview

RockOn! 2008

307

Lesson 7: Timers - Functions

- Upcoming Functions

setTimero(unsigned char ocr, prescale))

setTimeroFunction(func)

startTimero()

Page 308: Embedded System Overview

RockOn! 2008

308

Lesson 7: Timers - Functions

- Important Functions From Previous Lessons

cbi(register, pin) adcGet16(unsigned char ch)

sbi(register, pin) write16(unsigned short data)

_delay_ms(time) getEXTo()

write(unsigned char data) setEXTo(unsigned char val)

memFlush( )

ISMPCheck()

RSInit

adcGetChar(unsigned char ch)

Page 309: Embedded System Overview

RockOn! 2008

309

Lesson 7: Timers - Functions

- setTimer0(unsigned char ocr, prescale)

- Sets the OCR and prescale values for timer0-Uses defined values for prescale- Prescale values are limited to specific values in

hardware

- Example: setTimer0(78, TIMER0_DIV1024)

- Sets timer 0 to “go off” after it counts 78*1024 ticks of the clock

Page 310: Embedded System Overview

RockOn! 2008

310

Lesson 7: Timers - Functions

- setTimer0Function(func)

- Tells timer 0 to call func whenever it counts up to the value in the OCR register

- Example: void myFunc(void) { … }setTimer0Function(myFunc);

Page 311: Embedded System Overview

RockOn! 2008

311

Lesson 7: Timers - Functions

- startTimer0( )

- Starts timer 0

- Example: startTimer0( )

- Should only be used once timer 0 has been setup using setTimer0 and setTimer0Function

Page 312: Embedded System Overview

RockOn! 2008

312

Lesson 7: Timers

- Calculating settings for the timer is tedious

- Finding settings by hand can cause error in the desired frequency or period

- Solution: Use the AVR Timer Setting Utility, which minimizes the error for the desired values

- Open “timer_util.exe”

Page 313: Embedded System Overview

RockOn! 2008

313

Lesson 7: Timers

- Settings Box

-Allows user input for timer, clock speed, period/frequency, and flight duration

- For this flight, remember to find settings for Timer/Counter 0

Page 314: Embedded System Overview

RockOn! 2008

314

Lesson 7: Timers

- Recommended Settings

-Minimizes the error while staying within constraints

- Prescale value must be allowed by device

- OCR value must fit in 8-bit or 16-bit register, depending on the timer

Page 315: Embedded System Overview

RockOn! 2008

315

Lesson 7: Timers

- Possible Settings

-Allows the user to vary the prescale value to see what the OCR value would be for the given frequency

-OCR box turns red when a prescale value causes register overflow

Page 316: Embedded System Overview

RockOn! 2008

316

Lesson 7: Timers

- Your Turn

-Remove geiger.c from the project and add timers.c

-Write code in timers.c that blinks the status LED by using timer 0

Page 317: Embedded System Overview

RockOn! 2008

317

Lesson 7: Timers

- This should involve two parts

- In main( ), the system should be initialized and the timer setup with a period of 20 ms (Use timer_util.exe)

- In MyTimerFunction( ), the LED should be toggled

- To toggle the LED, use the static variable in the timer function

- This variable will save its value between function calls- To change the value of the LED, you can use an if

statement to check the value of is_on

Page 318: Embedded System Overview

RockOn! 2008

318

Lesson 7: Timers - Code

void MyTimerFunction(void){

static char is_on = 1; if (is_on == 1) {

sbi(PORTD, 6); is_on = 0;

}else {

cbi(PORTD, 6); is_on = 1;

}}

Page 319: Embedded System Overview

RockOn! 2008

319

Lesson 7: Timers - Code

int main( ){

sei( );

RSInit( ); ISMPCheck( ); sbi(DDRD, 6);

setTimer0(78, TIMER0_DIV1024); setTimer0Function(MyTimerFunction); startTimer0( ); while(1);

}

Page 320: Embedded System Overview

RockOn! 2008

320

Lesson 7: Timers

-Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 321: Embedded System Overview

RockOn! 2008

321

Lesson 7: Timers

-Connect the AVRISP to the programming header

-Disconnect the board from power during this procedure

Page 322: Embedded System Overview

RockOn! 2008

322

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 7: Timers

Page 323: Embedded System Overview

RockOn! 2008

323

Lesson 7: Timers

- Give power to the AVR Board before loading any code

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 324: Embedded System Overview

RockOn! 2008

324

- Click “Program” in the FLASH section

- Disconnect power and Data Retrieval Connector

- Connect power and activate G-Switch

- Is your LED blinking?

- Try again for 60 ms

- Disconnect power

Lesson 7: Timers

Page 325: Embedded System Overview

RockOn! 2008

325

Lesson 7: Timers - Code

void MyTimerFunction(void){

static char is_on = 1; if (is_on == 1) {

sbi(PORTD, 6); is_on = 0;

}else {

cbi(PORTD, 6); is_on = 1;

}}

Page 326: Embedded System Overview

RockOn! 2008

326

Lesson 7: Timers - Code

int main( ){

sei( );

RSInit( ); ISMPCheck( ); sbi(DDRD, 6);

setTimer0(256, TIMER0_DIV1024); setTimer0Function(MyTimerFunction); startTimer0( );

}

Change this value for 60 ms using Timer

Utility

Page 327: Embedded System Overview

RockOn! 2008

327

Lesson 7: Timers

-Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 328: Embedded System Overview

RockOn! 2008

328

Lesson 7: Timers

-Connect the AVRISP to the programming header

-Disconnect the board from power during this procedure

Page 329: Embedded System Overview

RockOn! 2008

329

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

Lesson 7: Timers

Page 330: Embedded System Overview

RockOn! 2008

330

Lesson 7: Timers

- Give power to the AVR Board before loading any code

- Loading the Executable to the AVR Board

- Click the “AVR” button on the bottom toolbar

Page 331: Embedded System Overview

RockOn! 2008

331

- Click “Program” in the FLASH section

- Disconnect power and Data Retrieval Connector

- Connect power and activate G-Switch

- Is your LED blinking?

- Disconnect power, Data Retrieval Connector and AVR ISP Connector

Lesson 7: Timers

Page 332: Embedded System Overview

RockOn! 2008

332

ENDLesson 7:

Timers

RockOn! 2008

Page 333: Embedded System Overview

RockOn! 2008

333

Lesson 8:Flight Code

RockOn! 2008

Page 334: Embedded System Overview

RockOn! 2008

334

Lesson 8: Flight Code

- Objectives

- Learn about the software organization for the project

- Learn how the memory protection system works

- Bring together lessons 1 – 7 into the final flight code for the project

Page 335: Embedded System Overview

RockOn! 2008

335

Lesson 8: Flight Code

- Objectives

- Learn about the software organization for the project

- Learn how the memory protection system works

- Bring together lessons 1 – 7 into the final flight code for the project

Page 336: Embedded System Overview

RockOn! 2008

336

Lesson 8: Flight Code

- Software Organized into three distinct parts

- Initialization Code

-Main Loop (Background)

-Memory Protection System

Page 337: Embedded System Overview

RockOn! 2008

337

Lesson 8: Flight Code

- Initialization Code- Sets up all systems (RSInit( ))- Checks if the data retrieval board has been plugged in- Sets up the memory protection system

Page 338: Embedded System Overview

RockOn! 2008

338

Lesson 8: Flight Code

-Main Loop (Background)

- Infinite loop that runs in the background- Constantly tries to flush the memory buffer to

external flash- Updates the memory protection latches

- Timer Function (Foreground)- Samples sensors and Geiger counter-Writes sampled values to the memory buffer

Page 339: Embedded System Overview

RockOn! 2008

339

Lesson 8: Flight Code

-Memory Protection System

-Checks accelerometers to detect when launch occurs

-After a launch is detected, any future power on operations will lock the external memory so that no write operations can occur

- This will protect data in case the payload is activated once it lands

-Was unnecessary during lessons, as it would have complicated programs and gotten in the way

Page 340: Embedded System Overview

RockOn! 2008

340

Lesson 8: Flight Code

- Check made for write protection

-Vertical Acceleration: A vertical acceleration greater than 2 g that lasts for a second will cause the vertical acceleration latch to be set

-Memory is write-protected only if the latch is set

Page 341: Embedded System Overview

RockOn! 2008

341

Lesson 8: Flight Code

- To clear the latches, the Software Arming mode of the ISMP Utility can be used

- All teams should ensure that their payload is ARMED before turning in payloads for flight

- After landing, the payload should be DISARMED if it is not already to protect flight data

-We will go over this in great detail

Page 342: Embedded System Overview

RockOn! 2008

342

Lesson 8: Flight Code - Functions

- Upcoming Functions

latchCheck( )

latch1( )

latchLED( )

Page 343: Embedded System Overview

RockOn! 2008

343

Lesson 8: Flight Code - Functions

- Important Functions From Previous Lessons

cbi(register, pin)

sbi(register, pin)

_delay_ms(time)

write(unsigned char data)

memFlush( )

ISMPCheck()

RSInit

adcGetChar(unsigned char ch)

adcGet16(unsigned char ch)

write16(unsigned short data)

Page 344: Embedded System Overview

RockOn! 2008

344

Lesson 8: Flight Code - Functions

- Important Functions From Previous Lessons

getEXTo()

setEXTo(unsigned char val)

setTimeroFunction(func)

setTimero(unsigned char ocr, prescale)

startTimero()

Page 345: Embedded System Overview

RockOn! 2008

345

Lesson 8: Flight Code - Functions

- latchCheck( )

-Checks if the memory protection latch has been set

- Example: latchCheck()

- If the latch is set, this function locks the external memory so that no writes can occur

- Should always be called in the initialization section of code AFTER RSInit( ) and ISMPCheck( )

Page 346: Embedded System Overview

RockOn! 2008

346

Lesson 8: Flight Code - Functions

- latch1( )

-Checks if the vertical acceleration latch condition has been met

- Example: latch1()

- If it has, this function sets the latch so that future calls of latchCheck( ) will see that a vertical jolt has been experienced

- Should be called in the main loop

Page 347: Embedded System Overview

RockOn! 2008

347

Lesson 8: Flight Code

- latchLED( )

-Updates the latch LED to show the status of the payload

- Example latchLED()

- LED will blink constantly if the payload is armed

- LED will have an irregular blink pattern with two blinks if the vertical latch is set

- LED will be steadily on if the payload is disarmed

- Should be called in the main loop

Page 348: Embedded System Overview

RockOn! 2008

348

Lesson 8: Flight Code

- Your Turn-Remove timers.c (NOT timer.c) from the project and

add flight.c

Page 349: Embedded System Overview

RockOn! 2008

349

Lesson 8: Flight Code

- Your Turn

-Write the final flight code for the AVR board

-Use the software model discussed earlier in this section and the hints in flight.c to write the required code

-Use a 50 ms sample period

-Use the timer utility to get your prescale and OCR values

Page 350: Embedded System Overview

RockOn! 2008

350

Lesson 8: Flight Code - Code

void sample(void){

write(adcGetChar(ACCEL_X_LOW)); write(adcGetChar(ACCEL_Y_LOW)); write(adcGetChar(ACCEL_Z_LOW)); write16(adcGet16(ACCEL_X_HIGH));write16(adcGet16(ACCEL_Y_HIGH)); write16(adcGet16(ACCEL_Z_HIGH));write16(adcGet16(TEMP)); write16(adcGet16(PRESSURE));write(getEXT0());setEXT0(0);

}

Page 351: Embedded System Overview

RockOn! 2008

351

Lesson 8: Flight Code - Code

int main( ){

sei( );

RSInit( ); ISMPCheck( ); latchCheck( );

setTimer0(195, TIMER0_DIV1024); setTimer0Function(sample); startTimer0( );

Page 352: Embedded System Overview

RockOn! 2008

352

Lesson 8: Flight Code - Code

while (1){

memFlush( ); latch1( );latchLED( );

}}

Page 353: Embedded System Overview

RockOn! 2008

353

Lesson 8: Flight Code

- Building Your Complete Code

-Once code is written, you need to compile and link it to make an executable file

-Click Build->Build (F7)

Page 354: Embedded System Overview

RockOn! 2008

354

Lesson 8: Flight Code

-Connect the AVRISP to the programming header

-Disconnect the board from power during this procedure

Page 355: Embedded System Overview

RockOn! 2008

355

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

- Timer code is still loaded so it will begin to execute

- New code will overwrite

Lesson 8: Flight Code

Page 356: Embedded System Overview

RockOn! 2008

356

Lesson 8: Flight Code

-Give power to the AVR Board before loading any code

-Loading the Executable to the AVR Board

-Click the “AVR” button on the bottom toolbar

Page 357: Embedded System Overview

RockOn! 2008

357

- Verify you are using the right *.hex file

- Click “Program” in the FLASH section

- Let program run for a minute

- Is you LED blinking? It should be blinking twice and then a pause

- Disconnect power

Lesson 8: Flight Code

Page 358: Embedded System Overview

RockOn! 2008

358

Lesson 8: Flight Code

- Remember,

- LED will blink constantly if the payload is armed

- LED will have an irregular blink pattern with two blinks if the vertical latch is set

- LED will be steadily on if the payload is disarmed

Page 359: Embedded System Overview

RockOn! 2008

359

Lesson 8: Flight Code

- Once the flight code has loaded properly, the flash memory should be erased in order to prepare for calibrations data recording

- Using the data retrieval utility, erase the memory of the board and reset the arming or latches

- Disconnect power and remove AVR ISP from the AVR board

Page 360: Embedded System Overview

RockOn! 2008

360

Lesson 8: Flight Code

- Open the Data Retrieval Utility-With the power on the AVR board off, connect the data

retrieval board to the data header on the AVR board

Page 361: Embedded System Overview

RockOn! 2008

361

- Give power to the board before using the Data Retrieval Utility

- Make sure RBF jumper is installed and activate the G-Switch

- Flight code will not execute because Data Retrieval Connector is attached

Lesson 8: Flight Code

Page 362: Embedded System Overview

RockOn! 2008

362

Lesson 8: Flight Code

- On the Data Retrieval Utility, select the “Software Arming” mode

- Should say “Partially Armed” and blink with the same pattern

- Click “Disarm” and then check status again

- Should say “Safe”

Page 363: Embedded System Overview

RockOn! 2008

363

Lesson 8: Flight Code

- Select the “Erase Memory” tab on the Data Retrieval Utility

- Select the Correct COM port

-Click “Erase Memory”

Page 364: Embedded System Overview

RockOn! 2008

364

Lesson 8: Flight Code

- On the Data Retrieval Utility, select the “Software Arming” mode

- Click “Check Armed Status”

- Click “Arm Payload”

- Should say “Armed”

- Disconnect power and Data Retrieval Connector from AVR board

Page 365: Embedded System Overview

RockOn! 2008

365

ENDLesson 8:

Flight Code

RockOn! 2008

Page 366: Embedded System Overview

RockOn! 2008

366

Big Picture

RockOn! 2008

Page 367: Embedded System Overview

RockOn! 2008

367

Lesson 9:Flight Code Testing

RockOn! 2008

Page 368: Embedded System Overview

RockOn! 2008

368

Lesson 9: Flight Code Testing

- Objectives

-Verify that the AVR board and software are working correctly

-Gather data that will later be used to calibrate sensors

Page 369: Embedded System Overview

RockOn! 2008

369

Lesson 9: Flight Code Testing

- Objectives

-Verify that the AVR board and software are working correctly

-Gather data that will later be used to calibrate sensors

Page 370: Embedded System Overview

RockOn! 2008

370

Lesson 9: Flight Code Testing

- In order to calibrate sensors, several tests must be run

- These tests will also be used to verify that the system is functioning correctly

- After each test, use the ISMP and Parser Utilities to create csv files of the output, and save these files

Page 371: Embedded System Overview

RockOn! 2008

371

- Connect power to the board

- Make sure RBF jumper is installed and activate the G-Switch

- LED should be blink twice and pause then blink twice again

Lesson 9: Flight Code Testing

Page 372: Embedded System Overview

RockOn! 2008

372

Lesson 9: Flight Code Testing

-With one single data gathering run of the flight code, conduct 3 tests

- Pressure Test- Blow into the pressure sensor with a straw for 10 to 15

seconds-Wait about 15 seconds before the next test

- Temperature Test- Touch the temperature sensor for 10 to 15 seconds-Wait about 15 seconds before the next test

Page 373: Embedded System Overview

RockOn! 2008

373

Lesson 9: Flight Code Testing

- Accelerometers Test- Perform the following actions in the correct order for

about 10 to 15 seconds each- Set the X-,Y-,Z-axis plates flat- Set X-accel pointing up- Set X-accel pointing down- Set Y-accel pointing up- Set Y-accel pointing down- Set Z-accel pointing up- Set Z-accel pointing down- Set X-,Y-,Z-axis plates flat

Page 374: Embedded System Overview

RockOn! 2008

374

Lesson 9: Flight Code Testing

- Set the X-,Y-,Z-axis plates flat

Page 375: Embedded System Overview

RockOn! 2008

375

Lesson 9: Flight Code Testing

- Set X-accel pointing up

Page 376: Embedded System Overview

RockOn! 2008

376

Lesson 9: Flight Code Testing

- Set X-accel pointing down

Page 377: Embedded System Overview

RockOn! 2008

377

Lesson 9: Flight Code Testing

- Set Y-accel pointing up

Page 378: Embedded System Overview

RockOn! 2008

378

Lesson 9: Flight Code Testing

- Set Y-accel pointing down

Page 379: Embedded System Overview

RockOn! 2008

379

Lesson 9: Flight Code Testing

- Set Z-accel pointing up

Page 380: Embedded System Overview

RockOn! 2008

380

Lesson 9: Flight Code Testing

- Set Z-accel pointing down

Page 381: Embedded System Overview

RockOn! 2008

381

Lesson 9: Flight Code Testing

- Set X-,Y-,Z-axis plates flat

Page 382: Embedded System Overview

RockOn! 2008

382

Lesson 9: Flight Code Testing

- Disconnect power

- Attach the Data Retrieval Connector

- Open the Data Retrieval Utility

Page 383: Embedded System Overview

RockOn! 2008

383

Lesson 9: Flight Code Testing

- Connect power to the AVR board before using the Data Retrieval Utility

Page 384: Embedded System Overview

RockOn! 2008

384

- On the Data Retrieval Utility, select the “Software Arming” mode

- Should say “Partially Armed” and blink with the same pattern

- Click “Disarm” and then check status again

- Should say “Safe”

Lesson 9: Flight Code Testing

Page 385: Embedded System Overview

RockOn! 2008

385

- On the Data Retrieval Utility, select the “Read Portion of Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Calibration_Kit_XX.txt- Use a start address of 0 and a

length of 100,000-Click “Retrieve Data”

Lesson 9: Flight Code Testing

Page 386: Embedded System Overview

RockOn! 2008

386

- Run parser_util.exe (NOT Parser.exe)

Lesson 9: Flight Code Testing

Page 387: Embedded System Overview

RockOn! 2008

387

- In the “Data File” field, enter the name of the file from the last exercise Calibration_Kit_XX.txt- This is the file to be parsed

- In the “Output File” field, enter a filename with .csv as the ending-Calibration_Kit_XX.csv

Lesson 9: Flight Code Testing

Page 388: Embedded System Overview

RockOn! 2008

388

-Make sure that both of the boxes are checked

- The first one toggles whether the output file is opened once parsing is complete

- The second box ensures that the output file is compatible with Microsoft Excel

Lesson 9: Flight Code Testing

Page 389: Embedded System Overview

RockOn! 2008

389

Lesson 9: Flight Code Testing

- In the “Number of Columns” field, enter the number of sensors or inputs in the data file

- In this case, 9 sensors were read, so enter 9

- Press “Apply”

Page 390: Embedded System Overview

RockOn! 2008

390

Lesson 9: Flight Code Testing

- For each sensor (in the order you sampled them in your code)-Name the sensor- Enter the number of bytes

per sample-Check the box if the data is

a count, not a voltage- The low accelerometers

and the geiger counter are 1 byte, the others 2 bytes- The Geiger counter

should be set as a count

Page 391: Embedded System Overview

RockOn! 2008

391

Lesson 9: Flight Code Testing

- Press “Parse Data”-A black console window

should appear

- This is the actual parser process, DO NOT close the window, it will close on its own

-When the parsing is finished, wait for the output file to open

Page 392: Embedded System Overview

RockOn! 2008

392

Lesson 9: Flight Code Testing

- Excel should open something like this.

- The data shown in the spreadsheet is the voltage seen by the sensors each time they were sampled

Page 393: Embedded System Overview

RockOn! 2008

393

- Verify that these files have been written to your Desktop.

-We will use these files on Day 5 of this workshop

Lesson 9: Flight Code Testing

- Select the “Erase Memory” tab on the Data Retrieval Utility

- Select the Correct COM port

-Click “Erase Memory”

Page 394: Embedded System Overview

RockOn! 2008

394

- On the Data Retrieval Utility, select the “Software Arming” mode

- Click “Check Armed Status’

- Click “Arm Payload”

- Should say “Armed”

- Disconnect power and Data Retrieval Connector from AVR board

Lesson 9: Flight Code Testing

Page 395: Embedded System Overview

RockOn! 2008

395

ENDLesson 9:

Flight Code Testing

RockOn! 2008

Page 396: Embedded System Overview

RockOn! 2008

396

Lesson 10:Flight Preparation

RockOn! 2008

Page 397: Embedded System Overview

RockOn! 2008

397

Lesson 10: Flight Preparation

- Objectives

-Activate system and let it record in the current configuration settings

- Prepare AVR and system for flight- Erase Memory

-Arm System

Page 398: Embedded System Overview

RockOn! 2008

398

Lesson 10: Flight Preparation

- Objectives

-Activate system and let it record in the current configuration settings

- Prepare AVR and system for flight- Erase Memory

-Arm System

Page 399: Embedded System Overview

RockOn! 2008

399

Lesson 10: Flight Preparation

- Open the Data Retrieval Utility

- Verify Power, AVR ISP, and Data Retrieval Connector are not attached to AVR board

- Connect the data retrieval board to the data header on the AVR board

- DO NOT CONNECT THE AVR ISP DURING THIS LESSON

Page 400: Embedded System Overview

RockOn! 2008

400

Lesson 10: Flight Preparation

Page 401: Embedded System Overview

RockOn! 2008

401

Lesson 10: Flight Preparation

- Connect the board to the computer using the data retrieval header, a serial cable, and the USB to Serial adapter

Page 402: Embedded System Overview

RockOn! 2008

402

Lesson 10: Flight Preparation

Page 403: Embedded System Overview

RockOn! 2008

403

Lesson 10: Flight Preparation

- On the Data Retrieval Utility, select the “Software Arming” mode

- To determine if the serial connection is active, select the check armed status button of the correct COM port

-You want the green LED to flash for a successful connection

- If an error message occurs,- Check your serial connections- check if AVR board has power

Page 404: Embedded System Overview

RockOn! 2008

404

Lesson 10: Flight Preparation

- Open the ISMP Utility and go to the Erase Memory Tab

- Verify that you have selected the correct COM port

- Press the erase button

Page 405: Embedded System Overview

RockOn! 2008

405

Lesson 10: Flight Preparation

- Now switch to the Software Arming Tab of the ISMP Utility

- Press the Check Armed Status Button

Page 406: Embedded System Overview

RockOn! 2008

406

Lesson 10: Flight Preparation

- Depending on the status of the payload, the button at the bottom of the utility will either read “Arm Payload” or “Disarm Payload”

- Press the button until the armed status field says “Armed”

- Disconnect power and the AVR ISP and Data Retrieval Connector

Page 407: Embedded System Overview

RockOn! 2008

407

Lesson 10: Flight Preparation

- Connect power to the AVR board

- Activate the system (while power is connected) by activating the G-switch

- The system should now be gathering data

- Run the system for a full 15 minutes if system is not using flight batteries. If using flight batteries or are integrated to the flight deck, only run this test for a few minutes

- After time has been reached, disconnect power from AVR Board

Page 408: Embedded System Overview

RockOn! 2008

408

- Connect power to the AVR board

- Connect the Data Retrieval Connector

Lesson 10: Flight Preparation

Page 409: Embedded System Overview

RockOn! 2008

409

- On the Data Retrieval Utility, select the “Software Arming” mode

- Should say “Partially Armed” and blink with the same pattern

- Click “Check Armed Status”

- Click “Disarm Payload” and then check status again

- Should say “Safe”

Lesson 10: Flight Preparation

Page 410: Embedded System Overview

RockOn! 2008

410

- On the Data Retrieval Utility, select the “Read Entire Memory” mode

-Choose the correct COM# for the port

- Pick an output file name and save to Desktop by selecting “…”

Less_11_Kit_XX.txt

-Click “Retrieve Data”

- This will take some time to complete

Lesson 10: Flight Preparation

Page 411: Embedded System Overview

RockOn! 2008

411

Lesson 10: Flight Preparation

- Open up the Data Parser Utility

- Do NOT make any changes to the utility; all setting should have been saved from lesson 9

- Press “Parse Data”-When the parsing is

finished, wait for the output file to open

Page 412: Embedded System Overview

RockOn! 2008

412

Lesson 10: Flight Preparation

- Verify that these values look logical (i.e. that nothing exceeds 5 volts)

- Proceed with final flight preparation steps

Page 413: Embedded System Overview

RockOn! 2008

413

Lesson 10: Flight Preparation

- Open the ISMP Utility and go to the Erase Memory Tab

- Verify that you have selected the correct COM port

- Press the erase button

Page 414: Embedded System Overview

RockOn! 2008

414

Lesson 10: Flight Preparation

- Now switch to the Software Arming Tab of the ISMP Utility

- Press the “Check Armed Status” Button

- Depending on the status of the payload, the button at the bottom of the utility will either read “Arm Payload” or “Disarm Payload”

- Press the button until the armed status field says Armed.

Page 415: Embedded System Overview

RockOn! 2008

415

Lesson 10: Flight Preparation

- Disconnect power from the AVR board

- Disconnect the Data Retrieval Connector from the AVR board

- CONGRATULATIONS, your system is now ARMED and Ready for Flight

- SYSTEM CANNOT BE ACTIVATED UNLESS ALL THREE ARE TRUE1. RBF IS CONNECTED2. POWER IS CONNECTED3. G-SWITCH IS ACTIVATED

Page 416: Embedded System Overview

RockOn! 2008

416

ENDLesson 10:Flight Preparation

RockOn! 2008