Maker Pro
Maker Pro

Can someone check a circuit for me please

L

Larry Green

Jan 1, 1970
0
Hi Folks,

I have recently been asked to come up with circuit for a hobby project and
it has been many, many years since I last dabbled in electronics and circuit
design.

After a lot of thought and investigation on the web I think I now have a
feasible design but for some reason one side of my brain is telling me there
is an error while the other side is saying everything looks good!

The main area for concern is in the push button/de-bounce resistor
arrangement. I have a suspicion that they may need reversing (i.e. the
switch needs to be at the top and the resistor at the bottom). My 'logic'
tells me it is wrong at the moment and the inputs will be 'high' at all
times, however my rusty electronic theory brain cells tell me that due to
current flow the circuit is correct as it stands. I am also concerned about
the location of D2 which is acting as a reverse polarity protection device
in case someone tries to connect the 9V battery backwards with the switch
still in the 'on' position.

Can someone please check it over and tell me which is correct and if you see
any other glaring errors could you point me in the right direction on those
too. The circuit is designed to randomly select one of two sound options
after a random delay. One push button will start the random sequence while
the other two will each play one of the sound options for identification
purposes.

The circuit can be found here......

http://www3.sympatico.ca/larry.green/circuit_diagram.gif

Thanks for any help you can give, once I have the circuit nailed I can
concentrate on programming the PIC (a totally new area for me but I am on
the learning curve.....lol).

Larry Green VE3YET
 
F

Frank Buss

Jan 1, 1970
0
Larry Green said:
The main area for concern is in the push button/de-bounce resistor
arrangement. I have a suspicion that they may need reversing (i.e. the
switch needs to be at the top and the resistor at the bottom). My
'logic' tells me it is wrong at the moment and the inputs will be
'high' at all times, however my rusty electronic theory brain cells
tell me that due to current flow the circuit is correct as it stands.

It's ok, but the resistors doesn't have any de-bounce effect, but you
can implement this in the PIC software without using any additional
capacitors.
I am also concerned about the location of D2 which is acting as a
reverse polarity protection device in case someone tries to connect
the 9V battery backwards with the switch still in the 'on' position.

Looks ok for me.
Can someone please check it over and tell me which is correct and if
you see any other glaring errors could you point me in the right
direction on those too. The circuit is designed to randomly select one
of two sound options after a random delay. One push button will start
the random sequence while the other two will each play one of the

I don't know the details of the PIC16F818, but on most PICs you need an
external crystal oscillator (or a low-cost RC combination) and you have
to connect the reset input.
once I have the circuit nailed I can
concentrate on programming the PIC

Perhaps this will help you:

http://www.mikroelektronika.co.yu/english/product/books/PICbook/0_Uvod.htm
 
L

Larry Green

Jan 1, 1970
0
Frank Buss said:
It's ok, but the resistors doesn't have any de-bounce effect, but you
can implement this in the PIC software without using any additional
capacitors.

Ok I will look into that when I get to the programming stage.
Looks ok for me.

Thanks for looking at that for me.
I don't know the details of the PIC16F818, but on most PICs you need an
external crystal oscillator (or a low-cost RC combination) and you have
to connect the reset input.

According to the data sheet it has an internal oscillator which will be good
enough for my needs I believe and from what I could see from the data sheet
there are a number of reset options but the POR seems to be taken care of on
the Vdd input pin. Is this the reset you were talking of or is there another
pin that needs connecting to either the +ve or -ve rail?

Thanks for that link, I had not seen that page before despite doing numerous
web searches for PIC tutorials/books etc. I have it bookmarked and will read
fully as soon as possible.

Thanks for all your help,

Larry Green VE3YET
 
S

Spehro Pefhany

Jan 1, 1970
0
Hi Folks,

I have recently been asked to come up with circuit for a hobby project and
it has been many, many years since I last dabbled in electronics and circuit
design.

After a lot of thought and investigation on the web I think I now have a
feasible design but for some reason one side of my brain is telling me there
is an error while the other side is saying everything looks good!

The main area for concern is in the push button/de-bounce resistor
arrangement.

