Presentation is loading. Please wait.

Presentation is loading. Please wait.

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project.

Similar presentations


Presentation on theme: "Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project."— Presentation transcript:

1 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project Hints Lecture 31

2 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 2Winter Quarter General Description Your software must detect each of five (5) possible frequencies of transmitted IR light Frequency detected must be displayed on Handy Board LCD screen Frequencies will in the range of 20 to 150 Hz No frequency will be closer than 15 Hz to any other possible frequency Transmitted frequency will change automatically and randomly to one of the other possible frequencies

3 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 3Winter Quarter IR Transmission and Reception Program should continuously detect frequency of the transmitting beacon Handy Board screen should display received frequency in Hertz as an "integer" value Only one of the specified frequencies (or 0) should be displayed IR Receiver IR Transmitter 6 to 12 inches

4 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 4Winter Quarter The IR Beacon Signal IR Beacon Signal "Digitized" copy of signal X X 0 1 Time tt X X

5 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 5Winter Quarter A Possible Approach Take a number of measurements of the received signal at regular intervals Determine how long it took to take all of those measurements & calculate time between samples Find the each of the "up" transitions Calculate an "average" period Calculate an "average" frequency Display appropriate frequency Repeat

6 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 6Winter Quarter Simple Loop in "main" while (!stop_button( )) { get_IR_data ( ); find_transitions ( ); calculate_period ( ); calculate_raw_frequency ( ); calculate_adjusted_frequency ( ); printf ("Frequency = %d\n", adj_freq); }

7 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 7Winter Quarter Find All "up" Transitions in IR Data Array void find_transitions ( ) { int i; n_trans = 0; for (i = 1; i < D_SIZE; i++) { if (IR_data[i-1]==0 && IR_data[i]==1) { transitions[n_trans] = i; n_trans++; } } }

8 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 8Winter Quarter Calculate the "Average" Period void calculate_period ( ) { int i; float sum = 0.0; if (n_trans > 1) { for (i = 0; i < n_trans - 1; i++) {sum = sum + (float)(transitions[i+1] - transitions[i]) * delta_t; } period = sum / (float) (n_trans-1); } else period = 0.0; }

9 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 9Winter Quarter The "Noisy" IR Beacon Signal IR Beacon Signal "Digitized" copy of signal X X X X X 0 1 Time X X X X X X X X

10 Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 10Winter Quarter A Possible "Noisy" Approach Take a number of measurements of the received signal at regular intervals Determine how long it took to take all of those measurements & calculate time between samples Find the each of the "up" transitions Calculate an "average" period –Ignore periods substantially shorter than average & calculate new "average" period Calculate an "average" frequency Display appropriate frequency Repeat


Download ppt "Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project."

Similar presentations


Ads by Google