168
Senior Design Group 8: Workout Buddy Chapter 1 Introduction 1.1 Executive Summary Workout buddy was proposed by Scott Martin, a senior at the University of Central Florida who is currently pursuing a degree in Electrical Engineering. He proposed the idea to the group and the project was chosen because it involves research in a wide range of different technologies. It will allow the group to explore and develop skills in various interests in biomedical engineering, embedded systems, electronics, and wireless protocols. The purpose of Workout buddy is to build an intelligent handheld electromyogram for the use the amateur body builders. Once completed workout buddy will be able to record workouts, track progress, and show areas of discern. Information will be stored on SD memory, and can be later viewed on a computer. Amateur weightlifters get the most benefit when they keep track of their exercises, the weights lifted, the number of repetitions and sets on a regular basis. When progress is tracked, additional motivation is gained and areas of improvement are more easily assessed. Workout buddy will automatically track all of this over time, as well as rate the intensity of each repetition, set, and workout session against previous efforts. The design will include a user friendly interface. The body builder will be able select the workout from the menu, enter the weight in pounds to be used, specify the number of sets to be attempted, and the number of repetitions to be completed per set. For simplicity, the design will be able to measure the intensity of three different muscle groups. The muscle groups that can be selected by the user will be the biceps, triceps, and pectorals. Through the use of electrodes, an 1

Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Embed Size (px)

Citation preview

Page 1: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Chapter 1Introduction

1.1 Executive Summary

Workout buddy was proposed by Scott Martin, a senior at the University of Central Florida who is currently pursuing a degree in Electrical Engineering. He proposed the idea to the group and the project was chosen because it involves research in a wide range of different technologies. It will allow the group to explore and develop skills in various interests in biomedical engineering, embedded systems, electronics, and wireless protocols. The purpose of Workout buddy is to build an intelligent handheld electromyogram for the use the amateur body builders. Once completed workout buddy will be able to record workouts, track progress, and show areas of discern. Information will be stored on SD memory, and can be later viewed on a computer. Amateur weightlifters get the most benefit when they keep track of their exercises, the weights lifted, the number of repetitions and sets on a regular basis. When progress is tracked, additional motivation is gained and areas of improvement are more easily assessed. Workout buddy will automatically track all of this over time, as well as rate the intensity of each repetition, set, and workout session against previous efforts. The design will include a user friendly interface. The body builder will be able select the workout from the menu, enter the weight in pounds to be used, specify the number of sets to be attempted, and the number of repetitions to be completed per set.

For simplicity, the design will be able to measure the intensity of three different muscle groups. The muscle groups that can be selected by the user will be the biceps, triceps, and pectorals. Through the use of electrodes, an electrical potential will be recorded, amplified, rectified, converted to a digital signal, and transmitted wirelessly to a second microcontroller, then viewed on a display. Additional devices will be used to help count sets and repetitions for certain workouts, especially exercises that will require a ninety degree bend on the arm. An accelerometer will be used when bicep/curl workout is selected for angle detection. The accelerometer will measure the angle that the individual bends his or her arm, and only count a repetition when the angle exceeds ninety degrees. Figure 1.1 shows that the electric potential can vary depending on the individual’s fat tissue. It also shows that given the same amount of muscle excitation, a person with less fat tissue will get a higher reading. This also applies to each muscle group. Larger muscles, such as the quadriceps, will always have a lower electric potential. This is why workout buddy will need a separate device to count repetitions instead of using the intensity calculation to count repetitions. Since the electrical potential generated by the body varies with

1

Page 2: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

each individual, people with more fat tissue surrounding a muscle will have a hard time reaching one hundred percent intensity during an exercise session. An idea to get around this was to have the individual do each exercise one time to get the standard voltage that their muscle generates for each muscle group. This standard voltage will then be used to calculate the intensity of each repetition, by taking the voltage generated by a single repetition, divided by the standard voltage. The problem with this technique is that the individuals would always read one hundred percent when applying maximum effort, and never see improvement in their workouts. Figure 1.1 displays the typical surface electromyogram that the group encountered during testing. Due to interference from outside signals, the output will vary.

Figure 1.1: This image shows how the voltage will vary depending on the fat tissue of the selected muscle. As shown, a lean person will generate a higher

electric potential, when compared to an individual with higher body fat. Permission was granted by Noraxon.

Workout buddy uses surface electromyogram technology which is shown in Figure 1.2. The figure shows the typical signal generated from the muscle fiber membranes in the bicep. Being that the signal is in the micro-Volt range, and the groups simulations and development will be in high noise areas, the use of an amplifier is crucial. As mentioned previously, electrodes will be used to measure the electrical potential when the muscles are active, and also when they are at

2

Page 3: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

rest. Measuring the electrical potential is not a trivial task, signals for large muscle groups range from one to two milli-Volts in amplitude. The figure is the typical signal that the group will be dealing with during the duration of the project. These signals also operate at a range from 10 Hertz to 1000 Hertz. Given that the voltage generated is inherently low, the use of an amplifier is imperative. The gain will need to be in the 1000-2000 range to achieve the five volt output that the group will use to do calculations. Since human bodies act like as an antenna to the 60-Hertz drawn from the electrical wiring in buildings, the use of a differential amplifier will be used to measure the voltage difference over the area of a muscle. The differential amplifier will need to have a high Common mode rejection ratio in order to filter out the 60-Hertz noise caused by electromagnetic fields from the surrounding electrical wiring. The unfiltered, non-amplified signal that the group will encounter throughout this project is shown below. A more detailed explanation of what the signal shows will be discussed further in chapter four. [1]

Figure 1.2: This image shows a typical surface electromyography signal generated by the bicep. It shows the three phases that each muscle contraction

will contribute too. Permission was granted from Noraxon.

Although testing and development will be done using a wired connection, an RF transceiver and RF receiver will be implemented to send and receive the amplified voltage generated by the muscle, as well as a set of coordinates that will be used for angle detection. Other options considered for the wireless protocol included blue tooth, and Zigbee.

One feature that is under consideration is to develop software that will simulate the workouts performed over a period of time. By using the data gathered during the workout sessions, Andrew Lee plans on creating a 3D model of the three body parts discussed earlier, and then simulating them in detail using K3D modeling software.

Everything needed for this design will be purchased or reimbursed by Vocational Rehabilitation and Employment Services. This program was created to help

3

Page 4: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

veterans with services connected disabilities to prepare for, find, and keep a suitable job. Vocational Rehabilitation offers these services to improve their ability to live as independently as possible. Due to this fact, and the limited cost of the design, a search for a sponsor was not needed.

Chapter 2 Definition

2.1 Motivation

Workout buddy is not limited to just weightlifters, it will benefit any individual willing and able to exercise. There has been research done by the Center for Disease and Control that shows there are a number of states where the obesity population exceeds thirty percent. A number are states are well on their way, ranging from twenty-five percent to twenty-nine percent. Figure 2.1 shows the Center for Disease and Controls annual obesity trend graph for 2007, which shows a major increase when compared with Figure 2.2, the 2000 annual obesity trend graph. Due to the fact that there has been a dramatic increase in obesity over the past few decades, the group wanted to implement a design that will attempt to keep people motivated while in the gym. In 2002, the Institute of Medicine suggested that all individuals should incorporate an exercise routine everyday for a minimum of one hour, to reduce the risk of cardiovascular disease. [2]

What is shown in Figure 2.3 is a graph that shows the death statistics for 2008. It shows that cardiovascular disease, which can be directly related to obesity, accounts for almost fifty percent of deaths last year. It accounted for 316,968 deaths, which surpassed cancer on the list, which had 307,655

deaths.[3]

4

Figure 2.1Permission pending

Figure 2.2Permission pending

Page 5: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Cancer43%

Cardiovascular Disease

44%

Car Accidents2%

Suicide4%

Other7%

2008 Death Statistics

Figure 2.3: This graph shows the number of deaths caused by cardiovascular disease which can be directly linked to obesity.

Ordinary gym members will ignore the idea of keeping a workout log, but without any record there is no way to keep track of progress, or areas that need improvement. When an individual does not keep track of their workouts, there is no reference for the future. Workout buddy eliminates the need to bring a notebook, and pencil or pen. Another key ingredient to building body mass is to do each repetition with a maximum intensity. Maximum intensity during a workout is more critical than anything else. People who just go through the motions are never going to reach their full potential. Workout buddy will keep track of the intensity of each and every repetition. When a maximum intensity of achieved during a workout, Workout buddy will advise the user to add more weights. Workout buddy will not interfere with any additional devices that an individual may carry while working out, for example an mp3 player such as an I-pod. With Workout Buddy, anyone can simply lay the display device next to them, or attach it around the wrist via a watch strap.

While doing research for this design many things were taken into consideration. Many ideas were thrown on the table, but due to time limitations the design will be simplified. Some of the plans included the following.

The user would be able to enter a cardio mode, where the use of an echocardiogram would be utilized. The electrodes would then measure the heart rate opposed to intensity, and the user could view his or her heart rate in real time via the Nokia 128x128. Due to time limitations of senior design two being taken during the summer, this idea will not be incorporated.

The system would involve a body suit, measuring multiple intensities at one time. The design would measure the electrical potential on all muscle

5

Page 6: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

groups simultaneously. The design would also an echocardiogram, and would lean more towards obese individuals opposed to body builders. The user interface would include instructions for certain workouts, and a three dimensional simulation to make sure the user implements the exercise in a correct manner. This idea was proposed by Matthew, but due to time limitations, it will not be designed.

The idea that an accelerometer would be used to count repetitions involving bicep exercises was introduced by Scott Martin. Since a maximum electrical potential occurs when the elbow is bent ninety degrees, the repetition count was going to be when the intensity reaches above eighty percent. Scott found that an accelerometer would be a more accurate way of counting repetitions due to the fact that it can measure the exact angle. This idea will be utilized in Workout buddy.

The idea of using a wireless protocol opposed to a wired connection between the sensor system and the display was proposed by Andrew Lee. He proposed that blue tooth wireless protocol be used to send data collected from the sensor system and transmitted to the microcontroller. Due to cost of a Bluetooth chip, an RF transmitter and receiver or a Zigbee unit will be used instead.

Another idea that was proposed was to implement a blood pressure device. Due to the complexity and time limitations, the idea was ignored.

After doing research on the project, the group discussed the pros and cons of such a design. Each group member had different reasons for going along with the idea of Workout Buddy, whether it was to further their knowledge in the field of electrical engineering or just the idea of building a biofeedback device. Scott Martin expressed his interest due to the fact that fitness gadgets are on the rise. He wanted to build a device that would be the next fun to use, and potentially profitable to build. At the very least, it would be a good learning experience to build it, as it would require the group to learn new skills and develop engineering design fundamentals.

2.2 Goals and Objectives

Weight lifters stay motivated when progress is achieved. The primary goal of Workout Buddy is to create a means of recording an exercise session, without the need of pen and paper. As an addition to viewing previous workouts on the display screen of ‘Workout Buddy’, the user will be able to upload all of the data to a computer via SD memory. This will all be achieved by designing a sensor system that detects voltages created by the muscles contracting.

Another one of the groups goals is to integrate a wireless interface between the sensor system and display module. This will be achieved by implementing a radio frequency transmitter and a radio frequency receiver. Other technologies

6

Page 7: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

that may substitute the RF module include bluetooth, infrared, or X-bee. Due to the time limitations of developing such a wireless system, and the elevated cost of the other technologies, the radio frequency module is the ultimate goal for the wireless interface. This will alleviate the irritation of having a wired interface that would get in the way of an exercise session.

The overall purpose of Workout Buddy is simple, to design a system that will eliminate the need for a pencil and paper due to the fact that the globe is moving into a paperless world. Although the scheme is simple, the research, prototyping, and implementation of such a design requires a lot of time and effort. The group wanted to make Workout Buddy as user friendly and straightforward as possible. Any individual who uses Workout Buddy must become comfortable with the system, and know that it is working properly without any concerns.

Given all this information, Workout Buddy is divided into five main sections. The work was divided equally, and the responsibilities were given based on the group member interest and motivation. Joshua Hamby and Matthew McNealy were assigned to the sensor system, which involved researching electrodes, amplifiers, accelerometers, and power supply design. Given that the unit must run for a minimum of four hours, research for the power supply included rechargeable batteries. The power supply design included research alkaline batteries, lithium ion batteries, Nickel Cadmium batteries, and various rechargeable batteries. It also required research in circuit protection in the case where lithium ion batteries were selected. Scott Martin was assigned to the research which involved selecting a microcontroller, and programming a microcontroller. Both Scott Martin and Matthew McNealy agreed to work on the user interface, and come up with a design on how Workout Buddy will be set up on the body. Andrew Lee was assigned the responsibilities of coming up with an idea on how the sensor system and the display module would communicate, and also to develop software that would simulate the workouts after an exercise session took place.

7

Page 8: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Chapter 3Requirements

3.1 Requirements

Essentially, the idea is to make a trip to the fitness center more enjoyable. Workout Buddy is designed in a way that requires many devices to be interfaced together in order to work properly. Early testing and research showed the group the importance of selecting the correct microcontroller that would interface all of the devices. These devices will be selected based off lowest power consumption while remaining cost effective.

The system will work similarly to an existing product developed by Noraxon, but it will have user options and multiple uses. It will have a voltage sensing device, an angle detection device, a processing unit, wireless protocol, and a display module. The sensor system must be precise and accurate, due to the fact that signals achieved in early testing were inaccurate, and noisy. The system will have a electrodes attached to the bicep, and the leads for the electrodes will be long enough to reach primary muscles of the upper body. It’s estimated that the leads should be at least 6 inches long, lengthy enough to reach the triceps, pectorals, and of course the bicep. The sensor system must be light weight, comfortable, and the dimensions must be small enough so that the device does not get in the way while working out. Other requirements that must be met are shown below:

Both the sensor system and display module must be powered by a DC battery.

The power system must supply enough power so that the device can run for a minimum of three to four hours before having to replace or recharge the batteries.

The display module must have an automatic timer that will shut down the device if not active for certain periods of time.

The connection between the two must have a wireless protocol, preferably an RF module or Zigbee.

The wireless extent must be able to reach a maximum of 100 ft.

The display module must be small enough and light enough to fit on a clip attached to a belt, or some type of holding device.

The console must be able to send and receive wireless signals efficiently.

8

Page 9: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The accelerometer must be able to detect angles proficiently.

Chapter 4Research

4.1 Initial Project Research and Documentation

The concept of Workout Buddy was simple, but initial testing proved that the task of designing it would require diligent research. It required heavy research in areas that were not of the project members expertise, such as detecting voltage generated by the body, the use of electrodes, and wireless protocols. Every component in Workout Buddy was thoroughly researched and arranged in a manner for it to operate correctly. With the many devices present in this project, each group member was assigned tasks to each device that would be part of the system. Interaction between the group members was vital because the interface between the devices were dependant on each other.

4.2 Previous Works and Similar Projects

Once research was started, it was apparent that there were similar items like Workout buddy on the market. Figure 4.1 shows Noraxons True Wireless EMG, which can be interfaced directly to a computer. This device is mainly used in clinical settings. These types of devices are significant due to this fact, and our chance to design a comparable wireless electromyogram will give the group the opportunity to join a growing field. Figure 4.1 is an image of a similar design made by Noraxon, called Tru Wireless EMG.

9

Page 10: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.1 This image shows Noraxons design that implements a wireless electromyogram. It is mainly used in clinical settings, and not for individual use.

Permission was granted by Noraxon.

4.3 Sensor System

It can be said that a device is only as good as the parts it contains. With that in mind, the success of the design was greatly dependent on the sensors chosen for the Workout Buddy. Without utilizing the correct sensors the device would not aid the user in achieving the target objective of a maximum efficiency workout.

With the abundant amount of sensors available on today’s market, there were several options to choose from for the project. Some of the many factors that contributed to the choices were power consumption, design simplicity, accuracy, and size. This section will discuss the different sensors researched before beginning assembly and design of the project. For each sensor, there will be short discussion on its’ ability to fulfill the specifications and requirements of the design.

4.3.1 Measuring Body Voltage

Measuring the electrical activity within a chosen muscle can be somewhat difficult. To get an accurate reading through the skin, there are several issues that must first be addressed. Below are a few of the expected problems that were anticipated, researched, and planned to overcome.

First, there is the possibility of interference from within the skin. The human body has the ability to absorb electrical interference given off by the 60Hz frequency commonly found in the power supplied in United Sates homes and offices [1]. This small electrical accumulation causes noise across the body which can interfere with the electrode’s readings. To correct this, filtering out the 60Hz interference with a band stop filter was considered. The band stop filter would be set to cut off the frequency before and after 60Hz. This would eliminate the potential noise and result in more precise measurements.

Second, the voltage produced in the human body is very small and can be difficult to accurately measure without the aid of a specialized device. The expected voltage can range from -70 mV to +50 mV and is expected to have a period of 0.5 ms to 1 ms [2]. The only problem expected was finding a sufficient way to measure the very small voltage difference and magnify it so that it could display the progress on a graph that ranges from 0 V to 5 V. This problem was easily solved by using a low powered operational amplifier with a large enough gain to reach the desired max of 5 V.

The last thing anticipated for was the negative voltage that is present during the rest state and the negative swing in voltage due to the depolarizing phase.

10

Page 11: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Although we are measuring a DC voltage, the body pulsates the electric signal which will read as a sinusoidal wave that is similar to AC voltage. When the signal returns from high voltage to its reference voltage, it undershoots down below the resting voltage before normalizing [3]. To prevent this from happening, the possibility of using a voltage rectifier to make all outputs positive or connecting a reference voltage to raise the normal resting voltage was considered.

In order to overcome these problems a number of sensors were researched. The sensors chosen encapsulated the best solution to the problem while maintaining a low cost ratio. All these issues, as well as others, will be addressed as each different type of sensor that was considered for the project is examined and explained.

4.3.1.1 Selecting the Electrode

The Workout Buddy was designed to measure and log the intensity of a flexed muscle in order to help the user better understand where and when peak performance was achieved during a workout. In order to do this, the correct electrode needed to be selected. Sensitivity, complexity, and price were just a few of the criteria that were researched in order to choose the best electrode for the project. The type of electrode required depended upon what exactly was being measured.

Electrical activity would need to be measured through the skin, which would necessitate an EMG (Electromyography) or sEMG (Surface Electromyography) electrode. The EMG style requires the insertion of the electrode into the skin in order to measure the electrical activity [4]. This was invasive and required sterile preparation of the electrode that was too complicated since the Workout Buddy was designed to be used regularly throughout a workout session. The sEMG was a better choice because it measured electrical activity through the skin without being invasive and comes in disposable or reusable forms. These factors made it the ideal choice for use in the project. Figure 4.3.1.1-1 displays the sEMG kit purchased for testing.

11

Page 12: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.1.1-1: This is an image of the sample electrode pack purchased for testing. Permission for image was granted by Bio-medical.

4.3.1.2 How Many Lead Placements

In order to obtain the most accurate data while still keeping the complexity of use low, it needed to be determined that the most efficient number of lead placements to use. If too many leads were required for operation the user would be overwhelmed with the system and be inclined not to use the product. On the other hand, if too few leads were used the device would be unable to capture the required data to provide a useful reading.

To measure the voltage difference across the muscle, a minimum of two leads is necessary. For example, if only one electrode was used, the readings would be of the difference between the activity in the targeted muscle and the electrically neutral reference. This reading would not give a precise indication of the actual difference across the muscle. Instead it would be registering the voltage change across multiple muscle groups resulting in skewed readings. Without at least two primary electrodes to register a difference across a targeted muscle, the readings would not be very accurate.

An optional third electrode can be added in an electrically neutral location to record a reference voltage that would act as a baseline reading [5]. This allows for more accurate readings since it offers more data to calculate the workout intensity. By placing the electrode on a boney location, such as the elbow, it will ensure that the neutral reference remains constant and provides an excellent starting point for all other readings. Figure 4.3.1.2-1 displays the two active nodes placement along with the reference node.

12

Page 13: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.1.2-1: The image displays the ideal placement of electrodes on the arm. Permission for image was granted through copyright provision.

During research the possibility of a third primary electrode was discovered. The Delsys Company found that by utilizing three primary electrodes, a more accurate reading across the muscles can be obtained [6]. This accuracy is due to the elimination of activity registered from nearby muscles that otherwise could interfere with true readings from the targeted muscle. Although this option can supply a more accurate reading, the third primary electrode was excluded from the design to avoid the complexity and keep cost to a minimum.

4.3.1.2.1 Accuracy Due To Placement

Accuracy of the readings was an important factor taken into account with each sensor that was considered for the project. The accuracy of the measurements depended greatly upon placement of the electrodes on the target muscle. In order to get the most accurate data a user manual is packaged with the device to aid the consumer to connect and place each electrode. This guide will give short explanations of the correct placement of the different electrodes for each targeted muscle. If the electrode is not placed in line with the muscle or spaced too far apart the reading will be skewed.

The basis for placing the electrode in line with the muscle comes from the linear flow of electricity present in the body. The electricity conducted through each muscle runs along the muscle fibers lengthwise down each muscle [7]. Placing the electrodes in a series crosswise on the muscle would not register properly.

13

Page 14: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.1.2.1-1: The image displays the ideal placement of electrodes on the leg. Permission for image was granted through copyright provision.

Along with linear placement, proper spacing of the electrodes plays an important part in the accuracy of the readings. If the targeted muscle is small, for example the peroneus longus found in the leg, the electrodes should be placed at the top and bottom of the muscle which would bring them closer together. However, if the muscle is large, the quadriceps for example, it may be possible for the electrodes to be placed further apart. Figure 4.3.1.2.1-1 above demonstrates the proper and improper placements of electrodes.