You don't have any debouncing- the resistors are just pull-ups.
I have a suspicion that they may need reversing (i.e. the
switch needs to be at the top and the resistor at the bottom). My 'logic'
tells me it is wrong at the moment and the inputs will be 'high' at all
times, however my rusty electronic theory brain cells tell me that due to
current flow the circuit is correct as it stands.

The inputs will be low when the switches are pressed. Deal with that
and and debouncing in firmware. Make sure you don't have an ESD path
from charged fingers through any of the switchs through the
microcontroller to ground.
I am also concerned about
the location of D2 which is acting as a reverse polarity protection device
in case someone tries to connect the 9V battery backwards with the switch
still in the 'on' position.

It's fine. The regulator will start to drop out at around 7.2V from
the "9V" battery- a bit high if you're using a NiCd or NiMH.
Can someone please check it over and tell me which is correct and if you see
any other glaring errors could you point me in the right direction on those
too. The circuit is designed to randomly select one of two sound options
after a random delay. One push button will start the random sequence while
the other two will each play one of the sound options for identification
purposes.

The circuit can be found here......

http://www3.sympatico.ca/larry.green/circuit_diagram.gif

You might want to try running the LEDs at a lot less current to save
battery life. You're shunting the red LED off. This has a couple of
issues- it maximizes battery drain and it may unnecessarily cause you
to deal with Read-modify-write issues on the PIC. Also, if that output
is driven high instead of tri-stated you can get a very high current
through the LED. Better to connect the LED to +5, series resistor and
drive the output LOW to turn it "ON".

Also, put a 0.1uF ceramic capacitor across the rails near the chip.
The 10uF is unnecessary, but it won't hurt. Don't expect too much
sound level out of the piezo. BTW, there's some chance that a
mechanical shock on the piezo could indirectly lead to the
microcontroller burning up.

Tie RA7 and RA5 to ground or Vdd, set the other unused port pins to be
outputs.
Thanks for any help you can give, once I have the circuit nailed I can
concentrate on programming the PIC (a totally new area for me but I am on
the learning curve.....lol).

Larry Green VE3YET

Best regards,
Spehro Pefhany
 
T

Tim Hubberstey

Jan 1, 1970
0
Larry said:
Can someone please check it over and tell me which is correct and if you see
any other glaring errors could you point me in the right direction on those
too. The circuit is designed to randomly select one of two sound options
after a random delay. One push button will start the random sequence while
the other two will each play one of the sound options for identification
purposes.

The circuit can be found here......

http://www3.sympatico.ca/larry.green/circuit_diagram.gif

There a few things I see...

Assuming D2 is present to protect against reverse insertion of the
battery, then R1 should connect to the cathode of D2 or your LED will be
damaged by the reverse voltage.

Depending on what type of piezo/buzzer/siren you have there may be
issues about flyback voltages generated by the buzzer damaging the
relatively fragile output of your micro. It might be OK as is, or you
may need to add protection diodes or even a separate driver. It all
depends on the buzzer.

The drive circuit for D3 is probably wrong. As drawn, you would need to
program the micro to create an open-drain output in order to shunt the
current around the LED to turn it off. This means that you will be
constantly drawing at least 20 mA whether the LED is on or not. What you
probably want is to connect the cathode of D3 to your micro instead and
drive a '0' to the pin to turn on the LED.
 
F

Frank Buss

Jan 1, 1970
0
According to the data sheet it has an internal oscillator which will
be good enough for my needs I believe and from what I could see from
the data sheet there are a number of reset options but the POR seems
to be taken care of on the Vdd input pin. Is this the reset you were
talking of or is there another pin that needs connecting to either the
+ve or -ve rail?

Yes, I've downloaded the data sheet and it looks like this chip has
integrated it and you don't need any external components for reset and
clock.

For the LED on RA3 I would suggest to connect RA3 - R - LED - GND. RA3 can
drive 25 mA, so 220 ohm would limit it to 22 mA max and it is not too much
for a normal LED.
 
B

Byron A Jeff

