20
1 Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Accelerometer Presented by: Presented by: Andy Lindsay Andy Lindsay Parallax, Inc. Parallax, Inc. [email protected] [email protected] om om

1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

Embed Size (px)

Citation preview

Page 1: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

1

Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Chapter 3: Tilt with the Memsic Dual-Axis

AccelerometerAccelerometer

Presented by: Presented by: Andy LindsayAndy LindsayParallax, Inc.Parallax, [email protected]@parallax.comom

Page 2: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

2

Copyrights and Trademarks

This documentation is copyright 2006 by Parallax Inc. By downloading or obtaining a printed copy of this documentation or software you agree that it is to be used exclusively with Parallax products. Any other uses are not permitted and may represent a violation of Parallax copyrights, legally punishable according to Federal copyright or intellectual property laws. Any duplication of this documentation for commercial uses is expressly prohibited by Parallax Inc. Duplication for educational use is permitted, subject to the following conditions: the text, or any portion thereof, may not be duplicated for commercial use; it may be duplicated only for educational purposes when used solely in conjunction with Parallax products, and the user may recover from the student only the cost of duplication.

BASIC Stamp, Stamps in Class, Board of Education, Boe-Bot SumoBot, SX-Key and Toddler are registered trademarks of Parallax, Inc. HomeWork Board, Propeller, Ping))) Parallax, and the Parallax logo are trademarks of Parallax Inc. If you decide to use trademarks of Parallax Inc. on our web page or in printed material, you must state that "(trademark) is a (registered) trademark of Parallax Inc.” upon the first appearance of the trademark name in each printed document or web page. Other brand and product names are trademarks or registered trademarks of their respective holders.

Page 3: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

3 Chapter 3, Pages 65 - 66

The Memsic Dual-Axis AccelerometerThe Memsic Dual-Axis Accelerometer

Page 4: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

4 Chapter 3, Page 67

Page 5: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

5 Chapter 3, Activity #1, Page 68

Circuit: Figure 3-3 on page 68Circuit: Figure 3-3 on page 68

Program: SimpleTilt.bs2 on page 70.Program: SimpleTilt.bs2 on page 70.

√ √ Follow the checkmarks on pages 70-Follow the checkmarks on pages 70-71.71.

Page 6: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

6 Chapter 3, Activity #1, Page 70

Page 7: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

7 Chapter 3, Activity #2, Pages 71 - 73

Using Using SEROUTSEROUT commands instead of commands instead of DEBUGDEBUG

Circuit: Figure 3-6 and Figure 3-7, pages 72 - 73Circuit: Figure 3-6 and Figure 3-7, pages 72 - 73

Program: SimpleTiltLcd.bs2, page 74Program: SimpleTiltLcd.bs2, page 74

√ √ Follow the checkmarks on page 74.Follow the checkmarks on page 74.

Page 8: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

8 Chapter 3, Activity #3, Pages 76 - 77

Applying Scale and Offset:Applying Scale and Offset:

1.1. Apply offset to align the input scale to zero.Apply offset to align the input scale to zero.

2.2. Apply the scale.Apply the scale.

3.3. Apply any additional offset needed for the output scale.Apply any additional offset needed for the output scale.

Scaling/Offset from Scaling/Offset from 1875 — 3125 1875 — 3125

to to -127 — 127-127 — 127

Applying Applying Scale/Offset to the Scale/Offset to the valuevalue variable variable

Page 9: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

9 Chapter 3, Activity #3, Pages 77 - 78

Choosing the right Choosing the right **** Constant for Scaling… Constant for Scaling…

……and Clamping the Input Range with and Clamping the Input Range with MINMIN and and MAXMAX

Page 10: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

10 Chapter 1, Activity #1, Pages 3 - 4

Program: TestScaleOffset.bs2Program: TestScaleOffset.bs2

√ √ Follow the checkmarks on pages 78 – 80.Follow the checkmarks on pages 78 – 80.

