Demo date: Tuesday February 8, 2005
Table of Contents
Project description………………………………………. 2
User Interface……………………………………………. 5
Major Component Description……………..…………… 7
Testing Philosophy……………………………………… 12
Analytical and Testing Results………………………….. 15
Project Internals…………………………………………. 29
Memory Utilized………………………………………… 33
Required Tools………………………………………….. 34
Cost Summary…………………………………………… 31
Listing File………………………………………………. 36
Appendix A……………………………………………… Project Proposal
Appendix B……………………………………………… Graded Progress Reports
Appendix C……………………………………………… Technical Data Sheets
Appendix D……………………………………………… Engineering Notebooks
Our overall design project is a mobile electromagnetic bicycle trainer system.
The objective is to design a “bolt-on” system for a bicycle that allows a user to choose a
level of resistance to be applied against the rear wheel. This resistance makes the user
either work harder to maintain the same velocity or effectively slow the user down
through applying torque to the wheel. The user will need to apply a greater force on the
pedals to overcome the torque applied to the wheel. This will serve multiple purposes to
- When two cyclists of different skill levels are riding together, a user-specified
resistance on the more skilled cyclist‟s system can equalize their speed but
still provide both riders with a challenging workout.
- A cyclist who lives in a flat area can simulate hills by increasing the resistance
on the bike at specific points in time where a simulation of a hill is desired.
- For the winter season the resistance mechanism can be used as an indoor
trainer by propping the rear wheel on a tripod or roller system. The user will
specify the resistance desired and can change it just like on an exercise bike.
The Equalizer system also interfaces a heart rate monitor system that tracks the
user‟s current heart rate. This will help the user realize his/her level of exertion and will
either adjust the resistance or their effort appropriately.
The system can be used as a complete training tool, maximizing the effect of
training for cycling or general exercise. Along with individual training optimization, it
will also maximize the effect of team training. Weaker riders will now be able to train
with stronger ones. The team members can adjust their resistance according to their
riding ability such that all members can go the same speed and still provide maximum
training efforts. Along the same lines, this tool can also promote effective exercising
and training in a more social atmosphere.
Figure @: Full System Diagram
Figure @: Brake Component Picture
Figure @: LCD Screen Picture
Figure @: Heart Rate Sensor
The primary user interface includes an LCD screen with 4 rows of characters,
having 20 characters in each row. To the right of the LCD, three buttons will control the
system. Up and down buttons will allow the user to increment and decrement numbers,
as well as scroll through a list of stored users. The third button is both an enter button
and a shift button. Pressed and released, it acts as an enter button. When shift is pressed
and held, either the up button or down button can be pressed to shift between modes.
This is the main mode for the system during use. The resistance currently applied
to the brake is displayed, as well as the user‟s heart rate, seen in Figure @a. Pressing the
up or down button will increment or decrement the resistance level, respectively. Valid
values range from 0 to 9. Pressing and releasing the enter button will toggle the enable,
indicated by parenthesis around the resistance level when disabled, seen in Figure @b.
Finally, to switch to the User Mode, the user presses and holds enter, then presses up or
Resistance Level: 4
Heart Rate: 95 bpm
Figure @a: Active Mode, resistance enabled
Resistance Level: (4)
Heart Rate: 95 bpm
Figure @b: Active Mode, resistance disabled
This mode allows the user to select a stored user profile. After shifting into this
mode, the currently loaded profile is displayed. Pressing up or down scrolls through the
list of users entered, skipping empty slots. As the user scrolls, the name and resistance of
each stored profile are printed to the LCD, as in Figure @c. When the enter button is
pressed, the currently displayed user is selected and loaded. For any stored user profile,
this means returning to Active Mode with the new profile and the resistance disabled.
The only exception is when the “NEW” user is selected. In this case, the third and final
mode is entered, Edit Mode.
Select a User
Figure @c: User Mode
Upon entering edit mode, the user first selects a user name. Three characters are
available, so initials are easiest to use. The cursor flashes over the first character, while
the spaces for other characters are underscored, as in Figure @d. Pressing up or down
will scroll through the letters of the alphabet for that position. Once the desired character
is reached, pressing enter saves that character and moves to the next. The same process is
used to set all three characters, as well as the initial resistance value. When the resistance
is set, the new profile is saved and the mode is changed to User Mode, with the new
profile on the screen. A total of nine new profiles can be stored, at which point the NEW
user will no longer be available.
Initials & Resist
Figure @d: Edit Mode
Major Component Description
Four main components compose the entire system. The brake provides resistance, the
heart rate monitor collects heart rate data, the LCD / buttons interface with the user, and
the HCS12 manages all these peripherals.
To provide resistance to the user‟s movements, a small wheel is mounted on the
brake‟s axle, and it turns against the bicycle wheel. The brake is mounted to a steel
bracket to provide mounting surface. To that bracket a metal dowel is welded, which
runs forward to the seat stem and through a bushing. These components basically
provide a hinged lever for the brake to ride on, and rest against the wheel, as in Figures
@ and @.
U - Bolt
Figure @: Brake Assembly Side View, Without
Figure @: Brake Assembly Rear View
Once this step in construction is complete, the brake rests against the rear wheel
of the bike but is not tensioned against it. In order to achieve this force, a length of
threaded rod runs through two short pipes, one welded to the main rod, and the other
bolted on a bracket to the rear fork. When the wing nuts on either both ends of this rod
are tightened together, the brake tightens up against the rear tire. If the user needed to
eliminate even the nominal torque of the brake, a nut under the brake can be raised,
lifting the brake wheel from the bike wheel.
The layout of the brake can be seen in Figures @ and @. In Figure @, the brake
is opposite the wheel from the perspective of the reader.
Figure @: Dimensions of the Hysteresis Brake
Heart Rate Monitor
The heart rate monitor pcb receives signals from the hand grips, and processes
those signals to determine heart rate information, and whether the heart rate is valid. The
monitor requires that both handgrips are in contact with the user‟s hands before heart rate
signals are processed. As the heart rate board generates this information, it sends it out
asynchronously over a UART connection to the HCS12. Though some control packets
are sent out, they are ignored by the HCS12, as it is interested only in the heart rate. Each
UART packet is made up of one start bit, 8 data bits, and one stop bit. Figure @
illustrates the format of these packets. In the final hardware layout, the
Figure @: The layout of a UART packet
Figure @: Heart Rate Monitor Wiring Diagram
LCD / Buttons
To allow user interface to the system, the LCD and buttons described above were
implemented. Many LCD displays are on the market, but a relatively small number of
drivers are produced to control them. There are standards for pin layout and command
syntax to send to the LCD, so multiple LCD models can be swappable for the application.
In order to interface with one common controller, the commands listed in Figure @ were
The buttons used did not have de-bouncing built in, so a circuit was devised to
handle that separately. After pre-charging each timer interrupt on the HCS12 to 5 volts,
each button was able to ground it‟s respective port to produce a high-to-low transition
visible by the HCS12. Pre-charging was achieved by charging a capacitor through a
resistor, each connected to the port. This layout is visible in Figure @.
Figure @: LCD Command Syntax
Figure @: Button Schematic
To ensure our system functioned as designed, we applied various tests while the
product was being conceptualized and developed. Once an overall component was
finished with a phase of development we tested it individually and then with the other
component it was to be interfaced with. The components that underwent testing were the
brake, HCS12 code, LCD module, push buttons, heart rate sensors, heart rate monitor
board, and current sourcing circuit.
LCD Module (Okaya RC2004-A)
Our first priority in testing was the LCD module, as this could be used as a
primary debugging tool once up and running. The first phase of LCD tests included the
use a switchboard and power supply to write characters and load ranges of memory
addresses with characters. The power supply was adjusted to the appropriate voltages for
power, and contrast voltage. See the diagram below for an example of our test circuit to
find the contrast voltage. Once all functionality of the LCD module and controller was
completely understood and voltages were satisfactory simple code was developed on the
HCS12 to write characters to the LCD module at various memory addresses.
Figure @: LCD Contrast Voltage Circuit
Push Buttons (GC Electronics)
Testing strategies for the push buttons included testing reaction time and for
bouncing issues. This was done with an oscilloscope. Once this was taken care of we
calculated how long of a rising and falling edge we wanted and applied an appropriately
sized capacitor to the active side of the switch.
Next the buttons were tested with the HCS12. Strictly from the button‟s
standpoint the tests included verifying the button triggered interrupts. Once these tests
were done, the rest of the functionality of the buttons was driven by the HCS12.
Heart Rate Monitor (Salutron)
The first testing strategy used for the heart rate sensors was to hold the contact
grips with our hands and check for our pulse on the oscilloscope. Since the noise
tolerance was about .5 mV, this was one item that received great attention.
Next, the heart rate sensors were tested with the Salutron heart rate monitor board
to check for signs of a strong enough signal for the board to read. Once the board outputs
a UART signal, the UART byte is checked to determine an appropriate value in the range
of 32 to 200 (only valid range on HR board).
Finally the heart rate board is interfaced with the HCS12 to ensure that the UART
can be read and output to the LCD screen. This proved to be more difficult than
MOSFET Current Source Circuit
Before the brake could be tested, there had to be a component between the PWM
output signal from the HCS12 to the current sourced into the brake. At first, a simple
BJT current source was implemented. Changing the resistor values going into the base
and between ground and the emitter depicted the transistor‟s gain. The current should be
maxed out at 360 mA so a transistor that can source this needed to be used in our tests.
Therefore a MOSFET was also tested along with a diode across the brake. A resistor was
used in place of the brake for earlier tests to avoid ruining the brake with high currents.
To avoid burning up the small resistors (28 ohm brake), 3 or 4 resistors were used in
parallel. A potentiometer was used to calibrate the correct resistor value for the
transistors. PWM values from the function generator were applied to the base and gate
respectively to simulate the PWM output from the HCS12 board.
28 Ohm Battery
PWM Buffer 1 kOhm
Figure @: Current Source Circuit Test Circuit
Hysteresis Brake (Placid Industries)
After the current sourcing circuit had the appropriate range of current, the brake
was applied in the above test circuit in place of the resistor. The brake was tested by
hand to check that the resistance changed as the current increased and decreased. Once
the brake could be mounted on the bike, it was tested with a transistor only circuit and
then with the microcontroller driving the voltage across the brake by way of the PWM
output. The resistance was then noticed through the applied torque to the wheel, which
Microcontroller (Motorola HCS12)
The HCS12 had numerous tests for various functions that were used in the
project. Tests were done to verify functionality of the PWM ports, timer ports, Port A,
Port B, SCI port, and power. After testing these individual ports the rest of the testing
was done interfacing the HCS12 with other components. Testing was mostly done with
an oscilloscope to verify that the correct signal was output from the microcontroller.
Analytical and Testing Results
This section will describe each analytical element of the project and the testing
results per component. If multiple tests were applied for a given part of the project they
will be listed as separate tests.
LCD Module Description and Test Results
There were two LCD modules used in our project. The original one was burnt out
due to a misconnection issue. This LCD module received most of the testing, so it will
be described in more length than the second one. LCD number one was an Okaya
RC2004-A. This module has a 20 character by 4 line display. The LCD controller
driving the screen is a Samsung KS0066U. The current LCD screen used is an Optrex
DMC20481NYU. This uses a Hitachi HD44780 LCD controller. Both of these modules
and controllers were equivalent except for 1.5 mm difference in width and the contrast
voltage settings differed by approximately 1.3 V.
The Samsung LCD controller is a dot matrix LCD driver and controller LSI that is
fabricated by low power CMOS technology. The internal driver contains a 16 common
and 40 segment signal output. The block diagram for the controller is below:
Figure @: Samsung KS0066U Block Diagram
Testing the LCD module started out primitive using a switchboard to send basic
commands to the LCD. When powered up initially the display revealed a series of dark
squares on the first and third lines of the display. The contrast voltage (potentiometer)
was adjusted until the squares were just barely visible. This voltage for the Okaya board
was found to be .3 V, so it was decided to simply tie the Vo pin to ground. Testing with
the Optrex board concluded in a 1.6 V contrast voltage, so a voltage divider circuit was
implemented to achieve this voltage from the 5V rail associated with the Vcc of the LCD.
The Display On/Off and Cursor commands were tested next. The data switches (S1
through S8) are set to 00001111 ($0F) and the RS switch (S10) is logic 0 so that the
device is in Command mode. Next the Enable switch (S9) is toggled from low to high to
low. A flashing cursor comes up on the screen. Various memory addresses were loaded
and the cursor moved there appropriately. It was found very frequently with the Okaya
board that the second and third column of memory addresses made the entire screen lose
contrast. The only resolution found was to not write to addresses in these columns.
Next a test is run to write characters to a variety of spots on the LCD screen. The
RS switch is moved to high, thereby switching the chip from Command mode to
Character mode. Binary value 01000001 ($41) is entered on the data switches and each
time the enable switch is triggered the letter „A‟ is output onto the LCD screen. Various
similar tests were run verifying that all addresses and ranges of values for characters
could be entered.
Screen addresses $00 - $27 & $40 - $67
RAM English character values $21 („!‟) to $7F („‟)
Figure @: Test Ranges for LCD Module
The next test is to connect the HCS12 to the LCD module and program it to run
the same tests as before. The interface between the HCS12 and the LCD module is
Figure @: Interface Between HCS12 and LCD Module
In order to run meaningful code on the LCD controller a setup process must be
run. The general flow of the initialization follows the flowchart below:
Figure @: Initialization Code Flow
After the initialization of the LCD module, there is a set of functions that can be
used to control the LCD screen. The functions are as follows:
1) Clear Display
Clear all the display data by writing “20H” (space code) to all DDRAM address,
and set DDRAM address to “00H” into AC (address counter).
Return cursor to the original status, namely, bring the cursor to the left edge on
the first line of the display.
Make the entry mode increment (I/D = “High”).
2) Return Home
* “- “: don‟t care
Return Home is cursor return home instruction.
Set DDRAM address to “00H” into the address counter.
Return cursor to its original site and return display to its original status, if shifted.
Contents of DDRAM does not change.
3) Entry Mode Set
Set the moving direction of cursor and display.
I/D: Increment / decrement of DDRAM address (cursor or blink)
When I/D = “High”, cursor/blink moves to right and DDRAM address is
increased by 1.
When I/D = “Low”, cursor/blink moves to left and DDRAM address is decreased
* CGRAM operates the same way as DDRAM, when reading from or writing to
SH: Shift of entire display
When DDRAM read (CGRAM read/write) operation or SH = “Low”, shifting of
entire display is not performed.
If SH = “High” and DDRAM write operation, shift of entire display is performed
according to I/D value
(I/D = “High”: shift left, I/D = “Low”: shift right).
4) Display ON/OFF Control
Control display/cursor/blink ON/OFF 1 bit register.
D: Display ON/OFF control bit
When D = “High”, entire display is turned on.
When D = “Low”, display is turned off, but display data remains in DDRAM.
C: Cursor ON/OFF control bit
When C = “High”, cursor is turned on.
When C = “Low”, cursor is disappeared in current display, but I/D register
preserves its data.
B: Cursor Blink ON/OFF control bit
When B = “High”, cursor blink is on, which performs alternately between all the
“High” data and
display characters at the cursor position.
When B = “Low”, blink is off.
5) Cursor or Display Shift
Shifting of right/left cursor position or display without writing or reading of
This instruction is used to correct or search display data.
During 2-line mode display, cursor moves to the 2nd line after the 40th digit of
the 1st line.
Note that display shift is performed simultaneously in all the lines.
When displayed data is shifted repeatedly, each line is shifted individually.
When display shift is performed, the contents of the address counter are not
6) Function Set
DL: Interface data length control bit
When DL = “High”, it means 8-bit bus mode with MPU.
When DL = “Low”, it means 4-bit bus mode with MPU. Hence, DL is a signal to
select 8-bit or 4-bit bus mode.
When 4-bit bus mode, it needs to transfer 4-bit data twice.
N: Display line number control bit
When N = “Low”, 1-line display mode is set.
When N = “High”, 2-line display mode is set.
F: Display font type control bit
When F = “Low”, 5 ´8 dots format display mode is set.
When F = “High”, 5 ´11 dots format display mode.
S/C R/L Operation
0 0 Shift cursor to the left, AC is decreased by 1
0 1 Shift cursor to the right, AC is increased by 1
1 0 Shift all the display to the left, cursor moves according to the display
1 1 Shift all the display to the right, cursor moves according to the display
7) Set CGRAM Address
Set CGRAM address to AC.
This instruction makes CGRAM data available from MPU.
8) Set DDRAM Address
Set DDRAM address to AC.
This instruction makes DDRAM data available from MPU.
When 1-line display mode (N = Low), DDRAM address is from “00H” to “4FH”.
In 2-line display mode (N = High), DDRAM address in the 1st line is from “00H”
to “27H”, and DDRAM address
in the 2nd line is from “40H” to “67H”.
9) Read Busy Flag & Address
This instruction shows whether KS0066U is in internal operation or not.
If the resultant BF is “High”, internal operation is in progress and should wait
until BF is to be Low, which by then
the next instruction can be performed. In this instruction you can also read the
value of the address counter.
10) Write data to RAM
Write binary 8-bit data to DDRAM/CGRAM.
The selection of RAM from DDRAM, and CGRAM, is set by the previous
address set instruction (DRAM address
set, CGRAM address set).
RAM set instruction can also determine the AC direction to RAM.
After write operation, the address is automatically increased/decreased by 1,
according to the entry mode.
11) Read data from RAM
Read binary 8-bit data from DDRAM/CGRAM.
The selection of RAM is set by the previous address set instruction. If the address
set instruction of RAM is not performed before this instruction, the data that has
been read first is invalid, as the direction of AC is not yet determined. If RAM
data is read several times without RAM address instructions set before read
operation, the correct RAM data can be obtained from the second. But the first
data would be incorrect, as there is no time margin to transfer RAM data.
In case of DDRAM read operation, cursor shift instruction plays the same role as
DDRAM address set instruction, it also transfers RAM data to output data
register. After read operation, address counter is automatically
increased/decreased by 1 according to the entry mode. After CGRAM read
operation, display shift may not be executed correctly.
The code flow for writing to the LCD screen is as follows:
Figure @: LCD_Write Subroutine Flow
Figure @: LCD_Addr Subroutine Flow
Figure @: Writing to LCD Test Code Flow
After testing the ability to write to the LCD screen with the HCS12, the LCD
screen testing is complete.
Heart Rate Sensor Description and Test Results
The Model 2000 Handgrip Heart Rate Monitor is a system developed for exercise
equipment, such as bikes, steppers, elliptical cross trainers, and treadmills. An
electrocardiogram, or ECG, is a measure of the electrical activity of the heart. Salutron‟s
heart rate monitor can quickly and accurately measure the heart rate from an ECG signal
under noisy environments. The Model 2000 simultaneously processes Handgrip Heart
Rate and Wireless Heart Rate receiver pulses. Either can be specified as the priority heart
rate. Two forms of outputs are available at the same time: Serial and regular pulse
outputs. Regular pulse output has several formats. Serial output appears at the SPI Port,
and at the UART port.
Below is the schematic for the heart rate sensor:
Figure @: Wiring Diagram for Salutron HR Board
In testing for noise on the heart rate sensors, a frequency of about 50mV peak to
peak was found. This hid the waveform of our EKG pulse, so changes needed to be
made in order to rid the signal of noise. Thus shielded cabling was used in the design and
connectors that hid the connecting pins also helped get rid of the majority of the noise.
Testing the heart rate monitor board, it was found that a buffer needed to be used
between the UART output signal and the HCS12 SCI port. The buffer used was the only
one available at the time, a 74LS08 AND chip with both inputs tied to the UART. This
provided sufficient time for the SCI port to sync with the UART at the same baud rate.
Testing was also done to find a baud rate of 1200 bps for the UART. The UART was
tested with an oscilloscope first to ensure proper bytes were received.
Figure @: Example UART Waveform
Magnetic Hysteresis Brake Description and Test Results
Torque range . . . . . . . . . . . . . . . . . . . . 3 to 85
Maximum RPM . . . . . . . . . . . . . . . . . . 6000
Max. heat dissipation with cover . . . . . 35
Max. heat dissipation, no cover . . . . . . 60
Maximum case temperature . . . . . . . . .180
Maximum overhung load . . . . . . . . . . . 40
Shaft inertia . . . . . . . . . . . . . . . . . . . . . 56 x 10-5
Response (unforced) . . . . . . . . . . . . . . . 40
Weight . . . . . . . . . . . . . . . . . . . . . . . . . 4.5
TORQUE: At 100% input current, output torque will be 85 oz.-in.
POWER SUPPLY: A "constant-current" D.C. power supply is
recommended for the best accuracy in open-loop control systems.
This type of power supply will maintain a fixed (but adjustable)
output current, regardless of the temperature of the brake, so
output torque is constant (but adjustable).
HEAT DISSIPATION: The brake can dissipate 35 slip (thermal)
watts continuously. (60 slip watts without the cover). For
continuous slip, calculate the heat input by the formula :
HEAT (watts) = RPM x TORQUE (oz.-in.) / 1356
Using the above formula: At rated torque, the maximum
continuous slip RPM is 558 (957 without the cover). The brake
can dissipate higher amounts of heat for short periods of time, but
the average must not exceed 35 watts (60 watts without the
cover). The case temperature must never exceed 180 degrees F.
In order to test the brake, a powerful current source circuit needed to be
implemented to provide enough current to drive the brake up to its rated current of 360
mA. Although the current source circuit didn‟t get up to exactly 360 mA it covered
approximately 93.5% of the rated current for the H85 brake. Below is a table describing
our different resistances as tested:
Resistance Level Torque (At Torque (At Current
0 Nominal (Drag Nominal (Drag 0 mA
1 1.82 oz-in 9.44 oz-in 37.4 mA
2 3.63 oz-in 18.89 oz-in 74.6 mA
3 5.45 oz-in 28.33 oz-in 112.2 mA
4 7.26 oz-in 37.78 oz-in 149.6 mA
5 9.08 oz-in 47.22 oz-in 187 mA
6 10.8 oz-in 56.67 oz-in 224.4 mA
7 12.71 oz-in 66.11 oz-in 261.8 mA
8 14.53 oz-in 75.56 oz-in 299.2 mA
9 16.34 oz-in 85 oz-in 336.6 mA
Figure @: Resistance and current output to brake
Figure @: H85 Brake Specifications
Since the HCS12 waits for input from the buttons or the heart rate monitor, the
system is designed to handle interrupts quickly (the button inputs) and set flags to alert
the main loop of the changes. The flags are handled at the beginning of the flow chart,
visible in Figure @.
Check read flags
UART? Yes Handle UART
Enable? Yes Toggle Enable
Up Pressed? Yes Handle Up
Yes Handle Down
Figure @: Main Program Loop
Each particular handler is described in greater detail below. The only process
neglected is the assignment of flag values by the interrupt registers, as this is fairly trivial.
The UART port on the HCS12 automatically looks for a start bit indicating the
start of the packet. Based on baud rate timing set in initialization, the HCS12 polls the
port to get each data bit of the packet. Once the packet is retrieved, it is processed. Any
packet with a data value less than 32 is actually a status byte, not a true heart rate, so it is
ignored by the system. When a new data value is received, if it is valid and the system is
in user mode, it is printed to the LCD.
No Enter? Yes Toggle Enable
Up / Down?
No Shifted? Yes User Mode
Figure @: Input Handling in Active Mode
Since the enter button causes functionality when it is released, and it must be held
to shift into user mode, caution must be taken. The system switches to user mode when
the enter button is held and up or down are pressed. As a result, the user enters user
mode with the enter button held down. When it is released, it could cause an undesired
interrupt, loading whatever name is currently on the screen. To avoid this, the first
interrupt from the enter button that the system sees after entering user mode is ignored.
Wait for Input
No Up / Down? Yes
Enter Edit Mode Yes New User? No
Enter User Mode
Figure @: Input Handling in User Mode
In edit mode, the user creates a new user profile. Three characters are selected, as well as
an initial resistance. Once this is done, the user is returned to the User Mode.
Wait for Input
Last Save and Go to
Wait for Input
Store New Profile /
Go To User Mode
Figure @: Input Handling in Edit Mode
$2002->$2014 RAM variables
$2015->$203D NAMES array
$0400->$09C8 code space
$09C9->$09F6 Strings for LCD
$09F7->$0A01 The PWM output table
$0A02->$0A19 Strings for new users
The NAMES array stores new user profiles set by the user. It starts with only the “NEW”
user, with room for 9 more profiles. When the ninth is set, the “NEW” user is removed.
Each added user contributes three characters that constitute a name, in addition to a
stored resistance value. This value could easily be expanded in future applications.
The strings for the LCD are terminated by a zero, and referenced statically in the code.
The format is standard for the print function, so any strings printed to the LCD must also
be set in the same format. The strings are primarily prompts to the user, in addition to the
resistance strings, which are used to set and remove the parenthesis that indicate whether
the resistance is disabled or enabled.
Each PWM output is a decimal value because the PWM timer was set so that the decimal
value sent to the PWM would be a percentage of 100% duty cycle. The values are
incremented linearly so that the user has maximum control over what output resistances
This project required a few tools in order to assemble and code. Much of the
hardware was assembled ourselves, especially the mounted bracket for the brake. Home
Depot helped us out in finding the appropriate tools and materials to be able to mount a 4
lb brake properly over a wheel. We needed to weld, cut and bend steel such that it would
fit our specifications. Thus we needed to use a large MIG welder for welding the tubes
and rods to the sheet metal. Also power cutting tools were needed to cut the sheet metal
and steel rods. A die grinder, cutting wheel and vice grip were used for most of the
mechanical aspects of the project. To connect wires and small components solder and
heat shrink tubing was used to secure connections. A soldering iron was our primary tool
used for heating solder and a heat gun was used to heat shrink tubing. A dremel tool was
use to cut the project boxes to our specifications.
For software building and coding MiniIDE was the primary tool used. This was
done to download all code to the HCS12 board. Screwdrivers and wrenches were used to
fasten all PC boards and nuts to the boxes and to the bike itself.
Component Product Quantit Item Cost Total cost to
Brake Magtrol HB-8-3 1 $174.95 $174.95
Push Buttons GC Electronics 3 $3.78 $11.34
LCD Display Okaya RC2004LRSASOK 1 $25.80 $0 (Donated)
Battery w/ Dantona 10 $3.50 $35.00
solder tabs DANAA1800MMHWT
50 pin Philmore 70-4250 2 $1.78 $3.56
Device LORD RD-3002-03 1 $170.00 $170.00
Microcontrolle Technological Arts 1 $133.00 $0
r with Adapt9S12E256 with
Evaluation Motorola MC9S12DP256D
Heart Rate Salutron 1 $25.95 $25.95
Total $579.60 $420.80
Switch bouncing was one issue that we ran into early. This provided us with an
obstacle due to over sampling of Timer input ports. This resulted in both duplicate and
erroneous inputs. Our first approach to resolution was debouncing with a resistor –
capacitor pair. This proved sufficient temporarily however it charged so slow that it
remained in a border state for longer than expected, resulting changing of „0‟ to „1‟ states
more than once per button push. This caused timer interrupts to fire multiple times in one
push of the switch. The values for the resistor-capacitor pairs were changed to
compensate for this error. Some accommodations were also made in the interrupt
Timing issues also arose with the UART timer. The baud rate was set properly for
RAM, however it failed in EEPROM mode due to changes in MCU clock rate for such a
Our current source design was developed with a BJT transistor current source
circuit originally. This did not provide sufficient current gain without drastic changes in
the functional characteristics of the Power BJT. Therefore we used a Power MOSFET
transistor circuit to solve our gain issue.