Jan 1, 1970
0
-
--> [snipped]
-
->
-> I don't know the details of the PIC16F818, but on most PICs you need an
-> external crystal oscillator (or a low-cost RC combination) and you have
-> to connect the reset input.
-
-According to the data sheet it has an internal oscillator which will be good
-enough for my needs I believe and from what I could see from the data sheet
-there are a number of reset options but the POR seems to be taken care of on
-the Vdd input pin. Is this the reset you were talking of or is there another
-pin that needs connecting to either the +ve or -ve rail?

You are on target with the oscillator. The 818 (and other nanowatt technology
PICS) have a multiselectable internal oscialltor that runs up to 8MHz.

The reset is the MCLR pin. While I do believe that in many of the modern
PIC parts the reset can be internalized, most of the time PIC designers will
tie MCLR to +5 to ensure that it resets when powered on.

BTW I took a second look at the circuit. Care to explain the purpose of the
red LED D3? That's a very odd configuration to control an LED. Also I
believe that the current that a 150 ohm resistor allows at 5V (33ma)
exceeds the current capacity of a single PIC I/O pin (25ma absolute max).


Also is the 9V a battery? Using a 7805 to regulate is quite wasteful. It
would be better to either power using 3 1.5V alkalines, or to switch to
something like Roman Black's ultra efficient, ultra cheap, switching
power supply: http://www.romanblack.com/smps.htm


-
->
-> > once I have the circuit nailed I can
-> > concentrate on programming the PIC
->
-> Perhaps this will help you:
->
-> http://www.mikroelektronika.co.yu/english/product/books/PICbook/0_Uvod.htm
->
-
-Thanks for that link, I had not seen that page before despite doing numerous
-web searches for PIC tutorials/books etc. I have it bookmarked and will read
-fully as soon as possible.

Let me throw out a laundry list of caveats:

1) That page, like most others targets the 16F84, which is a virtually
obsolete part. The F818 is a nice new part with a bunch of features that
such a tutorial will not necessarily explore. Unfortunately I can't really
offer anything too much better. One 16F628 tutorial (which is closer to the
818) exists here: http://www.winpicprog.co.uk/pic_tutorial.htm

2) Language choice is always a dicey proposition. While many designers are
firmly rooted in assembly, there are other choices. I outline some on my
PIC Languages page: http://www.finitesite.com/d3jsys/languages.html
Be aware that my NPCI system isn't available for public use yet. But JAL and
XCSB offer the ability to get PIC work done with a high level language.

3) One continuing discussion on the PICLIST mailing list is the fact that
building assembly projects with absolute code is a really bad idea. The problem
is that most examples use the technique. Embed Inc has a couple of really
good examples of using the Microchip linker here:

http://www.embedinc.com/pic

I hope this gives you some insight.

BAJ
 
F

Frank Buss

Jan 1, 1970
0
Tim Hubberstey said:
Assuming D2 is present to protect against reverse insertion of the
battery, then R1 should connect to the cathode of D2 or your LED will
be damaged by the reverse voltage.

Why? It doesn't flow any current through the LED on reverse voltage. But I
would suggest to connect the LED after the 7805, because then the light
doesn't change with lower battery voltage.
 
G

Gareth

Jan 1, 1970
0
Frank said:
Why? It doesn't flow any current through the LED on reverse voltage.

The maximum reverse voltage most LEDs will tolerate is less than 9V.

--
 
L

Larry Green

Jan 1, 1970
0
Frank Buss said:
Yes, I've downloaded the data sheet and it looks like this chip has
integrated it and you don't need any external components for reset and
clock.

For the LED on RA3 I would suggest to connect RA3 - R - LED - GND. RA3 can
drive 25 mA, so 220 ohm would limit it to 22 mA max and it is not too much
for a normal LED.
Ok........thanks for that....you are the second person to mention that to me
now and I will make the changes. I guess I shouldn't draw circuits in the
wee hours of the night ;-)

Larry
 
L

Larry Green

Jan 1, 1970
0
Byron A Jeff said:
-
--> [snipped]
- Snip

-
-According to the data sheet it has an internal oscillator which will be good
-enough for my needs I believe and from what I could see from the data sheet
-there are a number of reset options but the POR seems to be taken care of on
-the Vdd input pin. Is this the reset you were talking of or is there another
-pin that needs connecting to either the +ve or -ve rail?