4.3.1.2.2 Single vs. 3-in-1 Electrodes

There are many different medical grade, electrode designs used to collect voltage information. The specific electrode design would determine exactly how the consumer would connect the leads and collect the data required for maximum function of the Workout Buddy. Two main types of electrodes were discussed as possibilities for the project.

The first type considered was a 3-in-1 electrode pad that has three connection leads oriented in a triangle formation. Two of the three leads are placed in line with the target muscle to register electrical activity. The third connection lead serves as a reference voltage node. This configuration is convenient for the user since only one electrode needs to be placed. The disadvantage is that the user has no control of the spacing between the nodes and looses the option of adding

14

Page 15: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

additional pads for more accurate readings. Figure 4.3.1.2.2-1 below displays the 3 in 1 electrode pad.

Figure 4.3.1.2.2-1 Figure 4.3.1.2.2-2

The images above show the size difference between the 3-in-1 and the single electrode that will be used for testing. Image permission was granted by Bio medical.

A single node, electrode pad was the other option considered. It is much smaller, about ¼ of the size, than the 3-in-1 pad and therefore offers greater placement accuracy. The small size also offers the user more comfort when the skin the stretched and contracted during the workout. With the single node style, a better reference location can be selected further away from the targeted muscle to reduce cross talk from surrounding muscles. Even though the single node version does not offer the convenience of the 3-in-1, the benefits made it a more suitable choice. Figure 4.3.1.2.2-2 above on the right displays the single electrode.

4.3.1.2.3 Electrode Size

When selecting a single node electrode for use, size was considered primarily on its comfort factor. The electrodes are designed to be worn continually throughout the workout. If the electrode is too large the constant tightening of the skin could weaken the contact of the pad or irritate the user therefore hindering performance and distorting the data.

The standard sizes of electrodes range from about one inch to over two inches in diameter. To minimize the distraction of wearing the Workout Buddy during intense training, the smallest electrode is essential. The BMI GS26 standard, disposable, one inch, pre-gelled sensor disc was chosen based on its size, low price, and ease of attachment.

For the final model of the project, only the silver chloride pellet would protrude from the sleeve of the device. This pellet is only ½ inch in diameter therefore reducing any discomfort for the user to virtually non-existent. The sleeve

15

Page 16: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

configuration would aid to the aesthetics of the device without hindering the function of the electrodes.

4.3.1.2.4 Connecting a Reference Voltage Node

As mentioned in section 4.3.1.2, a third lead placement was considered to establish a reference voltage reading. According to research done by the Delsys company, obtaining a reference voltage is thought to reduce the amount of static noise picked up from the skin’s surface [8]. By including the background noise in the established baseline only voltage from the target muscle is displayed. This process can be best described as being like the tear feature on a scale. Any container or surface covering present on the scale is subtracted from the final reading.

Use of a reference voltage is not always required. In cases when the exact voltage offset is known, a reference voltage becomes unnecessary information. But when there is no known offset, for example if the manufacturer cannot calibrate the device for each individual user, a reference voltage taken at each workout will serve as the offset.

During research, it was unclear whether the amount of noise from the skin would be enough to cause significant signal distortion. Only testing the final version of the device will determine if a reference voltage node is needed. Fortunately, this lead can easily be added later to correct an interference problem.

4.3.1.3 Disposable vs. Reusable Electrode Pads

Once the specific type of sensor was decided upon the last choice was between disposable or reusable electrodes. The decision came down to convenience, price, and functionality of the end product. These criteria were based upon a general consensus of the group as to which factors contributed to their personal preference while using the device.

A disposable electrode is described as a one-time use sensor with a conductive silver chloride pellet imbedded into a pad. The pad is typically made of foam, clear plastic or fabric and coated on one side with adhesive to attach to the skin. The reusable electrodes consist of the silver chloride pellet only. This pellet can be imbedded into a sleeve worn by the user. This method gathers data without adhering to the skin.

A variety of disposable electrode pads were used during testing of the design. The disposable feature allowed for multiple electrode types to be tested with relativity little effort leading to a well researched decision on all aspects related to the electrodes. These aspects included spacing, correct placement on targeted muscles, and the benefit of a reference voltage lead. The disposable pads also have the advantage of being more hygienic since strenuous exercise produces

16

Page 17: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

excess amounts of sweat. Disposing of the electrode after each workout keeps the device clean and working properly.

The reusable electrode coupled with a cuff like apparatus offers more convenience for the user since, unlike the disposable models, there is no sticking and un-sticking required. This is extremely beneficial for men with body hair where the adhesive can cause discomfort when removed. A Velcro band will simplify the removal process. Also, the user will not need to purchase replacement pads for continued use; this could discourage normal use of the Workout Buddy due to the costly materials.

When the price of the two types of electrodes is compared, the disposable electrode is far more expensive. At about $0.25 a piece, they are five times more costly than the reusable pellets. However, there are additional costs associated with the reusable version. A cuff or sleeve must be created to house the reusable nodes and is normally constructed from high-price neoprene; whereas, the disposable versions are completely self-contained and ready for immediate use.

It must be noted that for either choice of sensor it is imperative to prepare the skin for contact with the electrode. The skin surface must be free of any dead skin cells, oils, or lotions. An abrasive, alcohol pad is ideal for cleaning the skin prior to application of the electrode. Also, if there is an excessive amount of hair where the electrode is to be placed, it may be necessary to shave the area. These precautions, along with the use of electrolyte gel, ensure maximum conductivity for more accurate readings [9].

Although disposable pads were preferred for testing, the reusable nodes were chosen for the final product. Therefore, to maximize the functionality for the user, the Workout Buddy will be packaged with an arm cuff containing reusable electrodes. Unfortunately, this could limit the use of the device to the arm. The possibility to add other neoprene bands that would enable readings from other targeted muscles, the chest for example, has been discussed but will not be focused upon due to time constraints.

4.3.1.3.1 Silver Chloride Sensor Pellets

All electrodes are comprised of a small node for collecting electrical data. In the disposable version, this node is embedded in a pad whereas the reusable electrodes are only the node. When a reusable node is used, some type of attachment device must also be designed. Most commonly, a sleeve or cuff is constructed to house the pellet.

The material most frequently used for the nodes is silver chloride, a metal chemically know as AgCl. Silver chloride is a very stable, low cost, and durable combination and can only be dissolved in harsh chemicals solvents. Apart from

17

Page 18: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

being used in EMG electrodes, silver chloride is contained in photography films and plates [10].

The sensor pellets researched for this project range in size from 0.35 to 0.5 inches in diameter. Though the discrepancy between the different sizes is limited, the larger styles are normally used for bigger electrode pads. One side of the pellet has a nipple that the lead attaches to and most nipples are of a standard size to allow universal function with a variety of leads. Moisture is required for proper conduction and an electrolyte gel is most often placed between the node and the subject’s skin to aid in the transfer of electrical impulses. Figure 4.3.1.3.1-1 below is an image of the silver chloride nodes.

Figure 4.3.1.3.1-1: These are the reusable pellets that will be used for final production. Image permission was granted by Bio medical.

4.3.1.3.2 Self-Adhesive Sensor

The most common types of disposable sensors come with a self-adhesive backing for adhering to the skin. The adhesive is applied during the manufacturing process to the back of a pad typically made from foam or fabric. These sensors vary widely in design size, shape, and number of nodes. The exact type of electrode pad used is normally dependant on the information intended for collection. Large pads with more than one nipple are used to measure the difference between the nodes; while smaller pads can collect data from multiple placements for any purpose.

Ease of use is the greatest asset of the disposable electrode. These pad/pellet combinations can come pre-gelled therefore making it very convenient to collect data without needing to keep additional supplies. Since it does not require extensive knowledge or skill to administer this type of electrode, they are the ideal choice for clinics and offices who employee personnel without medical training. Many doctors and clinicians utilize them in order to monitor and treat multiple patients without sterilization or the possibility of cross contamination.

For the testing phase of this project, disposable electrodes were used when determining correct lead placement and spacing. The use of the disposable electrodes allowed us to select several different configurations so that we could

18

Page 19: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

properly examine the variance in signals due to spacing and placement. Reusable nodes would have made this process much more time consuming because they would require us to utilize more materials to secure the electrode against the skin.

4.3.1.3.3 Extra Materials Required

As discussed in previous sections, reusable electrode nodes require extra materials to be utilized properly. These materials can be costly and time consuming to produce therefore needing additional funds that must be factored into the final cost of the product. With each electrode added to the system a new attachment device must be manufactured, which will increase the cost of production. Figure 4.3.1.3.3-1 is an image of the electrode leads that would be required for the design.

A sleeve or band of neoprene, constructed with Velcro to allow for adjustment in size, was determined to be the ideal housing for the pellets. Each band would house one to two nodes which would be glued into place. The system would require three separate bands; one to register target muscle activity, one for the optional reference voltage, and another for the angle detection device. Ideally, these bands will be made so that they can be placed around a small radius limb or around the torso by adding an additional piece which would lengthen the band. Figure 4.3.1.3.3-2 is an image of the various uses of neoprene.

Figure 4.3.1.3.3-1 Figure 4.3.1.3.3-2

The image on the left is of the electrode leads that are being used for testing and on the right is an image of the neoprene material that is being considered for the sleeve that will house the sensor circuit. Image permissions were granted by Bio medical and Foam Order.

4.3.2 Measuring Muscle Contractions

19

Page 20: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

In order to move any part of your body, it requires the contraction of muscles. To make the body move, such as raising the arm, the brain sends electrical impulses that trigger a contraction of the muscles in the shoulder, neck and back which all work in together to raise the arm.

The electrical impulse sent from the brain, is transmitted through the body with the use of two chemical elements found in the nervous system. These two elements, sodium and potassium, are circulating throughout the axon of the neuron. The neuron controls the levels of these elements to produce an electrical flow through the nerves, from the brain to the muscles. Once the charge has been received by the neuron, the signal is sent through the axon causing action potential spikes until it reaches the axon terminal and will continue to cycle through the nervous system until the brain terminates the signal. The time it takes to execute, from conception to completion, takes only milliseconds, making the muscle movement seem instantaneous [11].

The electric potential transmitted through the axon shown below in Figure 4.3.2-1, is very small and impeded by the thickness of the skin. To measure such a small voltage spike, the device used must be capable of measuring micro-volts. Most devices available are not capable of measuring such small differences. Therefore, the signals magnitude must be increased so that a difference in voltage can be obtained. Through some extensive research, it was estimated that the amplification would need to be in the 1,000 to 10,000 range. The amplifier chosen for the project is capable of amplification up to the 10,000 range making it possible to best acquire the signal [12].

20

Page 21: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.2-1: The image displays the chemistry of the electric potential that is sent through the axon a) without the insulator and b) with the insulator that protects the axon. Image permission granted through Copyright provision.

Many factors must be addressed when attempting to measure muscle activity. Some of which are thickness of the skin, fatty tissue between the muscles and measuring device, and the size of the muscle among others. These factors can contribute to the diminished strength of the signal and possibly even obstruct it completely. These obstacles cannot always be readily compensated for. However, they are obstacles that can be overcome by means of careful planning and proper circuit design creating a device that is as accurate as possible to offer the user a powerful tool for obtaining an optimal workout.

4.3.2.1 Circuit Devices Considered

The device circuitry is as important as the electrode sensor selected because without the proper circuit, the device will not function properly. The combination of the sensors and device(s) will enable the detection and logging of the signals produced during any given workout, so that they may be analyzed at a later time. The signals detected are subjected to small and medium frequency noise. Therefore, a suitable device to eliminate as much noise as possible, while not adding any additional noise of its own must be found.

21

Page 22: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The ideal device chosen would produce no noise that could affect the data collected. However, such a device does not exist. With every device comes some noise that is transmitted to the output, causing skewed results. For this project, the most desirable device would produce voltage noise of less than 1 mV. This interference can be reduced by increasing the common mode rejection ratio, otherwise labeled as CMRR. By closely matching the input resistance within a device, a higher CMRR will be obtained. With a higher rejection ratio the amount of noise that can be generated within the device will be very small. The ideal CMRR for the design is within a range from 70 dB to about 95 dB or higher [13].

Along with noise reduction, the device must also operate at the lowest possible current and voltage in order to conserve the battery source that will be powering it. Many devices available today are powered at 9 V or 12 V on average and can be higher depending on the individual device. There are however, much smaller applications/devices that are capable of operating efficiently at very low voltage and current supply of just over 2 V. These devices, while low in power consumption, do have limitations. These limitations include the amount of amplification, stability, and the ability to conserve power. Choosing a device that will encompass the desired attributes while minimizing the negative aspects is essential to the projects overall functionality.

Another crucial feature to the design is a device that has a very high input resistance. The need for high input resistance comes from the simple voltage division rule. In order to draw as much voltage as possible, a resistance that is much greater than the resistance of the skin is needed. The skin’s resistance is typically around 5 Mega ohms (obtained by using a multi meter against the skin surface) when dry, therefore trying to obtain an input resistance much greater while still achieving the gain necessary to observe a voltage, can be very difficult. The most common way to overcome this obstacle is to use the electrolyte electrode gel. The electrode gel is widely used throughout the medical industry. By utilizing the gel, the skins resistance is significantly lowered to about 30 Kilo ohms, far less than the 5 Mega ohms. This is still slightly too high to achieve extremely high gains while maintaining stability in the device. Thus, to create a resistance that is much greater than the skin’s impedance, the buffing operational amplifier was introduced. The use of a buffer will not only keep the circuit stable, but it will also produce 1 Mega ohm of impedance due to the device properties which allow it to act as a buffer.

These features, as well as others, will be key elements to the success of the design. Through extensive research and testing, a range of devices have been considered as possibilities to incorporate into the design. The following were considered, researched, and decided on after much thought of their operation in the design; a voltage comparator, operational amplifier, and a difference amplifier. Each of these will be discussed further in the sections following to determine which device configuration will work best for the design.

22

Page 23: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.3.2.1.1 Voltage Comparator

One of the devices considered for the design was a voltage comparator. The purpose for the voltage comparator is to select the higher of two voltages as a readings output. In order to fully utilize this feature, the active voltage would need to be compared with a reference voltage obtained from the body. This would enable any fluctuations in the muscles electric potential by only observing the voltage that is above the reference. The voltage comparator that best fit the needs of the design was the MAX9109 and is manufactured by Maxim Integrated Products.

4.3.2.1.1.1 MAX9109

Propagation Delay

Input CMVR to Neg. Rail

Min. Total

Supply (V)

Max Total

Supply (V)

Max Supply Current

(μA)

Input Voltage Range

(V)

Typical Offset (mV)

Max Offset (mV)

Logic output

25 ns

Yes

4.5

5.5

700

VEE 0.2 to

VCC 1.5

0.5

1.6

TTL

Figure 4.3.2.1.1.1-1: Key features of the MAX9109 [14]

The MAX9109 voltage comparator is ideal for battery operated applications. It is capable of using only +4.5 V single supply power and only requires 0.41 mA to be drawn from the power source for normal operation. By utilizing this very low power comparator, it would allow the user to operate the device for up to a week on a single 12 V battery. The length of operation would, of course, be subject to the length of each work out session and the frequency of the sessions.

The voltage comparator is also capable of a very high common mode rejection ratio. According to the data sheet, provided by Maxim Integrated Products, The typical CMRR that can be expected is 40 dB and the maximum CMRR that can be obtained at a given temperature is said to be at 82 dB [15]. Achieving a CMRR of 70 dB or above of noise from the comparator, would place its operation within specifications for low noise output.

Another beneficial feature provided by this comparator, is the built-in hysteresis. This feature allows for a more accurate voltage switching by reducing the noise feedback created within the device. This will provide a clear difference between the two input voltages while also maintaining a stable output even when the signal has a very low frequency, as is the case with a sEMG signal. An issue that would need to be addressed is the uncertainty of the comparators input resistance. Without knowing the exact design of the MAX9109, it must be properly planned for placing a buffer before each input to the comparator. This would ensure that the impedance is large enough to draw out most of the signal.

23

Page 24: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The image shown below demonstrates how the comparator would need to be implemented into the design. Figure 4.3.2.1.1.1-2 is an image created by a group member which shows a possible circuit setup for the use of a comparator.

Figure 4.3.2.1.1.1-2: This is a circuit that would be considered for the use of the MAX909CPA comparator setup.

Although the comparator would provide the least amount of electrode placements, it would also require the use of multiple operational amplifiers. These op amps would act as both the buffers as well as the amplifier to magnify the input signals enough to measure the difference in voltage. While this would be a very simple circuit to design, it would also require additional power to be supplied to each of the op amps as well as the voltage comparator. This would inevitably consume the battery power and prove an inefficient circuit to build when considering power consumption. Therefore, additional circuit designs to replace the idea of a comparator circuit were considered.

4.3.2.1.2 Operational Amplifier

An operational amplifier would be necessary for any circuit design that was considered. The reason for this is the sEMG signal attempting to be measured is quite small and cannot be measured by most devices without the aid of amplification. Therefore, several different amplifiers were researched that were suitable for the sensor circuit design. The key features were, of course, minimal power consumption, very high CMRR, and a gain of 1000 or higher. These features would allow long term use, great signal acquisition, and a very low output of internal device noise.

24

Page 25: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.3.2.1.2.1 AD620AN

Among the many amplifiers considered, the AD620 instrumentation amplifier encompassed all features that were essential to the design. This amplifier is commonly used for very low signal amplification due to its ability to achieve very large gains while still maintaining stability. As shown below in Figure 4.3.2.1.2.1-1, this instrumentation amplifier is easily adjusted for the desired gain by adding resistance between pin 1 and pin 8. The gain can range from as little as 1 to as much as 10,000 [16].

Figure 4.3.2.1.2.1-1: This image displays the resistance values that can be used for the desired gain. Image permission was granted by Analog Devices.

The 10,000 gain for the figure shown above in Figure 4.3.2.1.2.1-1 is not displayed. When using the gain equation provided by Analog Devices, the resistance value calculated would need to be below 5 ohms and may be substituted with a short (wire connection) between the two pins.

Another beneficial feature provided by the amplifier is the extremely high common mode rejection ratio. The AD620 is capable of maintaining a CMRR much higher than 100 for frequencies below 1 KHz [17]. Since the sEMG signal is only measured between 20 Hz and 250 Hz, the CMRR provided by the amplifier will be a great asset to the design of the device.

Among the many benefits of the AD620, is its ability to conserve power for other battery operated components. The amplifier can use up to 18 V, but will still operate efficiently with as little as 2.3 V. For the desired gain to reach 5 V max, no more than 6 V supplied to the amplifier will be necessary. This will ensure

25

Page 26: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

that there is no clipping effect or limit before the 5 V desired output. Along with the low voltage requirement, is the battery saving current that is needed to operate the device. The amplifier can use up to 1.3 mA max but can operate at a very reasonable 0.9 mA [18]. This would save considerable battery power and allow more devices to be added to the circuit for a more effective design.

As mentioned earlier, this amplifier is commonly used for low signal analysis. Since it is such a popular choice, Analog Devices has encouraged the use of their product by including a sample of an ECG circuit which is virtually the same as an EMG circuit. The main difference between the two is that the ECG measures the heart’s electrical activity and the Workout Buddy is measuring electrical activity from muscles throughout the body. The sample circuit shown below in Figure 4.3.2.1.2.1-2 demonstrates how the amplifier could be used for sampling electric potential from three places on the body to record a heart rate.

Figure 4.3.2.1.2.1-2: This is a sample ECG circuit that is similar to the circuit needed to sample the EMG signals. Image permission was granted by Analog Devices.

While the circuit, provided by Analog Devices, serves the same purpose as the Workout Buddy, it may not be configured correctly for acquiring EMG signals. This is because the voltage through a muscle is much weaker than the voltage from the heart. The signal collected with the Workout Buddy may need to be amplified more than shown taking careful consideration for power usage for the additional devices that will be necessary in the circuit.

4.3.2.1.3 Difference Amplifier

The last option considered for low signal analysis, was a difference amplifier. This amplifier, in theory, could eliminate much of the noise that is thought to affect the results by only amplifying the difference between the two inputs. That

26

Page 27: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

being the case, it may be possible to avoid the use of a third electrode placement that would otherwise be used as the reference for the measurements taken. This was a very attractive design due to the minimal amount of parts necessary to achieve the goal.

4.3.2.1.3.1 AD626AN

Several differential amplifiers were considered for the project. First, was the AD626AN, made by Analog Devices. The AD626AN was a superb choice for many reasons. Among the many desired features provided by this amplifier was its ability to maintain an excellent common mode rejection ratio. The amplifier is capable of maintaining a CMRR greater than 90 dB at frequencies up to 1 KHz. Since the only concerns are with frequencies lower than 1 KHz [19], this amplifier could provide an exceptionally low noise disturbance from the device providing a clean signal out.

This device, unlike others considered, also has a low pass filter available. The low pass filter is adjusted with the use of an external capacitor which is used to set the desired frequency. This option was very appealing due to the need for selective frequency observation. The frequencies which are most desired are between 20 Hz and 250 Hz. By utilizing the filter, it is possible to achieve cutoff frequencies above 250 Hz leaving only the frequencies below 20 Hz to address.

Figure 4.3.2.1.3.1-1: This image shows the basic features of the AD626 differential amp including the low pass filter option which could be set to the 250 Hz that is of no interest for EMG sampling. Image permission was granted by Analog Devices.

