|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan,
PWM outputs 13-16 are directly connected to the user processor's CCP modules, so you can use them to generate timed pulses. The default code has a section briefly covering this: Code:
/* FIFTH: Set your PWM output types for PWM OUTPUTS 13-16.
/* Choose from these parameters for PWM 13-16 respectively: */
/* IFI_PWM - Standard IFI PWM output generated with Generate_Pwms(...) */
/* USER_CCP - User can use PWM pin as digital I/O or CCP pin. */
Setup_PWM_Output_Type(IFI_PWM,IFI_PWM,IFI_PWM,IFI_PWM);
/*
Example: The following would generate a 40KHz PWM with a 50% duty cycle on the CCP2 pin:
CCP2CON = 0x3C;
PR2 = 0xF9;
CCPR2L = 0x7F;
T2CON = 0;
T2CONbits.TMR2ON = 1;
Setup_PWM_Output_Type(USER_CCP,IFI_PWM,IFI_PWM,IFI_PWM);
*/
So, using the CCP, you can get a square wave signal at (mostly) whatever frequency you want, but two problems remain. First, the signal will oscillate between 0(ish)V and 5(ish)V. Sending something like this through a speaker isn't particularly nice. Especially if the 0V side isn't 0V, as then you'd be constantly sending a current through the speaker. So you'd need an op-amp circuit to shift the square wave so it oscillates around 0V. You could, in fact, send this through the speaker, but it'd sound a bit odd as it's not a nice sine wave like a pure audio tone is. It's possible to get a nice pure tone out of a square wave, however. The sharp edges (more or less) represent higher frequency components of the signal. So if you create a filtering circuit to filter out high frequencies, you'll get a much purer, cleaner tone. That bit isn't as necessary to making a sound come out of the speaker, though. |
|
#2
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Thanks. I'll try to figure it all out this weekend. I just got a bunch of stuff working on it until a PWM cable randomly decided to go out or else a pin on the circuit board came loose and is not giving me a good connection. I think I may just try to move it to a different pin.
|
|
#3
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
You can block DC current by putting a suitable capacitor in series with the speaker. That's not always a perfect option, but it's certainly a lot easier, cheaper, and quicker than adding active circuitry that requires a bipolar power supply.
|
|
#4
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan,
Audio alerts can take many different forms. If you are trying to get someone's attention, a Sonalert or Piezo electric transducer works very well. These devices work best at their resonant frequency but can reproduce a range of frequencies in the mid band of human hearing. They are easy to interface and are pretty cheap. I have a used a few from Radio Shack like the ones here...http://www.radioshack.com/family/ind...032058.2032230 |
|
#5
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
|
|
#6
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan, again, you can customize the CCP output to produce different frequencies. Not a LOT if you want it to sound half decent, but still probably 3-4 distinct tones. Honestly, with just two tones and a little clever programming you could get several different signals by pulsing and alternating the tones at intervals, sort of like morse code or the BIOS beep codes computers use.
Addressing Alan's comments, yes putting a capacitor in series with your amplifier or speaker would remove the DC component of the signal, but if you're planning on using a bipolar amplifier of some sort to power your speaker, then I'd recommend the extra trouble of a little active filtering, as it would really help in the long run. What I wouldn't recommend is running he speaker directly from the RC digital output. I don't think they can source or sink nearly enough current to work well in that application. |
|
#7
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan,
You can use piezo buzzers in place of speakers. They are easy to interface and can play out a band of frequencies. At least one of the Radio Shack devices is listed as midband 1500-3000Hz. That is certainly enough to give you R2D2 like sounds. They are very efficient giving upwards of 90dB+ outputs at 10-15 ma. Most can be used as the collector load in a simple one transistor amp. Since the current demands are low, a 2N2222 or 2N3906 would work fine. When you choose, be sure to look for one that does not self resonate, i.e. make sound when connected to a power source. Most are able to take a variable frequency input. |
|
#8
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
I've run into a bit of a problem today. I was testing the whole setup, so I left it running for about half an hour. Every thing seemed fine. I turned it off and went to go run some errands, and when I came home I found that it was on. So I pushed the power switch off and it stayed on. "Hmm...," I thought to my self so I disconnected the battery and it turned off. I reconnected it and left it off. I went to do some chores around my house, came back to my room and found it on again! Somehow, this thing keeps on turning itself on, and I'm not sure how it can do it with the way I have the power switch wired. I'm totally lost on to what is causing this because there is no way for it to happen with the setup I have. You can see that the power relay is connected to the fuse panel, which must receive power from the power switch first in order to even turn on. Here is a rough hand drawn schematic of my electrical circuits:
http://nazaretian.homeip.net:8000/ry...%201%20001.png EDIT: Also it is receiving power from something non-mechanical. So I guess it's leaking through a transistor or something, but I don't see how since they're all connective negatively. Last edited by RyanN : 10-10-2007 at 14:03. |
|
#9
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
I partially found the problem. My power relay's contacts were stuck closed because my connection pushed the contact up, but... that doesn't explain why it would turn off then after a few minutes, it would turn back on unless the copper connections were bending slightly after it cooled down.
|
|
#10
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan,
When linking to your schematic the connection is refused so I can't be sure of what you are doing. As to the power relay, did you solder directly to the relay contacts? Often this melts the base material and leaves enough slop in the contact to move around with heat/cool and vibration. Add to this a few errant metal shavings or whiskers and you end up with a contact that you can't really see but is there none the less. The best way to use realys is to add a socket. The socket is made for soldering and the relay merely plugs into it. Relays are notorious for acting weird especially on low current signals. |
|
#11
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
![]() ![]() |
|
#12
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
Ryan,
Are you using the backup battery input to the RC? Since the relay outputs of the RC are intended for Spike connections, I am not sure what the actual signal output is. They may actually send a keep alive output which could turn the relay driver on. The Spike input circuit is pretty complex and has a lot of input filtering. I suspect that the RC is actually triggering the relay drive transistor. Also, the relay output only has to rise to 0.6 volts to turn the relay driver on in this configuration. You could simply try a 1k resistor in series with the base of the transistor and I would add a 0.1mfd cap base to emitter to quench any noise and see what happens. |
|
#13
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Actually all seems to be working well just after replacing the relay. I got my charger connected and it seems to work perfectly. I only have the LEDs and sensors to connect now. I like how it is wrapping up and I hope to post some pictures of the spaghetti I have made into my project. TOO MANY SIGNAL WIRES!!!!! Oh well, as long as it doesn't break I'll be fine, and if it does, I just need to set aside a day to fix it
. Thanks for all the help. If I encounter any trouble with the transistors, I will do what you said and add a resistor and a capacitor to the transistors. I actually found the Spike signal system to be very very simple. They output 5V (my personal favorite voltage for transistors and LEDs) It switches using IFI's seemingly favorite H bridge. If you put both fwd and rev to 1, then it outputs positive signals on the spike outputs, and they are both 0, then it's a negative signal. So what I've done is take like fwd and rev to turn individual spikes to only forward since accidentally reversing them will fry some things. Hopefully this all makes sense. If there are any questions for me, please don't hesitate to ask. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| two electrical questions | mechanicalbrain | Electrical | 9 | 11-07-2005 09:41 |
| Problems and questions about programming | hedgehogger | Programming | 4 | 15-01-2005 18:18 |
| Questions about DNS, URL Forwarding, and Cloaking | sanddrag | Website Design/Showcase | 7 | 22-10-2004 21:32 |
| Questions about Textures and Models | thoughtful | 3D Animation and Competition | 28 | 11-02-2004 22:13 |
| Pneumatics electrical wiring and programming | archiver | 2001 | 1 | 23-06-2002 23:10 |