You are on target with the oscillator. The 818 (and other nanowatt technology
PICS) have a multiselectable internal oscialltor that runs up to 8MHz.

The reset is the MCLR pin. While I do believe that in many of the modern
PIC parts the reset can be internalized, most of the time PIC designers will
tie MCLR to +5 to ensure that it resets when powered on.

Thanks for that and for safety I will tie the MCLR pin to +5V.
BTW I took a second look at the circuit. Care to explain the purpose of the
red LED D3? That's a very odd configuration to control an LED. Also I
believe that the current that a 150 ohm resistor allows at 5V (33ma)
exceeds the current capacity of a single PIC I/O pin (25ma absolute max).

That was an error.......... :-( it should be connected between the OP and
ground.
Also is the 9V a battery? Using a 7805 to regulate is quite wasteful. It
would be better to either power using 3 1.5V alkalines, or to switch to
something like Roman Black's ultra efficient, ultra cheap, switching
power supply: http://www.romanblack.com/smps.htm

Yes the 9V is a battery (PP3 type). The device has to be portable and self
contained. There are a couple of reasons I chose that option , I was hoping
that the drain would be low enough to give a long life (and I may have to
re-visit those resistor values on the push buttons) and they are readily
available and not too difficult to connect (trying to avoid reverse polarity
....KISS.......the diode protection is a back up!) plus I was hoping for +5V
for quite a while before the voltage dropped too low for operation. I had
looked at AA 1.5V battery holders but could only find 2 or 4 cell options
and that added to the weight of the project. Would 4.5V be enough to drive
the circuit (I know the 16F818 is a low power chip) or would the batteries
die too quickly?
-> > once I have the circuit nailed I can
-> > concentrate on programming the PIC
->
-> Perhaps this will help you:
->
-> http://www.mikroelektronika.co.yu/english/product/books/PICbook/0_Uvod.htm
->
-
-Thanks for that link, I had not seen that page before despite doing numerous
-web searches for PIC tutorials/books etc. I have it bookmarked and will read
-fully as soon as possible.

Let me throw out a laundry list of caveats:

1) That page, like most others targets the 16F84, which is a virtually
obsolete part. The F818 is a nice new part with a bunch of features that
such a tutorial will not necessarily explore. Unfortunately I can't really
offer anything too much better. One 16F628 tutorial (which is closer to the
818) exists here: http://www.winpicprog.co.uk/pic_tutorial.htm

2) Language choice is always a dicey proposition. While many designers are
firmly rooted in assembly, there are other choices. I outline some on my
PIC Languages page: http://www.finitesite.com/d3jsys/languages.html
Be aware that my NPCI system isn't available for public use yet. But JAL and
XCSB offer the ability to get PIC work done with a high level language.

3) One continuing discussion on the PICLIST mailing list is the fact that
building assembly projects with absolute code is a really bad idea. The problem
is that most examples use the technique. Embed Inc has a couple of really
good examples of using the Microchip linker here:

http://www.embedinc.com/pic

I hope this gives you some insight.

Thanks for those links and I will check them out. This will be my first
attempt at programming a PIC but many years ago I used to program in BASIC
and I did qualify as a CNC programmer (in a past occupation) so I am hoping
some of those skills may come back! I have noticed though that the PIC basic
is somewhat different and I am going to have to figure out how to get a
random time delay out of it (I already have some building blocks sorted but
not that one yet).

Thanks for your help,

Larry
 
L

Larry Green

Jan 1, 1970
0
Spehro Pefhany said:
Snip


You don't have any debouncing- the resistors are just pull-ups.

My mistake, I did say it had been many years since my last project ;-)
The inputs will be low when the switches are pressed. Deal with that
and and debouncing in firmware. Make sure you don't have an ESD path
from charged fingers through any of the switchs through the
microcontroller to ground.

I have decided to switch that arrangement around so that the inputs go
high.......it helps my brain comprehend what is going on better!
It's fine. The regulator will start to drop out at around 7.2V from
the "9V" battery- a bit high if you're using a NiCd or NiMH.

Thanks for that.....I was planning on using a 9V alkaline as they are
readily available.