27

Page 28: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Another feature provided by the amplifier was its low power consumption. As with all of the devices considered, it is a major concern for the design to optimize power conservation. Considering, the power required to operate the AD626AN is within reason. It requires a minimum of 2.4 V and only needs 0.16 mA to function effectively [20]. This would certainly enable a more efficient circuit design leaving more power for any additional devices that may heighten the operation of the Workout Buddy.

The advantages of using the AD626AN were significant when compared to the previous circuit designs. While the use of this amplifier would not eliminate the need for all additional parts, it would reduce the number required to achieve the appropriate gain necessary to read the sEMG signal. By utilizing buffers from within the device, there would be no need to worry about the impedance factor. Another advantage to this device was its ability to create a gain of 100. While the gain provided was not the ideal, it is possible to compensate for with the use of an additional amplifier which would achieve the required goal of 1,000 or more in gain. The total device count, minus resistors and capacitors, would be only 2, thus creating a much simpler circuit than previously considered.

4.3.2.1.3.2 INA122

The other differential amplifier considered was the INA122, designed by Texas Instruments. This amplifier was especially valuable to the design for several reasons. The INA122 does not only include all the desired features set forth to obtain, but it also was designed specifically for extremely low signal analysis. This device is widely used for low powered applications such as “portable/battery operated systems”, “physiological amplifier: ECG, EEG, EMG”, and “multi-channel data acquisition” [21].

The INA122 was found while searching for a differential device that required the least amount of power supplied for operation. There are other devices that were comparable in power requirements but none provided the many key features desired for the design. This amplifier was most desirable with only 2.2 V supply and an amazing 0.06 mA to operate effectively [22]. With this ultra low power device the user could easily use the same battery for up to a month or longer before needing a new one.

The complication of noise disturbance is also overcome with the use of the INA122. Since this device was specifically design for acquiring minimal distortion, low voltage signals, produced by the body, it is no surprise that the common mode rejection ratio is within an acceptable range for this device. Looking at gains of 1000 or higher and frequencies below 1 KHz, the CMRR remains above 64 dB and can reach up to 96 dB [23]. This will certainly ensure that noise from nearby power sources will not create any interference.

As demonstrated below in Figure 4.3.2.1.3.2-1, the INA122 is very easy to work with. To obtain the desired gain, a resistor RG is added between pins 1 and 8. In

28

Page 29: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

the image provided by Burr Brown there is a table of resistor values along with the corresponding gains that can be expected. While this is nothing uncommon among most data sheets, it was still very useful because it allowed for more time spent on other crucial parts of the design and less time testing for specific gains.

Figure 4.3.2.1.3.2-1: This is the INA122 differential amp with gain configuration and related resistor values. Image permission was granted by Texas Instruments Copyrights provision.

Once all designs were considered, it was decided that the best circuit design that fit the criteria for low power, minimal noise distortion, and very high gain, lies with the use of the INA122. For its ability to provide all of the required features along with space saving and minimal part usage, it outperforms all others that were considered.

4.3.3 Filtering noise

One of the many problems expected was the amount of noise that could interfere with the results. Any amount of noise created before the output of the amplification device would be amplified along with the low voltage EMG signal that is being measured. This noise can be generated by both internal devices as well as sources that are not part of the device but are acquired through the sensors used.

29

Page 30: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Noise created from within the device is not uncommon. This noise is usually caused by mismatched resistance built into the device. The resistance values generally are not purposefully mismatched but the error seems to come from the percentage of accuracy of the resistors used. The more expensive the resistor, the more accurate it can be expected. Finding a balance between accuracy and price is tricky but poses a worthwhile challenge for a low budget and cost effective design.

Also, when the resistors used in the device are of smaller values or they are made from a different manufacturer, the percentage of error is likely to be increased. The percentage error in overall resistance causes inaccurate results due to the noise that is produced from within the device. This noise is often measured in dB and labeled as CMRR (common mode rejection ratio). The lower the dB rating, the more noise and signal distortion are present with the results. For this device a CMRR of 70 dB or higher is required.

Since the CMRR cannot be improved after the device has been made, a device must be selected that produces the best rejection ratio over the frequencies at which the signal is being observed. The frequency being observed is located between 20 Hz and 250 Hz [24]. These two requirements are easily obtained for most devices and can be verified with the use of the data sheets provided by the manufacturer.

Along with the noise produced by the device, there are the external sources of noise. These sources can be; breaks in a wire, small movements made by the user, or even strong frequencies that are present in most buildings. The external noise received cannot be corrected with the use of an amplifier alone. Instead, it requires the use of filters. The filters can be easily created with the use of the configuration of a resistor and a capacitor.

For the design, a high pass filter will need to be built and be located before both of the inputs to the amplifier. To build the high pass filter a capacitor would need to be placed between the sensor and the amplifier with a resistor placed after the capacitor but before the amplifier. This will create a passive high pass filter which would require less power to operate and can be easily modified at any point. To collect the best sample signal, the cut off frequency will need to be set at or close to 10 Hz. Shown below in Figure 4.3.3-1, is a sample of the filter design selected for the high pass filters.

30

Page 31: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.3-1: This is a passive low pass filter configuration that will be used during testing.

In addition to the needed high pass filter, a low pass filter should also be used. The low pass filter is similar to the high pass filter with the exception being the configuration of the resistor and capacitor. By inverting the two, the filter becomes a low pass filter. For the placement of the low pass filter, it was decided that after the amplifier would most efficient. This would decrease the number of components and reduce the error in cut off frequencies of the many filters used. The ideal frequency for the low pass filter was set to be near 350 Hz. This would provide a signal that remains lower than the cut off frequency. Shown below in Figure 4.3.3-2, is an image of the desired low pass filter.

Figure 4.3.3-2: This is the high pass filter that may be used during testing.

All of the devices researched offered individual assets to the design but the chosen devices have proven to be the most cost effective and efficient. Integration of these filters along with a low noise amplifier will produce a signal that is clean and free of most interference allowing the Workout Buddy to function properly in most environments including homes, businesses, and outdoors without significant signal distortion.

31

Page 32: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.3.4 Design Simplicity

The Workout Buddy was designed with the user in mind. The concept behind it is to provide a method of accurately tracking the user’s exercise progress while maintaining a light weight, affordable, and low profile design, so that it can be used with little to no discomfort. This would create a more appealing option to the user when compared to the paper and pencil method that is commonly employed today by exercise enthusiasts. In order to accomplish this, the design needed to be made as simple as possible in both the number of components and the functionality of the Workout Buddy. If this is accomplished, it is hoped that more users will be attracted to a regimented workout schedule made easier by the Workout Buddy.

To reduce the number of components used for the design, the devices selected would need incorporate as many features necessary to the design as possible. This would ensure that the final product would be compact, light weight, and cost effective. Through research, a basic concept of the design emerged. The features that were simple and relevant dictated the design. The image shown below provides an idea of what the group is aiming to achieve. The final product may or may not resemble the Figure 4.3.4-1 shown below.

Figure 4.3.4-1: This is the desired final product for the Workout Buddy. On the left is the device platform that will process and store data and on the right is the sensor system that will transmit the data to the device platform.

There are several features that the group would like to include. However, due to time constraints, it may not be possible to include them all. One feature, in particular, that will only be completed if time permits, is the wireless communication. Due to the multiple sensor inputs, more components would

32

Page 33: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

need to be included to process and send the data. While this is not a very difficult task to achieve, it will take some time to research and test any methods that would be considered. Therefore, it will not be part of the prototype, yet it is the groups goad to add it to the final design.

The functionality of the Workout Buddy should be very appealing to those who want to track their progress over an extended period of time without the need of a pencil and a note book. One of the features the group hope to obtain is the ability of the Workout Buddy to recognize when to record a repetition and when to start a new set. This can be done very easily, provided the programming parameters are set correctly and the sensor used can accurately measure the body movements.

The programming part of the set and repetition counter will have its parameters set to count when the body movement reaches a certain angle. The angle determined by the group, for a bicep, was around 90 to 110 degrees from the original starting point. The device platform will utilize a timer to register a starting point. Then from there it will count a repetition after every curl of the arm that travels more than the set degrees from the original starting point that was acquired at the beginning of the set. After a period of no activity, the device platform will sense that the set is complete and begin a new one once a new starting point has been initiated.

This data can stored in the microcontroller can be downloaded onto any local computer by a USB cable for review by a physician or the user for analyzing the progress made. The goal is that the group will be able to simulate the movements made and the intensity of the muscle contractions measured as well as graph the results so that the person reviewing the data can see how the user performed during their work out session.

4.3.6 Angle Detection

One of the great features of the Workout Buddy is its ability to count repetitions and sets so that the user does not need to. In order to do this, a sensor that could indicate how much of an angle a body part has traveled from its last position was needed. The choice of sensor was crucial when considering its size, power requirements, and functionality. In order to maintain the goals, evaluation each sensor considered was needed to find the best one for the design.

The size of the sensor is very important when keeping the users comfort in mind. The group did not want to develop a sensor system that would need an additional apparatus to be worn by the user. This would cause more complications with use and could be bulky and become an annoyance to wear. Therefore, the group looked at very small mechanical and electrical devices that could be used to detect a change in angle. The ideal sensor to be utilized would be small

33

Page 34: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

enough to fit in the palm of a young adults hand and easily attached to a body limb while remaining unnoticed by the user.

The power consumption was also another major concern when deciding on the appropriate sensor. The sensor circuit needed to operate on a low power DC supply. This greatly limited the number of components that could be used to collect data. Therefore, in order to provide a long operational period for the circuit system, the group looked for low power operating sensors. The expected voltage required to operate the sensor would be between 2 V and 3 V. At this amount of voltage it could conserve the power stored in the battery supply by only using micro amps. The desired voltage to power a simple sensor seemed very reasonable to obtain for the circuit.

The Functionality of the sensor was also part of the evaluation of the multiple sensors that were researched. There were many sensors that could be used for detecting movement, most of which are in the form of potentiometers. They generally use mechanical movement to vary a voltage output. This output could be processed and converted into angle increments so that it can be simulated and graphed at a later time. In deciding which sensor would best fit the needs, the group looked for one that could easily be attached and would need little effort to move the potentiometer. This would provide for a sensor that may remain unnoticeable to the user.

Everything mentioned above was included, but not limited to, when determining which sensor would best fit the design specifications. Each type of sensor was carefully researched to verify its compatibility with the circuit design. Following this section, are a few types of sensors that were strongly considered for the circuit.

4.3.6.1 Optional Sensors

There were many sensors to consider for detecting angle movement, each one with its advantages and disadvantages. The advantages of most were the simplicity of the sensor design, the wide range of power that could be supplied, and the costs of the sensors were exceptionally reasonable. Some of the disadvantages, were maintaining proper placement (for removing and reattaching the sensors), the large devices necessary to complete the sensor circuit, and the uncertain accuracy that the device will have. All of the sensors considered for the circuit were carefully researched to determine which would be the best choice for the specifications set for the sensor circuit. The many sensors researched come from four different categories, to include: flex sensors, string potentiometers, rotational potentiometers, and MEMs devices.

34

Page 35: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.3.6.1.1 Flex Sensor

The flex sensor was one of the first to be researched. This sensor is essential a potentiometer that varies when bent. This seemed to be a very good choice due to the effort necessary to bend it was very little and it could be placed inside a sleeve, around the elbow, for detecting movement. The flex sensor we chose to look at was the Bi-Directional Flexible Bend Sensors (FLX-02).

While data is limited on the specifications for the FLX-02, it is easy to see how easily it could be implemented in the design. As shown in Figure 4.3.6.1.1-1, the flex sensor is a very simple design. It basically consists of a very fine sheet of conductive metal paired with a resistive material and separated by a acetate film. This makes for a very inexpensive sensor to both buy and build.

Another great feature about the FLX-02 is that it does not require a minimum voltage to operate it. Being that it is just a variable resistor, we can supply any reasonable amount of power to it and receive a varied output. This would enable more control for the amount of power used by the device and allow for optimal power conservation.

Figure 4.3.6.1.1-1: Here are the materials needed to build a Flex sensor. Image permission was granted by Images Scientific Instruments Inc.

One feature that the FLX-02 has that is very different from the rest is its ability to increase and decrease the resistance depending on which way it is bent. This would allow for a more accurate indication of which way a limb is moving. For example, if the arm or knee were being fully extended and possibly over extended, the sensor will only increase or decrease depending on which direction

35

Page 36: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

it was calibrated for while most other sensors would decrease resistance in both directions. Below in Figure 4.3.6.1.1-2, are the two in reference.

Figure 4.3.6.1.1-2: The image on top shows a flex sensor that decrease the resistance when flexed in both directions and the bottom image shows a flex sensor that will increase and decrease depending on which direction it is bent. Image permission was granted by Images Scientific Instruments Inc.

The FLX-02 seems to be a very good choice for the design. However, there are several more possibilities to explore. Therefore, this sensor will remain on the list of possibilities and possibly as a backup should another one fail.

4.3.6.1.2 Soft Rotational Potentiometer

The rotational potentiometer is a great sensor for angle detection. By utilizing a round potentiometer, we can position the sensor on the outside of the arm, at the elbow or on the side of the knee, where it will only rotate and not move linearly. The sensor would require a half sleeve for the elbow and knee area to house it as well as proper placement so that it is centered at a pivot or rotational point. The desired potentiometer would need to be a very low profile, easily adjusted device.

One of the sensors found to be the smallest in thickness was a soft pot rotational potentiometer manufactured by Spectrasymbol. This sensor is no thicker than a

36

Page 37: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

few sheets of paper and is small enough to fit on the arm without being noticed. The sensor is capable of varying resistance from 1,000 ohm to 100,000 ohm and can be ordered to size [25]. Below in Figure 4.3.6.1.2-1 is an image of the soft pot with measurements in mm.

Figure 4.3.6.1.2-1: Here are the dimensions of the soft pot in mm which gives an idea of how small and convenient the potentiometer would be to use in the design. Image permission was granted by Sparkfun.

The power requirements for the rotational potentiometer are also very good. The maximum that the soft pot can handle is 1 Watt. By using only 2 V to 3 V with a varying resistance of over 1,000 ohm, the soft pot will never reach maximum power ratings. This means it would be able to conserve much of the battery source and still operate all components at the necessary voltage.

One drawback to using this setup is the need for an additional part that can be bulky as well as being difficult to keep the assembly working correctly without housing for it. This would probably be too bulky and unattractive to the user. Therefore, this sensor was not considered beyond its research.

4.3.6.1.3 String Potentiometer

The string potentiometer was also researched for this design. The idea of a string pot seemed promising for the circuit due to the variety of sizes and lengths available. The device would require a small sleeve to be placed around the elbow or knee for attachment and it would need to be positioned so that the potentiometer can extend and retract its fullest to get optimal readings for angle detection.

37

Page 38: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.6.1.3-1: The images above display the dimensions of M150 String potentiometer which would be used in planning placement of the device. Image permission was granted by Celesco Transducer Products.

The string pot that was found to be most beneficial to the design was the M150. This string pot is said to be one of the smallest potentiometers available on the market today weighing in at only 4 oz. This particular string pot is about the size of a quarter and is just over a third of an inch thick, making this device virtually unnoticeable to the user. Shown above in Figure 4.3.6.1.3-1, are the images displaying all of the dimensions of the M150 potentiometer.

The string potentiometer is also very good in power consumption. This device requires an output current greater that 1 μA and a maximum of 20 V input. This is very easily attainable with the 2 V to 3 V that is has been allocated for the use of angle detection and would save the battery’s power for long term use.

In addition to the sleek design and low power requirements, the string potentiometer would also be very easily integrated into the design. The string pot has only one output which will be a variable voltage that can be converted into a corresponding angle or degree change with very little effort. This would limit the number of signals that would need to be processed by the microcontroller and simplify the amount of data that would be transmitted wirelessly, if the wireless feature is implemented.

38

Page 39: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.3.6.1.4 MEMs Accelerometer

The accelerometer was also researched for the sensor circuit. It was mentioned by group member Scott Martin as being a very popular device for angle detection in electronic devices such as the Apple i-phone and i-touch. The accelerometer detects the different angles through a 2 or 3 axis sensor located inside the device as well as gravitational forces and any other force disturbances. The sensor varies the voltage on each axis with the use of a floating capacitor that is placed between two other capacitors. Figure 4.3.6.1.4-1 displays the capacitors involved in varying the voltages. The voltages generated can be converted into a digital signal and with the use of some simple algorithms it can be determined which angle the accelerometer is positioned at.

Figure 4.3.6.1.4-1: This image displays the capacitors inside the MMA7260Q which vary the voltage supplied. Image permission granted by Sparkfun.

The accelerometer that was researched was the MMA7260Q. As shown in Figure 4.3.6.1.4-2, the sensor is very small. Even with the breakout board, the sensor is only slightly bigger than a quarter. Therefore, the group decided that if the part were to be ordered, it should be ordered already attached to the breakout board for testing and possibly for the final product as well. This was decided for the fact that the MEMs device would be very difficult to test without it being in DIP form as well as the possibility of damaging the device if the group attempted soldering it to their own circuit. Since the sensor circuit only has one major component, the group did not see any potential problems with ordering it.

39

Page 40: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.3.6.1.4-2: This image was used to show the compact circuit that contains the accelerometer. Image permission was granted by Sparkfun.

Among the many qualities that were found in the MMA7260Q, the power requirements were especially appealing. With a supply voltage between 2.2 V and 3.6 V and a current supply of 0.5 μA, the accelerometer can operate effectively and efficiently while conserving the battery’s stored power [26]. This works perfectly with the desired voltage that has been planned for this part of the circuit. If the energy saving device were to be coupled with an energy efficient electrode circuit, the battery used to power the sensor circuit could possibly last for a month or longer depending on the number and length of each of the workout sessions.

The MMA7260Q is also equipped with a selectable sensitivity that can range from 1.5 g to 6 g forces [27]. This could be useful if the device were to be used to measure how fast the arm or leg moves for each repetition. The idea of measuring the speed of a movement could be considered for determining the repetition or set that the user becomes tired. This moment of fatigue or weakness would be seen through the movement becoming slower than normal. This data could be useful when the user decides to optimize their workout by limiting or adding to the exercise routine. By doing this, the user could effectively lengthen their workout session by selecting a different area or muscle group to focus on while the over exerted muscles are resting.

For the placement of the accelerometer, the group decided that it would be best to fit the sensor on a part of the body that would be moving or traveling the furthest in angle during selected exercises. One location, thought to be an idea place, was on the forearm near the elbow. This would be measuring repetitions for curls, triceps extension (skull crushers), and dips. The other prime location would be placed on the lower leg area nearest to the knee. The exact placement has not been decided upon as of yet. However, the best location in theory would be above the calf muscle on the back of the leg. In that position, the sensor

40

Page 41: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

would be less likely to come in contact with equipment used during an exercise. The exercises that would be measured in this area could be squats, leg curls, leg extensions, and the leg press.

All things considered, the MMA7260Q accelerometer seemed to be the best sensor for detecting the angle changes during an exercise. It met all specifications and a requirement set by the group, and was a very affordable sensor to utilize. The only negative aspect of the accelerometer was the need for more than one output. To measure the angles, there would have to be at least two of the three outputs utilized. This would provide an angle between two axis, likely to be X or Y with Z axis, to be calculated by the microcontroller. The difficult decision that would need to be made is whether to transit the two signals or process the signals before wireless transmission which could possibly reduce the signal to a single output.

Figure 4.3.6.1.4-3: This image displays the different positions for the MMA7260Q and the expected voltages that can be expected. Image permission

granted by Sparkfun.

41

Page 42: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

42

Page 43: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.4 Microcontroller

4.4.1 Microcontroller Selection

A microcontroller is a complete computer system optimized for hardware control and includes a processor, memory, and all input and output devices in a single integrated circuit package. Being on the same piece of silicon means that speed is enhanced as read and write times are reduced. Optimization for hardware control means that the microcontroller provides machine level instructions for setting, clearing, reading, and writing individual bits on the I/O ports and in the registers. Without hardware control it would require addition hardware logic such as external AND, OR and XOR gates to manipulate individual bits on the ports or in the registers.

The project requires the use of two microcontrollers; one in at the end of the instrumentation signal chain and another inside the control unit. The control unit has the job of storing data from the sensors as well as outputting sensor data in realtime to its display. Additionally, the LCD on the control unit will display information such as time elapsed, the exercise being performed, as well as the current set and rep count. Several different microcontrollers from different manufacturers were evaluated on their feature sets, price, and ease of use to determine which would be best for this application.

4.4.1.1 Ti MSP430

Figure 4.4.1.1: The MSP430 microcontroller in a surface mount style package. Permission pending from Texas Instruments.

The TI MSP430 is a popular platform for all types of embedded projects. Pictured in Figure 4.4.1.1,It uses a 16 bit Von Neuman style CPU with a top speed of 25MHz. It has several serial interfaces including USART, SPI, and I2C as well as am analog to digital converter of up to 16 bit resolution. The price point of the MSP430F2274 configuration at Digikey is $11.25. However, only one chip variant, the MSP430F2013, is available in a dual inline package for simple

43

Page 44: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

prototyping. Its main drawback is the lack of simple prototyping and the relative learning curve of using its development tools.[1]

4.4.1.2 Microchip PIC18F452

The PIC18F452 is a popular microcontroller offering from Microchip with active use both in industry and in the amateur embedded markets. This chip has an 8 bit CPU running at a maximum 40 MHz, and operating from 2.2 to 5V. It can communicate serially via its UART as well as via SPI and I2C. It has an 10 bit analog to digital converter and is available in dual inline packages for $7.50 in quantities of 100 pieces at Futurelec. [2]

