|
|
| Author |
Message |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 22 January 2006, 14:40 PM Post subject: Connect LED, Switch and Piezo-buzzer |
|
|
I need to attach a SPST switch, a couple of LEDs and a piezo-buzzer to a ZX-24. I have attached a jpeg of my ideas for doing this. Am I on the right track or am I all wet? I am somewhat electronically challenged.
Any enlightenment will be appreciated.
Vic
| Description: |
Will these work?
BTW: I am NOT trying to use the same transistor for both connections. This is the danger of cut and paste! |
|
 Download |
| Filename: |
connects.jpg |
| Filesize: |
21.82 KB |
| Downloaded: |
3793 Time(s) |
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 22 January 2006, 17:15 PM Post subject: |
|
|
You are close. Beginning with the lefthand circuit, you need a current limiting resistor between the I/O pin and the base of the transistor. 10K should be fine for this example. Also, the LED is backwards. Current flows from anode to cathode but is largely blocked in the reverse direction. The easy way to remember this is that current flows in the direction indicated by the arrowhead. Lastly, the current limiting resistor for the LED may be too large. A value of 220 or 330 is more typical but you need to check the datasheet of the LED to find out what the typical current and forward voltage are. With those two values, you can use Ohm's law to calculate the value of the limiting resistor.
For the buzzer, this will work assuming that a) the buzzer is rated for 5 volt operation and requires less than 40mA of current. If it requires more current, the base resistor can be reduced in size (but not below a minimum of about 220 ohms).
The switch circuit is fine. I usually use a pullup resistor like you have shown but it is not necessary if you configure the I/O pin as zxInputPullup. In this case the ZX supplies the pullup with a value of 40K to 80K ohms or so.
I have been working on an application note that address just these issues. I hope to have it finished within the next few weeks.
As a side note, you could have posted this question directly in the ZX-24 Forum. The Files forum is intended for posting "finished work" intended for others to use.
|
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX
|
|
Posted: 22 January 2006, 18:08 PM Post subject: |
|
|
| dkinzer wrote: | | Lastly, the current limiting resistor for the LED may be too large. A value of 220 or 330 is more typical but you need to check the datasheet of the LED to find out what the typical current and forward voltage are. With those two values, you can use Ohm's law to calculate the value of the limiting resistor. | Actually 470 Ohms for a 5V circuit is not too bad. Using 220 or 330 will give a brighter LED and use correspondingly more current (which might be a concern if you are using the ZX-24 builtin regulator). The formula to calculate the series resistor needed for a LED is as follows:
| Code: | | R = (VCC - VDROP) / I | where VCC is the voltage of your circuit (usually 5V), VDROP is the forward voltage drop of the LED (which is roughly 2V for most green and red LEDS), and I is the required current. Blue and white LEDs have higher forward voltage drops.
So a 470 Ohm resistor will give you 6.3mA and 220 Ohm resistor will give you 13.6 mA. Most LEDs are dim at 2 or 3 mA and have a maximum current of 20-25 mA. So in the end it is up to you how bright you want the LED. The graph below shows current versus resistance for both 5V and 12V circuits assuming a 2V forward voltage LED.
| Description: |
| LED Current Limiting Resistor Values |
|
| Filesize: |
29.54 KB |
| Viewed: |
7116 Time(s) |

|
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 22 January 2006, 20:52 PM Post subject: |
|
|
Thanks for taking the time to answer my questions. You can be sure that your answers are appreciated.
I apologize for having the LED upside down. I know better than that. I have been told that the piezo-buzzers draw 10-15 mA. I plan on using ones that have a built-in oscillator so I do not have to be mucking around trying to output a tone to the critter. Loudness is somewhat more important than the tone in my case.
I also apologize for posting to the wrong forum. I thought I was doing right. I'll know better next time. Mea culpa
Vic
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 22 January 2006, 22:27 PM Post subject: |
|
|
| Quote: | | I have been told that the piezo-buzzers draw 10-15 mA. |
That range of current is not unusual. However, you'll want to confirm the actual current requirement for the particular part that you choose. The figure should be given in the datasheet for the part. The datasheet for the CEP-2242 indicates a maximum of 7mA at 12 volts.
If you can't find it, you can measure the current draw. If you know, for example, that the device can be run on +5 to +12 volts, you can connect it directly to a voltage source and measure the current drawn. You'll probably find that it a higher current will flow with the higher voltages.
Note that using the NPN configuration that you've chosen, you can operate the load (the buzzer, in this case) at any suitable (positive) voltage. You needn't constrain yourself to +5.
Note that a transistor (or other type of switch) is only required if the device operates on other than 5 volts or if it requires more than 10mA or so.
|
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
Posts: 665
|
|
Posted: 22 January 2006, 23:16 PM Post subject: |
|
|
| victorf wrote: | I have been told that the piezo-buzzers draw 10-15 mA. I plan on using ones that have a built-in oscillator so I do not have to be mucking around trying to output a tone to the critter. Loudness is somewhat more important than the tone in my case.
Vic |
The current varies alot between different buzzers. The Voltage also varies alot. I found that the 5 volt input which was at the low end of the range allowed in my Radioshack buzzer was not loud enough when it was stuck inside my project box.
Fortunately, I have access to 12v inside the box (used with a switching regulator to make the 5V for the microcontroller, LCDs, etc.
I then also took the 12v to feed the piezo thru an NPN transistor.
Quite loud. Annoyingly loud when I am testing the software. But it will be used in a higher ambient sound environment than my home. (sports car)
-Tony
|
|
| Back to top |
|
 |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 23 January 2006, 19:51 PM Post subject: |
|
|
With reference to my original post in this thread can I simpy replace the +5V on the piezo diagram with 12 volts without any other chances? I, too, have +12V available.
May I ask about your switching regulator. What is it and where can I get something like it?
Any enlightenment will be appreciated.
Vic
|
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX
|
|
Posted: 23 January 2006, 20:19 PM Post subject: |
|
|
| victorf wrote: | | May I ask about your switching regulator. What is it and where can I get something like it? |
Vic, we are drifting faster and faster off topic. First of all your question merits a separate append as it is really a new topic. Second this forum is about the ZX-24. We have all been kind enough to indulge your questions as you are getting started but to be fair to everyone (including you), may I suggest some alternative places to ask these questions such as the Electronics-101 group on yahoo.
|
|
| Back to top |
|
 |
|