CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

piezo buzzer drive: generate a 'click'

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

piezo buzzer drive: generate a 'click'
PostPosted: Fri May 12, 2006 1:22 am     Reply with quote

Hi,

our device has a 20 button keypad. As our device is a notetaker for visually impaired people, I'd like to add a click tone every time you press a button. Compare with a cell-phone.

Now this is the wiring:

Piezo buzzer pin 1 to port E2
Piezo buzzer pin 0 to ground.

This is my function to generate a beep:

Code:
void BUZZER()
{
      int8 i;
      for (i = 0 ; i < 170 ; i++ )
      {
         output_high(BUZZ);
         delay_us(200);
         output_low(BUZZ);
         delay_us(300);
      }
}


Now how can I adapt this to let the buzzer generate a "click" ?

thx
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri May 12, 2006 3:56 am     Reply with quote

'click' is a wideband sound, while your buzzer probably is designed to produces something close to a tone. I'm not sure if it will work, but try turning your buzzer for a very short time - one cycle of the buzzer's acustic frequency.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 12, 2006 6:20 am     Reply with quote

It sounds like he has a bare piezo element, as he is turning it on and off at a 2kHz rate (more of a squeak than a buzz). So if he gives it just one or two cycles it should give a click.
_________________
The search for better is endless. Instead simply find very good and get the job done.
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Fri May 12, 2006 9:16 am     Reply with quote

I will "third" what you've been told.

I have an ultrasonic distance measurment sensor which operates at 50 kHz and has a range of 40' (12.2m). This thing is LOUD! I can't actually hear the 50 kHz whistle, but when it transmits, you can hear a very loud "clack". You can actually hear the returning echo too.

The secret to generating your audible click is to power the piezo speaker for a very short time - perhaps 50 - 500 us. Play with the delay until you find one that gives the best click.
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Wed May 17, 2006 8:58 am     Reply with quote

What do you mean by 'power'?

Send pulses to it or give it a DC voltage?
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Wed May 17, 2006 9:45 am     Reply with quote

Christophe wrote:
Send pulses to it or give it a DC voltage?


It's hard to answer this question without knowing more specific details about your particular buzzer. Your buzzer either has an internal oscillator or it doesn't. But in either case, a single rectangular pulse might produce a click. If you post the part number for your buzzer, I might give you a more enlighted answer.
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Wed May 17, 2006 10:18 am     Reply with quote

kender wrote:
Christophe wrote:
Send pulses to it or give it a DC voltage?


It's hard to answer this question without knowing more specific details about your particular buzzer. Your buzzer either has an internal oscillator or it doesn't. But in either case, a single rectangular pulse might produce a click. If you post the part number for your buzzer, I might give you a more enlighted answer.


First try applying a DC level. Something like:

Code:
output_high(BUZZER_PIN);
delay_us(100);
output_low(BUZZER_PIN);


You should hear a click. Whether you find it to be acceptably loud is another story.

As an aside, I have a Micro Engineering Labs (www.melabs.com) Lab X1 board. It comes with a piezo buzzer which is connected to one of the port C pins. If I use that pin as a digital I/O line, I can hear a faint click coming from the piezo buzzer every time the line changes state. I'm fairly certain that the clicks you'll be able to produce without amplification will be very quiet.

It may be better to produce short beeps instead of clicks. The least processor-intensive way to do that is to configure the PWM to run at the resonant frequency of the piezo buzzer. Then simply gate the buzzer for a short period of time in response to a button press/whatever. All you have to do is change the PWM pin from being an input (no sound) to an output (so the buzzer gets driven by the PWM), wait a short period of time, then change the pin back to being an input (no sound).
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Thu May 18, 2006 1:47 am     Reply with quote

Sorry for giving not all hardware information.
Here is link to datasheet of the piezo:

http://be.farnell.com/jsp/endecaSearch/partDetail.jsp?SKU=3921165&N=401

and

http://www.farnell.com/datasheets/55401.pdf


My clicking function:

Code:
//******************************** KEYCLICK **********************************//

void CLICK()
{
         output_high(BUZZ);
         delay_us(75);
         output_low(BUZZ);
}


This indeed gives a click, still it is not loud. Max output of pic's ports are 3V.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu May 18, 2006 8:11 am     Reply with quote

It says that the max voltage is 20V AC.
Pump up the voltage.
Use a transformer to increase the pwm output.
OR
Maybe use the 3V pic output to control a FET that controls perhaps the source voltage before the 3V regulator.


Last edited by treitmey on Thu May 18, 2006 12:23 pm; edited 1 time in total
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Thu May 18, 2006 9:11 am     Reply with quote

treitmey wrote:
It says that the max voltage is 20V AC.
Pump up the voltage.
Use a transformer to increase the pwm output.


I was going to suggest a transformer too, but it really depends on the sound that is required. If a tone is acceptable, then the piezo can either be driven directly from the PIC, or it may need a transformer between the piezo and the PIC. It all depends on how loud the piezo is when driven directly from the PIC. Drive it at its resonant frequency for maximum volume.

If a click is desired (not a beep), then his options are kind of limited. Unless there is a "click transducer", of course.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

$0.02
PostPosted: Thu May 18, 2006 4:44 pm     Reply with quote

Christophe wrote:
our device has a 20 button keypad. As our device is a notetaker for visually impaired people, I'd like to add a click tone every time you press a button. Compare with a cell-phone.


Looked at the datasheet for the buzzer you're using. I guess, you are feeding it a square wave, which sets the primary frequency for the buzzer. Here's my $0.02: from a product design standpoint, you might be better off producing tones for button presses. Different tone for each button or a group of buttons. That might give the visually impared user an aditional feedback about whether or not the correct button has been actually pressed.
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Fri May 19, 2006 12:56 am     Reply with quote

Hi kender,

thx for your input again. Your suggestion is good, however there are too much button combinations possible. I just want a small click on any keypress, just like with a cell phone.

Here is a picture of the device:

[img]http://users.[spam].be/chs/Werk/ES20.jpg [/img]
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Anther $0.02
PostPosted: Fri May 19, 2006 7:03 am     Reply with quote

Christophe wrote:
Here is a picture of the device:



Nice industrial design! Since the device is fairly large, you could take advantage of setereo effect by locating 2 buzzers on different ends.
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Fri May 19, 2006 7:23 am     Reply with quote

Another good idea however again difficult as the production pcb's are allready being made, so I cannot change anything more for this batch of boards.

On the next run, I'll drive it with a higher voltage.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri May 19, 2006 7:37 am     Reply with quote

Or you could throw a relay. The mechanical action might make a nice click.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group