For development, a free assembler (MPLab) is available. Using a higher level language such as C is possible using the IDE from Microchip. The student version (free) of the compiler has a reduced functionality from the paid version of the C Compiler ($250), and some optimizations are not available.

4.4.1.3 Atmel Atmega 168

Figure 4.4.1.3-1: This is the pinout of the Atmega 168. Permission pending from Atmel.

The Atmega 168 from Atmel is the microcontroller that was chosen to be the best candidate for the control unit for our project. As seen in Figure 4.4.1.3-1, this chip is a twenty eight pin 8 bit microcontroller running at a maximum 20 MHz. It uses a modified Harvard RISC architecture and can be powered from a 1.8 to 5.5V supply. The RISC stands for Reduced Instruction Set Computing and means that the device is defined to run very fast through the use of a reduced number of machine instructions. With a limited number of machine instructions, most can be run in a single processor cycle. In terms of MIPS (millions of instructions per second), the Atmega 168 running at 20 MHz can execute close to 20 million instructions per second, or approximately 20 MIPS.[3]

44

Page 45: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

It can communicate serially via its UART as well as via SPI and I2C. There is a 6 channel 10 bit analog to digital converter, 3 timers and 6 Pulse width modulation channels.The internal block diagram is pictured in Figure 4.4.1.3-2.

Figure 4.4.1.3-2: This is an image of Atmega 168 internal block diagram. Permission pending from Atmel.

4.4.1.3.1 Interrupts

Interrupts are hardware generated function calls. They are used to interrupt the program flow to execute a prioritized and possibly time dependant function. Methods of user input from keypads to switches will generally call interrupt service routines, provided that the microcontroller is not polling for the event to occur. This saves processor resources to do other useful things. When the interrupt occurs the return address is placed on the stack and program execution jumps to a specific memory location. After that code is executed the program control is returned to the location in memory pointed to by the return address that was placed on the stack. Interrupts are initialized in the Atmega 168 by setting the appropriate bits in the general interrupt control register, and are then enabled by setting the global interrupt enable bit in the status register of the processor. The interrupts have priority in accordance with their Interrupt Vector position. The lower the Interrupt Vector address, the higher the priority.[4]

45

Page 46: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.4.1.3.2 I/O Ports

The parallel I/O ports are the most general purpose I/O devices. Each of these ports has three registers associated with it: the data direction register, the port driver register, and the port pin register. The data direction register is referred to as DDRx, where x is A, B, or C and its purpose is to set which bits of the port are used for input and which are used for output. The bits on the port can arbitrarily be set by the programmer, with a value of 1 setting the port bit to output. The port driver register is referred to as PORTx, where x is A, B, or C and its purpose is to set whether a pin is floating or is associated with a pull up resistor. The pull up resistor allows the pin to sink up to 20 mA. The port pin register is referred to as PINx, where x is A, B, or C and is used to read in or write out digital values on the pins. [5]

4.4.1.3.3 Serial Communication

4.4.1.3.3.1 UART

The UART (Universal Asynchronous Receiver Transmitter) is used to communicate between the microcontroller and various other devices. It is asynchronous in that a common clock signal is not required at both the transmitter and the receiver ends in order to synchronize the data transfer. Instead, a start bit and a stop bit are added to each byte to allow the receiver to determine the timing of each bit. The serial line idles at logic 1, or high and when it drops to zero it indicates the beginning of the start bit. It is followed by eight data bits with the least significant bit transferring first, and the most significant bit transferring last. The stop bit is another logic high and is the same as the idle state. The falling edge of the start bit begins the timing sequence in the receiver and the receiver samples each bit in the center of its time period for maximum reliability. C Library functions allow the programmer to avoid low level serial operations directly. The Atmega 168 has registers to initialize, set the baud rate, and control the status of the UART. The UART protocol can be used over relatively long distances, such as between a microcontroller and PC. [6]

4.4.1.3.3.2 SPI

The Serial Peripheral Interface is another form of serial communication available in the Atmega 168. It is a synchronous serial communication bus, meaning that the transmitter and the receiver must use the same clock to synchronize the detection of the bits at the receiver. The SPI protocol requires a relatively short communication distance such as that between a microcontroller and a device on the same circuit board. Three communication lines MOSI (master out slave in), MISO (master in slave out) and CLK (clock) are used to connect the 2 devices in

46

Page 47: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

a master and slave configuration. Both the master and slave send and receive data simultaneously but the master is responsible for providing the clock signal for the timing between the devices. The master sends eight bits along the MOSI line at the rate of one bit per cycle. The slave will concurrently send out eight bits to the master along the MISO line. Data is exchanged between the two devices in a single communication. Many different devices can be connected on a SPI bus A device on a SPI bus is determined to be a master if it is sending data. A device is determined to be a slave if it's slave select pin is grounded. The Atmega 168 has a SPI control register used to control the operation of the SPI interface which is located on PORTB. [7]

4.4.1.3.4 ALU

During an ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File in one clock cycle. The Atmega 168 ALU operates in direct connection with all the 32 general purposeworking registers. Within a single clock cycle, arithmetic operations between the general purpose registers or between a register and an constant can be executed. The ALU operations are divided into three main categories: arithmetic, logical, and bit-functions. The Atmega 168architecture provides an on chip two clock cycle multiplier which supports both signed and unsigned multiplication and fractional format. The ALU supports arithmetic and logic operations between registers or between a constant and a register. Single register operations can also be executed in the ALU. After an arithmetic operation, the Status Register is updated to reflect information about the result of the operation. Program flow is provided by conditional and unconditional jump and call instructions, able to directly address the whole address space. Atmega 168 instructions have a single 16 or 32 bit word format. [8]

4.4.1.3.5Atmega168 Memory

The memory section of the Atmega168 processor is based on the Harvard model meaning that the memory is separated into different areas to allow for faster access and increased capacity.. The CPU has a separate interface for the FLASH memory section, the data memory section, and for the EEPROM section.

The FLASH memory section is a 16K block of memory that starts at location 0x0000 and can be further divided into the Boot Program section and theApplication Program. The FLASH is nonvolatile memory and is used to store the executable code and constants because it retains its data when power is removed. Although the FLASH memory can be reprogrammed up to 10000 times with executable code, this must be done using and eternal programmer. there is no way for the executable code itself to modify the data in the FLASH memory area. This means that the software engineer must view this area as a read only

47

Page 48: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

memory and only store constants here. Every FLASH memory address contains a 16- or 32-bit instruction.

The data memory of the Atmega 168 is composed of three sections. The lowest section contains the thirty two general purpose registers, the next section contains the sixty four I/O registers, and the last section contains the 1K bytes of internal SRAM. The general purpose registers are used to store local and global variables, pointers into other memory locations, and other temporary data used by the program during execution. They typically will be out of the programmer's control if she is using the C compiler. The I/O registers are used to interface with other devices and peripherals on the circuit board like the LCD and the user interface buttons. Each I/O register has a name, an I/O address, and an SRAM address but the C programmer will usually just use the register name via including a header file with convenient definitions. The SRAM is used as a general variable storage area and also stores the processor's stack. The stack starts at the top of memory and grows down whereas data is usually stored at the bottom of the SRAM, but there are no special divisions. The processor uses the stack as temporary data storage of all kinds Some compilers will implement a system stack and a data stack, which has its own data stack pointer. The programmer must make sure that stacks do not grow so large that other memory locations get accidently overwritten.

The 512 bytes of EEPROM (Electrically erasable programmable read only memory) is non-volatile like the FLASH. It may be both written and read by the executable and is generally used for storing variables that must be retained in the event of power loss. The drawback of the EEPROM is the relatively slower read and write times that can be achieved, 1.8 ms for each read or write instruction. The EEPROM can be reprogrammed up to 100 000 times [9]

4.4.1.3.6 Analog to Digital Conversion

The ADC on the Atmega 168 has a 10 bit resolution so that between 0V and 5V

Equation 4.4.1.3.6: This formula calculates the correct sampling frequency.

on the input pin an approximate resolution of 4.9 mV can be realized. The ADC is slightly slower than the processor and can be operated in either interrupt driven mode or in continuously free running mode. The free running mode allows the control unit to continuously update the voltage received off the sensor and provide the user with a measurable output of intensity.

48

Page 49: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

For the device to count exercise repetitions, a threshold voltage of some value with be determined on a per exercise basis and used to determine whether to update the rep counter. This information is then displayed on the LCD screen. For the device to count exercise sets, the control unit will look for a specific time interval during which the threshold voltage on the ADC pin is not reached. This time interval value (5 sec, 10, sec, etc) is programmed by the user. If the threshold voltage is not reached during the interval, meaning no repetition has been reached, then the device will increment its set counter until the number of sets programmed by the user for their workout for the specific exercise is reached.

Figure 4.4.1.3.6: This image shows the timing diagram for the Atmega 168 ADC in free running mode. Permission pending from Atmel.

The ADC requires that the clock frequency be between 50 kHz and 200 kHz. This prescaler frequency is arrived at by taking the frequency of the external oscillator 16 MHz, dividing by 200 kHz, and then selecting the next higher prescaling division factor, which in this case is 128. Using Equation 4.4.1.3.6 above, this sets the ADC at the highest possible sampling frequency, 125kHz.In the ADC free running mode, as seen in Figure 4.4.1.3.6, new conversions are started immediately after the last conversion completes, on the next clock cycle, and the ADSC (ADC start conversion bit) stays high. One conversion takes 13 clock cycles. [10]

4.4.2 Programming the AVR Atmega168

4.4.2.1 Programmer Selection

The microcontroller requires the use of a special hardware device in order for the code to be loaded onto it. There are many options for programming the Atmel microcontrollers, which contributes to the devices' popularity. The STK500 is a

49

Page 50: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

development system from Atmel that is very feature filled. It can be managed with the AVR Studio IDE, provides sockets for all the Atmel microcontrollers, does In-System Programming (ISP), high voltage parallel and serial programming, has a built in RS232 connector, and has multiple clocking options and expansion ports. LEDs and buttons are provided on board for experimentation. The price is $79.00 from Digikey. However, the STK500 does would require an adapter for development on computer systems without a built in serial port. [11]

Figure 4.4.2.1-1: The image shows the USBtinyISP. Permission pending from Adafruit.

Because of the this, the high price, and the many unnecessary included features that the group would not be using, it was decided to do additional research into finding the appropriate programmer. The group decided to use the USBTinyISP from Adafruit Industries. Pictured in Figure 4.4.2.1, it is inexpensive, easy to use, and readily available. This programmer uses ISP style programming, is compatible with both AVRStudio and the open source avrdude, and connects via USB to Windows and Linux machines, as well as Mac OSX. The USBTinyISP comes as a kit which must be assembled. The full kit costs only $22.00 and includes a PCB, case, cables, various resistors, capacitors, diodes, an ATTINY2313 microcontroller, a 74AHC125 buffer, and various connectors. The time required to assemble the kit was less than 30 minutes.

Figure 4.4.2.1-2: The image shows the pin out of the USBtinyISP's 6 and 10 pin cables. Permission pending from Atmel.

50

Page 51: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

In-System Programming allows the user to program and reprogram any AVR microcontroller that is already inside a system. This means that the microcontroller does not need to be removed physically from the application circuit in order to reprogram it. A 3 wire SPI (Serial Peripheral Interface) connection interfaces directly with the microcontroller. It consists of the Serial Clock (SCK), Master In - Slave Out (MISO), and Master Out - Slave In (MISO). Each pulse on the SCK wire transfers one bit from the USBTinyISP to the target microcontroller. For the microcontroller to be programmable its RESET line must be held at logic low, and a common GND is required between the USBTinyISP and the target device.

4.4.2.2 Testing the USBtinyISP

Figure 4.4.2.2: The image shows an Atmega 168 being programmed.

The programmer was tested in the lab using a simple circuit to allow the verification of code being loaded onto the Atmega168. On a breadboard the Atmega168 was laid out with pins 7, 20, and 21 tied to the 5V coming from the USBTinyISP. The programmer has two standard AVR programming headers, 6 pin and 10 pin. For the groups use, the 6 pin was sufficient. A common ground was established between pins 8 and 22 and the programmer. An LED was wired on one of the GPIO pins via a resistor to GND. FInally, the MOSI, MISO, and

51

Page 52: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

SCK connections on the programmer were wired to the correct pins on the microcontroller. Orientation of the programmer header connection is important to note correctly, as displayed in Figure 4.4.2.1-2.Having setup the hardware for testing, a simple program to blink the LED was written and compiled using avrdude. The program runs an endless loop turning on the LED for 500 ms, and then off for 500 ms. Again, avrdude is used to send the compiled hex file to the device. This can be seen in Figure 4.4.3.2 using the command:

avrdude -c usbtiny -p atmega168 -U flash:w:adctest.hex:i

4.4.3 Development Environment

4.4.3.1 AVR Studio

As seen below in Figure 4.4.3.1, AVR Studio is an Integrated Development Environment for writing, compiling and debugging AVR applications in Windows environments.AVR Studio provides a project management tool, source file editor and chip simulator. It also interfaces with In-Circuit Emulators and development boards available for the AVR 8-bit RISC family of microcontrollers including the USBtinyAVR.AVR Studio has a fully symbolic source level debugger, configurable memory views, Including SRAM, EEPROM, Flash, Registers, and I/Os. Users can set an unlimited number of break points. Controls are available for trace buffering and trigger control. Other advanced features include variable watch, drag and drop editing, extensive program flow control options, port activity simulation and logging, and simulated pin input stimulation. It has support for programming in C, Pascal, BASIC and assembly languages.

Figure 4.4.3.1: The image shows the AVR Studio development environment.

52

Page 53: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The C compiler that we are using with AVR Studio is a version AVR-GCC called WINAVR. This development environment is only available for the Windows operating system. Some group members use other operating systems such as Linux and Macintosh OSX. While these environments do not run the AVR Studio suite natively, separate fully functional and well developed AVR tool chains which include the AVR-GCC compiler are available which can either be run from the command or through a GUI. [12]

4.4.3.2 AVRlib

Procyon AVRlib is a library C functions for a variety of conventional and unconventional tasks using AVR microcontrollers. The aim of AVRlib is to empower programmers to work quickly towards their end objective by reducing the time needed to write basic functions and variable definitions. Most AVRlib header (*.h) files have lengthy explanations of how to use the supplied library functions. All code (*.c) files are commented with additional documentation. [13]

Though the name "AVRlib" is similar to "AVRlibc", the two libraries are distinct and should not be mixed up. AVRlibc is the Standard C Library for AVR microcontrollers and provides basic functions like printf, stdio calls, math functions, plus some AVR-specific functions. In AVRlib's global.h file some AVR specific data types are defined with easy to use names as seen in Table 4.4.4.2.[14]

Table 4.4.3.2: The table shows the integer data types used on the Atmega 168.

53

Page 54: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.4.3.2.1 A/D Converter Function Library (a2d.c)

This library provides an easy interface to the analog-to-digital converter available on many AVR processors. [15]

unsigned short a2dConvert10bit (unsigned char ch) This function starts a conversion on A/D channel# ch and returns the 10-bit value of the conversion when it is finished.

unsigned char a2dConvert8bit (unsigned char ch) This function starts a conversion on A/D channel# ch and returns the 8-bit value of the conversion when it is finished.

void a2dInit (void) This function initializes the A/D converter and turns the ADC on and prepares it for use.

void a2dSetPrescaler (unsigned char prescale) This function sets the division ratio of the A/D converter clock and is automatically called from a2dInit() with a default value.

void a2dSetReference (unsigned char ref) This function configures which voltage reference the A/D converter uses and is automatically called from a2dInit() with a default value.

4.4.3.2.2 UART Function Library (uart.c)

This library provides both buffered and unbuffered transmit and receive functions for the AVR processor UART. Buffered access means that the UART can transmit and receive data in the "background", while the programmer’s code continues executing. Also included are functions to initialize the UART, set the baud rate, flush the buffers, and check buffer status.

For full text output functionality, the programmer may wish to use the rprintf functions along with this driver.Most Atmel AVR-series processors contain one or more hardware UARTs (aka, serial ports). UART serial ports can communicate with other serial ports of the same type, like those used on PCs. In general, UARTs are used to communicate with devices that are RS-232 compatible (RS-232 is a certain kind of serial port). By far, the most common use for serial communications on AVR processors is for sending information and data to a PC running a terminal program. [16]

54

Page 55: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

void uartInit (void)

This function enables and initializes the uart.

void uartInitBuffers (void)

This function creates and initializes the uart transmit and receive buffers.

void uartSetRxHandler (void(*rx_func)(unsigned char c)) This function redirects received data to a user function and sets the receive interrupt to run the supplied user function.

void uartSetBaudRate (u32 baudrate) This function calculates the division factor for requested baud rate and sets it.

cBuffer * uartGetRxBuffer (void) This function returns the receive buffer structure.

cBuffer * uartGetTxBuffer (void) This function returns the transmit buffer structure.

void uartSendByte (u08 txData) The function transmits a byte over the uart.

int uartGetByte (void) This function gets a single byte from the uart receive buffer.

u08 uartReceiveByte (u08 *rxData) This function gets a byte from the uart receive buffer if one is available.

void uartFlushReceiveBuffer (void) This function flushes all the data from the receive buffer.

u08 uartReceiveBufferIsEmpty (void) This function return true if the uart receive buffer is empty.

u08 uartAddToTxBuffer (u08 data) This function adds a byte to the end of the uartTx buffer.

void uartSendTxBuffer (void) This function starts the transmission of the current uartTx buffer contents.

4.4.3.2.3 Interrupt function library (extint.c)

A common task in embedded programming is checking when the state of pin has changed. Software can be written to poll a pin's state, or to reduce proessing

55

Page 56: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

overhead an interrupt can be set up. An interrupt can be used to notify the main program when a pin state has changed. [17]

void extintInit (void) This function initializes the external interrupt library.

void extintConfigure (u08 interruptNum, u08 configuration) This function configures the external interrupt trigger.

void extintAttach (u08 interruptNum, void(*userHandler)(void)) Attach a user function to an external interrupt.

void extintDetach (u08 interruptNum) This function detaches a user function from an external interrupt.

4.4.3.2.4 Encoder Library

This library allows easy interfacing of standard quadrature encoders (used for sensing shaft rotational position and speed) to the Atmel AVR-series processors. The library uses external interrupts to sense and keep track of the encoder's movements. The library is extendable with the maximum number of encoders equal to the total number of external interrupts available on the target AVR processor. Due to the wide range of external interrupt capability on AVR processors, this code will need to be customized for the Atmega 168.[18]

voidencoderInit(void);

This function initializes hardware and encoder position readings.

voidencoderOff(void); This function disables hardware and stops encoder position updates

s32encoderGetPosition(u08 encoderNum); This function reads the current position of the encoder

voidencoderSetPosition(u08 encoderNum, s32 position);

This function sets the current position of the encoder

4.4.3.2.5 HD44780 LCD Function Library (lcd.h)

This display driver provides an interface to the most common type of character LCD, those based on the HD44780 or SED1278 controller chip (about 90% of character LCDs use one of these chips). The display driver can interface to the display through the CPU memory bus, or directly via I/O port pins. When using

56

Page 57: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

the direct I/O port mode, no additional interface hardware is needed except for a contrast potentiometer. Supported functions include initialization, clearing, scrolling, cursor positioning, text writing, and loading of custom characters or icons (up to 8). Although these displays are simple, clever use of the custom characters can allow the programmer to create animations or simple graphics. The "progress bar" function that is included in this driver is an example of graphics using limited custom-chars. The driver now supports both 8-bit and 4-bit interface modes. For full text output functionality, it may be necessary to use the rprintf functions along with this driver [19]

void lcdInitHW (void) This function initializes the LCD. Turns LCD on and prepares it for use.

void lcdBusyWait (void) This function waits until LCD busy bit goes to zero and does a read from control register.

void lcdControlWrite(u08data) This function writes the control byte to the display controller.

u08 lcdControlRead (void) This function reads the control byte from the display controller.

void lcdDataWrite (u08 data) This function writes a data byte to the display.

u08 lcdDataRead (void) This function reads a data byte to the display.

void lcdInit (void) This function initializes hardware including I/O ports and control lines.

void lcdHome (void) This function moves the cursor to the Home position.

void lcdClear (void) This function clears the LCD.

void lcdGotoXY (u08 row, u08 col) This function places the cursor at an LCD location based on column and row values.

void lcdLoadCustomChar (u08 *lcdCustomCharArray, u08 romCharNum, u08 lcdCharNum) This function loads the first 8 custom characters.

57

Page 58: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

void lcdPrintData (char *data, u08 nBytes) This function calls lcdDataWrite to write a byte to the display.

void lcdProgressBar (u16 progress, u16 maxprogress, u08 length) This function draws a progress bar displaying starting from the current cursor position with a total length of "length" characters.

4.4.3.2.6 SDCard Interface Function Library (mmc.c)

This library offers some simple functions which can be used to read and write data on a MultiMedia or SecureDigital (SD) Flash Card. Although MM and SD Cards are designed to operate with their own special bus wiring and protocols, both types of cards also provide a simple SPI-like interface mode which is exceptionally useful when attempting to use the cards in embedded systems. To work with this library, the card must be wired to the SPI port of the Atmel microcontroller as described below. Typical cards can operate at up to 25MHz maximum SPI clock rate which is faster than mostAVR's maximum SPI clock rate. [20]

void mmcInit (void) This function initializes the SPI interface.

