BME 4900 Page 1 of 2 Semester One Week Two These past two saw a lot of progress with the Revo stationary bike project. During Thanksgiving break Shane spent most of his time doing research for the power generation and control system of the bike. Through e-mail with electrical component suppliers and TA s James and Eric Shane received a better knowledge base of how to control the voltage and limit the current to the components. Using resistors, voltage regulators, and fuses the electrical map has been safety designed and gives a visual of the overall project. The diagram of the electrical map below was created using Microsoft Visio. A brief summary of the system is the generator, due to gear ratios currently in place, spins 24X faster than the pedals the user is forcing around. Using an estimate of 50 RPM for the user thus causes the generator to rotate at 1080 RPM. Using the manual from the generator 1080 RPM generates ~6 Volts. Because the system has a 12V battery more voltage is required. The team needs to either redesign the gear system or to add a transformer. The values of the voltage regulators were also determined going to eat unit as well as the fuses. It was also decided that because the Philips LCD DVD player is only charged using AC unless using a car cigarette outlet adapter, the adapter needs to be purchased. Majority of Shane s portion
BME 4900 Page 2 of 2 of the final report was also written over the Thanksgiving break. This was so when he came back on Saturday he spent a lot of time in the SD lab working on the electrical system. By the end of Tuesday, with a lot of help from Eric, Shane was able to complete the 400 m mini-track multisim. Also with the help of Eric, Shane was able to produce a C code for the microcontroller used in the 400 m mini-track. The multisim file can be found below. However when the file was attempted to be converted to ultiboard, nearly all of the components were considered virtual and were not transferred. This is an issue that will be addressed in the very near future. The C code produced can be found at the end of this report. Future work for Shane includes fixing the ultiboard issue as well as actually determining the correct parts needed to build the electrical system and ordering them. Other parts that are a priority to order are the stock steel for reinforcing the frame. Basically the teams goal is to have all parts ordered by the beginning of break. Some of these parts include all the electrical components mentioned before, the wheel attachment for the generator, LEDs, stock steel, wires and fasteners, voltage regulators, fuses, crystal oscillator, and the PIC 18F877 microcontroller. Continuous updating of the budget, timeline, and parts is an always ongoing process.
BME 4900 Page 3 of 2 C CODE: #include <stdlib.h> //standard include files #include <pic.h> #include <htc.h> CONFIG(DUNPROT & PWRTDIS & XT & WDTDIS & BORDIS & LVPDIS); #ifndef _XTAL_FREQ // Unless already defined assume 4MHz system frequency // Used to calibrate delay_us() and delay_ms() #define _XTAL_FREQ 7372800 #endif #define pulse RB0 //Sets ENTER_BUTTON to the value of pin RB0 int ChangeState, counter; //;;;;;;; LoopTime subroutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; //; //; This subroutine waits for Timer2 to complete its ten millisecond count //; sequence. void LoopTime(void) for (;;) if ( TMR2IF ) // Check whether ten milliseconds are up TMR2IF=0; // Clear flag //;;;;;;; Initial subroutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; //; //; This subroutine performs all initializations of variables and registers. //; It is important to refer to the PIC datasheet to understand what is happening. void Initial(void) TRISA = 0b00001011; matter TRISB = 0b00000001; and RB1, RB2, TRISC = 0b00000000; TRISD = 0b00000000; TRISE = 0b00000100; matter PR2 = 95; PORTD = 0; // Set I/O for PORTA - doesnt // Set I/O for PORTB - RB0 must be input //RN4, RB5 must be output // Set I/O for PORTC - all output // Set I/O for PORTD - all output // Set I/O for PORTE - doesnt // Set up Timer2 for a looptime of 10 ms // Turn off LEDs
BME 4900 Page 4 of 2 PORTC = 0; T2CON = 0b01011111; // Finish set up of Timer2 counter = 0; // set count to 0 ChangeState = 0; // set inital flag to 0 OPTION = 0b00000100;// Timer 0 prescale set 32:1 INTCON = 0b10000000; // Enable interrupts //;;;;;;; Mainline program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; void distance_finder() //finds distance by counting if(!pulse) ChangeState = 1; sensor magnet is still on sensor if(changestate == 1) ChangeState = 0; revolution (magnet pass) //ChangeState remembers if magnet is on //Returns to program if //Resets the ChangeState for next if(counter == 1114) //NOTE magnet has radius 57.15 mm, thus circumference is //.359084 meters. 400/..359084 = 1,114 revolutions //If the final state, max xount, is currently in use the counter //is reset to 0 counter = 0; else counter = counter++; // increment count by 1
BME 4900 Page 5 of 2 void LightLED() //This function lights the LEDs depending on what //the value of the count is. if(counter<53) //It checks the value against a series of IF statements //chooses the appropriate level and sets the correct PORTD = 0b00000000; //number of pins high, turning them on // NOTE 1114/21 = 53 counts per LED // 21 options for LEd because all off is an option as // turning each one on one by one else if(counter<53*2) PORTD = 0b00000001; else if(counter<53*3) PORTD = 0b00000011; else if(counter<53*4) PORTD = 0b00000111;
BME 4900 Page 6 of 2 else if(counter<53*5) PORTD = 0b00001111; else if(counter<53*6) PORTD = 0b00011111; else if(counter<53*7) PORTD = 0b00111111; else if (counter<53*8) PORTD = 0b01111111; else if (counter <53*9) else if (counter <53*10) PORTC = 0b00000001; else if (counter <53*11) PORTC = 0b00000011;
BME 4900 Page 7 of 2 else if (counter <53*12) PORTC = 0b00000111; else if (counter <53*13) PORTC = 0b00001111; else if (counter <53*14) PORTC = 0b00011111; else if (counter <53*15) PORTC = 0b00111111; else if (counter <53*16) PORTC = 0b01111111; else if (counter <53*17) PORTC = 0b11111111; else if (counter <53*18) PORTC = 0b11111111; RB1=1; else if (counter <53*19)
BME 4900 Page 8 of 2 PORTC = 0b11111111; RB1=1; RB2=1; else if (counter <53*20) PORTC = 0b11111111; RB1=1; RB2=1; RB4=1; int main(void) //This is the main body of the program //All functions of the program start here and are called //either by the endless FOR loop or a subsidiary. Initial(); //This function initializes necessary registers for(;;) distance_finder(); LightLED();