Snip
You might want to try running the LEDs at a lot less current to save
battery life. You're shunting the red LED off. This has a couple of
issues- it maximizes battery drain and it may unnecessarily cause you
to deal with Read-modify-write issues on the PIC. Also, if that output
is driven high instead of tri-stated you can get a very high current
through the LED. Better to connect the LED to +5, series resistor and
drive the output LOW to turn it "ON".

The red LED was shown with incorrect connections......this has now been
changed.
Also, put a 0.1uF ceramic capacitor across the rails near the chip.
The 10uF is unnecessary, but it won't hurt. Don't expect too much
sound level out of the piezo. BTW, there's some chance that a
mechanical shock on the piezo could indirectly lead to the
microcontroller burning up.

I will add the extra cap and I am now also looking at protecting against the
potential piezzo damage with a couple of diodes.
Tie RA7 and RA5 to ground or Vdd, set the other unused port pins to be
outputs.

Did you mean to +5V or Vdd or did you mean to ground or Vss??? I am confused
here. I will make all unused pins 'outputs' in the program when I get to
that stage. Do these need to be connected to ground too or is it ok to leave
them unconnected once they are set as outputs?

Thanks for the help.


Larry Green VE3YET
 
B

Byron A Jeff

Jan 1, 1970
0
-
--> In article <[email protected]>,
-> -
-> --> -> [snipped]
-> -
-Snip
-[And snip even more]