u08 mmcReset (void) This function initializes card for operation, turns off CRC checking, and sets the block length to 512bytes.

u08 mmcSendCommand (u08 cmd, u32 arg) This function toggles the Chip Select pin on the SD card interface.

u08 mmcRead (u32 sector, u08 *buffer) This function calls spiTransferByte() to read data in 512 byte chunks from SD card.

u08 mmcWrite (u32 sector, u08 *buffer) This function calls spiTransferByte() to write data in 512 byte chunks from SD card.

4.5 User Interface Hardware

4.5.1 Buttons

Buttons are one of the most common ways for users to interact with electronic devices. They essentially are switches. The most common types are momentary and nonmomentary. Momentary switches open or close a circuit only while the

58

Page 59: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

button is depressed. Non-momentary style buttons act like toggles. The state of the circuit connection is changed from open to closed or closed to open each time that the button is depressed and the user need not hold the state physically as she would with a momentary style button.Buttons can have as few as two terminals but may contain many more depending upon the logic of the circuit. A double pole double throw style switch is equvalent to two single pole single throw switches. When interfacing buttons with the I/O pins of a microcontroller, care must be taken to debounce the input so that the MCU can correctly read the state. Debouncing is discussed in greater detail in section 4.5.2.

4.5.2 Rotary Encoder

Figure 4.5.2-1: The image shows the Bourns Pec11. Permission pending from Bourns

The Rotary Encoder is a three terminal device which is used to get sequential input data from a user. Its usage is somewhat like a potentiometer, but turns output 2 bit binary numbers instead of varying a resistance. During the brief intervals where the switches were not perfectly in-sync with each other, there exists the possibility of many false position codes being generated at the output of the logic devices connected to the encoder. This solved by using a grey code, a binary code in which any increment up or down only changes the value by a single bit. The Bourns Pec11, as seen in Figure 4.5.2-1, uses a 2 bit grey code on its output. The gray code is used so that only 1 bit changes during an increment or decrement on the shaft.

Sequence channel B channel A1 0 02 0 13 1 14 1 0

59

Page 60: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Table 4.5.2: The table shows how the gray code differs from standard binary code.

In order for the microcontroller to know whether to increment or decrement based on the clockwise or counter clockwise turning of the shaft, it must keep track of the previous output state of the micro encoder and changes must be recorded as they occur. This can be accomplished by using sets of nested "if" statements which take into account each of the possible grey code states.

It may be necessary for the design to take into account the mechanical nature of the switching from one state to another. When mechanical contact is made state will generally not change cleanly but will "bounce" from one to another is an unpredictable way for a short time interval. This is referred to as bouncing and the solution is called debouncing. One solution is adding low pass filters to the outputs of the encoder as seen in Figure 4.5.2-2.

Figure 4.5.2-2: The image shows the encoder terminals being denoised using low pass filters.

A second solution is to hold the values that are read off the outputs in variables in software and then make sure that they don't change for at lest 5 ms, as described in the datasheet. [22]

4.5.3 USB

The Universal Serial Bus protocol is a commonly used and reliable method for interfacing all types of electronic equipment. The standard is well documented and has been in use long enough that it is considered mature. Research was performed to evaluate the feasibilty of including a USB interface to the Control Unit portion of the project. The USB 2.0 specification requires precise timing in order to interface with the UART on the Atmega168. Future Technology Devices

60

Page 61: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

International makes an integrated circuit, the FT232R, specifically for the purpose of converting between USB and serial RS232 interfaces. The chip has an integrated clock, integrated EEPROM for managing vendor and product IDs, asynchronous and synchronous bit bang data transfer modes, integrated voltage regulator (supply can be between 3.3V and 5.25V), and low current consumption. True CMOS and TTL logic level inputs and outputs are available at 5V, 3.3V, 2.8V, and 1.8V. The FT232R performs serial to parallel and parallel conversion of the USB data, while its UART FIFO Controller (First In, First OUT) manages the FIFO transmit and receive buffers for interfacing on the USB side, and the UART transmit and receive registers on the RS232 side. The UART interface supports 7 or 8 data bits, 1 or 2 stop bits, and even, odd, or no parity. Its supports a Baud Rate from 183 baud up to 3 million baud and is programmable within that range using the 48MHz reference clock and 14 bit pre-scaler.

Figure 4.5.3: The image shows one way to connect the FT232R to an MCU. Permission pending from Future Devices Technology International.

Sample Application circuits for interfacing with generic microcontrollers are available in the datasheet for the FT232R. In the Figure 4.5.3, pin CBUS0on the FT232R is being used to clock the microcontroller with a 12MHz output. TXD and RXD are being used for transmitting and receiving data. While in UART mode the UART controller can manage the handshaking portion of the connection via the RTS and CTS pins, and is handled in hardware on the IC to ensure fast response times, as seen in the figure. If the microcontroller is handling power management functions, one of the CBUS pins can be setup as a RECEIVE/ENABLE pin and the receiver can be disabled when in USB suspend mode. Decoupling capacitors are shown with values recommended by the manufacturer.

For testing, the circuit in the figure above the datasheet suggests it would be helpful to add LEDS to verify that signals are present on the TXD and RXD pins. Any of the 5 CBUS pins can be configured to drive an LED. Two LEDs can be connected between Vcc and their respective CBUS pins via 270R resistors. A digital one shot timer is use internally so that even a small percentage of data transfer is visible to the end user.

61

Page 62: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Implementing a USB interface could allow data transfer at rates of up to 12 Mbps. This would be overkill for the for the size of the data files that the control unit would transfer to the PC, which will be only tens of thousands bytes. Also, the power system could be designed such that the control unit would charge its battery via the 5V available on the USB line. Additionally, drivers for all common versions of Microsoft Windows, Mac OSX, and Linux with 2.4 or greater kernels are available on the manufacturer's website. The FT232R is available at Sparkfun electronics for the price of $3.95 per piece. The device comes in a 28-pin SSOP package and would need a specialized breakout board to be built to interface with the rest of the hardware circuitry. Sparkfun also offers a breakout board for the price of $14.95 per piece. [23]

4.5.4 HD44780 Controller LCD

Figure 4.5.4: The image shows the Vikay 2220 with HD44780 controller. Permission pending from Wright Hobbies.

The control unit hardware must be able to interface with the user in a way that is ergonomic and intuitive. A logical method to provide realtime information to the user about their current workout is an LCD display. Several LCDs were evaluated based on their features, size, ease of use, and price. Shown above in Figure 4.5.4 is the Vikay 2220. It is a 2 line by 20 character black and white monochromatic LCD with adjustable backlight, and a Hitachi HD44780 controller chip. The HD44780 has two 8 bit registers, an instruction register (IR) and a data register (DR). This is a well known controller chip with the pin out described in Table 4.5.4. [24]

Pin Number Function1 Vss Ground2 Vdd +5V Supply Terminal3 Vo Power supply for LCD4 RS Register Select5 R/W Read/Write6 E Enable7-14 DB0~DB7 Bidirectional Data Bus15 LAMP- Negative LED Power Supply

Terminal16 LAMP+ Positive LED Power Supply Terminal

62

Page 63: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Table 4.5.4: This table shows the pin out of the Vikay 2220 HD44780 controlled liquid crystal display.

Pins 1 and 2 are self explanatory. Pin 3 is wired as the output of a voltage divider using a a variable resistor, to set the amount of contrast. In the 8-bit mode, 8 data lines are used and 3 additional lines are used for the Enable, Read/Write, and Register Select control lines. The register select pin must be set high when writing data to the LCD and for receiving commands it must be set low. The read/write is used for setting the data direction. When writing it must be set low and when reading from the LCD it must be set high. It can be tied to ground if it is unnecessary to read from the LCD.

The LCD can be set up to be addressed by either 4 or 8 bits. 4-bit mode, only 4 data lines are used instead of 8, with the benefit being saved GPIO pins on the microcontroller. Writing data or commands to the LCD in 4-bit mode is done high nibble first, then low nibble, so the enable pin (E) has to be strobed twice. Special care should be taken when using a single AVR port, as mixing up input and output lines can damage both the AVR and the LCD.

The RS (Register Select) line is used to determine if the information should be interpreted as data or a command. The R/W (Read/Write) line plays its important role to switch the data direction between the module and the microcontroller.Writing characters to the LCD works like writing commands, but when writing characters RS is taken high, while for commands it is taken low. The data direction pins for the data lines are set for output and then all the LCD lines are cleared. In the 4 bit mode the high nibble is written first so byte needs to be saved on the stack and then a masking operation is done to remove the low nibble. After writing the high nibble, the byte is popped off the stack and another masking operation performed to remove the high nibble. At the end of the routine the data direction of the LCD data port needs to be set to input again but the control lines will stay as outputs. This procedure will be used regardless of whether commands or data are being sent to the LCD.

There are other schemes for using even fewer general purpose I/O pins to interface the microcontroller with the HD44780 LCD display. One method which uses only three I/O pins uses a shift register to take a byte received serially from the microcontroller and converts it to a parallel representation before sending it to the eight data pins on the LCD. This method uses additional parts and increases the cost of the design. [25]

4.5.4.1 Color LCD 128x128 Nokia Clone

For the portable display unit that will be worn by the user, a display screen is needed. The group decided to use a color LCD screen supplied by SparkFun Electronics. It is an exact clone of the LCD screen used in various Nokia phone models. The color LCD comes from China. Shown below in Figure 4.5.4.2-1 is a picture of the Color LCD screen compared to the size of a quarter.

63

Page 64: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.5.4.1-1 Picture of Color LCD 128x128 Nokia Clone. Permission Granted by SparkFun

Features of the Color LCD 128x128 Nokia Clone:

LCD Logic - 3.3V @ 2-3mA LED Backlight - 7V @ 40-50mA (very bright) Full 4,096 Color Display Uses the Epson S1D15G10 or Philips PCF8833 Controller

Frame Dimensions: 1.35x1.58"Active Display Dimensions: 1.2"x1.2"

The group wanted to implement a portable display unit in which information from the sensors would be displayed on a small LCD screen. This LCD screen would be part of a portable unit worn by the user separate from the sensor unit. What was found was a small, inexpensive LCD screen that would display the information from the sensors. It has a full 4,096 color display which is nice. Even though color is not necessary, it makes the Workout Buddy more appealing to the eye. The LCD backlight requires 7V at 40-50mA. The LCD Logic requires almost just have of that at 3.3V at 2-3mA. These power requirements will be used for the design of the power supply.

The frame dimension is 1.35x1.58 inches. This satisfies the need for a small portable display unit. The actual active display dimensions are 1.2x1.2 inches. Show below in Figure 4.5.4.1-2 is a sample of the active display when the LCD backlight is enabled with sample code running on the microcontroller.

64

Page 65: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.5.4.1-2 Picture of Active Display. Permission Granted bySparkFun.

Pin Out (use the numbering visible on the display connector):

1. VCC-Digital (3.3V)2. RESET3. SDATA4. SCK5. CS6. VCC-Display (3.3V)7. N/C8. GND9. LED GND10.LED V+ (6-7V)

Shown above are the pin assignments for the LCD 128x128. Pins 1 and 6 will be connected to the power source to enable the LCD logic. Pin 10 will be connected to the power supply to enable the LCD backlight. In order to test the functionality of the backlight the power source can be connected to pin 10 and pin 9 (ground) to see if the screen will light up.

More information on this unit can be found at the URL:

http://www.sparkfun.com/commerce/product_info.php?products_id=569

From the website above there are dozens of documents on how to implement code with the unit. This will be very helpful when it comes time to program our unit. It was decided that this was the LCD screen that would be used in the

65

Page 66: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Workout Buddy design. From its low cost and compact size, it best suits the design.

4.5.5 Control Unit Layout

The control unit design was laid out using the software package Eagle 5.4.0 Light by Cadsoft. This software allows the user to draw schematics using familiar drag and drop techniques and provides access to a vast library of electronic parts. Eagle will automatically generate a printed circuit board layout in an industry standard format which can then be electronically relayed to PCB manufacturing vendors. The result of this is a professionally made PCB which is ready to bepopulated by the team after it arrives.

Figure 4.5.5: The image shows the schematic diagram for the Control Unit prepared in EAGLE.

As shown in Figure 4.5.5, the Atmega168 microcontroller is the centerpiece of the control unit. It interfaces with the encoder the microSD card, the LCD, the buttons, and the sensor. The digital encoder requires 3 GPIO pins, 2 for each of the channel states and one for the momentary pushbutton. The encoder's terminals are wired to pins PD0 and PD1, and it's momentary style switch is actuated by pressing the front of the assembly. Its functionality is very similar to that of a volume or tone control on a modern car stereo head unit. When the momentary switch is closed it pulls PC1 on PORTC low to generate an interrupt.

66

Page 67: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The LCD shares PORTD with the encoder. Pins PD3 through PD7 on PORTD are wired to the 4bit interface to the LCD controller, pins D4 through D7. The microcontroller's pin PD3 is wired to the Register Select pin on the LCD controller. The LCD's pin 1 is wired to ground and pin 2 is wired to 5V. Pin 3 is uses to set the contrast via a voltage dividing 10K ohm potentiometer. The LCD's pin 4 is the register select line and it is connected to PD3. Pin 5 on the LCD is the Read/Write Not line and is wired to ground as we will only need to write to the device. The microSD card requires an SPI serial connection to the microcontroller so it is restricted to being wired to specific MCU pins. Pins 3 and 6 are wired to ground. Pin 4 is wired to ground via a .1 uF capacitor. Pin 1 is wired to PB1 on PORTB. Pin 2 is wired to MOSI on the microcontroller via a 100 ohm resistor. Pin 5 is wired to SCK on the microcontroller via a 100 ohm resistor. Pin 7 is wired to the MISO pin via a 100 ohm resistor.

The EMG sensor will be connected to the ADC on PD0. Alternatively if the wireless interface is developed, it would also be connected at the same pin.

4.5.5.1 Building and Testing the Control Unit Layout

Figure 4.5.5.1-1: This image shows the crystal setting theprocessor speed.

The testing of the Control Unit will be performed in discrete stages so that time is not wasted troubleshooting multiple problems simultaneously. The circuit in Figure 4.5.5 will be set up for prototyping on a solderless breadboard. Care was taken to select DIP style IC packages for ease of breadboard setup. The first test involves loading simple code onto the microcontroller to verify its integrity and also to verify that the development tools are set up correctly. This will be done by watching to see if an LED is blinking on the specified pin. This step also includes testing the USBtinyAVR microcontroller programmer, AVR Studio, and avrdude. Care must be taken to correctly read the pinout of the programmer cable, and indeed that the cable itself has been wired correctly. The diagrams show the pinout from "above looking down". Also, there is a notch on the connector to aid in determining correct orientation. That the Vcc pin on the connector always puts out 5V,which is supposedly guaranteed by the USB specification, is another tool in troubleshooting the cable and programmer integrity.

67

Page 68: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The next testing stage involves setting up the crystal oscillator on the breadboard as in Figure 4.5.5.1-1.Then, some code to verify that the crystal is setting the clock to operate at 20 MHz will be loaded. The clock must be at a specific frequency in order to set the correct sampling rate to sample data from the EMG sensor. The clock value was chosen to ensure the highest sampling resolution possible that the Atmega 168 can support.

Figure 4.5.5.1-2: The image shows how the LCD display interfaces with the Atmega 168.

This sampling rate may not be necessary once additional testing is performed, but it is useful to have the widest amount of options available to the group should changes to the design be necessary. Once this is done it will be necessary to verify that a signal can be acquired via the ADC pin that eventually will connect to the sensor. Before introducing the sensor signal we will want to verify that the instrumentation portion of the project is outputting a signal in the 0V to 5V range. We will also verify ADC operation using a function generator or other known signal.

Shown in Figure 4.5.51-2 is the pin assignments between the LCD display and the Atmega 168. The LCD will be attached next. We will verify that the display is receiving power and that the contrast pin and the Vcc pin are at the proper voltage. Arbitrary text will be written to the display using the routines from AVRlib. Next we will write arbitrary text to specified locations on the screen. Once we are able to write text to the screen in predictable ways we will write values which vary over time to the screen. A simple test of this is outputing incrementing integer values. After successfully demonstrating all of this we will connect the LCD in the 4 bit addressing mode and then go back through each of the steps described above. Once all of these steps have been demonstrated we will be able to use the LCD itself as a debugging tool for the rest of the functional blocks as they are added to the circuit

68

Page 69: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Next we will attach the rotary encoder. As seen in Figure 4.5.5.1-3 a couple resistors and debouncing capacitors are needed. Having demonstrated that we can write to the LCD, we can now have the LCD display the values as they are read off the pins connected to the rotary encoder terminals. Should this be troublesome, we will troubleshoot by verifying the correct voltage on the lines. We can read values off the encoder and use the presence of any data there as a control to toggle activity on another pin, for instance to blink an LED. A multimeter in continuity mode connected to the device terminals can aid in determining if the device itself is at fault we are still having trouble reading values off the encoder. The same techniques can be used to test the button portion of the rotary encoder. Pressing the button can be used to control activity on the LCD, or to toggle a pin from a low to high state and blink an LED.

Figure 4.5.5.1-3: The Image shows the rotary encoder interfacing with the Atmega 168.

The microSD card reader/writer assembly will be attached and tested next as in Figure 4.5.5.1-4. Before inserting a blank microSD card into the assembly, the card will be formatted with a FAT32 file system using a Windows PC and the operation verified. We will verify that the mmcSendCommand from AVRlib correctly sets the Chip Select pin to the correct state with a multi meter. We will attempt to write arbitrary bytes in 512 byte blocks to the card. and then attempt to read them back. To troubleshoot this a multi meter can be used to check activity on the SPI interface when running the initializing mmcInit routine and the other

69

Page 70: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

routines that use this interface. However, in order to do more precise debugging a logic analyzer may be necessary. There are many guides available online describing procedures to debug an SPI interface. Only when we are able to both read and write arbitrary data to the microSD card we can perform additional testing of the data storage system. A small testing subroutine will be written to sample a known signal via the ADC and then to write the sampled values to the microSD card in 512 byte chunks as they accumulate.

Figure 4.5.5.1-4: The image shows the MicroSD card interfacing with the Atmega 168.

By this time we can begin testing that the various control unit functions work concurrently. The values that are being read off the ADC line can be output to the LCD. The LCD datasheet lacks a specification for the maximum speed at which it can be updated, so the upper limit of this value can be found and recorded. Finally we will connect the instrumentation portion with the control unit and test the sampling of the data. We will want to verify that we are getting the expected spikes when the EMG sensor is excited and we will test the set and rep counting routines.

4.6 User Interface Software

The inspiration for the user interface design is that of the ubiquitous Ipod from Apple Computer. As seen in Figure 4.6.1 below, this device consists of a screen to display information to the user and, a rotary encoder for selecting and moving the cursor around the screen, and five buttons for selecting various tasks. This interface style has been proven to be easy to use and is very familiar to users worldwide.

4.6.1 User Interface Menus

70

Page 71: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Upon booting and while initializing the hardware the user will be presented with a splash screen giving the name of the device, the creators' names and the name of our school. The device will present a main menu with the following options: Select workout, Build Workout, Settings, and Test Mode. The rotary encoder will be used to move up and down between the options and the center button will be used to select the chosen option.

Figure 4.6.1: The image shows a simple and friendly user interface. Permission pending from Apple.

4.6.1.1 Building a Workout

Figure 4.6.1.1 shows the flow chart for the menu of Workout buddy. The requirement of the user interface was to program it to be as user friendly as possible. The user options are limited to what is strictly necessary to perform a workout and record the essentials.

71

Page 72: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

72

Figure 4.6.1.1: This image shows the flow chart for the user interface.

Page 73: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.6.2 User Interface Design

The Select Workout option will bring up a screen of previously built workouts labeled with a user generated name. The user selects the desired prebuilt workout by turning the rotary encoder until the name is highlighted, and the presses the center button. This immediately brings up a screen in which the user is prompted to select the time to rest between sets in increments of minutes. This is necessary so that the rep and set counting routines will be able to distinguish between the termination of a set and the user simply taking a breather in between reps. This value is selected as described on the previous screen. The next screen shows the current workout name, the first exercise of the routine, the current time, a blank time elapsed counter and the words "start" and "exit". These are the only user selectable values on this screen. If the user selects "exit" she will return to the main menu. If the user selects "start" the device will display on the screen the current time, the current workout and exercise, the number of sets performed in realtime, the number of reps performed in realtime, the intensity of the last rep as a percentage and the time elapsed field will begin counting and the workout begins. No visible options will be available to the user in this state, and turning the encoder or pressing the button will have noticeable effect. This is similar to the "hold" functionality on certain mp3 players which prevent the user from inadvertently changing settings accidentally. Figure 4.6.2 shows one way to implement this. However, the button is continuously being polled and should the user quickly tap the button three times the program will pause and the user will be presented with a menu to either resume the workout, or to return to the main menu after saving any unsaved data.

Figure 4.6.2: A hold button keeps the user from accidently modifying values during operation

From the main menu the second option is to build a workout. Selecting this option brings up a screen with a list of muscle groups from which the user can select those which she wants to include in a pre-saved, repeatable workout. These include at minimum biceps, triceps, front deltoid, mid deltoid, traps, laterals, quads, hamstrings, and calves. Using the encoder, the user highlights the muscle group to work out and presses the button to select that item and put it first in the queue. This is done until, satisfied, at which point the user selects

73

Page 74: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

