View Single Post
  #6   Spotlight this post!  
Unread 25-09-2007, 23:30
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Project Questions about Programming and Electrical

Quote:
Originally Posted by Kevin Sevcik View Post
You could pretty easily use the CCP ports represented by PWMs 13-16 to output single frequency tones. You'd set it up to output a square wave at the particular frequency you want. You'd have to filter it fairly heavily if you wanted a pure tone, of course. Square waves have harmonics at odd multiples of the fundamental frequency, so if it were me, I'd pick what your high frequency is, make yourself something like a 4th or 6th order low pass filter with a corner frequency at that highest frequency. Then you can put out frequencies down to about 1/2 that highest frequency and still have a pretty pure tone. You'd need to make up a separate amp to drive your speaker, and you'd want it to filter out the DC offset inherent in that initial PWM-style square wave and you'd probably need to create a virtual ground split between your 0V and 12V and various other things as well, of course.
Can you please elaborate? Like I've connected my speaker to a this transistor and I have sound, but it's just a steady pulse, like you would expect from a PWM signal. I really need the help with the programming. I'm electrical, not programming, though I've just learned my first lessons with C like creating variables, the evil semicolon; how to compare things using if {} and how to set variables to certain values. That is literally all I know. I even had trouble compiling the code... (due to something going crazy with MPLAB and not saving my user_routines_fast.c... that took about 20 minutes to figure out). Some coding examples or some electrical schematics of what you are talking about will help a lot. I also have the option to use a Homework Basic Stamp boards as like a sound card, but I'd rather not do that because of the power consumption and the price.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364