-> The reset is the MCLR pin. While I do believe that in many of the modern
-> PIC parts the reset can be internalized, most of the time PIC designers
-will
-> tie MCLR to +5 to ensure that it resets when powered on.
-
-Thanks for that and for safety I will tie the MCLR pin to +5V.
-
->
-> BTW I took a second look at the circuit. Care to explain the purpose of
-the
-> red LED D3? That's a very odd configuration to control an LED. Also I
-> believe that the current that a 150 ohm resistor allows at 5V (33ma)
-> exceeds the current capacity of a single PIC I/O pin (25ma absolute max).
-
-That was an error.......... :-( it should be connected between the OP and
-ground.

And you really need to raise the value on that resistor. In fact since this
is a battery powered circuit, you need to look into high efficiency LEDs
that are bright even at 2 ma. Then you'll probably want to go ahead and
blink them so that you can gain even more battery savings. So if they are
bright enough even at 40% duty cycle at 2ma then the average consumption
will be 0.8ma, a far cry from the nearly 60 ma of current you're consuming
now.

->
-> Also is the 9V a battery? Using a 7805 to regulate is quite wasteful. It
-> would be better to either power using 3 1.5V alkalines, or to switch to
-> something like Roman Black's ultra efficient, ultra cheap, switching
-> power supply: http://www.romanblack.com/smps.htm
-
-Yes the 9V is a battery (PP3 type). The device has to be portable and self
-contained. There are a couple of reasons I chose that option , I was hoping
-that the drain would be low enough to give a long life (and I may have to
-re-visit those resistor values on the push buttons)

A cheap power saving trick is use a PIC I/O pin as the power source to your
switches. Then tie the anode of a diode and a resistor for each switch.
Something like this (need a fixed width font to view)

+------------------- PIC I/O pin
|
PIC I/O pin --+---->|----/\/\/\/\/\---------+------/ -------GND
|
| +------------------- PIC I/O pin
| |
+---->|---/\/\/\/\/\----------+------/ -------GND
|
| +------------------- PIC I/O pin
| |
+---->|-----/\/\/\/\/\--------+------/ -------GND

Here's how it works: The I/O pin on the left supplies +5V to the circuit when
on. You can ground it or tri-state it to turn it off. When it's on the PIC
supplies a 4.4V (5V-diode drop) signal to the input inputs on the right via
the resistors. So if no switches are on, each will read a one.
Now if a switch is on then it will ground the I/O pin that it is connected to.
The diodes prevent one switch from affecting the others. So while it adds
3 diodes to the circuit, you eliminate the constant power draw that using
a pullup resistor for each switch will create.

- and they are readily
-available and not too difficult to connect (trying to avoid reverse polarity
-...KISS.......the diode protection is a back up!) plus I was hoping for +5V
-for quite a while before the voltage dropped too low for operation.

Not a chance. 9V are the least powerful of ordinary battery types. Then with
the 7805 you're throwing away 40 percent of your capacity. Then on top of that
the 7805 requires 2V or headroom so it goes out of regulation once you hit
7V. Then 9V batteries are ill equiped to pull a bunch of load, and in your
original circuit you are in the 70ma range. Of course with some of the tips
I've outlined above, along with making the pic either sleep or run real slow
using that multispeed internal oscillator, it'll help.

But the bottom line is that you are going to have to either run your circuit
directly from the battery, or you're going to have to use a high efficiency
switching power supply. There's really no middle ground here if you want to
get any type of decent battery life.

-I had
-looked at AA 1.5V battery holders but could only find 2 or 4 cell options
-and that added to the weight of the project. Would 4.5V be enough to drive
-the circuit (I know the 16F818 is a low power chip) or would the batteries
-die too quickly?

Yes 4.5V would be enough to drive it. However the voltage will drop off. 6V
regulated down to 5 with a switching regulator would give you more overall
power.

BAJ
 
A

Active8

Jan 1, 1970
0
Yes the 9V is a battery (PP3 type). The device has to be portable and self
contained. There are a couple of reasons I chose that option , I was hoping
that the drain would be low enough to give a long life (and I may have to
re-visit those resistor values on the push buttons) and they are readily
available and not too difficult to connect (trying to avoid reverse polarity
...KISS.......the diode protection is a back up!) plus I was hoping for +5V
for quite a while before the voltage dropped too low for operation. I had
looked at AA 1.5V battery holders but could only find 2 or 4 cell options
and that added to the weight of the project. Would 4.5V be enough to drive
the circuit (I know the 16F818 is a low power chip) or would the batteries
die too quickly?
NiCd batts are very lightweight compared to primary cells.

mike
 
A

Active8

Jan 1, 1970
0
I have decided to switch that arrangement around so that the inputs go
high.......it helps my brain comprehend what is going on better!
on the 'F628A, RB7-RB4 can be used as interrupts for the switches. you
can also set the weak pullup on those pins and set them to trigger the
interrupt on a falling edge ao that grounding them causes an interrupt.

this way, you don't have to poll the inputs to test for a switch press
and you don't have to debounce. adebounce is usually accomplished by
ignoring pulses after the first for say 50ms. now you have to leave the
interrupt flag set for 50ms IIRC or the switch bounce will trigger
another int.

those pins someone told you to tie high... thats osc in and /mclr. you
don't want the clock in or the /mclr floating. as for setting i/o pins
as output. you don't want them as floating inputs, either. TTL *and*
CMOS inputs are commonly grounded to keep the gates from oscillating,
but setting these i/o pins as outs eliminates the need to tie them to a
reference.

HTH,
mike
 
B

Byron A Jeff

Jan 1, 1970
0
-
--> On Tue, 21 Oct 2003 12:43:13 -0400, the renowned "Larry Green"
->
-> >Hi Folks,
-
-Snip
-
-> >
-> >The main area for concern is in the push button/de-bounce resistor
-> >arrangement.
->
-> You don't have any debouncing- the resistors are just pull-ups.
-
-My mistake, I did say it had been many years since my last project ;-)
-
->
-> > I have a suspicion that they may need reversing (i.e. the
-> >switch needs to be at the top and the resistor at the bottom). My 'logic'
-> >tells me it is wrong at the moment and the inputs will be 'high' at all
-> >times, however my rusty electronic theory brain cells tell me that due to
-> >current flow the circuit is correct as it stands.
->
-> The inputs will be low when the switches are pressed. Deal with that
-> and and debouncing in firmware. Make sure you don't have an ESD path
-> from charged fingers through any of the switchs through the
-> microcontroller to ground.
-
-I have decided to switch that arrangement around so that the inputs go
-high.......it helps my brain comprehend what is going on better!
-
->
-> >I am also concerned about
-> >the location of D2 which is acting as a reverse polarity protection
-device
-> >in case someone tries to connect the 9V battery backwards with the switch
-> >still in the 'on' position.
->
-> It's fine. The regulator will start to drop out at around 7.2V from
-> the "9V" battery- a bit high if you're using a NiCd or NiMH.
-
-Thanks for that.....I was planning on using a 9V alkaline as they are
-readily available.
-
-Snip
-
->
-> You might want to try running the LEDs at a lot less current to save
-> battery life. You're shunting the red LED off. This has a couple of
-> issues- it maximizes battery drain and it may unnecessarily cause you
-> to deal with Read-modify-write issues on the PIC. Also, if that output
-> is driven high instead of tri-stated you can get a very high current
-> through the LED. Better to connect the LED to +5, series resistor and
-> drive the output LOW to turn it "ON".
-
-The red LED was shown with incorrect connections......this has now been
-changed.
-
->
-> Also, put a 0.1uF ceramic capacitor across the rails near the chip.
-> The 10uF is unnecessary, but it won't hurt. Don't expect too much
-> sound level out of the piezo. BTW, there's some chance that a
-> mechanical shock on the piezo could indirectly lead to the
-> microcontroller burning up.
-
-I will add the extra cap and I am now also looking at protecting against the
-potential piezzo damage with a couple of diodes.
-
->
-> Tie RA7 and RA5 to ground or Vdd, set the other unused port pins to be
-> outputs.
-
-Did you mean to +5V or Vdd or did you mean to ground or Vss???