"done" at the end of the list. To allow the user to perform multiple exercises on the same muscle or muscle group, muscles can be selected more than once and will queue that way during the workout. After selecting "done" the full listing will display on the screen and the user can review their workout and either select "continue" or "go back". "Go back" allows the previous screen to reload and the user can rebuild their workout. If the user selected "continue", the next screen prompts the user to name the workout and an alphanumeric alphabet is presented in the same vertical arrangement as the rest of the menus. The user turns the encoder, highlights a letter, presses the button to select, and the letter appears at the bottom of the screen. The user does this until the desired name appears at the bottoms of the screen and then selects "done" located at the end of the alphanumeric characters. The next screen prompts the user to enter the number of sets, 1 to 10. The will determine the number of sets to perform for each exercise. The device then returns to the main menu.The main menu will also have an option called "Settings". Here the user can set the time, see how much battery time is available and see how many bytes have been written to the microSD card.

4.6.3 Testing the User Interface

Testing for the user interface will be done piecemeal and incrementally. Additional functionality will be implemented only when previous routines are verified.

A "test and calibration mode" will certainly be useful for the developers during the testing phase of the project. This mode would mainly be used to show the free running output of the EMG sensor. Instead of hard coding the threshold EMG value at which the device considers an event to have occurred, this could be adjustable in real time via the encoder with the current value displayed to the screen.

Some improvements to this barebones interface are evident. The user could be able to set the number of sets and reps per exercise. During the workout the user could be allowed to skip certain sets, or entire exercises and be prompted to skip completely, or to enqueue at the end of the list. This might be useful when working out in a busy gym where the equipment is not immediately available when the devices prompts to perform exercises requiring that equipment. A nice addition would also be to display some statistics based on previous workouts. This might include average intensity per muscle worked, and total time to complete workouts. Also, the user may like to keep track of the amount of weight used per exercise. This could be implemented in a way that the user is prompted to record the weight being used right at the beginning of each set. It would be useful for the device to remember the previous value and auto fill that field so it can easily be selected by a quick button press.

4.6.4 Control Unit Firmware

74

Page 75: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The control unit firmware has been designed to be flexible and modular as possible. This makes it easier to test the functionality of the code, helps keep the code readable by humans, and allows for additions to the code to be done more easily. The code will be extensively simulated using the built in simulator included with the AVR Studio environment as seen in Figure 4.6.4.1-5. The design makes extensive use of the Procyon AVRib C library for interfacing with the various hardware elements such as the LCD, the EMG sensor, the microSD card, and the rotary encoder. The basic structure of the program after initializing all the hardware is a main loop, which can be interrupted to perform different functions as requested by the user. During a workout session when the signal from the sensor is being converted to digital values and computational resources are highest. the only available interrupts will be to pause, or to end the session. Periodically as the memory buffer fills, writes will be made to the microSD card resulting in a file that includes the workout, the exercise, the total reps and sets, time elapsed, average intensity, and range of motion. The format for this is a comma separated value file which the user can import into their analysis software of choice or into the custom visualization software that will be provided with the Workout Buddy.

Figure 4.6.4.1-5: This image shows code being simulated in AVR Studio.

The repetition and set counting can be performed in 2 different ways. The first method to do this involves the EMG sensor. A certain threshold value for the intensity of the sensor output taken in via the ADC is hardcoded into the software. When the actual EMG output is higher than this threshold, count a repetition. When the elapsed time between repetitions is greater than a preselected value, increment the set counter and count the next measured

75

Page 76: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

threshold crossing as the first repetition of the next set. Alternatively, the accelerometer can also be used to count sets and reps. This is done by keeping in memory the last few states of the X, Y, and Z outputs of the accelerometer. A software routine will run a while loops and notice when the values change from incrementing to decrementing, or vice versa. When this happens, the repetition counter will increment. And as with the previous method, when the time interval between state changes is greater than a specified value the routine will consider the set has ended and either increment the set or jump to the next exercise in the workout.

4.7 Wireless Interface

In this project the group decided on adding a wireless interface to the system. After the completion of the non-wireless prototype, the group planned on implementing a wireless system to communicate between the sensors and the display unit. The main reason for adding wireless to the Workout Buddy was for the convenience of the user. The user has the choice in whether to wear the device or to either place it in the close vicinity of himself. The group also decided that adding a wireless interface to the project would add more challenges then just implementing a wired device. In order to implement the wireless transmission the group came up with two possible solutions that could be integrated into the design; a Zigbee unit (4.7.1) or a HP3 Series RF module (4.7.2) from Linx Technologies. In the following sections the wireless options will be further discussed to examine the advantages and disadvantages for each chip. The general layout for the wireless interface is shown below in Figure 4.7.

Figure 4.7: Block Diagram for Wireless.

The biggest issue anticipated by the group was deciding on which module to use for the wireless addition to this project was. To simplify the design, the group decided on limiting the sensors to transmit one at a time. Initially the group thought about having several sensors transmitting simultaneously to one receiver. This deemed quite difficult to achieve and would have been costly to

76

Page 77: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

develop. The RF receivers that were looked at seemed to only receive one signal at a time. Therefore, it was decided to have the transmitters alternate the signals and only transmit one signal at any given time.

4.7.1 ZigBee®

The first option was suggested by Dr. Richie. His suggestion was to use Zigbee because Bluetooth was considered overkill for this project. Zigbee is a company that makes low cost/ low power wireless sensor networks. According to Digi, they can operate on unlicensed frequencies ranging from 2.400–2.484 GHz, 902-928 MHz and 868.0–868.6 MHz [1]. All of these frequencies fall into the UHF or Ultra High Frequency range. The frequency the group is interested is in the range of 902-928 MHz range. Protocol features of ZigBee are listed below.

ZigBee protocol features:

Low duty cycle - Provides long battery life Low latency Support for multiple network topologies: Static, dynamic, star and mesh Direct Sequence Spread Spectrum (DSSS) Up to 65,000 nodes on a network 128-bit AES encryption – Provides secure connections between devices Collision avoidance Link quality indication Clear channel assessment Retries and acknowledgements Support for guaranteed time slots and packet freshness (1)

An advantage of choosing a ZigBee wireless unit is the long battery life it can have. Their units can have a battery life span of anywhere from 100 to 1000 days. Another feature of the Zigbee is the DSSS or Direct Sequence Spread Spectrum. The direct-sequence spread-spectrum transmissions multiply the data that is being transmitted by a noise signal. The noise signal is a sequence of 1 and -1 values. By doing so, it spreads the energy of the original signal to a much wider band. The receiving end then multiplies the signal by the same sequence of numbers which then makes then restores the signal to its original state. There are several benefits to this feature; resistance to intended or unintended jamming, sharing of a single channel among users, reduced signal/ background-noise level hampers interception, and determination of relative timing between transmitter and receiver. When transmission of data is successful, the transmitter receives an acknowledgement to tell it that it is completed. If no acknowledgment is received after a certain amount of time, the transmitter will then retry and resend the data. With the Workout Buddy, when data is sent from the sensors to the portable display unit, it is an advantage to know that data is successfully sent. If this feature is not present, data can be lost and unattainable.

77

Page 78: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

More information on Zigbee can be found on the Digi website: http://www.digi.com/technology/rf-articles/wireless-zigbee.jsp.

Looking at Zigbee modules more specifically, the group decided to look at the Xbee modules. In the next section, this module will be further discussed.

4.7.1.1 & XBee-PRO® 802.15.4

According to the digi.com the Xbee modules yield two to three times the range of standard Zigbee modules. Range is not important for the Workout Buddy. The max range needed for the device would roughly be at most a few meters. The user who is working out is assumed not to be more than 10m away from the device. The product summary of this specific device is shown below.

Product summary:

ISM 2.4 GHz operating frequency 60 mW (18 dBm), 100 mW EIRP power output (up to 1 mile range) U.FL RF Connector, RPSMA, Chip or Integrated Whip antenna options Industrial temperature rating (-40° C to 85° C) Advanced networking & low-power modes supported

Shown below in Table 4.7.1.1-1 are the electrical specifications of the XBee-Pro 802.15.4 chip. The RF Data Rate is 250kbps which is much larger than the HP3 Series RF wireless chips discussed in the next section of 4.7.2. Such a large data rate is not necessary for the information the Workout Buddy needs to transmit and receive. The power requirements needed for the chip is also shown below. A minimum voltage of 2.8V is required which seems typical of most chips researched. An amazing feature of these chips is the range. The outdoor line-of-sight range can reach up to 1mi (1.6km). Such a range is unnecessary for the Workout Buddy, but is still impressive. The sole aim and use of the Workout Buddy is for the typical weight lifter. If the project branched off for mass usage for the military and for keeping track of the progress of each soldier, this would be viable feature.

78

Page 79: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Table 4.7.1.1-1: Electrical Specifications. Permission Pending by Digi

In the Figure 4.7.1.1-2 shown below are the dimensions of the XBee and XBee Pro Chips that would have been used in the Workout Buddy design. The length of the XBee Pro is 1.297 x 0.866 inches with a thickness of 0.110 inches. This chip is fairly small but the HP3 Series Chips discussed in the next section of 4.7.2 are a tad smaller.

79

Page 80: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.1.1-2: XBee-PRO® 802.15.4 dimensions. Permission Pending by Digi

This specific module has a range of 30m to 100m. As stated before, range is not important. The range seems to be more than enough for the Workout Buddy. The receiver of this module is limited to receiving one signal at a time. The transmitter obtains a signal via the microcontroller. Before the signal reaches the transmitter, the microcontroller receives the signals from the sensors on the Workout Buddy. The signal the microcontroller receives is analog. Before the microcontroller can pass the signal to the transmitter, it must convert the analog signal into a digital signal. Once completed, the transmitter sends the data to the receiver located on the portable display unit. The Xbee unit operates on the 2.4 GHz frequency which was not the frequency the group wanted to use.

The group decided not to use the Xbee module. The Xbee module looked like a very powerful choice, but had features that were unnecessary. With that said, there was another choice of a RF module that seemed easier to implement with more information on the uses and implementations of it. In the next section, Linx Technolgies’ HP3 Series RF module will be discussed.

80

Page 81: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.7.2 HP3 Series

The other option for adding a wireless module to the Workout Buddy was to use a RF module from Linx Technologies. The linx website said that for these units, it should be straightforward on how to connect each module (transmitter/receiver), even for an engineer with no prior knowledge of wireless modules. The group decided that this would be the best option for implementing wireless to the Workout Buddy. Information on all Linx Technologies’ modules can be found and purchased on their website:

http://www.linxtechnologies.com/

The two chips can be found on E-bay going for around a total of $50 which would save a couple of bucks. After a little digging, the group decided on using this series of RF chips.

Product Features include:

Precision frequency synthesized architecture SAW filter for superior out-of-band rejection FM / FSK demodulation for outstanding performance and noise immunity Exceptional sensitivity (-100dBm typical) Up to 100 selectable reception channels (PS versions) Wide-range analog capability, including audio (50Hz to 28KHz) Transparent serial data output (56kbps max.) Direct serial interface Receive Signal Strength (RSSI) and power-down lines Cost-effective Pinned or SMD packaging Wide supply range (2.8-13VDC) Extended temperature range (-30C to +85C) No production tuning or external RF components required (except an

antenna)

The transmitter and receiver of this series can either come in the pinned or SMD (surface mounted device) packaging. For prototyping, the pinned versions could be used so it would be easier to install and remove from the board. Once the devices are working and the design is final, the SMD style chip could be used.

In the next two sections 4.7.2.1 and 4.7.2.2, the transmitter and receiver will be discussed respectively.

81

Page 82: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.7.2.1 Transmitter: TXM-900-HP3-xxx

In this section, the TXM-900-HP3-xxx will be discussed. Shown below in Figure 4.7.2.1-1 are the electrical specifications. The time needed to change channels is 1.5ms. Originally the idea was to have one transmitter, with one receiver receiving signals simultaneously. But after reading the specifications of the module it seemed that it was not possible. So instead the Workout Buddy will have two sensors either taking turns transmitting the data via the microcontroller or having them merge data and sending it together. The transmitter can be directly connected to the digital peripheral of the microcontroller via the pin 12. It has an impedance of 200k ohms and can be used with any data that transitions from 0V to a 3V to 5V peak amplitude. The power required to operate this module is a minimum of 2.8V. This module does not encode the data sent. The date rate of the transmitter ranges from 100bps to 56,000 bps which should be more than enough to send the data from the microcontroller.

Figure 4.7.2.1-1: HP3 Transmitter - Electrical Specifications. Permission was granted by Linx Technologies

82

Page 83: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

From the electrical specifications it states that this chip can operate between the temperatures of -30 to 85 degrees Celsius. This translates to -22 to 185 degrees Fahrenheit. Although it is not intended to use the Workout Buddy in extreme temperatures like that, it is good to know that temperature will not cause this unit to malfunction.

Shown below in Figure 4.7.2.1-2 are the pin assignments of the transmitter. There are two types of transmitters to choose from. On the left is the pinned style transmitter TXM-900-HP3-PPO which means that it stands sideways with the pins coming out of the side of the transmitter. The other style is the surface-mount style transmitter TXM-9009HP3-SPO shown on the right in the figure. This means that the transmitter would lay flat on the circuit board. The choice of these transmitters is yet to be decided. Since implementation of the wireless module is at the end of the milestone diagram, the final layout of the board is not official.

Figure 4.7.2.1-2: HP3 Transmitter Pin Assignments. Permission was granted by Linx Technologies

Shown below in Figure 4.7.2.1-3 are the dimensions of the two styles of transmitters. At the top of the figure is the SIP Style transmitter and at the bottom of the figure is the SMD style of the transmitter. The dimensions of both the units are almost the same, but the SIP Style transmitter is just a little larger height, width, and thickness-wise. This unit sells for around $30 from digikey.com

83

Page 84: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.2.1-3: HP3 Transmitter Chip Dimensions. Permission was granted by Linx Technologies.

Since the TXM-900-HP3-xxx has all the requirements necessary, it is likely that the unit will be used for the final product of the Workout Buddy. In the next section 4.7.2.2 the receiver RXM-900-xxx of the HP3 Series will be discussed.

4.7.2.2 Receiver: RXM-900-HP3-xxx

In this section the RXM-900-HP3-xxx will be discussed. This is the receiver end of the HP3 Series chips. Shown below in Figure 4.7.2.2-1 are the electrical specifications of the chip. They are very similar to the transmitter of the previous section. The power needed to for this unit is also at 2.8V. The rate at which data is received is 56,000 bps which is how much the transmitter will be sending out.

The Electrical Specifications:

84

Page 85: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.2.2-1: HP3 Receiver – Electrical Specifications. Permission Granted by Linx Technologies

The operating temperature of the RXM-900-HP3-xxx ranges from -30 to 85 degrees Celsius. This translates to -22 to 185 degrees Fahrenheit. Although the Workout Buddy is not intended to be operated in extreme temperatures, it is good to know that the receiver will not fail due to temperatures.

85

Page 86: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.2.2-2: HP3 Receiver Pin Assignments. Permission was granted by Linx Technologies.

Shown above in Figure 4.7.2.2-2 are the pin assignments of the RXM-900-HP3-PP0 on the left side and the RXM-900-HP3-SPO on the right. The receiver of this module is limited to receiving one signal at a time. The transmitter will be communicating with the microcontroller. The microcontroller should be taking in an analog signal and converting it into a digital signal. This digital signal is then passed into the transmitter and sent to the receiver which is connected to the portable display unit. The data received from the transmitter is available from pin 18. Since the data is not encoded, it gives the freedom of how the data will be handled on the portable display unit. The unit costs $44.98 from digikey.com.

Figure 4.7.2.2-3: HP3 Receiver Dimensions. Permission was granted by Linx Technologies.

86

Page 87: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Shown above in Figure 4.7.2.2-3 are the dimensions of the two styles of receivers. At the top of the figure is the SIP style receiver which stands at a height of 1.940 inches and a width of 0.780 inches. In the Workout Buddy design, small and compact is the general idea. Therefore using a SIP style receiver was not chosen. Adding almost 2 inches to the device is something that needed to be avoided. At the bottom of the figure is the SMD style receiver. This unit has a length of 1.950 inches and a width of 0.750 inches. Since these receivers lay flat on the board, it’s thickness of 0.190 inches is a much favorable choice of the two. The group decided on using the RXM-900-HP3-SPO receiver module which is SIP style.

4.7.2.3 Antennas

Choosing the right antenna for the project is important. There are three common types of antennas to choose from; whip style, specialty style, and loop style. After research, the group decided that the whip style antenna is the most stable. The length of the antenna is based on the wavelength of the operational frequency. The formula for determining the antenna length is:

L = 234/ F MHZ

Where:

L = length in feet of quarter-wave length.

F = operating frequency in megahertz

But since these devices are going to be worn, it was then considered to select an antenna that could be concealed inside the unit. There are several antennas off the antenna factor website that would work well with the Workout Buddy. Since the two devices connected by wireless modules are not more than a meter or so away, the antenna does not have to be very powerful.

4.7.2.3.1 JJB Series

The JJB Series Antenna is one type of a whip style antenna. It is ideal for compact, cosmetically attractive, low cost antenna solution. This unit can be directly connected to the PCB either internally or externally.

87

Page 88: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.2.3.1: JJB Series Antenna Dimensions. Permission Granted by Linx Technologies

As seen in Figure 4.7.2.3.1 the dimensions of this antenna are very small. Since this antenna is very compact it would have made a good choice in a “small, compact” design. It gives the choice of mounting it in two different ways; straight up and down as shown on the left in the figure or in a 90 degree angle which is shown on the right in the figure. Even so, the antenna was not chosen because of the amount of space needed vertically to mount it. The JJB Series antenna would need at least 0.69 inches in height which would make the Workout Buddy’s two units a little thicker.

The Electrical Specifications:

• Center Freq. 916MHz• Bandwidth 30MHz• Wavelength 1/4-wave• VSWR <2.0 typ. at center• Impedance 50 ohms• Connection Direct solder

The antenna operates at a center frequency of 916 MHz which is in range of what is needed for the HP3 Series wireless chips. To connect this antenna to the PCB board, soldering is required. These antennas run for $1.96 a piece and can be purchased from digikey.com. This antenna would have made a good choice, but was not chosen because there were smaller and more concealable antennas discussed in the next two sections of 4.7.2.3.2 and 4.7.2.3.3.

88

Page 89: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.7.2.3.2 HE Series

The HE Series Antenna is ideal for short ranges. They are not as efficient as the whip style antennas, but it seems to fit well in the design. The antenna has a length of 1.5” and is mounted on a 1.5” PCB. Though this antenna was considered, it was not chosen because a smaller and more effective antenna was found. Shown below in Figure 4.7.2.3.2 are the dimensions of the HE Series antenna. The dimensions of this antenna are quite slim. Having the length of 1.5 inches and a height of 0.25 inches makes this antenna a better choice than the JJB Series antenna discussed in the previous section.

Figure 4.7.2.3.2: HE Series Antenna Dimensions. Permission Granted by Linx Technologies

These run for $0.88 a piece and can be purchased from digikey.com. Although the each antenna is quite cheap, the height of this antenna can still be smaller. This antenna was not chosen because “The Splatch” antenna discussed in the next section 4.7.2.3.3 has more favorable dimensions.

4.7.2.3.3 SP Series “The Splatch”

The SP Series Antenna uses a grounded-line technique to help receive/ transmit data. It is designed to be directly mounted to the PCB. Unlike the previous antenna this part seems a little more compact lengthwise. It is almost a ½ inch shorter, not to mention the thickness is only 0.06”. The exact dimensions of this antenna are shown below in Figure 4.7.2.3.3. Since the thickness is only 0.06 inches, it will allow the two units of the Workout Buddy to be a small as possible. The Linx website states that this antenna is most suitable for handheld devices, therefore seemed like the best choice for the group’s design. There exists even smaller antennas, but was decided that this antenna would be easier to implement. The design will use two of these units; one for the transmitter and one for the receiver.

89

Page 90: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.2.3.3: “Splatch” Antenna Dimensions. Permission Granted by Linx Technologies

The Electrical Specifications:

• Center Freq. 916MHz• Bandwidth 30MHz• Wavelength 1/4-wave• VSWR <1.9 typ. at center• Impedance 50 ohms• Connection Surface-mount

Since the operating frequency of the HP3 series transmitter and receiver ranged from 902MHZ to 927MHZ, the model ANT-916-SP of this antenna is chosen which operates at a center frequency of 916MHZ which is show in the electrical specifications above. Each antenna costs $2.08 from digikey.com. Although the price of the unit is more expensive than the previous antenna, it was felt that paying for small and compact size was worth it.

4.7.3 Testing the Wireless Design

In order to test the feasibility of the wireless design, researching each unit involved is necessary. The biggest part of the researching is figuring out the pin assignments of each part. Starting with the power source shown below in Figure 4.7.3-1, each part necessary to test the wireless interface will be discussed. Shown below in Figure 4.7.3-1 is the 3.7V battery with the 3.3V regulator. The 3.3V regulator will be used to power the Atmega168, the accelerometer, and transmitter.

90

Page 91: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.3-1: 3.7V Battery and 3.3V Regulator

Shown below in Figure 4.7.3-2 is the Atmega128 Microcontroller Unit. The Atmega168 has 28 pins total. The majority of the pins will remain unused. The wireless design will be interested in the following pin numbers; pin7, pin8, pin22, pin3, pin23, pin24, pin25 and pin26. Pin 7 will be connected to the 3.3V regulator. Pin 8 and 22 will be connected to the common ground. Pin 3 will be connected to the transmitter. Pin 23-26 will be connected to the accelerometer and sensors.