Page 11: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

11 Chapter 3, Activity #3, Pages 80 - 81

PBASIC and Negative NumbersPBASIC and Negative Numbers

Program:SignedNumbers.bs2Program:SignedNumbers.bs2

√ √ Follow the checkmark instructions on Follow the checkmark instructions on page 81.page 81.

In PBASIC, only Word In PBASIC, only Word variables can hold variables can hold signed numbers, for signed numbers, for example: example: value VAR value VAR WordWord

All signed numbers All signed numbers have 16 bits.have 16 bits.

Look at Bit 15 of the Look at Bit 15 of the variable to know if a variable to know if a signed number is signed number is negative or positive.negative or positive.

For example, if the For example, if the variable variable value.bit15value.bit15 is equal to 1, the is equal to 1, the number is number is negativenegative..

Page 12: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

12 Chapter 3, Activity #4, Page 84

Sample Readings at Sample Readings at Various OrientationsVarious Orientations

Scaling and Offset Scaling and Offset for 1/100 g.for 1/100 g.

Program: Program: SimpleTilt.bs2SimpleTilt.bs2

√ √ Follow the checkmark Follow the checkmark instructions on page instructions on page 85.85.

Page 13: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

13 Chapter 3, Activity #5, Pages 85 - 86, 88 - 89

Calculating Arctangent with Calculating Arctangent with ATNATN The result of an The result of an ATNATN operation is expressed operation is expressed in Brads (Binary in Brads (Binary Radians)Radians)

Program: TestAtn.bs2, p. 90Program: TestAtn.bs2, p. 90

√ √ Follow the checkmarks on Follow the checkmarks on page 89.page 89.

Page 14: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

14 Chapter 3, Activity #5, Pages 87 - 88

Converting from Brads to Degrees with the Converting from Brads to Degrees with the */*/ OperatorOperator

angle = 361 */ angleangle = 361 */ angle

The The */*/ operator multiplies the operator multiplies the operand by a number of 256operand by a number of 256thsths

Program: Program: BradsToDegrees.bs2, page BradsToDegrees.bs2, page 9090

√ √ Follow the checkmarks on Follow the checkmarks on page 90.page 90.

Page 15: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

15 Chapter 3, Activity #5, Page 92

Measuring Tilt Angle on the Vertical PlaneMeasuring Tilt Angle on the Vertical Plane

Page 16: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

16 Chapter 3, Activity #5, Pages 92 - 94

Program: VertWheelRotation.bs2, p. Program: VertWheelRotation.bs2, p. 9595

√ √ Follow the checkmark on page 95.Follow the checkmark on page 95.

Page 17: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

17 Chapter 3, Activity #6, Page 99

Page 18: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

18 Chapter 3, Activity #6, Pages 99 - 102

Sine, Cosine and the Unit CircleSine, Cosine and the Unit Circle

Program: SineCosine.bs2, page 101Program: SineCosine.bs2, page 101

√ √ Follow checkmarks on pages 101 – Follow checkmarks on pages 101 – 102.102.

The The SINSIN and and COSCOS operators operators return values return values

from from -127 to 127-127 to 127

Page 19: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

19 Chapter 3, Activity #6, Pages 101 - 105

Arcsine and Arccosine SubroutinesArcsine and Arccosine Subroutines

Program: TestArcsine.bs2, page 103Program: TestArcsine.bs2, page 103

√ √ Follow checkmarks on pages 103, 105.Follow checkmarks on pages 103, 105.

Page 20: 1 Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Smart Sensors and Applications Chapter 3: Tilt with the Memsic Dual-Axis Accelerometer Presented

20 Chapter 3, Activity #6, Page 106 - 108

Displaying Accelerometer Tilt AngleDisplaying Accelerometer Tilt Angle

Program: HorizontalTilt.bs2, page 108Program: HorizontalTilt.bs2, page 108

√ √ Follow checkmarks on page 108.Follow checkmarks on page 108.