190 likes | 477 Views
Software Design Project. Lecture 29. ENG H192 Software Design Project. Problem: Detect frequency of IR transmitter Two-person teams will -- Design Code Test Document Teams will be provided -- Handy Board Sharp GP1U5 IR receiver Access to IR transmitter beacon. The Handy Board.
E N D
Software Design Project Lecture 29 Winter Quarter
ENG H192 Software Design Project • Problem: Detect frequency of IR transmitter • Two-person teams will -- • Design • Code • Test • Document • Teams will be provided -- • Handy Board • Sharp GP1U5 IR receiver • Access to IR transmitter beacon Winter Quarter
The Handy Board Winter Quarter
The Sharp GP1U5 IR Receiver Winter 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 20 Hz to any other possible frequency • Transmitted frequency will change automatically and randomly to one of the other possible frequencies Winter Quarter
6 to 12 inches IR Receiver IR Transmitter 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 Winter Quarter
The IR Beacon Signal IR Beacon Signal 1 X X X X X X X X 0 X X X X X X X X X X X X "Digitized" copy of signal Time Winter Quarter
A Possible Approach • Take a number of measurements of the received signal at regular intervals • Determine how long it took to take those measurements • Analyze set of measurements • Display appropriate frequency • Repeat Winter Quarter
Useful Handy Board Functions • digital (p) -- Returns the value of the sensor connected to digital port "p" as a true/false value. • The parameter "p" should be in the range of 7 through 15, matching port to which receiver is connected • Note that "true" = zero volts, which is sometimes called "active low" • start_button ( ) -- Returns the value of the start button. "True" when button is pressed. Winter Quarter
Useful Handy Board Functions • stop_button ( ) -- Returns the value of the stop button. "True" when button is pressed. • mseconds ( ) -- Returns a long integer value representing the system time in milliseconds. • Like the seconds ( ) function, but data type of returned value is long & units are milliseconds • reset_system_time ( ) -- Resets the count of system time to zero milliseconds. Winter Quarter
Interactive C • Remember, there are things that are different in IC (compared to ANSI C): • No function prototypes • Limited formats possible in printf • Array bounds checked at run time • No #include statements • Smaller set of allowable data types -- only int, long, float, char, and struct (v3.2 only) • Character strings are supported, but simple char variables are not Winter Quarter
Interactive C • More things that are different in IC (compared to ANSI C): • No switch/case construct • Can only do +, -, and * on long int • All source files must be compiled together • #define has global scope • User functions come first in source file • No do/while construct • No mixed mode arithmetic Winter Quarter
Design Project "Deliverables" • List of brainstorming ideas • Neatly written algorithm and/or flow chart of user-written functions • Documentation package which includes: • A description of the program for use by developers, complete with a list of variable names and uses • A description of the program for use by a general user with an abstracted discussion of the program. Winter Quarter
Receiving in a "Noisy" World • Real world communications are affected or "degraded" by noise, for example: • Normal conversations in a busy public place • Cell phones in fringe reception areas ("Can you hear me now?"™) • AM radio stations during thunderstorms • Often measured as a "signal-to-noise" ratio which is usually called SNR • Almost all forms of communication are range dependent -- longer range => lower SNR Winter Quarter
Receiving in a "Noisy" World • The IR transmitter and receiver system we are using is "range dependent" • How does light intensity vary as a function of distance? • IR receiver "drops out" if transmitted signal is too weak • What does "drops out" mean? • Can we improve our ability to "see"? Winter Quarter
The "Noisy" IR Beacon Signal IR Beacon Signal 1 X X X X X X X X X X X 0 X X X X X X X X X X X X X X "Digitized" copy of signal Time Winter Quarter
A Possible "Noisy" Approach • Take a number of measurements of the received signal at regular intervals • Determine how long it took to take those measurements • Analyze set of measurements and ignore periods that are shorter than average • Compare results of several sets (Steps 1 - 3) • Display appropriate frequency • Repeat from beginning Winter Quarter
Possible Programming Pitfalls • Failing to use global variables, particularly for medium or large arrays • Scarcity of comments in code (comments don’t take any memory space) • Improper use of Handy Board functions • Not using modular approach to designing code • Too much floating point arithmetic • Too much code – exceed memory of Handy Board Winter Quarter