Figure 4.7.3-2: Atmega168 Pin Assignments.

Shown in Figure 4.7.3-3 of section 4.7.3 is the pin assignments for the TXM-900-HP3-xxx transmitter. Using the pinned version of the transmitter, pin 1 will be connected to a common ground. Pin 2 will be connected to the “Splatch” antenna chosen in section 4.7.2.3.3. Pin 8 will be connected to the 3.3V regulator. Pin 10 will be connected to be connected to pin 3 of the Atmega182 unit.

91

Page 92: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Shown below in Figure 4.7.3-3 are the pin assignments of the accelerometer (MMA7260Q). Pin 3 will be connected to the 3.3V regulator. Pin 4 will be connected to the common ground. Pin 14 will be connected to pin 23 of the Atmega168. Pin 13 will be connected to pin 24 of the Atmega168.

Figure 4.7.3-3: Pin Assignments for MMA7260Q.

The two electrode sensors will be connected to pin 25 and 26 of the Atmega168. Shown below in Figure 4.7.3-4 is all of the parts connected together. When a part is connected to another part the pin numbers are shown. The unused pins are not shown in the figure.

92

Page 93: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.7.3-4: Layout of Parts Transmitter.

Once all parts have been connected the unit should be ready to transmit data to the RXM-900-HP3-xxx receiver. The Receiver will also be connected to an Atmega168 microcontroller unit. The portable display unit will be using a 7.4V battery along with a 5V and 3.3V regulator to power the various units. Connected to the 5V regulator is the LCD 128x128 Nokia Clone screen and also the Atmega168. Connected to the 3.3V regulator is the receiver module. Shown below in Figure 4.7.3-5 is the layout of the batteries.

Figure 4.7.3-5: 7.4V Battery with 5V and 3.3V Regulators.

93

Page 94: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The pin assignments for the Atmega168 are found in Figure 4.7.3-2 . Pin2 is connected to the RF receiver. Pin22 and 8 are connected to a common ground.

Shown in Figure 4.7.2.2-2 of section 4.7.2.2 is the pin assignments for the RXM-900-HP3-xxx RF receiver. Pin1 will be connected to the “Splatch” antenna. Pin2 is connected to a common ground. Pin18 is connected to pin2 of the Atmega128. Pin16 is connected to the 3.3V regulator.

Shown in section 4.5.4.2, are the pin assignments of the LCD 128x128. Pin10 is connected to the 5.5V regulator. Pin1 and 6 are connected to the 3.3V regulator. Pin9 and 8 are connected to the common ground. Shown below in Figure 4.7.3-6 is the pin layouts for the parts used in building the receiver end of the portable display unit.

Figure 4.7.3-6: Layout of Parts Receiver.

Once all the necessary parts are connected, programming of the Atmega128 is necessary. Not shown above is the SD module. The SD module chosen for the Workout Buddy is later discussed in section 4.9.1.3. The microcontrollers will be responsible for controlling the data transmitted and received.

4.8 Programming Languages

94

Page 95: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

According to “The Encyclopedia of Computer Languages” by Murdoch University, it states that:

“A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that specify the behavior of a machine, to express algorithms precisely, or as a mode of human communication.”

Programming is involved in this project. There is a vast list of different types of languages that could be used for programming specific parts of the Workout Buddy. From Perl to C++ to C#, it was decided that the design would use two programming languages. These languages will be discussed in the next two subsections of 4.8.1 and 4.8.2. The reason for the choosing of this project was because of the vast fields of study required to complete it. Being able to program is just one of the many skills necessary to complete it. This gives each group member the opportunity to be able to learn the basics of programming if they are unfamiliar.

4.8.1 C Language

According to "History of the C Programming Language" by Bill Stewart “C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system.”

Most of the group members know a fair amount of C because it is the first programming language students usually learn. It is the basics to which other programming languages are based off of. The microcontrollers will be programmed using the C language. Also, it is a possibility that the interface on the portable device will be programmed in C. It was felt that the C-language is basic and well suited enough to program the devices effectively.

Below is a list of characteristics of the C-Language:

non-nestable function definitions variables may be hidden in nested blocks partially weak typing; for instance, characters can be used as integers low-level access to computer memory by converting machine addresses

to typed pointers function and data pointers supporting ad hoc run-time polymorphism array indexing as a secondary notion, defined in terms of pointer

arithmetic a preprocessor for macro definition, source code file inclusion, and

conditional compilation complex functionality such as I/O, string manipulation, and mathematical

functions consistently delegated to library routines

95

Page 96: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

A lexical structure that resembles B more than ALGOL, for example { ... } rather than ALGOL's begin ... end the equal-sign is for assignment (copying), much like Fortran two consecutive equal-signs are to test for equality (compare

to .EQ. in Fortran or the equal-sign in BASIC) && and || in place of ALGOL's and and or (these are semantically distinct

from the bit-wise operators & and | because they will never evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation)).

a large number of compound operators, such as +=, ++, etc.

The characteristics listed above describe the C Language. The C Language was designed for implementing system software and also for developing application software. Keeping that in mind, the C Language was good choice to use.

4.8.1.1 Dev-C++

In order to program in C, software was needed that could compile and run programs. One of the programs the group is using is called Dev-C++. It is a free editor and compiler for the C and C++ programming languages. It was first introduced from the group members who took the class Computer Science I. The professor of that course recommended that everyone downloaded and used it for programming the assignments given. It is free software that can be downloaded from the bloodshed.net website:

http://www.bloodshed.net/devcpp.html

Features of Dev-C++:

- Support GCC-based compilers- Integrated debugging (using GDB)- Project Manager- Customizable syntax highlighting editor- Class Browser- Code Completion- Function listing- Profiling support- Quickly create Windows, console, static libraries and DLLs- Support of templates for creating project types- Makefile creation- Edit and compile Resource files- Tool Manager- Print support- Find and replace facilities- CVS support 

96

Page 97: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The group found the features of this IDE (Integrated Development Environment) to be suited for the task needed to be accomplished. Bloodshed Dev-C++ uses the Mingw port of GCC (GNU Compiler Collection) as its compiler. If the programmer did not want to you use Mingw, the IDE can also be used in combination with any other GCC based compiler. The compiler requires Windows 95/98/NT/200/XP and free space of 13.5mb.

4.8.2 Java

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.

It was decided that java was to be used as the programming language for the simulation program. The capabilities of java best suit the needs of the simulator. Being based on the C language, java seemed like the better choice for programming the interface. Not many of the group members know much about this language but are eager to learn. This is a good way to expand the knowledge of programming with a language that seems standard nowadays practices. The object orientated capabilities of java should make this part of this project seem simple enough. As opposed to the C language, java has more abundant built-in functions. In the C language, it seems like the user has to create everything from start to finish. Java seemed like the perfect way to create an interface. To help the developer Sun Microsystems created a comprehensive documentation system called “Javadoc”. It provides the developers with an organized system for documenting their code. Java.sun.com also provides an API Specification document for the version 6 JSE (Java Standard Edition). This documentation contains all the methods Java has built into the environment. This is located at the URL: http://java.sun.com/javase/6/docs/api/

4.8.2.1 Eclipse

In order to program in java it is necessary to have a text editor and compiler. The software chosen for this is called Eclipse. This was the recommended software group members have used when taking the UCF course Object Orientated Programming. Eclipse has features which can make programming faster. For instance, it has a feature that while the user starts typing known syntax, a little window pops up and shows the available methods that match the syntax which then they can select. There is also a feature which constantly checks the written code for errors. If errors are found they are highlighted. Eclipse then tries to tell the user what is wrong with the code, and recommends how to fix it. It is almost

97

Page 98: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

like having another person watching you program. This software is free and can be downloaded and installed on any computer with access to the internet. The website where Eclipse can be downloaded is:

http://www.eclipse.org/

The file is called Eclipse IDE for Java Developers. The file size is 85mb. A requirement of using this program is to have the latest JRE (Java Runtime Environment) installed on the computer using it. The program recommends Java 5 JRE.

4.9 Simulator/ Simulation

After data is saved onto the SD memory card, the SD card should be able to be used to take the information gathered and read on a simulator which will then simulate the workout(s) performed. This data should include the body part being used, the repetitions, and the intensity of the workout. The idea is to create 3D body parts of the arm, leg, and pectorals using 3D modeling software. The models created will be used to simulate the workout saved on the memory card. More detail on the SD card/module can be found in section 4.9.1.3. The simulator’s purpose is to have an easy way to interpret a person’s workout. This is a way to keep track of what someone is doing, and the progress a person makes when working out over a period of time.

4.9.1 The Interface

The interface is going to be a stand alone program that will be able to be loaded onto any computer to interpret the data stored in the SD memory card. The interface will be programmed using java. Java seemed to be the best way to program an interface because of its object orientated capabilities. The interface will include a 3D simulation along with data to better understand each workout. The interface will also include a graph which will show progress of the user’s workouts over time. Most likely it will take the average intensity of a user’s workouts of each day and plot it over time on a graph using Excel or Matlab. The other data that will be displayed will most likely be similar to the outputs of the portable display unit. This is still in the design phase and yet to be finalized. A sample of what the interface will/may look like is shown below in Figure 4.9.1. There are only two interactive buttons on the interface. The down arrow by the sample date will be used to choose either a specific date or the grouping of all of the dates that the user has data for. The second interactive button is the other down arrow. This will give the user a choice of body parts he or she has data for. On the left side of the simulator there will be information displaying the average intensity of either a specific date or of a period of time chosen. Also there will be the Total number of repetitions performed during a specific date or of a period of time chosen. And lastly the total time that the user worked out for a specific day or period of time chosen.

98

Page 99: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.9.1: Simulator.

The interface should be straight-forward and simple. The user will be able to choose which body part and view the progress of it. The 3D body part will be an animation of the body part selected. The 3D body part will be created using the program K-3D. The graph will be the average intensity of the date of the workout over a given period of time. This will help show the progress of the user’s workouts. If the user is working out effectively they should see a linear increase. The user’s intensity should gradually increase over time. If the user’s intensity is decreasing, their workouts are not properly being done and should be changed. In the interface, the user will have an ability to choose a given date, and it will display the information gathered on the workouts performed on that date. The colors of the interface and design will stay simplistic. The group wants to keep the user interface as user friendly as possible. Just by looking at the interface, a user should be able to figure out how to operate and use it.

99

Page 100: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.9.1.1 Anim8or

The first software found for the purpose of modeling and animating 3D models was a program called Anim8or. Once the software was downloaded and installed, it was tested. It was found to be very hard to do anything on this software. Trying to draw simple objects turned out to be a pain. It was then decided to try and find something else that was more user-friendly. The Anim8r software can be found and downloaded at the URL:

http://www.anim8or.com/

Features of Anim8or according to the website include:

3D Modeler - Create and modify 3D models.  Built-in primitives such as spheres, cylinders, platonic solids, etc.; mesh-edit and subdivision; splines, extrusion, lathing, modifiers, bevel and warps,

TrueType font support - 2D and 3D extruded text for any TrueType font. OpenGL based real time operation, Import and modify .3DS (3D Studio), .LWO (Lightwave), and .OBJ

(Wavefront) object files, Export .3DS files, Built in 3D Object browser, Jointed character editor, Morph targets, Anti-aliased software renderer for high quality, production quality images, Create 3D scenes and animations and output .AVI movie files, .JPG

and .BMP images, Supports textures, bump maps, soft shadows, spotlights, fog, and much

more, Texture support for .BMP, .GIF, and .JPG format files, Print images of scenes and models. OpenGL shaders for realistic previews. Scripting language. Plug-ins for parameteric shape and object export.

The software comes with built in primitives such as spheres, cylinders, and platonic solids. Having these basic shapes save time on creating the body parts needed. Using the mesh-edit feature, the shapes should be easily modified to the desired state.

The system requirements:

Windows NT4, Win95, Win98, WinSE, Win2K, or WinXP, OpenGL accelerated graphics card with full ICD support, (ala GeForce), 64 MB memory, 128MB recommended, or 256MB if you use WinXP, 300 MHz Pentium,

100

Page 101: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

5MB disk space.

This software requires minimal space and very low end computing power. It could be a good choice for an animator with a low budget of equipment. For the Workout Buddy the group wanted something better. Another program found that required more computing power and had an easier interface to understand was K-3D. This program is discussed in the next section of 4.9.1.2.

4.9.1.2 K3D

Another program found for the purpose of drawing and animating 3D models was called K-3D. This program seemed more promising. This program has a built in 3D render engine called “RenderMan Engine”. Also found was a couple of forums that taught the basics of using this software. Using this program, it should possible to be able to manually draw a model of a human arm, leg and pectorals. Once each body part is created, it should then be possible to create a simple animation of what the general workout of the body part is doing. This will basically be the flexing of the muscle.

Here is screenshot of the K-3D interface:

Figure 4.9.1.2: Screenshot of K-3d.

Starting with a basic shape, it can then be manipulated to create the body part needed. The cost of this software is free. Anyone with internet can go to the website and download it.

According to the website, the features of K-3D:

Licensed under the GNU General Public License (GPL). Record interactive tutorials and macros. Unlimited undos / redos.

101

Page 102: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Create and edit documents in multiple realtime OpenGL solid, shaded, texture-mapped views.

Scripting interface supports K3DScript and Python, with an open API for other scripting languages.

Model, animate, and interact with animations while they play back for maximum productivity.

Highly-evolved architecture allows complete extensibility at runtime through third-party plugins.

Animated geometric procedural effects. Powerful control-spline based animation in a uniform interface. Uses the Pixar Renderman Interface to render motion-picture-quality

images with a wide variety of rendering engines. Supports Renderman Subdivision Mesh output. Background rendering and batch rendering. Written in ANSI C++, and GTK+.

Developers are not perfect. Having the feature of unlimited redo’s and undo’s is great.

The system requirements:

CPU: 400Mhz RAM: 256 MB Video: A good OpenGl card Hard Disk: About 150mb of disk space should be more than enough. (if

you are going to compile it you will need between 0.5-2Gb depending on the options)

As seen above in the system requirements, they are a little more requiring of a system compared to the previous software Anim8or discussed in the previous section. This is the first time any of the group members have attempted to create a 3D model of anything. It is not expected that the models will be amazing, but basic enough to see what it is suppose to be. Also creating an animation of each body part will be challenging. The group feels that it will be nice to learn these techniques for future projects. The software can be found and downloaded at the URL:

http://www.k-3d.org/wiki/Main_Page

4.9.1.3 SD Card/ Storage

In order to create a simulator on a computer, a source of information is needed to be translated. A SD chip module will be added to the portable device which will store information from each workout. This information will include, but not limited to: Time/Date, Type of workout, intensity, and repetitions. Most likely the format of the data will be in CSV (Comma-separated values) style.

102

Page 103: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Example format of CSV file:

Date: 4/1/09, St_Time: 07:05, Type: Biceps, Intensity: ##, Reps: ##, En_Time: 08:30,

Since the information is strictly text data, the size of the SD card will not have to be large. It will be compatible with cards with 32mb-2GB of storage space. A flowchart of what happens to the data is shown below in Figure 4.9.1.3-1:

Figure 4.9.1.3-1: Block Diagram SD module.

The price of a micro SD card is pretty cheap. At newegg.com the 2Gb SD card can purchased for $5.75. Shown below in Figure 4.9.1.3-2 is the 2Gb SD card from Newegg.com.

103

Page 104: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.9.1.3-2: The image shows the OCZ 2GB Secure Digital (SD) Flash Card Model OCZSD60-2GB. Permission pending from OCZ.

The SD Module will store the data onto a SD memory card that is inserted into it. When finished, the memory card is removed and placed into a reader that is connected to the computer the user is using. He then opens the data with the simulator created and views results. Shown below in Figure 4.9.1.3-2 is a SD card module made by MDfly found on Ebay for $9.95.

Figure 4.9.1.3-3: This image shows the SD card module found on Ebay. Permission pending from MDfly electronics.

Model: MDSDM01The Product Description is as follows:

MDfly presents a brand new Standard SD Card Module for electronic application.

Standard SD Card Slot, compatible with all SD memory cards. All control signals are brought out to header. Easy to connect to your electronic designs or application. SD Card Module Schematics is provided.

Original Packaging: MDfly original packaging.

This unit would be used to write all the data from the sensor unit to the SD card being inserted into it. From the description of the product, it says that it is a compatible with all SD cards. This gives the wide range of choosing which SD card to use with it. The SD card module schematic is also provided. The group requested via email the schematic that is included with this product. MDfly provided the schematic shown below in Figure 4.9.1.3-4.

104

Page 105: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.9.1.3-4: Schematics of SD card Module.

All of the information needed to correctly attach the SD card module to the Atmega168 should be in the schematic shown above in Figure 4.9.1.3-4. Typically, like most of the parts contained in this design, it requires a 3.3V power source. The 3.3V regulator will provide the proper voltage for this unit.

4.10 Power Supply

When Workout Buddy was contemplated, it was decided that the device would be driven by a linear power supply. The device originally, to keep cost at a minimum, was going to be powered by some sort of alkaline battery. When the

105

Page 106: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

battery life was taken into consideration, and the cost of batteries, the group decided to move to a rechargeable battery supply. The device must be powered long enough to produce electricity for long duration workouts, which in certain cases can be up to three hours. An additional requirement mentioned was that the battery should be a brief charging time, as a result of some individuals exercising on a day to day basis. There will be two battery systems in place, one for the sensor system, and one for the display module. The first system will need to power many devices including a microcontroller, accelerometer, amplifier, and the RF transceiver. The second battery system will also power a microcontroller, an RF module, and the display module.

4.10.1 Power Requirements.

Workout Buddy must be able to run for an extended period without having to replace or charge the power supply due to the fact that some individual’s spend more than three hours exercising. The design requires many components that will be interfaced together. The power requirements for the design, as well as the power requirements for the microcontroller, accelerometer, RF module, and amplifiers for the sensor part of the system are as follows:

Workout Buddy components must be selected based on the lowest power consumption.

Workout Buddy must run for extended periods of time, without having to recharge or replace the powering device.

If a rechargeable battery is chosen, the charge time should be a minimum of two hours.

If a rechargeable battery is chosen, a safety device must be implemented into the design to monitor the temperature, and certain voltages to prevent deep discharge.

If rechargeable batteries are selected, the sensor system must be able to be recharged from a USB.

Shown below are the power requirements for each individual component in the sensor system of the design. The components that make up the design include an RF transmitter, microcontroller, amplifiers, and an accelerometer. Components selected were based on the lowest power consumption rating. All devices selected in the sensor system will be operating at 3.3V, to limit the size of the battery needed and also to reduce the power consumed by the battery.

The microcontroller used for the sensor system will use a voltage of 3.3V. The voltage supplied to the device must be a DC source. Different components may be selected for the final design, but these were selected for the initial prototype.

Transmitter: TXM-900-HP3-xxx

106

Page 107: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Parameter Range  Operating Voltage 2.8V-13V  

Current Consumption14mA,17mA  

Power-Down Current 15µA  Output Power (Watts) 39mW to 221mW

Table 4.10.1-1: This table shows the power requirements for the selected RF transmitter, the TXM-900-HP3. Permission was granted.

Microcontroller: ATmega168/V

Parameter Range  Operating Voltage 1.8V-5.5V  Current Consumption 15µA-250µA  Power-Down Current 0.1µA  Output Power (Watts) 27µW to 1mW

Table 4.10.1-2: This table shows the power requirements for the selected microcontroller, the Atmel Atmega 168/V. Permission was granted.

Amplifier: INA122

Parameter Range  Operating Voltage 2.2V-36V  Current Consumption .06mA  Output Power (Watts) 132µW to 2.16mW  

Table 4.10.1-3: This table shows the power requirements for the selected amplifier which the electrodes will sense the voltage. Permission was granted.

Accelerometer: MMA7260Q

Parameter Range  Operating Voltage 2.2V-3.6V  Current Consumption 500µA  Output Power (Watts) 1.1mW to 1.8mW  

Table 4.10.1-4: This table shows the power requirements for the selected accelerometer. Permission was granted.

Given this information, the demand for the sensor circuit is approximately 18mA. The group knows additional components may be needed for the design, like additional amplifiers to implement a notch filter. The group is estimating the demand will be approximately 25mA. With this aside, the group wants the sensor system to be able to run for three hours a day for any given week. With this approximation, the group wants the selected battery to have a capacity of

107

Page 108: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

600 mAh, which can run the module for approximately 30 hours. With this information, it is possible to power the sensor system via USB. The USB provides the up to 5V, and 500mA. This power can be used to charge the sensor system if the battery selected is 3.7V. Additional devices will be needed in order to charge the sensor system through a USB. This will be discussed in the ‘Charging the Battery’ section.

A 3.3V linear regulator will be used to get the required voltage needed for each component in the sensor system. Figure 4.10.1-1 shows the linear regulator that is under consideration is the LP8345CDT-3.3-ND. A heat sink is not required for this device, and ground will be connected to the tab on top of the device. It has a low drop out voltage of 210mV at a full load of 500mA. It’s dimensions are small, and the component meets all requirements. It is often used in battery powered electronics and portable instrumentation.

Figure 4.10.1.1: This image shown is the LP8345 voltage regulator that is under consideration for the design. Permission was granted from Digikey.

The display module with the user interface has considerably more power consumption due to the LCD display which has a very high brightness. A more efficient display may be chosen for the final design, but this will be used for testing purposes. All components were selected on lowest power consumption rating and also the least cost. The control unit includes the LCD screen, a microcontroller, and a RF receiver. The power requirement for the display module broken down by part is as follows:

