ece 511 project report - george mason …ece.gmu.edu/.../ece511-f17/project/group-5-report.pdfece...

13
1 ECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost Naif Maliki Fall 2017

Upload: letram

Post on 16-Jun-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

1

ECE 511 PROJECT REPORT

MSP430 Balance Beam

Submitted by Group 5:

Ali Mirzaeian

Jason Kost

Naif Maliki

Fall 2017

Page 2: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

2

TABLE of CONTENT:

Abstract 3

Motivation 3

Solution 3

Flowchart 5

Breakdown of Electrical Components 6

Result and Conclusion 10

Biography 10

Appendix 11

Table of Figures:

Figure 1 Balance Beam Mechanical Structure 4

Figure 2 Balance Beam Block Diagram 4

Figure 3: FlowChart 5

Figure 4: output coding example 5

Figure 5: SPI sequence for read commands 6

Figure 6 MSP430 Launchpad 6

Figure 7 Inclinometer 7

Figure 8 Stepper Motor 7

Figure 9 Motor Driver 8

Figure 10 Limit Switch 8

Figure 3 Step-Up Regulator 9

Figure 4 Step-Down Regulator 9

Figure 5 Balance Beam Motherboard 9

Figure 6 Motherboard Schematic 11

Figure 7 Accessory Components Schematic 12

Page 3: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

3

Abstract

This project seeks to explore the classic problem of balancing an inverted pendulum in a manner

consistent with the capabilities of the MSP430 microcontroller. This problem has wide ranging practical

and entertainment applications. Our goals were to build a form of inverted pendulum, the balance beam,

controlled by a MSP430, that could maintain balance as objects of different masses are placed on its ends,

and could deal with fault conditions such as when a mass is too heavy to be balanced. The project

culminated in a balance beam that meets these goals.

Motivation

The act of balancing an inverted pendulum is a classic control problem that has practical

applications as well as pure entertainment value. An example of a practical application is the Segway, a

two-wheeled motorized vehicle on which a rider stands while traveling about, whether for a leisurely tour

or for efficiently traversing a factory floor. Some examples of pure entertainment value include the

tightrope walker, the circus performer balancing on his head (perhaps on top of another performer balancing

on top of his head!), or simply the baseball player balancing a bat on its end. Suffice it to say that the

balancing problem is ubiquitous and interesting. To that end, we (the team members) sought to explore the

balancing problem in a manner suitable to the capabilities of the Texas Instruments MSP430

microcontroller.

Solution

Since the balancing problem can be challenging, we sought to maximize our chances of success

through careful mechanical design of the structure to be balanced (i.e., make it easier to balance!). Just as

a tightrope walker uses a long beam to increase the moment of inertia, and lower the center of gravity

(among other possible reasons), we devised an apparatus based on a long 80/20 brand T-slot beam, on

which other parts could easily be attached and adjusted as necessary. A carriage with a linear bearing was

slid on to the beam, with metal bars attached to function analogously to the legs of the tightrope walker.

The legs, although thin, do have flat ends to aid in the balancing task. To move the carriage, we decided

on a stepper motor with integral leadscrew, with body fixed to the beam, and with the leadscrew threaded

through a traveling nut affixed to the carriage. One end of the leadscrew is supported with a bearing to

eliminate wobble. We chose the stepper motor because that is the only type of motor in which the rotation

of the shaft can be determined without needing another sensor, because each step command results in a

predetermined amount of rotation. To finish out the mechanical construction, we attached small wheels on

either end of the beam, and two magnetic reed switches to interact with magnets on the carriage, to detect

when the carriage has reached either end of its range of motion. A top-view photo of the completed

mechanical assembly is shown in Figure . Note the water bottle added to counterbalance the weight of the

motor, electronics, and battery on the other end. The square pads on the ends are for placing objects to be

balanced.

Page 4: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

4

Figure 1 Balance Beam Mechanical Structure

We further sought to increase our chances of success through judicious choice of electronic

components. Some research about other balancing robots revealed that a combination of sensors is often

used, for example an inclinometer for periodic calibration and one or more accelerometers for most of the

sensing tasks. Usually an inclinometer alone is not enough, simply because the response time is too slow.

We hoped that we could get away with using just an inclinometer, though, due to our mechanical design.

To further our chances, we picked an inclinometer with the highest bandwidth we could find, the

ADIS16203 from Analog Devices. To drive the motor, we sought the simplest solution, and identified a

ready-made driver board from Pololu Robotics, which houses the DRV8825 driver chip from Texas

Instruments; this chip needs just two inputs, one being a logic level for the direction of rotation, and the

other a pulse input, where each pulse results in a single step of angular rotation. To complete the

electronics, DC-DC converters were procured to convert the varying voltage of a lithium battery to a steady

12V for the motor, and to 3.3V for the rest of the electronics. A block diagram of the electronics solution

is shown in Figure .

Figure 2 Balance Beam Block Diagram

Flowchart

Page 5: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

5

The following flow chart used for implementing the Balance Beam project.