Yes. Spehro was saying to tie them to either rail, and it didn't matter
which one you choose.

- I am confused
-here. I will make all unused pins 'outputs' in the program when I get to
-that stage.

Right.

- Do these need to be connected to ground too

[Think of the Duke Brothers in "Trading Places" when Eddie Murphy asks if
he can break anything else...]


NOOOOOO!!!!!!!!

If for any reason those outputs become +5 you smoke the chip!


- or is it ok to leave
-them unconnected once they are set as outputs?

They must be unconnected. The only exception is if you use pullup/pulldown
reisistors, and with you battery application, you don't want to do that.

BAJ
 
B

Byron A Jeff

Jan 1, 1970
0
-On Tue, 21 Oct 2003 15:51:55 -0400, Larry Green said,
-> Yes the 9V is a battery (PP3 type). The device has to be portable and self
-> contained. There are a couple of reasons I chose that option , I was hoping
-> that the drain would be low enough to give a long life (and I may have to
-> re-visit those resistor values on the push buttons) and they are readily
-> available and not too difficult to connect (trying to avoid reverse polarity
-> ...KISS.......the diode protection is a back up!) plus I was hoping for +5V
-> for quite a while before the voltage dropped too low for operation. I had
-> looked at AA 1.5V battery holders but could only find 2 or 4 cell options
-> and that added to the weight of the project. Would 4.5V be enough to drive
-> the circuit (I know the 16F818 is a low power chip) or would the batteries
-> die too quickly?
->
->
-NiCd batts are very lightweight compared to primary cells.

And with a 1.25V output voltage 4 of them would be 5V! And it could be
rechargable too!

BAJ
 
S

Spehro Pefhany

Jan 1, 1970
0
Did you mean to +5V or Vdd or did you mean to ground or Vss??? I am confused
here. I will make all unused pins 'outputs' in the program when I get to
that stage. Do these need to be connected to ground too or is it ok to leave
them unconnected once they are set as outputs?

The particular pins I mention CANNOT be made into outputs, so I
suggest you tie them to either supply rail.

If a pin *can* become an output, it's better to either leave them open
and set them as outputs early on in the program or tie them to a
supply rail through individual resistors (but that's a bit anal for a
hobby circuit).

Best regards,
Spehro Pefhany
 
L

Larry Green

Jan 1, 1970
0
Byron A Jeff said:
-
--> In article <[email protected]>,
-> -
-> --> -> [snipped]
-> -
-Snip
-[And snip even more]

And snipped again
And you really need to raise the value on that resistor. In fact since this
is a battery powered circuit, you need to look into high efficiency LEDs
that are bright even at 2 ma. Then you'll probably want to go ahead and
blink them so that you can gain even more battery savings. So if they are
bright enough even at 40% duty cycle at 2ma then the average consumption
will be 0.8ma, a far cry from the nearly 60 ma of current you're consuming
now.

