Need Help with code for a Doppler Effect for Sound demo project
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.
;NCO.asm ;Test program for 12F1501 ;LED on RA2 (pin 5) ;NCO1 outputs on RA1 (pin 6) and RA5 (pin 2) list p=12f1501 ; list directive to define processor #include <P12F1501.inc> ; processor specific variable definitions errorlevel -302 __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _BOREN_OFF & _CLKOUTEN_OFF __CONFIG _CONFIG2, _WRT_OFF & _STVREN_OFF & _LVP_OFF ORG 0x000 ; processor reset vector goto Main ; go to beginning of program ORG 0x004 ; interrupt vector location ; W reg, STATUS, BSR, FSTs, aand PCLATH regs are saved ; automatically in the Shadow regs (Bank 31) retfie Main: banksel OSCCON movlw b'01111000' ; Int. osc. 16 MHz movwf OSCCON btfss OSCSTAT, HFIOFR ; Int. osc. running? goto $-1 ; No, loop back btfss OSCSTAT, HFIOFS ; Osc. stable? goto $-1 ; No, loop back. ; initialise I/Os banksel TRISA movlw b'11111101' ; RA1 output (pin 6) movwf TRISA movlw b'11011111' ; RA5 output (pin 2) movwf TRISA ; initialise NCO registers banksel NCO1CON movlw b'11010000' ; Enable NCO, enable O/P, O/P low, O/P active high, fixed duty-cycle mode. movwf NCO1CON movlw b'01100000' ; NCO output pulse 8 clocks, clock source HFINTOSC (16 MHz). movwf NCO1CLK movlw b'00000000' ; High inc. register (needs to precede setting of low inc. register). movwf NCO1INCH movlw b'00000001' ; Low inc. register. movwf NCO1INCL banksel APFCON bsf APFCON,NCO1SEL ; NCO1 output on RA5 Loop: goto Loop end'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