For detecting how much is tilted the beam we used the inclinometer (ADIS16203). This device has two

output formats +360˚ and ±180˚ for measuring the inclined-angle. We used output format

±180˚(INCL_180_OUT) In this project because it was easier to detect the movement direction of beam

from the measured angle sign bit. INCL_180_OUT has 14 bits resolution (with step size 0.025 ) and data

format is in Tows complement. In the Figure 1 the output coding example of INCL_180_OUT is shown.

Figure 4: output coding example

Figure 3: Flow Chart

Page 6: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

6

ADIS16203 uses SPI protocol for communicating with other peripherals. The ADIS16203’s SPI port

includes four signals: chip select (CS), serial clock (SCLK), data input (DIN), and data output (DOUT).

Figure 2 shows the SPI sequence for read.

Figure 5: SPI sequence for read commands

Breakdown of electrical components

Texas Instruments MSP430 Launchpad

Figure shows the Texas Instruments MSP-EXP430F5529LP launchpad board, which houses the

MSP430F5529 microcontroller. It is powered with 3.3V supplied by the balance beam motherboard. We

will use the SPI port to communicate with the inclinometer, and several GPIO ports to drive the motor and

to read the limit switches.

Figure 6 MSP430 Launchpad

Page 7: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

7

Inclinometer

Figure shows the Analog Devices ADIS16203/PCBZ eval board, which contains the ADIS16203

inclinometer. The board is nothing more than the sensor, two connectors, and some convenient mounting

holes. It encodes absolute angular position about an axis perpendicular to the plane of the die, with a

resolution of 0.025°, and a bandwidth of 2.25 kHz; it is mounted such that this axis is parallel to the axis of

rotation of the beam. The MSP430 communicates with the inclinometer using SPI, i.e. the three lines

UCA0SOMI, UCA0SIMO, and UCA0CLK.

Figure 7 Inclinometer

Stepper Motor

Figure shows the motor used for the balance beam, the SOYO SY42STH38-1684A NEMA-17

bipolar stepper motor with integrated leadscrew. In full stepping mode, there are 200 steps per revolution;

in full (x32) microstepping mode, which we use, there are 6400 steps per revolution that results in 1.25 μm

of linear motion per step. We found that full microstepping resulted in the smoothest operation and best

balance performance. The motor is rated to draw 1.7 Amps of current, which is controlled by the motor

driver board, as described in the following.

Figure 8 Stepper Motor

Motor Driver

Figure shows the Pololu DRV8825 stepper motor driver carrier board, which contains the Texas

Instruments DRV8825 stepper motor driver. The carrier includes some supporting components to allow

the output current to the motor to be set, along with convenient input and output pins. The board is capable

of providing up to 2.2 Amps of current to the motor coils, but the motor is rated to handle only 1.7 Amps;

we conservatively set the output current to 1.4 Amps by turning the board’s trimpot until the onboard

voltage reference reached 0.7 Volts, as instructed by the driver’s datasheet. The driver supports

Page 8: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

8

microstepping; as mentioned before, we made use of this to allow for the smoothest motion and best

balancing performance. Full microstepping (x32) mode is enabled simply by applying a logic high to three

of the board’s input pins. Four output pins drive the two coils of the stepper motor, while one input pin sets

the direction of the steps, and another pin accepts pulses to step the motor. We interfaced the latter two

pins of the board with two GPIO pins on the MSP430, P2.4 for the step pulses and P2.5 for the direction.

Figure 9 Motor Driver

Limit Switches

These are Hamlin 59065-040 normally closed magnetic reed switches, shown in Figure 8, mounted

on brackets on either end of the carriage’s range of motion. They open when they are within about 1 cm of

either of two rare earth magnets screwed to the carriage. For each switch, one electrical terminal is

connected to ground, while the other is connected to both logic high through a 4.7k pull-up resistor, and a

GPIO input on the MSP430; these are P1.4 for one switch and P1.5 for the other.

Figure 8 Limit Switch

Power supply

Not shown on the block diagram, but important nevertheless, is the power supply solution. We

didn’t want wires hanging and interfering with the balancing, so we based our power supply on a 3.7V

(nominal) Lithium rechargeable battery. We tested the mechanical operation of the balance beam by driving

the motor driver with pulses from a function generator, and determined that the motor/driver combination

consumes about 5 Watts. Our battery is rated to supply 3.3A, which results in over 12 Watts of available

power (when fully charged). We picked a step-up 12V regulator, the Texas Instruments PTN04050 to

supply the motor driver, shown in Figure 9, and a Murata OKL-T/1-W12 3.3V step-down regulator, shown

in Figure 10, to supply everything else. The 3.3V regulator draws from the 12V, so that it can continue to

produce a stable 3.3V even when the battery drops to 3.0V.

Page 9: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

9

Figure 9 Step-Up Regulator

Figure 10 Step-Down Regulator

Balance beam motherboard

To tie all the electronics together, we built a motherboard, shown in Figure 11. This board has the

