Microcontroller input

A

A ELLIS UK

Jan 1, 1970
0
Hi Group

Can anyone give me some advice? I have just built a device that triggers a
microcontroller when you tap the box it is mounted in. The trigger circuit is
so simple, it worries me that I am missing something? The transducer is just a
piezo disc coupled to the base of an NPN transistor by a 100n cap, a resistor
(4M7) is also connected to the base and + 5V. The transistor has a pull-up
resistor from its collector and that's basically it.

It works, but as the piezo disc could make some high voltages, do I need to add
any protection to the trigger circuit? I would think that the transistor would
buffer the micro input from any harmful over voltage? Should I add a current
limiting resistor to the transistor's base, even though it's AC coupled? Can
anyone see any potential problems with my scheme and if so advise how to solve
them?

Thanks in advance for any help.

Regards

Chris H
 
M

mook johnson

Jan 1, 1970
0
A base resister is recommended. as close to the device as possible. make
sure you have enough base drive to trigger it at the lowest levels but can
limit the current to a safe level at the maximum anticipated input level.
The base - emitter diode should clamp the spike voltage to less than 1 volt
so the micro should be fine. You should probably put a diode between the
emitter and base (cathode) to clamp negative voltages when AC coupled. The
base emitter diode of the BJT typically breaks down at about 6 volts.
 
S

Spehro Pefhany

Jan 1, 1970
0
Hi Group

Can anyone give me some advice? I have just built a device that triggers a
microcontroller when you tap the box it is mounted in. The trigger circuit is
so simple, it worries me that I am missing something? The transducer is just a
piezo disc coupled to the base of an NPN transistor by a 100n cap, a resistor
(4M7) is also connected to the base and + 5V. The transistor has a pull-up
resistor from its collector and that's basically it.