I will look for the high efficiency LEDs as nothing has been purchased for
this project yet.
->
-> Also is the 9V a battery? Using a 7805 to regulate is quite wasteful. It
-> would be better to either power using 3 1.5V alkalines, or to switch to
-> something like Roman Black's ultra efficient, ultra cheap, switching
-> power supply: http://www.romanblack.com/smps.htm
-
-Yes the 9V is a battery (PP3 type). The device has to be portable and self
-contained. There are a couple of reasons I chose that option , I was hoping
-that the drain would be low enough to give a long life (and I may have to
-re-visit those resistor values on the push buttons)

A cheap power saving trick is use a PIC I/O pin as the power source to your
switches. Then tie the anode of a diode and a resistor for each switch.
Something like this (need a fixed width font to view)

+------------------- PIC I/O pin
|
PIC I/O pin --+---->|----/\/\/\/\/\---------+------/ -------GND
|
| +------------------- PIC I/O pin
| |
+---->|---/\/\/\/\/\----------+------/ -------GND
|
| +------------------- PIC I/O pin
| |
+---->|-----/\/\/\/\/\--------+------/ -------GND

Here's how it works: The I/O pin on the left supplies +5V to the circuit when
on. You can ground it or tri-state it to turn it off. When it's on the PIC
supplies a 4.4V (5V-diode drop) signal to the input inputs on the right via
the resistors. So if no switches are on, each will read a one.
Now if a switch is on then it will ground the I/O pin that it is connected to.
The diodes prevent one switch from affecting the others. So while it adds
3 diodes to the circuit, you eliminate the constant power draw that using
a pullup resistor for each switch will create.

OK.......but would I need to do that as the push buttons are of the
momentary type and will only be 'active' for a split second? It is not as if
they are going to be turned on for any length of time. Once the pin has gone
high there is no need to continue holding the button.
- and they are readily
-available and not too difficult to connect (trying to avoid reverse polarity
-...KISS.......the diode protection is a back up!) plus I was hoping for +5V
-for quite a while before the voltage dropped too low for operation.

Not a chance. 9V are the least powerful of ordinary battery types. Then with
the 7805 you're throwing away 40 percent of your capacity. Then on top of that
the 7805 requires 2V or headroom so it goes out of regulation once you hit
7V. Then 9V batteries are ill equiped to pull a bunch of load, and in your
original circuit you are in the 70ma range. Of course with some of the tips
I've outlined above, along with making the pic either sleep or run real slow
using that multispeed internal oscillator, it'll help.

But the bottom line is that you are going to have to either run your circuit
directly from the battery, or you're going to have to use a high efficiency
switching power supply. There's really no middle ground here if you want to
get any type of decent battery life.

The device has to be portable and self contained so battery power is a must
as it will be used out doors with no external power available.
-I had
-looked at AA 1.5V battery holders but could only find 2 or 4 cell options
-and that added to the weight of the project. Would 4.5V be enough to drive
-the circuit (I know the 16F818 is a low power chip) or would the batteries
-die too quickly?

Yes 4.5V would be enough to drive it. However the voltage will drop off. 6V
regulated down to 5 with a switching regulator would give you more overall
power.

Ok......so are we looking at something like a LM2576 here (see the following
url for spec. sheet)

http://www.national.com/ds/LM/LM2576.pdf

although the cost may go up going this way as the regulator and auxiliary
components cost more than the 7805 but then again the savings in batteries
would probably make up the difference in a short space of time. I suppose
that switching to 4 x 1.5 AA batteries could also mean that rechargeable
NiMH batteries could be a possibility too.

Larry Green VE3YET
 
L

Larry Green

Jan 1, 1970
0
Spehro Pefhany said:
The particular pins I mention CANNOT be made into outputs, so I
suggest you tie them to either supply rail.

If a pin *can* become an output, it's better to either leave them open
and set them as outputs early on in the program or tie them to a
supply rail through individual resistors (but that's a bit anal for a
hobby circuit).

I've got it now......thanks!

Larry
 
Top