DC-DC converters soldered directly to it, and connectors for the Launchpad, switch inputs, battery input,

sensor input, and motor output. These connectors are soldered to the board, and the appropriate pins are

tied together with soldered wires.

Figure 11 Balance Beam Motherboard

Page 10: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

10

Results and Conclusions

We were able to meet our goals of producing a functioning balance beam. Upon powerup, and

with no weights on either end of the beam, the motor turns at a constant speed until both ends of the beam

are suspended and only the legs on the carriage are touching the ground, i.e. the beam becomes balanced.

Placing an object of up to about 200 grams on either end, the motor again turns and adjusts the carriage

until once again balance is achieved. If the object is too heavy, the carriage gets to within 1 cm of its range

of motion, then backs up by a full turn of the leadscrew, then resumes normal operation; to the human

observer it looks like the carriage is bumping against a stop. If the excess weight is removed, the beam

again becomes balanced.

Lessons learned along the way relate to knowing the limitations of the microcontroller, as well as

the human operator! We tried to lengthen the legs to make the balance problem more difficult, but this was

not successful: the beam ended up teetering back and forth and never achieving balance. Our simple,

constant speed operation of the motor meant that the beam could only handle so much angular velocity

before it became overwhelmed.

When testing the reaction to the limit switches, one of us had a finger on the power switch, ready

to turn off the power if the carriage didn’t move as expected and went crashing into either of the two hard

stops. Sure enough, one time the carriage didn’t reverse direction as expected, but kept going and even

sped up! In that instance the human finger wasn’t fast enough and the carriage did indeed crash into a hard

stop. Luckily, no damage was done. After that we switched to soft stops until we were satisfied that the

carriage reacted correctly.

In conclusion, the MSP430 is a versatile and capable microcontroller, as long as one keeps in mind

its limitations. We designed an experiment with the KISS (keep it simple Sherlock) principle in mind, and

as a result we had a successful outcome. Our balance beam does indeed achieve balance when objects are

placed on either (or both) ends, and doesn’t crash when an object is too heavy to be balanced!

Bibliography

All source code, electrical design, and mechanical design is the work of the team members.

Inspiration for the project derives from the following:

http://processors.wiki.ti.com/index.php/Self_Balancing_MSP430_Bot

http://43oh.com/2010/07/balancing-a-two-wheeled-robot-with-an-msp430f1232/

Braunl, Thomas. Embedded Robotics: Mobile Robot Design and Applications with Embedded Systems.

Springer, 2008.

Page 11: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

11

Appendix:

Task Division

Ali Mirzaeian: programming, report writing

Jason Kost – mechanical design and construction, electrical design and construction, report writing

Naif Maliki: programming, report writing

Figure 12 Motherboard Schematic

Page 12: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

12

Figure 13 Accessory Components Schematic

Page 13: ECE 511 PROJECT REPORT - George Mason …ece.gmu.edu/.../ece511-f17/project/Group-5-Report.pdfECE 511 PROJECT REPORT MSP430 Balance Beam Submitted by Group 5: Ali Mirzaeian Jason Kost

13

item # qty designator description value part # mfr

1 1 BT1 Li battery 353 Adafruit Industries

2 2 C1,C4 ceramic cap 10u 25V

3 4 C2,C3,C5,C8 electrolytic cap 100u 35V

4 1 C6 ceramic cap 22u 16V

5 1 C7 electrolytic cap 100u 16V

6 1 D1 zener diode 1SMB5928BT3 ON semiconductor

7 3 H1,H2,H3 jumper

8 6 J1,J3,J4,J6,J8,J9 2-pin connector

9 2 J2,J7 4-pin connector

10 2 J5,J10 12-pin connector

11 1 M1 stepper motor SY42STH38-1684A Soyo

12 1 Q1 P-channel MOSFET MTP50P03HDL ON semiconductor

13 1 R1 resistor 1Ohm 3W

14 2 R2,R5 resistor 1kOhm 0.25W

15 1 R3 resistor 1.3kOhm 0.25W

16 1 R4 resistor 3.32kOhm 0.25W

17 1 R6 resistor 402 Ohm 0.25W

18 2 R7,R8 resistor 4.7kOhm ).25W

19 1 SW1 slide switch SS12SDP4 NKK switches

20 2 SW2,SW3 magnetic reed switch 59065-040 Hamlin

21 1 U1 step-up regulator PTN04050C Texas Instruments

22 1 U2 step-down regulator OKL-T/1-W12N-C Murata

23 1 U3 motor driver 2133 Pololu

24 1 U4 MSP430 Launchpad MSP-EXP430F5529LP Texas Instruments

25 1 U5 Inclinometer eval board ADIS16203/PCBZ Analog Devices

26 1 3 feet 1" extruded aluminum 80/20

27 1 carriage with linear bearing 80/20

28 1 pillow block

29 assorted aluminum angle

30 assorted aluminum plates

31 assorted hardware

32 2 standoff legs

Table 1 Parts List