Add a diode from the emitter to base (to prevent beta degradation due
to reverse E-B breakdown. Check that the transistor beta is guaranteed
to be low enough with ~1uA of base current to guarantee a logic "1" at
the collector, over temperature and unit to unit variations. If you
want to see if a series esistor is required, put a small resistor in
series with
the piezo andmeasure the current when it gets a worst-case shock, then
add some safety actor. I suspect it won't be required, but I'd either
confirm that or put a resistor in there. I don't think DC bias across
the piezo will e a problem at ~500mV but if you have a moist
environment
or are concerned, the 100n cap won't hurt. It won't limit the current
to
any great degree (the piezo looks like a capacitor in series with a
voltage
source anyhow).

Best regards,
Spehro Pefhany
 
R

Robert Monsen

Jan 1, 1970
0
A ELLIS UK said:
Hi Group

Can anyone give me some advice? I have just built a device that triggers a
microcontroller when you tap the box it is mounted in. The trigger circuit is
so simple, it worries me that I am missing something? The transducer is just a
piezo disc coupled to the base of an NPN transistor by a 100n cap, a resistor
(4M7) is also connected to the base and + 5V. The transistor has a pull-up
resistor from its collector and that's basically it.

Cool circuit. What size pullup resistor are you using? Does the uC have an
internal pullup, like the PIC?

Sounds like a fun halloween toy. "Knock on the box for a treat!"

Regards,
Bob Monsen
 
A

A ELLIS UK

Jan 1, 1970
0
or are concerned, the 100n cap won't hurt. It won't limit the current
to
any great degree (the piezo looks like a capacitor in series with a
voltage
source anyhow)

Hi Spehro

Thanks for the great advice! One question though, are you saying that DC
coupling the piezo to the amp/buffer transistor would be best? Both ways work,
but I am not sure which is the best? An earlier poster, talked of a pair of
diodes from base - emitter and emitter - base to protect for +/-
overvoltage do you think I should add this, or will the single diode suffice?

Thanks again for all your help

Best Regards

Chris H
 
A

Active8

Jan 1, 1970
0
On 13 Oct 2003 07:22:05 GMT, A ELLIS UK, said...
Hi Spehro

Thanks for the great advice! One question though, are you saying that DC
coupling the piezo to the amp/buffer transistor would be best? Both ways work,
but I am not sure which is the best? An earlier poster, talked of a pair of
diodes from base - emitter and emitter - base to protect for +/-
overvoltage do you think I should add this, or will the single diode suffice?

i'm assuming your driving the PIC off the collector. doesn't matter
much. you can get teh PIC to interrupt on either edge.

you use the base to emitter diode to protect against reverse breakdown.
i don't recall mention of the other, but you *can* add a diode from base
to Vcc in reverse so that if the input goes above Vcc, the diode would
conduct. I'd call it a clamp, but it's been called "input protection
diode" (the other one too). they're used to protect logic chip inputs,
too, but those are internal to the chip.

i was wondering why you have the base tied to Vcc through that 4.7M R.
granted, it causes negligible collector current assuming a 1K - 10K
pullup or Rc (Rload), but i wouldn't bother.

your AC/DC coupling depends only on whether you need to block DC from
the base, and you don't in this case.

brs,
mike
 
A

Active8

Jan 1, 1970
0
Cool circuit. What size pullup resistor are you using? Does the uC have an
internal pullup, like the PIC?

Sounds like a fun halloween toy. "Knock on the box for a treat!"
yeah, you don't have to answer the door :)

mike
 
S

Spehro Pefhany

Jan 1, 1970
0
Active8 said:
On 13 Oct 2003 07:22:05 GMT, A ELLIS UK, said...

It's only better because it has one less part. I mentioned one reason why
it might be worse.

The E-B junction is one diode. I don't see that post, so I can't
comment on the exact circuit. You don't want a single diode directly
in parallel (same direction) with the E-B junction or it will shunt
away a lot (an uncertain amount) of the base current.
i'm assuming your driving the PIC off the collector. doesn't matter
much. you can get teh PIC to interrupt on either edge.

you use the base to emitter diode to protect against reverse breakdown.
i don't recall mention of the other, but you *can* add a diode from base
to Vcc in reverse so that if the input goes above Vcc, the diode would
conduct. I'd call it a clamp, but it's been called "input protection
diode" (the other one too). they're used to protect logic chip inputs,
too, but those are internal to the chip.

i was wondering why you have the base tied to Vcc through that 4.7M R.
granted, it causes negligible collector current assuming a 1K - 10K
pullup or Rc (Rload), but i wouldn't bother.

It biases the transistor slightly on, so perhaps 50-100mV on the piezo
will trigger the interrupt vs. more like 600mV. More sensitivity.

I'm not so sure about the collector current being negligible, though,
especially under worst-case conditions (high temperature, an especially
high gain transistor). The hfe of a BJT typically varies by 2~3:1
over temperature. Just to take an example, a jellybean MMBT3904
has hfe (typical) of ~230 at 25°C and ~375 at 125°C, at Ic=1.0mA.
There a guaranteed minimum of 70 and no maximum, though you can
infer from the 10mA figures that it's probably less than about 400.
With a 10K collector resistor, the voltage will be 1.3V under those
conditions.. not even a TTL "1". With a more tightly specified
transistor or a lower load resistor it might be okay.
your AC/DC coupling depends only on whether you need to block DC from
the base, and you don't in this case.

Because the piezo acts like a capacitor with a voltage source in series.

Maybe someone has the time and inclination to draw up a nicer AC
amplfier for this fellow with better controlled bias and guaranteed
logic-level output swing. One thing I've seen used is a CMOS unbuffered
inverter used as an amplifier.

Best regards,
Spehro Pefhany
 
A

A ELLIS UK

Jan 1, 1970
0
I'm not so sure about the collector current being negligible, though,
especially under worst-case conditions (high temperature, an especially
high gain transistor). The hfe of a BJT typically varies by 2~3:1
over temperature. Just to take an example, a jellybean MMBT3904
has hfe (typical) of ~230 at 25°C and ~375 at 125°C, at Ic=1.0mA.
There a guaranteed minimum of 70 and no maximum, though you can
infer from the 10mA figures that it's probably less than about 400.
With a 10K collector resistor, the voltage will be 1.3V under those
conditions.. not even a TTL "1". With a more tightly specified
transistor or a lower load resistor it might be okay

Hi Spehro

The (weak) pull-up resistor on the microcontroller inputs are 500K, I was
hoping to use this, do you think I should use an external much lower value
resistor (collector to the + rail), below 10K?

Also should I add the clamp diode from base to + rail?

My thanks to everyone who has helped/advised on this thread.

Best Regards

Chris H
 
A

Active8

Jan 1, 1970
0
It biases the transistor slightly on, so perhaps 50-100mV on the piezo
will trigger the interrupt vs. more like 600mV. More sensitivity.

I'm not so sure about the collector current being negligible, though,
especially under worst-case conditions (high temperature, an especially
high gain transistor). The hfe of a BJT typically varies by 2~3:1
over temperature. Just to take an example, a jellybean MMBT3904
has hfe (typical) of ~230 at 25°C and ~375 at 125°C, at Ic=1.0mA.
There a guaranteed minimum of 70 and no maximum, though you can
infer from the 10mA figures that it's probably less than about 400.
With a 10K collector resistor, the voltage will be 1.3V under those
conditions.. not even a TTL "1". With a more tightly specified
transistor or a lower load resistor it might be okay.

i was only going on a rough guess. i have no way of knowing the actual
components being use, but that's a ggod guess you made.
Because the piezo acts like a capacitor with a voltage source in series.

Maybe someone has the time and inclination to draw up a nicer AC
amplfier for this fellow with better controlled bias and guaranteed
logic-level output swing. One thing I've seen used is a CMOS unbuffered
inverter used as an amplifier.
not much required there. how about a 39 cent inverter?


Vdd/Vcc 5V
+ note: the lame looking diodes
| ___ are pointing up
1N4148/1N914 - +---|___|-+
^ | R 1M |
| | |
| | |
___ | | |\ | |\ to PIC
+ ---|___|----+----+---| >O--+-----| >O---->
| R 100 | |/ |/
-+- | 74HC04 or any HC rigged as inverter
___ |
|___| - 1N4148/1N914
--- ^
| | ground all unused inverter
| | inputs!!
=== ===
GND GND

created by Andy´s ASCII-Circuit v1.22.310103 Beta www.tech-chat.de

if roughly 50mV input sensitivity ain't enough, you'll need another amp.

brs,
mike
 
A

Active8

Jan 1, 1970
0
On 13 Oct 2003 15:00:23 -0700, Spehro Pefhany, said...
It biases the transistor slightly on, so perhaps 50-100mV on the piezo
will trigger the interrupt vs. more like 600mV. More sensitivity.

I'm not so sure about the collector current being negligible, though,
especially under worst-case conditions (high temperature, an especially
high gain transistor). The hfe of a BJT typically varies by 2~3:1
over temperature. Just to take an example, a jellybean MMBT3904
has hfe (typical) of ~230 at 25°C and ~375 at 125°C, at Ic=1.0mA.
There a guaranteed minimum of 70 and no maximum, though you can
infer from the 10mA figures that it's probably less than about 400.
With a 10K collector resistor, the voltage will be 1.3V under those
conditions.. not even a TTL "1". With a more tightly specified
transistor or a lower load resistor it might be okay.

i was only going on a rough guess. i have no way of knowing the actual
components being used, but that's a ggod guess you made. my guess ended
up with a slightly less than 5V to 4V out for hfe 100 and Rc 1k to 10k.
Because the piezo acts like a capacitor with a voltage source in series.

Maybe someone has the time and inclination to draw up a nicer AC
amplfier for this fellow with better controlled bias and guaranteed
logic-level output swing. One thing I've seen used is a CMOS unbuffered
inverter used as an amplifier.
not much required there. how about a 39 cent inverter?

view in courier or other fixed pitch font


Vdd/Vcc 5V
+ note: the lame looking diodes
| ___ are pointing up
1N4148/1N914 - +---|___|-+
^ | R 1M |
| | |
| | |
___ | | |\ | |\ to PIC
+ ---|___|----+----+---| >O--+----| >O---->
| R 100 | |/ |/
-+- | 74HC04
___ |
|___| piezo - 1N4148/1N914
--- ^
| | ground all unused
| | inverter inputs!!
=== ===
GND GND

created by Andy´s ASCII-Circuit v1.22.310103 Beta www.tech-chat.de

if roughly 50mV input sensitivity ain't enough, you'll need another amp.
sorry 'bout the lousy looking transducer.

brs,
mike
 
A

Active8

Jan 1, 1970
0
i wonder if an opto-isolator would be good for this.

mike
 
Top