Microcontroller: ATmega168/V

Parameter Range  Operating Voltage 1.8V-5.5V  Current Consumption 15µA-250µA  

108

Page 109: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Power-Down Current 0.1µA  Output Power (Watts) 27µW to 1mW

Table 4.10.1-5: This table shows the power requirements for the selected microcontroller used for the display module. Permission was granted.

Receiver: RXM-900-HP3-xxx

Parameter Range  Operating Voltage 2.8V-13V  Current Consumption Approx. 10mA  Power-Down Current 15µA  Output Power (Watts) Approx 30mW

Table 4.10.1-6: This table shows the power requirements for the selected RF Receiver, the RXM-900-HP3. Permission was granted.

Display: LCD-00569

Parameter Range  LCD Logic 3.3V  Current Consumption 2mA-3mA  LED Backlight 5VCurrent consumption 40mA-50mA  Output Power (Watts) 260mW

Table 4.10.1-7: This table shows the power requirements for the selected display unit, the LDC-00569. Permission was granted.

The estimated demand for the display module is approximately 70mA. This is more than three times as large of the demand of the sensor circuit, and is going to require a battery with a large capacity to ensure the device remains powered for long durations of time. This estimate does not include additional devices and components that may go into the design including voltage regulators, and other active or passive components. Based on these figures, we want to design the power supply for the display module to have a capacity of a minimum of 700mAh and a maximum of 1800mhA. Since the highest voltage demanded is 5V, it may require two lithium ion batteries connected in series, or even more batteries connected in series depending on the chemistry of the battery. An alternate would be to use a 7.4 polymer lithium ion battery which is used in most handheld devices.

As mentioned, a 5V linear regulator will be used to step down the voltage from the power source to power the LED backlight, and the microcontroller in the display module. The 5V linear regulator under consideration is the LP2954. It can handle an input ranging from 6V to 30V, and output the 5V that is required. It has a low drop out voltage that ranges from 60mV up to 250mV depending on the load current. It is estimated to be in the 100mV range assuming that is the

109

Page 110: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

demand for the circuit is 70mA. Figure 4.10.1-2 shows the LP2954 should be configured, using two external capacitors at a rating of 1 and 2.2 micro-farads. It guarantees 250mA output of the voltage regulator, which more than meets the requirements for the load on the display module. It is cost efficient, costing $2.68 for a single component.

Figure 4.10.1-2: This image shows the LP2954 linear regulator, a high efficiency 5V regulator. Permission was granted by Digikey.

4.10.2 Battery Selection

There were many different batteries on the market and available to the group. Workout buddy needs two different power supplies, and due to the sensor circuit being attached to the body, it is important that the battery selected can’t weigh more than a few ounces, due to the the device being attached to the body. The group researched many different batteries ranging from classic alkaline batteries, lithium ion batteries, polymer lithium ion batteries, and other rechargeable batteries. Other batteries researched involved nickel cadmium and nickel metal hydride. Stated previously, the battery should be able to power the device for extended periods of time. If rechargeable batteries are selected, additional devices may be needed in order to monitor the battery for instances where the battery could be overheated and cause a fire. The battery to be selected must meet all power requirements stated in section 4.10.1.

4.10.2.1 Lithium Ion Battery

The lithium ion battery was one of the first rechargeable batteries the group considered. It was considered due to its wide use in electrical equipment and devices such as laptops, cell phones, and other handheld electronics. Since the power supply is going to be attached to the body, it is essential to have a power

110

Page 111: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

supply that is light weight. Lithium ion batteries are light weight, which is required for our design. Lithium ion batteries have been used in a variety of different fields ranging from laptop computers and now cars. It has a longer life cycle than most rechargeable batteries and carries almost twice the voltage of an alkaline battery. Due to the fact that some individuals workout every day, Workout buddy will need to have a short recharge time, which lithium ion surpasses its competitors in that area. Compared to its competitors, it draws more voltage and more current and is light weight, which meets all of the groups design criteria for a power supply. The maximum recharge life cycle for lithium ion batteries is around 500, which should last an individual more than a year. Lithium ion batteries also work better than most batteries in unusual temperatures and climates. Our choice for a lithium ion battery must be completely intact and ready to mount onto a PCB. Lithium ion batteries are also more dangerous than other batteries and may explode if not handled or charged properly. The lithium ion battery is under consideration for the display module because it will let the individual avoid having to purchase new batteries on a daily basis. Figure 4.10.2.1-1 shows the LC-18650S2WR, a 7.4V lithium ion cell that may be used if the group decides to use Li-ion. It has a 700mAh capacity which would keep the sensor circuit powered for almost 38 hours, or the display module powered for 10 hours, making the individual having to charge the devices weekly, opposed to daily. Its dimensions are small and the device is of light weight. It meets all power requirements mentioned earlier. [4]

Figure 4.10.2.1-1: This image shows one of many lithium ion batteries under consideration. Permission is pending from Battery Space.

The disadvantage of the battery is the cost, when compared to alkaline batteries and other rechargeable batteries. If lithium ion is chosen then a battery charger will also be needed. The recommended battery charger for the LC-18650S2WR is the Smart Charger (1.2A) for 7.4V Li-ion/Polymer Rechargeable Battery Pack. If this combination is chosen, more than 30 dollars will be put into the power supply for the display module, not including the power supply for the sensor system, which will use a polymer lithium ion. Although the design would be more expensive, the cost of replacing batteries on a daily basis would outweigh the cost to put it in the design, which would save the buyer money. Figure 4.10.2.1-2 shows the recommended battery charger for the selected lithium ion battery mentioned previously.

111

Page 112: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.10.2.1-2: This image is the charger for the 7.4V lithium ion battery mentioned previously. Permission was granted from batteryspace.com

4.10.2.2 Alkaline Battery

The alkaline battery was the first battery purchased for this experiment, being the most common type of battery. These types of batteries are frequently selected because they have a long shelf life, as well as a high drain rate. We were able to find a relatively small and inexpensive 12V battery that would be suitable for this design. Although this battery fits well for the design, it would not be easily accessible to individuals who decide to purchase workout buddy. The most common battery that is available is the AA, and AAA. If this route it chosen it would require batteries to be connected in series, which would not meet the specification of having a small power supply. Alkaline batteries have two terminals and can be mounted with ease. In order for the power supply to operate correctly it will need to have a battery holder. When the dc battery is in the battery holder, it will have both positive and negative leads, and wires will be coming out of both. Although alkaline batteries have an improved capacity when hot, the capacity drops considerably under colder temperatures. If alkaline batteries are chosen then Workout Buddy would not be operable in outdoor weather in northern states where it is normal for the temperature to reach below thirty degrees Celsius.

Further research revealed that the 12V alkaline battery mentioned earlier does not meet the current demand needed by the sensor circuit. The 12V battery meets the weight and dimensions required for the design, but the current demanded by the sensor circuit would give Workout buddy a relatively low lifespan. If this battery is chosen, the individual using workout buddy would have to replace the battery after only 1.5 hours of usage. If the individual exercises every day, he would have to replace the battery seven times a week, paying $2 a battery which would cost him $14 a week in batteries. A long battery life is the solution to having to replace batteries on a daily basis. To determine what battery we needed to use we took a look at the batteries lifespan. Figure

112

Page 113: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.10.2.2 is a picture of the 12V battery that was under consideration. It has an operating capacity oh 59mA*h which would let the sensor circuit from for approximately 2 and half hours, which does not meet requirements.

Figure 4.10.2.2: This image is the 12V alkaline battery used for initial testing. Permission was granted from batteryspace.com

The largest voltage demanded by the circuit is 5 volts, required by the microcontroller. If AA or AAA alkaline batteries are selected, it would require a minimum is four batteries connected in series to achieve the voltage required for the design. The group decided that that a rechargeable battery would be more beneficial to the customer, and more cost efficient in the long run.

4.10.2.3 Nickel Cadmium and Nickel Metal Hydride

Nickel cadmium was another option for a rechargeable power supply. They have a lower nominal cell potential, when compared to lithium ion batteries which have a 1.5V per cell. It has an excellent life cycle and temperatures do not impact the performance. Due to the size of the battery needed and the impact that the material has on the environment, it will not be used in this project. Nickel Metal Hydride was also mentioned when deciding how to power the device. It has its advantages and disadvantages, but the group decided that it would not be best for the design.

4.10.2.4 Battery Comparison

Each battery discussed previously has their own advantages and disadvantages. All the design requirements for Workout Buddy have the group pointing towards using a polymer lithium ion battery or just lithium ion for both the sensor system and the display module. Table 4.10.2.4 shows the advantages and disadvantages of the different battery chemistry including Alkaline, Lead Acid, Nickel Cadmium, Nickel Metal Hydride, and Lithium Ion. Selection of the battery was based upon the advantages of the battery, and selection based on cost efficiency. Although Nickel Cadmium and Nickel Metal Hydride have much

113

Page 114: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

higher capacities, the impact that the materials have on the environment as well as the cost of the batteries made the group aim towards a lithium ion unit.

Battery Chemistry Advantages Disadvantages

Alkaline Inexpensive, readily available,

Limited current capacity, limited life cycle.

Lead Acid Inexpensive, high discharge rates, dependable

Low energy density, environmentally unfriendly, limited charge cycles.

Nickel Cadmium

Long Life cycle, tolerates deep discharge, high energy density

Costly, extremely toxic,

Nickel Metal Hydride

Higher capacity, recyclable Low service life, performance degradation in certain temperatures

Lithium Ion Light weight, no memory effect, high OP circuit V, 3.7V per cell

Shelf life, deceased capacity

Table 4.10.2.4: This is a table comparing the battery types that may be used in the design. Permission is pending from www.batteryspace.com

4.10.3 Battery Selected

After thorough research, the group decided to use lithium ion batteries. To eliminate the need to connect batteries in series, the polymer lithium ion battery was chosen. Some components, which can handle higher voltages, are going to operate at a lower voltage to reduce power consumption. For the sensor system, the power will stream directly from the battery Figure 4.10.3 shows the battery selected for the sensor circuit. The battery that was chosen by the group to run the sensor system was the BT50 battery used by the Motorola MOTORIZR. The chemistry of the battery is polymer lithium ion, and it has a nominal rating of 3.7V. The capacity of the battery is 810mAh The battery type is very efficient,

114

Page 115: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

but must be monitored very closely due to the fact that lithium ion batteries have the potential to catch fire if discharged or charged improperly. This polymer lithium ion meets all the power requirements needed for the components to operate properly, and costs only $18.95.

Figure 4.10.3: This image shows the battery selected to supply power to the sensor system, this battery is commonly used to power the Motorola MOTORIZR

cell phone. Permission is pending from http://www.batteries4less.com

4.10.4 Charging the Battery

Charging a battery can be complex for lithium ion batteries. The charging circuit must determine when the battery is fully charged to prevent damage to the battery. The battery must be limited to how fast it can be charged, if it is charged too quickly heat will be generated, and can not be dissipated. The battery is limited to a charge rate which is dependent on the chemistry of the battery. The MAX1811 integrated circuit is the top candidate to monitor how the battery charges. It can sense when the chemical process is complete, and suspend charging. This device is needed to help reduce the chance of a fire because of the chemistry of the battery. This will be accomplished because of the capability of the integrated circuit to monitor the changing algorithm. The circuit was chosen because the package is small, and is provided in a many different packages. This integrated circuit will allow easy prototyping and troubleshooting will be even easier. Figure 4.10.4-1 shows how the MAX1811 is interfaced between the battery and the USB hub, as well as required components and voltages needed for it to work properly. The package will help keep the requirements of having a small power supply, since the circuit will be attached to the body.

115

Page 116: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Figure 4.10.4-1: This image shows the pin configuration and operation of the integrated circuit, the MAX1811. This integrated circuit will be used to monitor

the battery. Permission is pending from

The battery will be charged when Vcc on the integrated circuit is connected and the MAX1811 is energized. Figure 4.10.4-2 shows how the MAX1811 is interfaced with the USB port, and the battery. The battery will be monitored during all modes of the device. The MAX1811 will measure and monitor the voltage of the battery, and the temperature during the charging state. A thermistor may be used to monitor the temperature of the battery. It important that the temperature is monitored closely due to the fact if it gets too hot it can create a fire and could compromise the rest of the circuit. The integrated circuit will also check for deep discharge when the battery is low. To check for deep discharge, it will check the battery for a voltage around 3.0 Volts.

Figure 4.10.4-2: This image shows how the Li-ion battery selected for the sensor circuit is going to be charged. Image created by group member.

116

Page 117: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

4.10.5 Power Supply Summary

Two different batteries are going to supply power the two systems. A polymer lithium ion battery with a 3.7V was chosen to power the sensor circuit. A 7.4V polymer lithium ion battery will power the display module. In the sensor circuit, a 3.3V linear regular will be used to get the required voltage needed for the components including the microcontroller, accelerometer, RF transmitter, and the instrumentation amplifier. In the display module, a 5V linear regular will be used to power the LED backlights, and a 3.3V linear regular will be used to power the RF receiver, and microcontroller. Figure 4.10.5 shows the basic setup for the circuit and how each device will be powered, as well as the voltage required for each device.

Figure 4.10.5: This image shows all essential components, how they will be powered, and what voltage is required to power the device for the two different

systems.

117

Page 118: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Chaper 5Design Summary

5.1 Sensor system

The critical part of designing Workout Buddy was developing an accurate and precise sensor unit. This involved selecting the correct electrodes that would detect the electrical potential and then be amplified. It was important to choose an amplifier that was common with surface electromyography. The INA122 instrumentation amplifier was chosen due to its high common mode rejection ratio, giving it the ability to ignore interference that would be caused by the surrounding power systems. This amplifier is very accurate, and very sensitive. The angle detection device that was selected was the MMA7260Q accelerometer. This device was important to the design because it will be used to count repetitions when exercises involving the biceps are selected. Once the angle is detected and the electrical potential is generated, these two signals will then be converted from an analog into a digital signal on the Atmel Atmega 168/V. At this point, the information will be processed and then sent to the TXM-900 HP3 transmitter. All these devices will be powered by a single 3.7V polymer Li-ion battery, the BT50, which is commonly used in Motorola cell phones. All devices will run off of 3.3V to reduce power consumption. The linear regulator chosen to step down the 3.7V is the LP2954. All components were selected based on lowest power consumption, which is one of the many advantages of the groups design. Figure 4.7.3-4 shows the layout for the sensor system, as well as pin assignments. Additional devices that may be needed in order for the design to function properly include the battery charger.

5.2 Control Unit

For design simplicity, the microcontroller used in the sensor system will also be used in the control unit. As shown in Figure 4.5.5, the Atmega168 microcontroller is the centerpiece of the control unit. It interfaces with the encoder the microSD card, the LCD, the buttons, and the sensor, and the receiver.

118

Page 119: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Chapter 6Administrative content

6.1 Budgeting and Financing

The group members participating in the design of workout were under the assumption that all costs were to be divided up equally. The group wanted to limit the cost of the design to a grand total of $1,000.00. Workout buddy is considerably lower than the anticipated cost of the design, and a search for a sponsor was not needed. Further research into funding the project revealed that vocational rehabilitation and employment services would fully reimburse any costs needed for the design. This service was created to help veterans with service connected disabilities to prepare for, find, and keep a suitable job. VR&E pays one hundred percent tuition and expenses while the student is attending classes, also providing a living allowance. The purchasing process requires many steps due to the fact that it is going through veteran affairs. A material detail sheet will need to be created, and the document will need to be signed off by the head of the Electrical Engineering department, or a professor. Once approved, the material detail sheet will then be sent to the vocational rehabilitation counselor, and ordered from there. The program will pay for all necessary components needed to properly build the design. All testing equipment needed for test and development will be paid for as well. Although veterans affairs will cover the costs needed for the design, one of the goals of Workout buddy is to design it in a cost efficient manner. The total estimate for material is currently $289.88. The total estimated cost of the design including labor is $67,000.00. This figure was estimated assuming that each group member puts in twenty hours a week until the end of senior design two at an hourly rate of thirty dollars an hour.

Table 6.1 shows a list of the required material that will be or has already been purchased. The most expensive part of the design will be implementing the wireless communication between the two systems. The RF module alone costs almost one fifth of the design. The decision to implement a rechargeable battery supply stepped the price up another sixty dollars, but when compared to the alkaline batteries which were originally thought to be used for the power supply, it would save money in the long run. The original design cost was estimated at $167.33, but to make the device more efficient other devices were added.

119

Page 120: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

Material Detail Sheet        

Prototype Parts list Part No. Quan CPUTotal Cost

Breadboard G16567 1 $4.95 $4.95 Amplifier AD620AN 2 $3.64 $7.28 sEMG Sensor Starter Kit EMGSTRKIT 1 $37.00 $37.00 Low Cost, Single-Supply Differential Amplifier AD626AN 1 $7.46 $7.46 Crystal 16MHz COM-00536 1 $1.50 $1.50 Breakout Board for FT232RL USB to Serial BOB-00718 1 $14.95 $14.95 Triple Axis Accelerometer Breakout MMA7260Q 1 $19.95 $19.95 Color LCD 128x128 Nokia Knock-Off LCD-00569 1 $14.95 $14.95 AVR 28 Pin 20MHz 16K 6A/D - ATMega168 COM-07957 2 $4.11 $8.22 12VDC 55mAh Alkaline Battery GP23AE C6860 1 $1.49 $1.49 EMG leads TDE205 1 $25.00 $25.00 Instrumentation amplifier INA122p-nd 4 $5.56 $22.24 RF Receiver RXM-900-HP3 1 $44.98 $44.98 RF Transmitter TXM-900-HP3 1 $29.45 $29.45 Antenna ANT-916-SP 2 $2.08 $4.16

Lithium Ion 7.4V BatteryLC14430S2R1 1 $12.95 $12.95

Lithium Ion battery charger Bottom of Form CH-9VUNWM 1 $19.95 $19.95 3.7V Polymer Li-ion battery BT50 1 $18.95 $18.95 5V Linear Regulators LP2954 3 $2.68 $8.04 3.3V Linear regulators LP8345 3 $3.00 $9.00 MDFly MDSDM01 1 $9.95 $9.95 Breakout Board for FT232RL USB to Serial BOB-00718 1 $14.95 14.95

 Total Cost $337.37

Table 6.1: This table includes the material needed to finish a final prototype, as well as the cost associated with each item.

120

Page 121: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

The group wanted to design Workout buddy in a cost efficient manner. The group decided the best value for each device would more than fulfill the group’s goal. Due to the fact that similar items like Workout Buddy range from the $500 dollar range up to $1500, the group had to find a way to incorporate as cheap of an design as possible thus making it more feasible. All items to be and that are already purchased were consulted among the group members and were unanimously agreed upon that the device would be the best possible choice for the money. The reason everything must go through the group first is to avoid any unnecessary expenses, which will reduce the money wasted in the project.In order for the device to work, many things were taken into consideration. The device attached to the body must weigh less than one pound.

6.2 Project Milestone

Figure 6.2 is the project milestone showing the provisional timeline for certain tasks that need to be completed by a certain date. If the project milestone is accurate, the group should have the project done as early as June 15. The given date is the time the group has to work out all the predicted and unpredicted glitches in the design. The group originally got together for ideas before Christmas break during the fall 2008 semester, and research began shortly after.

Figure 6.2: Provisional Project Milestone

121

Page 122: Senior Design Group 8: Workout Buddy - UCF Department Web viewWorkout buddy was proposed ... senior design two being taken ... This problem was easily solved by using a low powered

Senior Design Group 8: Workout Buddy

This milestone is entirely provisional. The group originally met first in December to start discussing ideas for senior design. This idea was first mentioned by Scott Martin, and he proposed it in a way that made the design seem achievable. Shortly after, the group started the research phase in early January, where certain tasks were assigned to each group member. Before making a list of material needed to do testing, group members researched diligently in the area they were assigned. Any material ordered was discussed with the group members first, to cut costs of material that would not be needed. All parts needed for testing must be ordered by the beginning of February, to guarantee that it was the part needed for the design. By February 15, team members must have sufficient knowledge of their area of design. The next part was to test each individual device to make sure that the group was getting the results needed.

Due to a short summer semester, the group will need to start testing and resolve all glitches in the design by the beginning of the 2009 summer semester. During the two week break the group will have between the spring and summer semester the group will need to make sure all devices are working properly. This will involve connecting and powering all devices in the design, and making sure all material needed is ordered. Testing and troubleshooting all the devices will also be done during this break, this is important to have all material ordered and or delivered before the beginning of the summer semester. All of the components should be in working condition by the beginning of the summer semester, and any revisions or extra features added to the design will be ordered during this time period. Any replacements needed for the final prototype will be ordered during this stage as well.

Once the summer semester begins and the sensor circuit has been completed, Andrew Lee’s major task will be to interface the sensor circuit and the display module. At the same time the task of interfacing the accelerometer the microcontroller, programming the microcontroller, and setting up the user interface will be accomplished during this time period. While interfacing the accelerometer with the microcontroller, tests will be done in order to make sure the group is getting accurate and precise angles needed for counting repetitions. Using the electric potential generated by the muscle to come up with an intensity calculation will be done during this period, as well as making simulation software for the computer. This should all be completed, preferably by the end of May or early June. By June 15, the group should have successfully completed the design, and having a fully or partially working prototype. At this time, any extra features that were contemplated for the design will be discussed again. If any extra features are then decided on, they will be added to the design. The group should have the final design ready by June 21, and will be ready to prepare for the final presentation in July. Any revisions to the Senior Design I document will be completed during this time.

122