Need Help with code for a Doppler Effect for Sound demo project
enjelika
Posts: 7
I am currently working on creating a demonstration for the Doppler Effect for Sound for an Intro to ENGR class:For this apparatus, there is an IR remote control that can turn the power on/off in which a rotational motor and the affixed speakers will turn on/off. Also, this IR remote control can cycle through a total of three preset frequencies: 500 MHz, 650 MHz, and 800 MHz.
I have tried my best to find information (via web searches) on how the coding will be for programming frequencies into the microprocessor to no avail. Also, I will need help on how to set up the program for the IR remote control element.
Please, can anyone help?
I have tried my best to find information (via web searches) on how the coding will be for programming frequencies into the microprocessor to no avail. Also, I will need help on how to set up the program for the IR remote control element.
Please, can anyone help?
Comments
There's a good reference for IR remote control programming. See "IR Remote for the BoeBot Robot" here.
As mentioned in this tutorial, you need a remote control that uses Sony's remote control protocol. Most universal remotes can be set to use this. You'll also need a few parts shown in the tutorial. Most of these can be found at a RadioShack store or equivalent or they can be ordered from Parallax.
Is there a way for the Stamp to turn the motor on and then, while the motor is on, send the frequency chosen to the speaker? Can this be done with one Stamp or do I need two?
As far as relays are concerned, the Stamp turns it on or off and the relay will stay in tha state until the Stamp changes it. I still don't understand what you mean by "send the frequency chosen to the speaker". Do you expect the Stamp to generate the signal to the speaker? The Stamp can't really do that. It can generate tones in the range of 1Hz to 32KHz, but it can't do anything else while doing that. It can't look for IR signals. It can't change the relay settings. It also can't produce a signal that would drive a speaker, not without amplification. A 555 timer based tone generator would work using a power transistor as an amplifier. Do a web search for "tone generator ic". The Stamp could use reed relays to switch in and out different resistors to set the frequency.
Now, to figure out how to make an in-expensive tone generator circuit that will create the frequencies needed.
Thank you again for all of your help.
'Doppler Effect for Sound Demo - DopEffSound.bs2
'IR remote turn motor on and off. IR remote choses audio frequency.
'{$STAMP BS2}
'{$PBASIC 2.5}
'
[Program description]
'This program is designed to be used with the Doppler Effect for Sound
'demonstration at Rose State College. The IR remote control signals
'are used for controlling the demonstration; motor ON/OFF,
'audio frequencies 500Hz, 650Hz, and 800Hz.
'
'
[I/O definitions]
IRdetect PIN 3
Motor PIN 5 '10 volts
Freq500 PIN 8 ' 5 volts
Freq650 PIN 10 ' 5 volts
Freq800 PIN 13 ' 5 volts
'
'
[Variables]
IRinput VAR Nib 'change to what the remote signal is (byte?)
'
[Program Code]
Main:
DO
IRinput = IRdetect
IF IRinput = (condition) THEN
DO
HIGH Motor
IF IRinput = (condition) THEN
DO
HIGH Freq500
ELSE IRinput = (condition) THEN
DO
HIGH Freq650
ELSE IRinput = (condition) THEN
DO
HIGH Freq800
END IF
ELSE
END IF
LOOP
Am I on the right track?
Do remember that "IRinput = IRdetect" is really quite complex. The part about doing something with the IR codes is really very simple. You might just start with the IR detection code from "IR Remote for the BoeBot". Chapter 2 shows a variety of programs of increasing complexity depending on how you want to control things. In most cases, there's a SELECT statement where each CASE is a response to a particular remote control button. One might turn the motor on (HIGH) and another might turn it off (LOW). One CASE might set Freq800 HIGH and the others to INPUT, etc.
Would that work?
We had a bit of an issue when soldering the circuit onto a printed circuit board, but we managed to fix it.
Thank you for all of the references, and info. It helped greatly.
- Debra