Searching \ for 'Inputs' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ios.htm?key=input
Search entire site for: 'Inputs'.

No exact or substring matches. trying for part
PICList Thread
'Ports And Clocks Inputs'
1997\07\31@143713 by Tejpal Singh

flavicon
face
Hi,

I am using the PIC 17cxx series.  I want to use the pin 15(RB4/TCLK12) as
the external clock input for the timer 1.  If I do this by setting the
appropriate bits in the Timer1 configuration registers, will the Port B
peripheral interrupt still cause an interrupt on every change in level of
the external clock signal, as every port B pin configured in the input mode
causes an interrupt on the change in level. I also want the other port B
pins to cause on the level change.

Do I also have to configure the pin for the input mode?

TIA.


-------------------------
Tejpal Singh,
River Run Software Group
4815 Emperor Blvd. #100
DURHAM, NC 27703 (USA)
Ph#  (919) 941-0722
Fax# (919) 941-0527
-------------------------


'Ports And Clocks Inputs'
1997\08\01@104213 by Tejpal Singh
flavicon
face
Hi,

I am using the PIC 17cxx series.  I want to use the pin 15(RB4/TCLK12) as
the external clock input for the timer 1.  If I do this by setting the
appropriate bits in the Timer1 configuration registers, will the Port B
peripheral interrupt still cause an interrupt on every change in level of
the external clock signal, as every port B pin configured in the input mode
causes an interrupt on the change in level. I also want the other port B
pins to cause on the level change.

Do I also have to configure the pin for the input mode?

TIA.

-------------------------
Tejpal Singh,
River Run Software Group
4815 Emperor Blvd. #100
DURHAM, NC 27703 (USA)
Ph#  (919) 941-0722
Fax# (919) 941-0527
-------------------------


'Floating Inputs'
1997\12\06@044621 by Dave Celsnak
flavicon
face
Does the PIC require it's Analog-to-Digital Convertor inputs to be tied
down if unused?   I am using the PIC 16c72 with 5 A/D Channels.  If the
consumer of my product forgets to install one of the analog inputs, will
the on-chip A/D's have any problems 'floating'?

Thank you,               6500
                             7000
Dave Celsnak                    ___7500
                              / /     8000     (Shift!)
                            /-/
                          / /              RPM
                        / /
                      / /

1997\12\06@103617 by Michael S. Hagberg

flavicon
face
i just tie the input with a 1Mohm resistor to either Vcc or Gnd. if either
max or zero count is outside the normal reading then you know that either
the sensor failed or is not connected.


michael


{Original Message removed}

'3 pushbuttons to 2 inputs?'
1997\12\22@112658 by Jason Wolfson

flavicon
face
part 0 813 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
Does anyone have any clever, low parts count
methods of multiplexing 3 pushbuttons onto
2 port pins?
 
Thanks
Jason Wolfson
Lipidex Corp
 
jason@lipidex.com

1997\12\22@130637 by Philip Martin

flavicon
picon face
In article <01bd0ef3$be656600$spam_OUTb04206d1TakeThisOuTspamlipidex.ma.ultranet.com>, Jason
Wolfson <.....jasonKILLspamspam@spam@LIPIDEX.COM> writes
>Does anyone have any clever, low parts count
>methods of multiplexing 3 pushbuttons onto
>2 port pins?
>
>Thanks
>Jason Wolfson
>Lipidex Corp
>
>jasonspamKILLspamlipidex.com
Easy,

Switch one connects to pin one.
Switch two connects to pin two.

Switch three connects to both pin one and two, each connection via an
IN4148 diode.

Would have done it in asci picture but my art is crap:-)

--
Philip Martin   ----------------------------------------------------------------
Royal Quays             If at first you don't succeed, try again. Then quit:
North Shields.          no use being a damn fool about it !
                                                       W.C. Fields
email .....philipKILLspamspam.....philmart.demon.co.uk

1997\12\22@132651 by John Payson

picon face
> Switch one connects to pin one.
> Switch two connects to pin two.
>
> Switch three connects to both pin one and two, each connection via an
> IN4148 diode.

Slightly easier approach:

[1] Switch one connects pin one to ground
[2] Switch two connects pin two to ground
[3] Switch three connects pin one to pin two

To read switches one and two, set the port pins to input (with pullups
enabled).  To read switch three, ground one port pin and read the other.

I've managed to get eight switches with 2 I/O pins and one input-only pin
using only two resistors as external components.  In practice, I'd say it's
usually better not to scrunch things quite that much.

1997\12\22@135624 by Dmitry Kiryashov

flavicon
face
Jason Wolfson wrote:
>
> Does anyone have any clever, low parts count
> methods of multiplexing 3 pushbuttons onto
> 2 port pins?

Just ideas:

1.
First PIC pin (in output mode) clock a shift register with running
"0" or "1". Shift register switch the keys. To eliminate the additional
switches apply shift register with open collector outputs.
First PIC pin (in input mode) read the out of 1-st cascade of the shift
register to detect situation when scan impulse placed in first position.
(clocking and reading through the one pin require additional elements
such as resitors and transistor(or diode) )
Second PIC pin read the keys level.

2.
First PIC pin through simple low-pass RC filter connected to data input
of shift register and directly connected to clock input of register.
To write "1" to register send the following pulse: (shift register have
to be fall_clocked)
+--------------+
|              V
-+              +----

To write the "0" to register send another pulse:
               +--+
               |  V
----------------+  +-

Due to that trick you have ability to write any information into shift
register.
Second PIC pin read the keys level(the same as in 1-st idea).

But i think will be much easy to add third PIC pin and scan keys
directly.

WBR Dmitry.

1997\12\22@142119 by Dmitry Kiryashov

flavicon
face
John Payson wrote:
>
> > Switch one connects to pin one.
> > Switch two connects to pin two.
> >
> > Switch three connects to both pin one and two, each connection via an
> > IN4148 diode.
>
> Slightly easier approach:
>
> [1] Switch one connects pin one to ground
> [2] Switch two connects pin two to ground
> [3] Switch three connects pin one to pin two
>
> To read switches one and two, set the port pins to input (with pullups
> enabled).  To read switch three, ground one port pin and read the other.

To detect one key this method work fine. But this method don't allow
to detect keys combinations. For example Sw_1+Sw_2 result to the same
scan code as Sw_2+Sw_3 or Sw_1+Sw_3 (00_0).

WBR Dmitry.

1997\12\22@143559 by Robert Nansel

flavicon
face
Jason Wolfson wrote:
--------8<--------
>>Does anyone have any clever, low parts count
>>methods of multiplexing 3 pushbuttons onto
>>2 port pins?
--------8<--------

Then Philip Martin replied:

--------8<--------
>Easy,
>
>Switch one connects to pin one.
>Switch two connects to pin two.
>
>Switch three connects to both pin one and two, each connection via an
>IN4148 diode.
--------8<--------

The problem with this (which may not be a problem, depending on the
application) is that you can't distinguish between switch 3 being pressed
vs. switches 1 & 2 being pressed simultaneously. Without some kind of
lockout circuitry in the encoder, there's no way to do this with just a
diode/resistor matrix alone.

That being said, you might be able to do something using diodes & pullup
resistors in conjunction with time multiplexing code to sort out which
switch (or combination) is being pressed. It would go something like this:

B0, B1 are the I/O pins, SW1-SW3 are the switches. SW1 is connected between
B0 & B1 with its diode D1 in series, and SW2 its diode D2 are connected
antiparallel. SW3 is connected to both B0 & B1 through two steering diodes,
D3 & D4:



                      Vcc
 SW3                   |
    __I__              R1
                +      |                           |
+---o   o---o----D3----o--------o----------o-------| B0
|           |                   |          |       |
R3          |             SW1 | o    SW2 | o       |
|           |                -|         -|         |
Gnd          |                 | o        | o       |
            |                   |          |       |
            |         Vcc       |+         |       |
            |          |        D1         D2      |
            |          R2       |          |+      |
            |   +      |        |          |       |
            +----D4----o--------o----------o-------| B1
                                                   |





To read the status of the switches, you must set the TRIS & data bits so as
to cycle B0 and B1 through the following three states:


    B1         B0               Meaning
---------------------------------------------------------

State 0
  out low    in high        Neither SW2 nor SW3 pressed
  out low    in low         SW2 OR SW3 pressed

State 1
  in high    out low        Neither SW1 nor SW3 pressed
  in low     out low        SW1 OR SW3 pressed

State 2
  in low     in low         SW3 pressed
  in high    in high        No switch pressed



Just a little more work will allow you to figure exactly which switch is
pressed.

Note: I haven't tested this, but it seems as if it should work. No doubt
others will spot any errors or shortcomings.

--BN


----------------------------------------------------------------------------
  Country Robot            "Modular robot components
  69 S. Fremont Ave. # 2     for education and industry"
  Pittsburgh, PA 15202
----------------------------------------------------------------------------

1997\12\22@144207 by John Payson

picon face
> To detect one key this method work fine. But this method don't allow
> to detect keys combinations. For example Sw_1+Sw_2 result to the same
> scan code as Sw_2+Sw_3 or Sw_1+Sw_3 (00_0).

I don't think there are any particularly good/reliable approaches for
detecting more than two buttons with two port pins that can deal with
combinations of buttons being pressed.  The closest thing I could
suggest would be wiring buttons with different resistors and using an
RC-timer based approach; not sure that would be 100% reliable, though.

1997\12\22@150521 by Dmitry Kiryashov

flavicon
face
Robert Nansel wrote:

Excellent idea, but check polarity of D3 & D4. With polarity shown in
you
schematic SW3 seems to be never scanned.

WBR Dmitry.

{Quote hidden}

1997\12\22@151606 by Dmitry Kiryashov

flavicon
face
Hello John.

> I don't think there are any particularly good/reliable approaches for
> detecting more than two buttons with two port pins that can deal with
> combinations of buttons being pressed.  The closest thing I could
> suggest would be wiring buttons with different resistors and using an
> RC-timer based approach; not sure that would be 100% reliable, though.

Why not? There are method with additional external shift register.
It have excellent reliabilty (i practically use it).
First PIC pin clock the shift register ( D input through the low pass RC
and \C input directly ) I post idea to PICLIST some minutes before.
Register with open collector's outputs. The keys wired directly to
register output.

Second PIC pin read the second common wire of key's matrix.

I apply this method to scan up to 16 keys matrix with two PIC pins.
(One additional shift register chip + RC)

WBR Dmitry.

1997\12\22@153046 by Andrew Mayo

flavicon
face
There is another method, which I have tried, and it does work, but may
offend the squeamish. It requires only 1 port pin. Basically it involves
connecting the three switches through three different resistors to +5V.
Values of say, 10K,22K and 47K would do, from memory. The other side of
the switches is joined to form a rail, connected back to a schmitt
trigger input on the PIC. A small capacitor (0.1uF) is connected to
ground from this rail.

To scan the switches,turn this line into an output and pull it low. (you
could place a small series resistor like 470 ohms in there if you feel
nervous about discharging the cap directly into the PIC).

Then you turn the line into an input and loop, counting, (or use the
RTC) until the input line reads logic 1. Depending on the time this
took, you can deduce which switch or switches were pressed. If nothing
happens by the maximum time (depends on RC), then no switches were
pressed. Essentially you are doing a single-slope integrating A/D
conversion.

It does work, and due to the nature of CMOS, the switching point for the
input is fairly temperature-independent, and given that modern resistors
and capacitors are quite stable, this seems to be quite effective. Of
course, it can take a millisecond or more to scan the switches....

{Quote hidden}

'Correction: 3 pushbuttons to 2 inputs'
1997\12\22@154858 by Robert Nansel

flavicon
face
>Robert Nansel wrote:
>
>Excellent idea, but check polarity of D3 & D4. With polarity shown in
>you
>schematic SW3 seems to be never scanned.
>
>WBR Dmitry.
>
-------8<--------
{Quote hidden}

-------8<--------

The schematic is correct, but I see now that I used a confusing convention
for diode polarity. Thanks for pointing that out.

I meant the "+" sign to indicate the direction current would flow FROM the
diode when forward biased (instead of the more usual direction of current
flow INTO the diode).

Your way is more logical, though, so here's how the original circuit would
look with the "+" representing the ANODE of the diode:


                      Vcc
 SW3                   |
    __I__              R1
                   +   |                           |
+---o   o---o----D3----o--------o----------o-------| B0
|           |                   |          |       |
R3          |             SW1 | o    SW2 | o       |
|           |                -|         -|         |
Gnd          |                 | o        | o       |
            |                   |          |       |
            |         Vcc       |          |+      |
            |          |        D1         D2      |
            |          R2       |+         |       |
            |      +   |        |          |       |
            +----D4----o--------o----------o-------| B1
                                                   |



Again, the "+" indicates the direction current will flow INTO the diode
when it is forward biased.

With programmable pullups on B0 & B1, R1 & R2 can be eliminated. If you
want to gamble that the code will never set either B0 & B1 as high outputs,
you could even eliminate R3, though I wouldn't.

--BN


----------------------------------------------------------------------------
  Country Robot            "Modular robot components
  69 S. Fremont Ave. # 2     for education and industry"
  Pittsburgh, PA 15202
----------------------------------------------------------------------------

1997\12\22@175338 by Dmitry Kiryashov

flavicon
face
Hello Robert.

After i look second time to your schematic i understood that you idea
have the
same misadvantage as John idea - the Sw_3 being pressed lock the other
keys.

It seems to be no way easily than John offer without disadvantages of
John's idea.
(impossibility to detect multi-key combinations)

WBR Dmitry.

{Quote hidden}

'3 pushbuttons to 2 inputs?'
1997\12\22@183812 by Craig R. Autio

flavicon
face
part 0 2324 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
 
{Original Message removed}

1997\12\22@205400 by DREITEK

picon face
In a message dated 97-12-22 15:33:02 EST, you write:

<<
There is another method, which I have tried, and it does work, but may
offend the squeamish. It requires only 1 port pin. Basically it involves
connecting the three switches through three different resistors to +5V.
Values of say, 10K,22K and 47K would do, from memory. The other side of
the switches is joined to form a rail, connected back to a schmitt
trigger input on the PIC. A small capacitor (0.1uF) is connected to
ground from this rail.
 >>
Don't feel squeamish! This technique works well and is quite reliable.  A lot
of the old VCRs with wired remote use exactly this same trick.  I have used it
on several products.  In fact in one case it totaly blew away an engineer that
was hired to reverse engineer my design.  He couldn't figure out how I used 1
bit to read a 5 position rotary switch, and wound up redesigning it from
scratch!.  I used a pic84 and a single PCB (This was all very small for a hand
held medical instrument)  He had to use a PIC73 and two boards sandwiched
together!
His design failed in the field because of surface mount connector failure
between the two boards.  They only made a hand full of his design and then
went out of business!

Good luck
Dave Duley

1997\12\23@022159 by Pasi T Mustalahti

picon face
On Mon, 22 Dec 1997, Jason Wolfson wrote:

> Does anyone have any clever, low parts count
> methods of multiplexing 3 pushbuttons onto
> 2 port pins?
>
> Thanks
> Jason Wolfson
> Lipidex Corp
>
> @spam@jasonKILLspamspamlipidex.com
>
PTM: First approximation: 74147.

If you only have one finger, you can do like this:

       + ------X----X-----X                    V  =diode
               |    |     SC                   Sx =switch
               V    V     V                    X  =connection
               SA   SB    X-X                  R  =resistance
               |    |     | |
               X----------X------------ PB0
                    |       |
                    X-------X---------- PB1
                    R       R
       - -----------X-------X
Here the SC switch gives the same code as SA and SB pressed together.
--------------------------------------------------------------------------
PTM, KILLspampasi.mustalahtiKILLspamspamutu.fi, RemoveMEptmustaTakeThisOuTspamutu.fi, http://www.utu.fi/~ptmusta
Lab.ins. (mikrotuki) ATK-keskus/Mat.Luon.Tdk                    OH1HEK
Lab.engineer (PC support) Computer Center                       OI7234
Mail: Turun Yliopisto / Fysla, Vesilinnantie 5, 20014
Pt 02-3336669, FAX 02-3335632 (Pk 02-2387010, NMT 049-555577)
--------------------------------------------------------------------------

'Correction: 3 pushbuttons to 2 inputs'
1997\12\23@071542 by paulb

flavicon
face
Robert Nansel wrote:

> The schematic is correct, but I see now that I used a confusing
> convention for diode polarity. Thanks for pointing that out.

 No, Robert, you used the CORRECT convention in the first place.
Please do not use another!

 The plus sign goes on the cathode and corresponds to the "band" on the
body of the diode.  It indicates which side of the diode develops a
positive voltage when used in a rectifier circuit (which is what diodes
were originally used for!).  If in a rectifier circuit, you put a DC
meter across it, this side will register the positive voltage.

 Cheers,
       Paul B.

'Thanks 3 buttons to 2 inputs'
1997\12\23@091218 by Jason Wolfson

flavicon
face
part 0 2170 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
Thanks for all the feedback on my 3 button to 2 input 
question.
 
I was thinking about John Payson's approach of botton 3 shorting 1 and 2, but I wanted to
make this interrupt driven since it will be a low use input. That would have to be scanned...
 
besides if I take anymore advice from John on this project
I'm going to have to put his name on the schematics :)
 
The dual diode approach using RB6 and RB7, with a common
cathode SOT-23 device only adds one small part and with it INT
driven, it will be very hard to hit both buttons at exactly the same time.
Once I get an INT and read the pins I will not re enable INTs until I read
11 on the port again for a DEBOUCE length of time....etc.....
 
I'm keeping in mind Dave Duley's 1 pin RC approach though!
 
Thanks again all.
Jason Wolfson


'16C6X inputs'
1998\02\11@201611 by Calvin
flavicon
face
Does anyone know the input protection of the 16c6x series pics?
I know the c5x series have 2 clamping diodes on each input (but MCLR, this
only has one), but I have not been able to find any info for the midrange
PICs. I have checked the Data Sheets to no avail... :(

TIA

Gabriel Gonzalez
TGO Electronics

1998\02\11@210016 by JULIO CARBALLO

flavicon
face
part 0 558 bytes
                                       saludos julio

----------
De:             Calvin[SMTP:spamBeGonetgospamBeGonespamCHIH1.TELMEX.NET.MX]
Enviado:        MiŽrcoles 11 de Febrero de 1998 8:16 AM
Para:           TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU
Asunto:         16C6X inputs

Does anyone know the input protection of the 16c6x series pics?
I know the c5x series have 2 clamping diodes on each input (but MCLR, this
only has one), but I have not been able to find any info for the midrange
PICs. I have checked the Data Sheets to no avail... :(

TIA

Gabriel Gonzalez
TGO Electronics


1998\02\12@033757 by Mike Keitz

picon face
On Wed, 11 Feb 1998 07:16:22 -0600 Calvin <RemoveMEtgospamTakeThisOuTCHIH1.TELMEX.NET.MX>
writes:
>Does anyone know the input protection of the 16c6x series pics?
>I know the c5x series have 2 clamping diodes on each input (but MCLR,
>this
>only has one), but I have not been able to find any info for the
>midrange
>PICs.

The port hardware is almost the same.  On the 16C5X, the RTCC input pin
also lacks a diode to Vdd.  The major difference with the 14-bit PICs is
that PORTB has pull-up devices which can be enabled.

>I have checked the Data Sheets to no avail...

The notes in Figures 5-1, 5-2, and 5-3 of the 16C6x data sheet indicate
that all port pins except RA4 have diodes to Vdd and Vss (RA4 only has a
diode to Vss).  The RA4 pin is analogous to the RTCC pin on the 16C5x
PICs.

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


'BS1 vs BS2 Inputs'
1998\08\02@192817 by parkiss
picon face
I've got a problem that's driving me nuts.  My BS2 (PIC16C57-based)
reads a serial stream just fine, while my BS1 (PIC16C56-based)
refuses to handle the same input stream correctly.

Is there something different about the input interface
characteristics that might explain this (noise immunity, thresholds,
whatever)?  Would greatly appreciate any opinions, wild guesses,
advice...

Thanks,

Steve


'115 VAC inputs to PIC direct (again)'
1998\09\22@115416 by Harrison Cooper
flavicon
face
We have talked about this before, but I can't seem to find the saved
mail.

This brings up an interesting item.  The current limited/voltage dropped
110 VAC inputs (2M resistor), is this limited to only the F84?  I've
done this on a '54, but as a interrupt for 50/60 Hz cycles to determine
what the mains frequency is.

My current project needs to monitor 8 115 VAC loops, for just activity.
I have 3 approaches.  Use HCPL3700 AC to DC optocouplers (works great,
gives isolation but $5.00 per input).  Second, use a '54 to only monitor
the inputs and send the data to the main controller.  No isolation, but
does isolate from main controller.  Direct to the C64, the main
controller.  I'd prefer the third, as it eliminates the '54 to act as
the go between.  But does the '64 allow 115VAC inputs?

Also, I have yet to prove I can do this.  I figure that I would sample
each input such that I would hit at least 2 or 3 times in the cycle, and
if the input was high, indicating the input was cycling, write to a
register to hold this value.  If during the sampling, nothing was high,
it would indicate a low, and thus write to the temp register.  Then I
could just look at this register and determine if any inputs were
active.  Now, the main controller is going to be busy, so offloading to
another pic might make sense, even tho it would be waste of the
controller power, it would offer some isolation and just have to send
the data to the main control.

The other alternate solution is to use the standard industrial 24 VDC
solution, but I am wary of using DC in a noisy environment.

Comments?


'Protecting ADC inputs'
1998\10\19@120953 by Steve Parker
flavicon
face
      Hi there folks!

          I am currently contemplating the risk of damage to my humble
      16C71JW. Basically I am powering it with 5V, but I have the o/p
      of a dual rail OP AMP going to one of the ADC inputs. The OP AMP
      is capable of swinging to +/- 9V and I am therefore worried. I
      have put a 1K series resistance prior to the pin and a 5V6 Zener
      from the pin to earth. However, this is a bit hit and miss and I
      would love to be told the proper way to protect the i/p by some
      experts.
            Yours hoping for a technical slapping!!

                        Steve Parker

1998\10\19@163205 by Harold Hallikainen

picon face
On Mon, 19 Oct 1998 15:22:27 BST Steve Parker
<Steve.ParkerEraseMEspam.....SRC.BAE.CO.UK> writes:
>       Hi there folks!
>
>           I am currently contemplating the risk of damage to my humble
>       16C71JW. Basically I am powering it with 5V, but I have the o/p
>       of a dual rail OP AMP going to one of the ADC inputs. The OP AMP
>       is capable of swinging to +/- 9V and I am therefore worried. I
>       have put a 1K series resistance prior to the pin and a 5V6 Zener
>       from the pin to earth. However, this is a bit hit and miss and I
>       would love to be told the proper way to protect the i/p by some
>       experts.


       Since the PICs have internal clamp diodes, I'd say the zener is
not required.  I'd also set the resistor to the maximum the PIC A/D will
allow without error (10K, I believe).  I've got a circuit where one end
of a 24VCT transformer (center tap grounded) is driving the INT input of
a PIC through a 10K resistor.  The PIC clamls it great!

Harold



Harold Hallikainen
EraseMEharoldspamhallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm




___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

1998\10\19@170654 by Bob Blick

face
flavicon
face
> >           I am currently contemplating the risk of damage to my humble
> >       16C71JW. Basically I am powering it with 5V, but I have the o/p
> >       of a dual rail OP AMP going to one of the ADC inputs. The OP AMP
> >       is capable of swinging to +/- 9V and I am therefore worried. I
> >       have put a 1K series resistance prior to the pin and a 5V6 Zener
> >       from the pin to earth. However, this is a bit hit and miss and I

There's two or three things you need to consider. The PIC has clamp diodes
to the supply rails, so you could just use a series resistor and forget
the zener. However, If your PIC and whatever loads it drives consumes less
than 3 milliamps, you could raise the PIC's supply rail when your opamp
drives high. You could increase the value of the resistor to 10k, and no
longer have that problem, but 10k is about 9k higher than I like to have
the source impedance to an ADC. You'll get errors on the order of 2 bits
under some conditions(especially on the channel next to the crystal pin).
You could put a .01 cap from the ADC pin to ground to zero out the high
impedance, but then you've increased the settling time you'll get out of
the opamp.

As your attorney <grin> I commend you on your choice of parts and advise
you to stick with the 1k resistor and 5.6v zener.

Cheers,
Bob

1998\10\19@193852 by Chris Eddy

flavicon
face
One more comment on this item, I have found that when a negative voltage is
exposed to a channel, the other analog channels go ballistic.  If you use
more than one channel on the 7X family, I strongly suggest using single
supply front end circuitry only.

Chris Eddy

Steve Parker wrote:

{Quote hidden}

1998\10\19@195351 by Dwayne Reid

flavicon
face
>           I am currently contemplating the risk of damage to my humble
>       16C71JW. Basically I am powering it with 5V, but I have the o/p
>       of a dual rail OP AMP going to one of the ADC inputs. The OP AMP
>       is capable of swinging to +/- 9V and I am therefore worried. I
>       have put a 1K series resistance prior to the pin and a 5V6 Zener
>       from the pin to earth. However, this is a bit hit and miss and I
>       would love to be told the proper way to protect the i/p by some
>       experts.

Personally, I use a 10K series resistor, sometines with the zener, mostly
without.  Be aware that voltages that exceed (VCC + 0.5V) or (GND - 0.5V)
can cause erroneous readings on other a/d inputs on the chip.  No damage -
just bad readings.

I don't like using zener clamps because of their leakage currents.

If I am multiplexing a large number of inputs into the 'c71 with external
muliplexors (4051 or 4052), I dedicate 1 mux input from each a/d channel
used on the '71 to a known voltage.  What I mean is: if I am using a pair of
muxes to 2 inputs on the '71, 1 input from each mux reads a known voltage
(1/3 VCC, 2/3 VCC).  If those voltages read wrong, it means that one or more
of the other MUX inputs is out of range and I can't trust any of the
readings.  I take action accordingly (show the error and go fail-safe).

Hope this helps.

dwayne


Dwayne Reid   <RemoveMEdwaynerEraseMEspamEraseMEplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(403) 489-3199 voice     (403) 487-6397 fax

1998\10\19@230133 by Mike Keitz

picon face
On Mon, 19 Oct 1998 19:53:51 -0400 Dwayne Reid <RemoveMEdwaynerspam_OUTspamKILLspamPLANET.EON.NET>
writes:

>Personally, I use a 10K series resistor, sometines with the zener,
>mostly
>without.  Be aware that voltages that exceed (VCC + 0.5V) or (GND -
>0.5V)
>can cause erroneous readings on other a/d inputs on the chip.  No
>damage -
>just bad readings.

>I don't like using zener clamps because of their leakage currents.

Put the zener on the other end of the resistor -- directly at the op-amp
output.  The PIC diodes will see only small currents through the resistor
since the voltage on the other side is only 5.6 V.  Nearly all op-amps
have current limited outputs (to 10 or 20 mA) that won't mind running
into a zener for a while.  The op amp's feedback will null out any
leakage through the zener.  Of course the supply current will increase
considerably while the output voltage is being clamped.

Better performance with the voltage at the negative limit may be possible
using a Schottky diode in parallel with the zener to clamp to a less
negative level.  The forward voltage drop of a zener is higher than even
a regular silicon diode.  Or place a pull-up resistor to 5V on the PIC
side so even when the op-amp output/diode voltage is negative, the PIC
input is positive.  With that circuit, the input voltage will be shifted
and rescaled some.

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

1998\10\20@134405 by John Payson

flavicon
face
part 0 1494 bytes
I personally don't usually bother with zeners on PIC inputs, given the
existence of clamp diodes; a zener between VDD and ground may be a good
idea, though, since PICs generally don't like excessive VDD's.

The 1K resistor's probably a pretty good call; I had a 1K between the
tap on a pot (0-5V) and the PIC, and found it to be adequate even when
a ground loop put 120VAC on that pot; the 1K resistor blew open, but
the PIC was undamaged.  When people say PICs are indestructible, believe
'em.  The following is a rough catalog of non-OTP PIC's I've destroyed:

16C84 -- Accidentally connected RB6 to about 90VDC @unlimitted current.
 Remainder of chip worked fine, but couldn't reprogram without that
 pin.

16C622's (a few) -- Eventually wore out due to problem in programming
 software (the prog. pulses were sometimes too long).

12C508's -- Some OTP's of these failed for the same reason as the 622's
 above.

17C756 -- Mis-inserted into hand-built programming fixture (no current-
 limit on that one).  One of the bonding wires was sorta glowing (it
 was a window part--OUCH!)

16C925 -- Applied VPP without VDD and tried to program (was ICSP'ing and
 didn't have enough juice on my prog'ger to power VDD).

Plus probably a half dozen or so PICs of various types whose legs gave
out from too many insertion/removal cycles.  If you look through the
list, only one failure was due to something other than a programming or
handling failure, and that's going through a LOT of chips.

1998\10\20@154049 by Harold Hallikainen

picon face
On Tue, 20 Oct 1998 12:42:38 -0500 John Payson <RemoveMEsupercatTakeThisOuTspamspamCIRCAD.COM>
writes:

>'em.  The following is a rough catalog of non-OTP PIC's I've
>destroyed:
>
>16C84 -- Accidentally connected RB6 to about 90VDC @unlimitted
>current.
>  Remainder of chip worked fine, but couldn't reprogram without that
>  pin.
[deletia]
>17C756 -- Mis-inserted into hand-built programming fixture (no
>current-
>  limit on that one).  One of the bonding wires was sorta glowing (it
>  was a window part--OUCH!)
>


       Sure glad that wasn't a PicMaster Emulator!  Gets kinda
expensive!  In general, all my PIC stuff has only +5V on the board, so
damage possiblity is limited.  Recently I had a 16c74a driving a serial
DAC driving a 4051 demux, driving a 324 op amp.  Accidentally shorted the
+15V on the 324 to an input, blowing the 4051 and the DAC.  Luckily it
did not get back to the PicMaster!

Harold


Harold Hallikainen
EraseMEharoldspamspamspamBeGonehallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

1998\10\20@174625 by John Payson

flavicon
face
part 0 1044 bytes
In all fairness to makers of emulators, how often is an emulator
useful for anything other than the code download ability (which
exists semi-natively in the 16C84/16F84 as well as many of Atmel's
parts)?  I have used emulators myself, and have on some occasions
made use of the live debugging facilities they offered, but often
I find the extra bulk of the emulator (having to balance everything
on the desk, etc.) to be a major nuisance.

I think the philosophy in the micro industry is that anyone who's
anyone will spend $10K-$20K on emulation equipment for any micro
they're going to use, and at the very bottom of the scale that
philosophy sorta makes sense (some 4-bit micros don't exist AT ALL
in anything other than mask-ROM versions).  In the PIC range, though,
I think in-circuit-erasable-programmable micros are in many cases as
useful as emulators, if not moreso (no giant ribbons hanging around);
I'm pained by the fact that we **STILL** don't have anything bigger
than the 16x84 in such a configuration...

[soap box mode off]



1998\10\20@215854 by Harold M Hallikainen

picon face
On Tue, 20 Oct 1998 16:46:27 -0500 John Payson <RemoveMEsupercatKILLspamspamCIRCAD.COM>
writes:
>In all fairness to makers of emulators, how often is an emulator
>useful for anything other than the code download ability (which
>exists semi-natively in the 16C84/16F84 as well as many of Atmel's
>parts)?  I have used emulators myself, and have on some occasions
>made use of the live debugging facilities they offered, but often
>I find the extra bulk of the emulator (having to balance everything
>on the desk, etc.) to be a major nuisance.
>


       I find emulators VERY useful.  I'm always using the WATCH, breakpoint,
and single step to figure out what my code is doing.  The only problem is
that the emulator for a 16c74 only runs at 4 MHz and my product requires
16 MHz (to receive data at 250 Kbps).  So I modified some of our DMX
generating and receiving equipment to run at 1/4 speed so I can see
what's going on.  Once it runs on the emulator, I move on to "crash and
burn" debugging, rotating my dozen erasable chips through the eraser and
the programmer 'til it works...
       I really like to see what's inside the chip using the emulator instead
of just staring at a dead product and trying to figure out where the code
went wrong.
       But... emulators ARE expensive!


Harold


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

1998\10\21@015045 by paulb

flavicon
face
Mike Keitz wrote:

> Better performance with the voltage at the negative limit may be
> possible using a Schottky diode in parallel with the zener to clamp to
> a less negative level.  The forward voltage drop of a zener is higher
> than even a regular silicon diode.

 Seems to me the real answer if you don't mind buying the parts, is to
put a Schottky from the input to each rail, then put the Zener (5.6V or
perhaps 5.1V) across the supply.

 Minimal leakage, avoids problems of parasitics with the internal
"catch" or clamp diodes, and prevents the PIC supply from being jacked
up by an unreasonable amount.  Zener may not actually be necessary if
the regulator chip performs the function without complaint (up to a
reasonable number of mA).  But is that parameter in the spec sheets?
--
 Cheers,
       Paul B.


'Analog inputs for C compiler'
1999\01\18@174352 by Darren Logan
picon face
Thanks a million Peter !.

Darren

'bipolar A/D inputs'
1999\01\21@221803 by jmnewp

flavicon
face
Let's just start out with my background....I've never had an electronics
class in my life and know next to nothing about analog electronics.
Unfortunatly, we live in an analog world, and I need to get some analog
signals into digital format.  I can do A/D just fine between 0-5 volts,
but what if I want to measure the voltage swing from -5 to 5 volts
without some exotic chip.  I have experimented with the ADC12451 (which
does just this) from national semi, and it works well, but is pretty dog
gone expensive...Would there be anyway to, say, use a pic's onboard A/D
and some sort of other external circuit to set a bit to tell if it is
positive or negative?  I thought about some sort of comparator scheme,
but I'm not too familiar with them either...I'm a digital boy.  How has
anyone else tackled this problem?  on another note, how have people
stored this info, I've never heard of 9-bit EEPROMs...just use up
another byte for every + or - ?  anyways, comments are more than
welcome.


Jon

1999\01\22@012754 by Gerhard Fiedler

picon face
At 21:32 01/21/99 -0800, MARK D NEWPORT wrote:
>I can do A/D just fine between 0-5 volts,
>but what if I want to measure the voltage swing from -5 to 5 volts
>without some exotic chip.

if you want to do that more than once, you should read a bit about op amps.
eases life a lot in these spheres, as they are relatively easy to work with
(in the basics, and you can do a lot with just the basics). for example you
can build a simple amplifier which transforms your range (-5..+5V) into the
0..5V the pic's adc understands. (you need a negative supply voltage for
that.) -5V would become 0, 0 to 2.5, and 5 to 5. that's an amplifier with
an amplification of 0.5 and an offset of +5V. (i don't like ascii art
fiddling, so i leave you here on your own. but something like 1 hour
reading a primer about op amp circuits should give you the basics for this
type of problem.)

>on another note, how have people
>stored this info, I've never heard of 9-bit EEPROMs...just use up
>another byte for every + or - ?

in this solution, you'd have 8 bits for the whole range. if that is not
enough, you need to do something different; there are various
possibilities, depending on the circumstances.

ge

1999\01\22@014236 by Harold M Hallikainen

picon face
On Thu, 21 Jan 1999 21:32:15 -0800 MARK D NEWPORT
<jmnewpSTOPspamspamspam_OUTworldnet.att.net> writes:
{Quote hidden}

       If the voltage source driving the A/D is relatively low impedance, you
can put a resistor between the sample voltage and the A/D input, then
another equal value resistor to +5V (assuming a +5V reference).  You
could use 10K to 50K resistors with a PIC A/D without too much trouble
due to bias current.  When the sample voltage is -5V, the A/D would get
0V.  When the sample voltage is +5V, the A/D would get +5V.  The formula
for the A/D input voltage would be 2.5+(Vin/2).
       This was a neat trick used in a Maxim A/D converter chip.

Harold

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1999\01\22@041549 by paulb

flavicon
face
Gerhard Fiedler wrote:

> For example you can build a simple amplifier which transforms your
> range (-5..+5V) into the 0..5V the pic's adc understands. (you need a
> negative supply voltage for that.)

 Err, no, you don't need a negative supply voltage.

 It will suffice if you use a high-grade op-amp which can pull the
output to either rail, as well of course, as a common-mode input range
including both rails.
--
 Cheers,
       Paul B.

1999\01\22@085246 by Mike Keitz

picon face
On Thu, 21 Jan 1999 21:32:15 -0800 MARK D NEWPORT
<spamBeGonejmnewpSTOPspamspamEraseMEworldnet.att.net> writes:
>Let's just start out with my background....I've never had an
>electronics
>class in my life and know next to nothing about analog electronics.
>Unfortunatly, we live in an analog world, and I need to get some
>analog
>signals into digital format.  I can do A/D just fine between 0-5
>volts,
>but what if I want to measure the voltage swing from -5 to 5 volts
>without some exotic chip.

Yod don't need anything too exotic.  A simple way to do this is to use a
voltage divider consisting of 2 resistors the same value:


       +5v
        |
       R1
        |
        ------ ADC in
        |
       R2
        |
Input-----

I would suggest 10K for the resistor values.  When the input is at 0 V,
the ADC input is +2.5V.  When the input is at -5V, the ADC input is 0V.
When the input is +5V, the ADC input is +5V.  The input resistance is
20K, but it is to +5V rather than to ground.  If this causes a problem
with the signal source, an amplifier may be needed.


> I have experimented with the ADC12451
>(which
>does just this) from national semi, and it works well, but is pretty
>dog
>gone expensive...Would there be anyway to, say, use a pic's onboard
>A/D
>and some sort of other external circuit to set a bit to tell if it is
>positive or negative?  I thought about some sort of comparator scheme,
>but I'm not too familiar with them either...

Using the circuit above with the internal ADC produces an 8-bit result.
If the result is >128, the voltage is positive, if less it is negative.
Inverting the high bit of the result places it in proper two's complement
form.

It is possible to use a comparator and a switching circuit to change
negative inputs to a value the ADC can read.  Unless you need more than 8
bits of precision, it's more trouble than it's worth.

>  on another note, how have people
>stored this info, I've never heard of 9-bit EEPROMs...just use up
>another byte for every + or - ?

Now that's a digital question.  It isn't too complicated to write a
routine to "pack" 9-bit results into 8-bit bytes.  It would take 9 bytes
to store 8 results.  If you have a lot of extra memory space, just use 2
bytes for each result.  If the ADC hardware is upgraded to more than 9
bits, the storage process would need little change.




___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]


'PIC12C672 and RS232 inputs'
1999\02\19@105454 by Helen Corns
flavicon
picon face
I been using PIC16c84's for a couple of years, and am trying to
convert a program from the PIC16c84 to a PIC 12C672, but I'm
having problems.

The program should wait for data from an RS232 input and echo it
straight out again to the RS232.  I use this program with
hyperterminal to test my RS232 subroutines.  This program works fine
with the PIC16c84, but after I've converted it for the PIC12c672  it
appears to be cycling through the program, continuously reading the
RS232 input as 0.
Does anyone know what might be wrong.
Thanks
Helen Corns

1999\02\19@131124 by Vincent Deno

flavicon
face
I would suspect it to be that you've not configured the RS232 data input
pin as digital input.  Try checking the A/D or port configuration
registers (I'm unfamiliar with this part).

Good Luck,
Vincent Deno

> I been using PIC16c84's for a couple of years, and am trying to >
convert a program from the PIC16c84 to a PIC 12C672, but I'm
{Quote hidden}

1999\02\19@193203 by g.daniel.invent.design

flavicon
face

1999\02\19@193203 by g.daniel.invent.design

flavicon
face
an easy thing to overlook when changing pics is the ram starting address
location, also some i/o control registers may now be in page 1 of ram.

Helen Corns wrote:
{Quote hidden}

--
Steam engines may be out of fashion, but when you consider that an
internal combustion engine would require recovery of waste heat by
transfer just before top dead centre then fashion becomes rather
redundant, USE STRATIFIED HEAT EXCHANGERS ! and external combustion.

You heard it first from: Graham Daniel, managing director of Electronic
Product Enhancements.
Phone NZ 04 387 4347, Fax NZ 04 3874348, Cellular NZ 021 954 196.

1999\02\19@214808 by wwl

picon face
On Fri, 19 Feb 1999 14:34:39 GMT, you wrote:

> I been using PIC16c84's for a couple of years, and am trying to
>convert a program from the PIC16c84 to a PIC 12C672, but I'm
>having problems.
>
>The program should wait for data from an RS232 input and echo it
>straight out again to the RS232.  I use this program with
>hyperterminal to test my RS232 subroutines.  This program works fine
>with the PIC16c84, but after I've converted it for the PIC12c672  it
>appears to be cycling through the program, continuously reading the
>RS232 input as 0.
>Does anyone know what might be wrong.
>Thanks
>Helen Corns
Are you sure the pins haven't been set up as analog inputs ?


'bipolar A/D inputs....again'
1999\03\19@012641 by jmnewp
flavicon
face
several months ago I asked a question about bipolar A/D inputs....say,
-5v to +5v.  Someone suggested something using just a couple of
resistors to use as a voltage divider.  Could anyone say that again?
All of my messages were deleted....

does this look like anything close to being right?

                             |
                             < R1
                             >
                             |
                  Vout-------|----- Vin
                             >
                             < R2
                             |

               where r1 = r2

reminder...I know this is a simple, simple question, but I remind you
I've never had an electronics class in my life.  I much better on the
digital end than on the analog...

1999\03\19@015651 by Vincent Deno

flavicon
face
What they were probably referring to was:
       Vin ----+
               <
               < R1
               <
               |
               +--- Vout
               |
               <
               < R2
               <
               |
               GND (=0V)

Using nodal analysis, you can get the equation:
(Vout-Vin)/R1+(Vout-GND)/R2=0
=>Vout/R1-Vin/R1+Vout/R2-GND/R2=0
=>Vout/R1-Vin/R1+Vout/R2-0=0
=>Vout/R1+Vout/R2=Vin/R1
=>Vout(1/R1+1/R2)=Vin/R1
=>Vout[(R1+R2)/(R1*R2)]=Vin/R1
=>Vout=(Vin/R1)*[(R1*R2)/(R1+R2)]

(Finally) => Vout=(Vin*R2)/(R1+R2)

Remember though, this equation does not take into account any additional
load (in parallel with R2).

You might consider putting protections diodes in to avoid exessive voltage
at the input:

               Vcc
                |
               ---
               / \ D1
                |
       Vin -----+--------------+
                |              |
               ---             <
               / \ D2          < R1
                |              <
               -Vcc            |
                               +---- Vout
                               |
                               <
                               < R2
                               <
                               |
                              GND

Hope this helps.  Sorry about the primitive ascii art.

-Vincent Deno

{Quote hidden}

--------------
Vincent Deno
Design Engineer
Theta Digital Corp.
http://www.thetadigital.com
KILLspamdenovjspamBeGonespamemail.uc.edu
_____________
| ____   ____ |
|/| | | | | |\|
| | |/| |\| | |
| | | | | | | |
| |_/ | | \_| |
| |   | |   | |
|_/  /___\  \_|

1999\03\19@022637 by Gerhard Fiedler

picon face
At 01:55 03/19/99 -0500, Vincent Deno wrote:
{Quote hidden}

the problem with this is that a negative input results in a negative output. in
the case of -5..5V => 0..5V, it is better to reference the divider to the 5V,
like this:

               +--- +5V
               <
               < R1
               <
               |
               +--- Vout
               |
               <
               < R2
               <
               |
       Vin -----

Now the output is (if you make R1=R2) 0..5V

ge

1999\03\19@022843 by Harold Hallikainen

picon face
On Fri, 19 Mar 1999 00:41:58 -0800 MARK D NEWPORT
<EraseMEjmnewpspamEraseMEworldnet.att.net> writes:
{Quote hidden}

       Tying Vin and Vout together, as shown above, will not have much effect
on the voltage!  Connect one of the resistors between your sample and the
A/D input.  Connect the other resistor between the A/D input and +5V.
Probably the simplest way to analyze the circuit is to use superposition.
Apply one of the voltages one at a time, setting the other to zero.  Add
the results.

Harold

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1999\03\19@023258 by Vincent Deno

flavicon
face
Find out for yourself... solve the equation I gave you and replace GND
with +5.


{Quote hidden}

--------------
Vincent Deno
Design Engineer
Theta Digital Corp.
http://www.thetadigital.com
@spam@denovj@spam@spamspam_OUTemail.uc.edu
_____________
| ____   ____ |
|/| | | | | |\|
| | |/| |\| | |
| | | | | | | |
| |_/ | | \_| |
| |   | |   | |
|_/  /___\  \_|

1999\03\23@005044 by jmnewp

flavicon
face
Thank you very much....This works wonderfully....I don't quite
understand that nodal analysis thing, but otherwise...I'm so stupid....I
can't wait to get to callege and actually take some of these classes
that will teach me very very simple things such as RESISTOR
CIRCUITS!!!!!  I can program some pretty cool programs in assembly...but
I don't know the simplest theory...I'm using too many ellipses...

Vincent Deno wrote:
{Quote hidden}


'protecting 'user connected' adc inputs?'
1999\05\23@140003 by Ross Bencina
flavicon
face
Greetings O PICsters,

I'm building a device for a friend that has a bunch of external (user
connected) (8 to 12bit) adc inputs (the current design uses a 16f84 and a
tlc542 adc). The box will be used in a "musical" environment. The adc inputs
will be (mostly) powered from the unit itself (ie resistive sensors, light
sensitive transistors circuits etc.). Sensors may be connected using longish
leads.

As electronics isn't my strong point I'm looking for some advice on
how/whether to "protect" the inputs to avoid having the adc inputs fried. At
the moment I'm planning to connect simple (RC) lowpass filters at each
input. Other than noise I'm not sure what other potential "issues" could
arise (esd etc?), or whether I should even be worried about this in a
non-industrial context.

Any comments would aid my understanding considerably,

Thanks,

Ross.
<.....rossbspam_OUTspamaudiomulch.com>

.................................
http://www.audiomulch.com/~rossb/

1999\05\24@002442 by Ravi Pailoor

flavicon
face
part 0 1730 bytes content-type:text/x-vcard; charset=us-ascii; name="vcard.vcf" (decoded 7bit)

         |   Max vtg of ADC input
       ---
        /\
        -
        |
----------------/\/\/\/\/--------
        |            |
      ---        ----
       /\         ----
       -            |
       | GND   |

Pailoor
-
Ross Bencina wrote:

{Quote hidden}

--
Website : http://business.vsnl.com/chiptech


Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Description: Card for Ravi Pailoor
Content-Disposition: attachment; filename="vcard.vcf"
Content-Transfer-Encoding: 7bit

Attachment converted: wonderland:vcard.vcf 1 (TEXT/CSOm) (000072FA)

'[OT] Re: protecting 'user connected' adc inputs?'
1999\05\25@115219 by Adam Bryant

picon face
Forgive my limited electronics background, but what is the purpose of the
RC component in this diagram?  I understand the purpose of the diodes,
but why would you use the RC component?  I would guess as a method to
reduce spikes and "slow down" the rate of change of the incoming signal?

Thanks in advance for increasing my electronics knowledge,
Adam

On Mon, 24 May 1999 09:39:54 +0530 Ravi Pailoor <TakeThisOuTchiptechKILLspamspamspamVSNL.COM>
writes:
{Quote hidden}

Adam Bryant (age 0x23)
RemoveMEabryantspamspamBeGonepeaktech.com (work)
spamBeGoneadamdb@spam@spamspam_OUTjuno.com (home)
Parker, CO, USA
Robotics, RC Airplanes, anything using a PIC

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1999\05\25@132832 by Wagner Lipnharski

picon face
Adam Bryant wrote:
>
> Forgive my limited electronics background, but what is the purpose of the
> RC component in this diagram?  I understand the purpose of the diodes,
> but why would you use the RC component?  I would guess as a method to
> reduce spikes and "slow down" the rate of change of the incoming signal?
>
> Thanks in advance for increasing my electronics knowledge,
> Adam
>

Adam, any capacitor has its internal "resistance", the difficulty the
electrons have to flow into and out of the capacitor plates. Better
capacitors has low ESR (resistance) so they are the ones to be chosen to
be used at power supply filters, mainly when high demand of current is
required by motors and low impedance short pulses.  So, it is somehow
clear that low ESR is good for capacitors, but not always.  A low ESR
capacitor can "suck" fast voltage transitions, ac signals horsing dc
levels, and this is the main usage in power supplies, removing the ac
component from the dc, as a filter.

A capacitor also has the use as an integrator, creating a non linear
ramp of voltage over time.  This time is calculated as "factor RC". The
formula is "R x C", R in Ohms, C in Farads, the result is the transient
time to reach aprox 60% of the value of the charging voltage.  It is
widely used as a timer in lots of circuits that demand time control.  If
you use a R = 10,000 Ohms, a C = 0.0001 Farads (100uF), connect both in
series, and apply 10 Volts to them, after (10,000 x 0.0001) 1 second,
the capacitor would has aprox 6 Volts.  Larger values of R or C increase
the time, smaller reduce it.  We can call it "RC time".

If you think that if instead of apply a steady 10Vdc over the RC, you
apply 10VAC, it means that the AC component would try to charge the cap
with its polarity, when the ac polarity reverses, it would try to charge
the cap with that polarity. To do that, it first need to discharge the
cap from the previous (other polarity) loaded voltage, then try to
charge the cap, and it repeats itself.  If the period of time the AC
signal stays in each polarity is long enough to charge the cap to its
60% or more, it means that the cap would be "saturated" before that
polarity period of time ends, and the cap would not "suck" current from
that voltage or circuit, as if it do not exist anymore.

If the "RC Time" is very small and the AC period is long, the RC
"filtering" would be very small and would not interfere much into the AC
signal.  By the other way, if the RC time is long and the AC period is
short, the RC filtering would make great effect over the AC signal,
"sucking it" in great effect, so representing a heavy filter to the AC
signal.

Imagine a transformer 110 x 10 Vac powered with 60 Hz (16ms AC period).
If you apply a RC with "RC time" longer than 150ms to the 10Vac
transformer secondary, it probably would drop the 10Vac significatively
(R=150 Ohms, C=1000 uF). Capacitor would need to be non polarized, or
two polarized capacitors (2000uF each) connected in reversed serial.

Now, if the AC signal is mounted over a DC voltage, the capacitor would
never receive reversed polarization, but electrons would enter and exit
the capacitor, with a large amount of charge at the plates caused by the
DC component.  This is what happens in a power supply, AC (top of the
wave) over the DC generated by the diodes and capacitors.  To have the
best filtering, you need to use resistors as low as possible, so "no
resistor" is the best one at the power supplies.  Some "PI" filtering
with two capacitors connected by a resistor is used as a "low pass"
filter.  For better efficiency, an inductor (coil) can replace the
resistor, since its impedance is higher to AC then DC.

A low pass filter allows only signals below certain frequency to cross
it. The "RC time" just rules about what would be AC frequency to pass
and which not.  There are plenty of formulas and models of low pass
filters around.  One of them is just as you saw and asked about the ADC
input, a plain resistor and a capacitor. The main reason at that drawing
is just reduce the AC component at the ADC input, so yes, it is a plain
filtering, an integrating RC.

--------------------------------------------------------
Wagner Lipnharski - UST Research Inc. - Orlando, Florida
Forum and microcontroller web site:  http://www.ustr.net
Microcontrollers Survey:  http://www.ustr.net/tellme.htm

1999\05\26@011233 by Ross Bencina

flavicon
face
Adam Bryant writes: [in respect to filtering an ADC input]

>Forgive my limited electronics background, but what is the purpose of the
>RC component in this diagram?  I understand the purpose of the diodes,
>but why would you use the RC component?  I would guess as a method to
>reduce spikes and "slow down" the rate of change of the incoming signal?


You guessed right.

Wagner just gave more electronics info on RC filters than I ever knew, but
from the DSP side of the fence...

Given an adc system that samples at a constant rate, any frequencies above
half the sampling frequency (called the 'Nyquist' frequency) will cause
interference ("aliasing artifacts"). This can be demonstrated by drawing a
high frequency sine wave on a piece of paper and then "sampling" is at a
small nember of evenly spaced points (more than half a wavelength apart) -
the "voltage" at these points could be anything within the amplitude of the
waveform, and bears little relation to either the average level of the
signal or the wavform of the signal.

So the rule of thumb is to block any frequencies above the nyquist from
entering the ADC. The RC filter hasn't got a sharp frequency rolloff so it
should probably be tuned well below the nyquist, or an active filter could
be used. Another technique called "oversampling" involves sampling at a
(integer ratio) higher rate than needed (but still performing the analog
filtering for the original sample rate), and then filtering the signal in
the digital domain and decimating down to the required rate - I'm doing a
bit of both.

Regards

Ross.


'[OT] Protecting inputs etc'
1999\06\01@152525 by Roland Andrag
flavicon
face
part 0 1152 bytes
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META content='"MSHTML 4.72.3110.7"' name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000000 size=2>Hello everyone,</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2>I am looking for some info about 'ruggedizing'
(for lack of a better word) a pic application. This would mean safeguarding as
many of the inputs pins, supply etc. against everything possible (overvoltage,
reverse polarity etc.).&nbsp; This is a very open question and I am sure there
have been books written about the subject - please tell if you know of
any.&nbsp; I would appreciate pointers to any good web sites as well.
</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2>Thanks a lot</FONT></DIV>
<DIV><FONT color=#000000 size=2>&nbsp; Roland</FONT></DIV></BODY></HTML>

</x-html>


'low cost isolated A/D inputs?'
1999\08\22@221813 by tec
flavicon
face
Hello all,

I've been struggling with a way to do a low cost isolated A/D ( <$2/
channel) for a PIC 16C877.  I need a total of 4 isolated inputs at 500V
of isolation with 8bits of resolution.  I've looked at a lot of
different possiblities, so far, a voltage to frequency converter coupled
through an optocoupler seems to be the most cost effective solution.
Then just count the pulses on a PIC pin in a fixed amount of time.
National semiconductors V/F LM331 is ~$1.50 and it's conversion is
linear.  I've also wondered if there was any op-amp configurations
(maybe Microchip's low cost op-amps) that might be cheaper than the
National's V/F and still linear.  I was considering powering each
channel with a flyback converter through a quad ethernet isolation
transformer.  I'm not sure if it would need a switching controller
(LTC1424-9 ~$2.90) or if I can simply send a buffered 1Mhz clock off my
CPLD.

Suggests welcome and appreciated.

Thanks in advance,

Todd Conard

1999\08\22@224139 by l.allen

picon face
>
> I've been struggling with a way to do a low cost isolated A/D ( <$2/
> channel) for a PIC 16C877.  I need a total of 4 isolated inputs at 500V
> of isolation with 8bits of resolution.  I've looked at a lot of
> different possiblities, so far, a voltage to frequency converter coupled
> through an optocoupler seems to be the most cost effective solution.

I haven't done the full costs but my first reaction would be to do the
A2D on the isolated side with a chip like the MAX1111 and optocouple
the serial interface. Power would be via an isolated capacitor drive
(cheapest method) and since the I.C. only draws 6uA@1kS/S and 85uA at
50 kS/S the 1 MHz drive wouldn't have to be too grunty.
Its also single supply and costsUS $1.69 (last 1000up price I have)
_____________________________

Lance Allen
Technical Officer
Uni of Auckland
Psych Dept
New Zealand
_____________________________

1999\08\23@093319 by Russell McMahon

picon face
+AD4- I've been struggling with a way to do a low cost isolated A/D
+ADwAJA-2/
+AD4- channel) for a PIC 16C877.  I need a total of 4 isolated inputs at
500V
+AD4- of isolation with 8bits of resolution.  I've looked at a lot of
+AD4- different possibilities, so far, a voltage to frequency converter
coupled
+AD4- through an optocoupler seems to be the most cost effective solution.


Todd,

What conversion time do you need to achieve?

I won't discuss power supply here in any detail.
Sigma Delta / Delta modulator / Variable mark space could be attractive
here if speed is not critical.
Similar to VCO but POSSIBLY easier to get a good result.

Effectively you have a delta modulator which outputs a data stream whose
mean value is proportional to the input voltage.
You can think of it as an oscillator which is mark/space modulated by the
input voltage.
A comparator acts as the decision maker.
A capacitor is fed by a resistor from the input voltage AND a feedback
hi/lo level controlled by the comparator. The comparator compares (what
else :-)?) it's input to a reference voltage and drives the feedback
resistor to +ACI-correct+ACI- and error. When this is done with a
microprocessor a
digital delay is effectively inserted by the computation time. In an all
analog version you use either hysteresis on the comparator OR a delay
between comparator response and the feedback. This could be a second
comparator with a simple RC delay so there is a delay between when the 1st
and 2nd comparators toggle.

Output of comparator fed via opto or magnetic coupling or whatever.

LM339 comparators cost under +ACQ-NZ0.50 for a pack of 4. There are newer
better and dearer devices available. You will need either 1 or 2 per
+ACI-channel+ACI-

The main disadvantage is that it is comparatively slow. Depends on uP loop
time to read values and sum hi/lo results. Vertical counters mentioned here
previously may apply.
Say you can get 10uS per loop then you need about 2x 2+AF4-N  samples so
for 8
bit this is 512 samples +AD0- 5.12 mS. Say 10mS and 1000 samples.

There is more to this than meets the eye but if this is a volume
application this may be a good way to do it. If time needed is much slower
than this you could do one channel at a time making processing very easy.

You COULD easily put a PIC on the +ACI-hot+ACI- side and do 4 channels
there (16C71
or newer variants) and then use opto-serial to send data to cold side.

Same applies to a Sigma delta version. Scott Datallo was getting 10 bits
plus with ease with a PIC and NO comparators at all. (Code on his website).
I'm using a Z8 with its internal comparator to get similar results. PIC
+ACQ-NZ3 (anything will do), 2N resistors, N capacitors for N Sigma Delta
channels, Opto and resistor, resonator, power source. Cheap. Needs 2N pins
for SD done all at once or N pins done one at a time (all can share
common feedback pin).
If pressed a 12C508 could do 4 channels :-) (4 input, 1 feedback, 1 opto
output).



Russell McMahon

+AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD
0APQA9AD0APQA9AD0APQA9AD0APQA9-

{Original Message removed}

1999\08\23@132458 by wwl

picon face
On Mon, 23 Aug 1999 19:57:35 +1200, you wrote:

>+AD4- I've been struggling with a way to do a low cost isolated A/D
> +ADwAJA-2/
>+AD4- channel) for a PIC 16C877.  I need a total of 4 isolated inputs at
>500V
>+AD4- of isolation with 8bits of resolution.  I've looked at a lot of
>+AD4- different possibilities, so far, a voltage to frequency converter
>coupled
>+AD4- through an optocoupler seems to be the most cost effective solution.
>
Does each input need isolating from the other ? If not how about a
12C671 on the hot side sending async serial data through an
optoisolator ?

1999\08\23@140055 by tec

flavicon
face
Low cost isolated A/D

1.  Each of the four inputs needs isolation from each other.
2.  It can be a very slow conversion and only one at a time is necessary.
3.  It only needs to be 8 bits.
4.  The isolation barier only needs to be 500V.

Has anybody looked at sending power and signal through a high voltage cap.?
Linear Tech. had an interesting app. note where they sent power to an A/D and
recieved data back from it through the same transformer.

Thanks,

Todd Conard


Mike Harrison wrote:

{Quote hidden}

1999\08\23@165919 by Scott Dattalo

face
flavicon
face
On Mon, 23 Aug 1999, Todd Conard wrote:

> Low cost isolated A/D
>
> 1.  Each of the four inputs needs isolation from each other.
> 2.  It can be a very slow conversion and only one at a time is necessary.
> 3.  It only needs to be 8 bits.
> 4.  The isolation barier only needs to be 500V.

Several years ago (about 6 or 7) I did a design that had similar
requirements. Though in my case, more analog inputs were required. What I
did was to use CPClare solid state relays (first the LCA then later the
dual LAA series) to isolate the signals from one another and from the A/D
conversion circuitry. At the time only 400V relays were available, but
I've seen higher since (1000 iirc). Now the trick was that the conversion
circuitry had to be isolated from ground. So the input power supply had to
be able to withstand high primary to secondary voltages too. When a signal
was to be converted, the relays were closed and the whole conversion
circuitry would float up to the common mode voltage of the signal. The
'A/D' converter was in fact a 'V/F' converter, the AD652. This is
considerably more linear (and more expensive) than the LM331. I was able
to achieve about 14 or 15 bits of dynamic range and about 30 conversions
per second. (The V/F conversion time was exactly 2 cycles of 60Hz - common
mode noise at 60hz is very common). Low cost? well...

When you speak of 500V isolation, what do you mean exactly. In other
words, how much leakage current can you tolerate? Because for 8-bits you
could design a resistive divider + difference amplifier. I don't have time
to draw the picture... But have you ever seen ground reference opamps
measuring the voltage drop across a high-side current-sense resistor?
These circuits essential use two identical resistor dividers- one on each
side of the sense resistor and use an opamp two measure the voltage
difference at the divided-down junctions. Look at instrument-amplifiers
and difference-amplifiers to get an idea what I'm talking about. A point
of caution though, 5V/500V is a 40db range, and 1/256 is another 48 db.
Which is to say that you're gonna need very well matched resistors to
minimize common-mode voltage errors...


'[OT] Differential inputs (was how to.. (was :Handi'
2000\01\14@033721 by Caisson
flavicon
face
> Van: Thomas McGahee <TakeThisOuTtom_mcgaheespamspamSIGMAIS.COM>
> Aan: PICLISTEraseMEspamMITVMA.MIT.EDU
> Onderwerp: Re: [OT] how to.. (was :Handicap Mouse & Computer Interface)
> Datum: donderdag 13 januari 2000 15:42

Hello Thomas,

 Could you explain to me why you position the Ground-wire between the
differential inputs ?  I would think that those should be as close together
as possible (to get the same effect of outside disturbances on both lines),
wedged between two Ground-lines.

Most differential inputs cables I've seen where either Coax (two wires with
a Grounded shielding), or a simple twisted three-wire cable.

Regards,
 Rudy Wieser


> The electrode interface begins with an isolated instrumentation
> amplifier with two "active" differential inputs and a third
> "guard" electrode that establishes the ground reference.
>
> The "guard" electrode is physically located between the two
> differential inputs. This helps to cancel out much of the
> common mode signal. This helps to cancel out much of the
> common mode signal.

<Snip>

2000\01\14@111442 by Thomas McGahee

flavicon
face
-----Original Message-----
From: Caisson <RemoveMEcaissonEraseMEspamspam_OUTTELEBYTE.NL>
To: @spam@PICLISTRemoveMEspamEraseMEMITVMA.MIT.EDU <EraseMEPICLISTspam@spam@MITVMA.MIT.EDU>
Date: Friday, January 14, 2000 3:41 AM
Subject: Re: [OT] Differential inputs (was how to.. (was :Handicap Mouse &
Computer Interface))


{Quote hidden}

It is mostly a matter of convenience. The three wires are twisted
together to reduce common mode noise. The "ground" electrode then
goes in the center to maintain electrical symmetry.
You can also surround the two signal wires with a ground, but this
is a bit messier to implement in the real world. You can
obviously use coaxial wiring instead of the twisted 3 pair
wire, but for the target application you do not really gain
much for the extra expense. Remember that the target application
is simply to get a *useable* signal from a muscle movement. If
we were interested in the exact waveform (as in electrocardiographs),
then the extra expense is warranted.

In regard to the spacing between the active electrodes, it depends on
the signal source. For the heart you would want them separated
by at least a few cm since the heart is located rather deep.
For muscles located nearer the surface you can reduce the spacing.
Note that if separation of the electrodes is too far, then you get
a mixture of several muscle signals, and that is fairly useless.

For the target application (handicapped person), you would want to
find a muscle that the subject has good control over, and then
isolate that signal as much as possible. One subject might use
a finger muscle, and another a jaw muscle. It also helps a lot
in the real world if you can make an electrode carrier that
can be readily applied and which is comfortable to the user.

Fr. Tom McGahee


{Quote hidden}

'[OT] Differential inputs (was:Handicap Mouse &Comp'
2000\01\14@122302 by Robert Rolf

picon face
Typically the 'Guard' electrode surrounds the two active electrodes to
effectively
short out surface leakage currents and improve signal/noise ratio.
Typical separation
is 2 cm. If placed in between the electrodes it is to ensure the best
possible balance
in the noise pickup to maximize the CMRR.

You can get readymade electrodes (as used for myoelectrically controlled
prosthesis)
from Otto-Boc, or other electrically powered prosthetic makers
(Schmidel?). Check with
your local prosthestist or hospital rehab department for local sources
and options.

The Otto Boc electrode has a single switched output (with adjustable
thresholds) for
controlling open/close of an electric hand so you may be able to use it
directly
as input to mouse switches or the 'mousekeys' program (Microsoft
accessibility option
pgm) with a suitable scan code stuffer.

A now defunct local company (Leaf electronics) made an interface that
allowed
a single EMG electrode to control both opening and closing with a single
muscle site
by use of a graded muscle contraction. A light contraction would open
the hand, a strong
one would close it. I presume that this is now commercially available
elsewhere,
but I haven't checked.

Another local company specializes in building devices to assist
handicapped individuals
with computer control.

http://www.madentec.com/

There are many other companies out there, and most of their engineers
are quite
happy to answer questions about their technology.

Robert.RolfspamBeGonespamUAlberta.ca

{Quote hidden}


'How to read 2 inputs connected together?'
2000\02\03@044510 by Darren King
flavicon
face
part 0 16 bytes
</x-html>

2000\02\03@053711 by Joseph Rutsky

picon face
You would set one pin high/low and see which pin in the matrix is pressd
ny seeing which reads the same.  Reading in succession and keeping track
of which pin you are reading will tell you which key is pressed.

Joe

2000\02\03@055812 by Quentin

flavicon
face
Darren
If I understand you correctly, you are using a keypad with 6 connector
pins correct?
Then your keypad then either has 9 keys (3x3) or 8 keys (2x4)correct?
If so, read on, if not, please explain better.

The way I derived that you either has 8 or 9 keys is from what we know
as a matrix (no, not the movie) layout. Let's work on the 9 keys, then
your pins are something like this:
Pin
1---(7)-(8)-(9)
    |   |   |
2---(4)-(5)-(6)
    |   |   |
3---(1)-(2)-(3)
    |   |   |
    |   |   |
    |   |   |
    4   5   6

(keypad keys are in () )

pins 1, 2 , 3 we call scan lines and 4, 5, 6 we call datalines. What you
do now is to make the scan lines high in sequence and everytime the pin
is high, you read the data lines.
IE:
You make pin 1 high, then read 4, then 5, then 6 to see which one is
high, then you make pin 1 low and 2 high and read 4, 5, 6 again, etc.

Say pin 3 is high and after you read 4, 5 and 6, you see 6 is high, then
you you would know key 3 was pressed because the high of 3 gets switched
to 6 because key (3) was pressed.

The sequence of the scan lines and data lines you will have to get from
a data sheet.
For PIC examples see AN529.

Hope this helps
Quentin

2000\02\03@070630 by paulb

flavicon
face
Quentin wrote:

> 1---(7)-(8)-(9)
>      |   |   |
> 2---(4)-(5)-(6)
>      |   |   |
> 3---(1)-(2)-(3)
>      |   |   |
>      |   |   |
>      4   5   6

> You make pin 1 high, then read 4, then 5, then 6 to see which one is
> high, then you make pin 1 low and 2 high and read 4, 5, 6 again, etc.

 That's not *quite* correct.

 Firstly, pins you are using as an input must be given a known state.
The PIC has built-in pull-ups on port B which you may care to use or you
can use external pull-up resistors for all keyboard lines.

 Note that for protection against shorts to ground, which are rather
more likely than shorts to supply, it is usual to use pull-ups rather
than pull-downs as in a short to ground (being in effect the same as a
switch closure to ground) the current will be safely limited by the
pull-up.

 Secondly, you "strobe" each row (or if you wish, column) in turn by
making it an output and pulling it *low*, but the rows you are *not*
strobing, you do *not* pull high, but rather open-circuit them by making
them inputs.

 If both rows and columns are part of port B and you elected to use the
internal pull-ups, then the non-selected rows will be pulled up by the
pull-ups as well as the columns but this does not matter (in fact, you
don't really want any inputs to float).  The point is that by this means
multiple switch closures in any given row will *not* cause high and low
outputs to conflict.

 When one row, say pin 1, is low, then any column may be pulled down by
a corresponding closed switch on that row, while all other columns are
pulled up by their pull-ups.  By pulling each row low in turn, and
reading (generally in one I/O operation, using a shift operation to
test each in turn) all columns, all the switches can be read.

 You may note a couple of cunning tricks which may or may not be
useful.  One is to hold *all* rows low whilst reading the columns,
waiting for *any* closure before strobing them individually.  This makes
it very simple to perform a status check on the keyboard as a whole, it
can even be done in SLEEP using the Port B interrupt-on-change.

 Also, a quite fast way of finding a single key closure (i.e., does not
work if more than one key is pressed), is to pull all rows low and read
the columns, then pull all columns low and read the rows.  As long as
you only see one column and one row pulled down as a result, this
uniquely indicates the closure.

 Note that the PORT register is kept clear to do this, (do not use
read-modify-write instructions on it) and only the TRIS register is
changed (use the TRIS instruction!) but the PORT is read each time.
--
 Cheers,
       Paul B.

2000\02\03@092748 by Ken Webster

flavicon
face
Paul B. Webster wrote:
{Quote hidden}

Good advice!

I just happened to have an example sitting around.  It is for a 4x4 keypad
connected to a 17C756 on PORTB.  It doesn't do the fast scan ... just a
plain old one-row-at-a-time scan.  I had PORTB (output latch) set to 0.
Weak pullups were enabled.

Pinout is kinda funky (to make PCB layout easier):


6---(1)-(2)-(3)-(A)
    |   |   |   |
7---(4)-(5)-(6)-(B)
    |   |   |   |
5---(7)-(8)-(9)-(C)
    |   |   |   |
2---(*)-(0)-(#)-(D)
    |   |   |   |
    3   4   0   1



;------------------------------------------------------------
;Called by interrupt handler to scan the keypad
;Returns with W=ASCII if a key is pressed, W=0 otherwise
;Interrupt handler performs debounce
SCAN1   MOVLW   ~0X40         ;Enable ROW0 output
       MOVWF   DDRB
       NOP
       NOP
       BTFSS   PORTB,3
       RETLW   '1'
       BTFSS   PORTB,4
       RETLW   '2'
       BTFSS   PORTB,0
       RETLW   '3'
       BTFSS   PORTB,1
       RETLW   'A'
       MOVLW   ~0X80         ;ROW1
       MOVWF   DDRB
       NOP
       NOP
       BTFSS   PORTB,3
       RETLW   '4'
       BTFSS   PORTB,4
       RETLW   '5'
       BTFSS   PORTB,0
       RETLW   '6'
       BTFSS   PORTB,1
       RETLW   'B'
       MOVLW   ~0X20         ;ROW2
       MOVWF   DDRB
       NOP
       NOP
       BTFSS   PORTB,3
       RETLW   '7'
       BTFSS   PORTB,4
       RETLW   '8'
       BTFSS   PORTB,0
       RETLW   '9'
       BTFSS   PORTB,1
       RETLW   'C'
       MOVLW   ~0X04         ;ROW3
       MOVWF   DDRB
       NOP
       NOP
       BTFSS   PORTB,3
       RETLW   '*'
       BTFSS   PORTB,4
       RETLW   '0'
       BTFSS   PORTB,0
       RETLW   '#'
       BTFSS   PORTB,1
       RETLW   'D'
       RETLW   0


Cheers,

Ken

2000\02\03@153415 by paulb

flavicon
face
Ken Webster wrote:

> I just happened to have an example sitting around.  It is for a 4x4
> keypad connected to a 17C756 on PORTB.  It doesn't do the fast scan
> ... just a plain old one-row-at-a-time scan.

 Whoa-hoah, that *is* hard-wired!  And that's the series without the
rotten "bank select" muck-up.  Interesting.
--
 Cheers,
       Paul B.

2000\02\03@165510 by Andre Abelian

picon face
part 0 16 bytes
</x-html>

2000\02\03@183733 by John Mullan

picon face
part 0 16 bytes
</x-html>

'Static Protection on PIC inputs'
2000\02\04@021235 by Jim Ruxton

flavicon
face
Hi
I am reading a switch at the end of a long line (ie. 300 ft) . I'm also
driving a bipolar LED out  there. This means I can only put about 1K
ohms in series with the line. Is this and the internal diodes of the PIC
generally enough to quench any static. I'll probably also put a .01 uF
cap on the input. Thanks for any thoughts on this!
Jim

2000\02\04@111548 by jkitchen

picon face
I put the 0.1 uF cap across the long leads.  I'd also put small ferrite
beads on all the long leads.  You might fidn it necessary to also put a
small RF choke in series with all the long leads.

Jim Ruxton wrote:

> Hi
> I am reading a switch at the end of a long line (ie. 300 ft) . I'm also
> driving a bipolar LED out  there. This means I can only put about 1K
> ohms in series with the line. Is this and the internal diodes of the PIC
> generally enough to quench any static. I'll probably also put a .01 uF
> cap on the input. Thanks for any thoughts on this!
> Jim

'How do I hook up ADC Differential Inputs (ie do AD'
2000\02\07@215125 by Darren King

flavicon
face
Sorry about the HTML message.  I just usually Reply someone's message and it
sets it to the format the sender.  However if I don't then it defaults to
HTML.  Fixed sorry.

I'm trying to hook up an ADC sensor that will read a differential signal.
Though I've gone through the Data Sheet for my 16F877.  I can't seem to get
it to read correctly the inputs.  Infact I didn't get it to work at all.
What are the steps I'm supposed to init the ADC and then how do I wire the
Differential Inputs on my Controller.

Thanks for the Helps
Darren King

2000\02\08@002804 by Dwayne Reid

flavicon
face
>Sorry about the HTML message.
No problem.  The insidious thing about HTML is that the sender has no idea
it is being sent!  Thus my request.

>I'm trying to hook up an ADC sensor that will read a differential signal.
>Though I've gone through the Data Sheet for my 16F877.  I can't seem to get
>it to read correctly the inputs.  Infact I didn't get it to work at all.
>What are the steps I'm supposed to init the ADC and then how do I wire the
>Differential Inputs on my Controller.

Yikes!  you have me there (for now) - not one of my projects uses the 16F8xx
series yet.  The few projects that needed differential input also needed 12
bit accuracy, so I just used a LT1298 - its a tad pricey but did the job and
was easy to use.

But initing the a/d in the 16c7x series is easy - congiure the tris bits so
that the a/d pins are inputs, configure adcon1 (in ram page 1) so that the
required pins are a/d input, set up adcon0 (select correct input channel,
etc), wait til the sample is aquired (50 uS or so), set the 'go/done' bit to
start the conversion, wait til bit is cleared (or look for ADIF interrupt),
read result.

I'm assuming that it is almost the same for the 16F8xx series since they are
supposed to be code compatible.

dwayne


Dwayne Reid   <RemoveMEdwayner@spam@spamspamBeGoneplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 16 years of Engineering Innovation (1984 - 2000)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
My posting messages to Usenet neither grants consent to receive
unsolicited commercial email nor is intended to solicit commercial
email.

2000\02\08@043050 by Darren King

flavicon
face
> >I'm trying to hook up an ADC sensor that will read a differential signal.
> >Though I've gone through the Data Sheet for my 16F877.  I can't seem to
get
> >it to read correctly the inputs.  Infact I didn't get it to work at all.
> >What are the steps I'm supposed to init the ADC and then how do I wire
the
> >Differential Inputs on my Controller.
>
> Yikes!  you have me there (for now) - not one of my projects uses the
16F8xx
> series yet.  The few projects that needed differential input also needed
12
> bit accuracy, so I just used a LT1298 - its a tad pricey but did the job
and
> was easy to use.

Well now I'm strangly compelled...  I also am going to need 12 bit accuracy
later and I'm just using the PIC16F877 to learn on.  I bought a PIC-X1 board
a while ago and though it was definatly very pricy for what I got, it has
been one of the best learning tools I could have ever wished for.  It has
the ADC stuff on it already, will require some changes to do differential.
Could you tell me how the Circuit with the LT1298 worked?  If its also not
to much to ask a schematic so that I can get upto speed faster.  I work for
this company and my project now is doing ANALOG data logging.  I have no
idea about ANALOG stuff.  I can program my controllers and write server
code, but they are asking me to be to much of an engineer now.  Some
schematics of a circuit that I have to re-invent would really help out.

> But initing the a/d in the 16c7x series is easy - congiure the tris bits
so
> that the a/d pins are inputs, configure adcon1 (in ram page 1) so that the
> required pins are a/d input, set up adcon0 (select correct input channel,
> etc), wait til the sample is aquired (50 uS or so), set the 'go/done' bit
to
> start the conversion, wait til bit is cleared (or look for ADIF
interrupt),
> read result.

Exactly what the Data sheet said, though you said it MUCH clearer.  I'm
going to have to figure out what symbol go/done is in my compiler...


> I'm assuming that it is almost the same for the 16F8xx series since they
are
> supposed to be code compatible.

What you said seemed exactly correct, so I'm going to have to run some tests
using just regular Analog inputs.  My confusion is more about the filters
and the Wiring then anything.

Thanks for the Help.

'inputs for the pic'
2000\02\09@085025 by Longley, Jason

flavicon
face
Hi I wonder if anyone out there can help me ?
I am trying to incorporate a PIC microcontroller into my
project however one of my input sources is from a High
tension lead to a spark plug (See Note. Can anyone help me
with some kind of circuit that will prevent the spike from
blowing up my PIC.


Note : the HT lead has a single winding around the outside
which induces a voltage when a voltage is sent to the spark
plug.
----------------------------------------
Longley, Jason
Email: .....Jason.Longley@spam@spamEraseMEuwe.ac.uk
"University of the West of England"

2000\02\09@093130 by Thomas McGahee

flavicon
face
Use an opto-isolated technique.
I have successfully used the loop
pickup (the one turn you refer to)
to cause a high brightness LED to
generate a blip of light at each
firing of the spark plug. I then
used a length of fiber optic cable
to get the blip of light into the
receiver box where a photodetector
circuit transformed the light blip
into a nice clean electrical pulse.
In my case the fiber optic cable
was several feet long.

Check the catalogs of companies like
Digi-Key. Many of them carry opto
isolator kits consisting of a LED
transmitter, couplings, length of
cheap plastic fiber optic cable,
and optoelectric receiver.

But for experimenting you can roll
your own very inexpensively. The
LED should have a resistor in series
with it to limit peak current.

A simple sealed optoisolator such as the
4N33 can be used if you don't need
more than a few hundred volts of isolation.
For experimenting you can also just use
a standard LED/phototransistor assembly
sealed with black electrical tape to keep
out extraneous light.

It is sometimes useful to place a diode
in reverse-parallel with the LED
section. This helps prevent excessive
reverse voltage from being applied to the
LED.

Fr. Tom McGahee



{Original Message removed}

'Reading ternary inputs'
2000\02\25@062115 by Russell McMahon

picon face
This may be old hat.
Anyone care to critique my thought processes.

Ternary (3 state) inputs are handy for increasing the number of options that
one can get from strapped option inputs.

eg
       3 binary inputs give 8 states (2^3).
       3 ternary inputs give 27 states (3^3)

I had a discussion today with a friend who said an input could be read as
high, low or floating by using a single resistor to any of these inputs and
perhaps a hi value pullup if the pin does not have an internal pullup. I
suggested a small value capacitor was also needed at the pin.

He commented ~~ that eg an input strapped to ground "could not be pulled up
so its state is known".

Hmm, comes clear as I type.
He works often in the 8031 world to which I am not accustomed.
They have I believe a "pseudo I/O" type of pin which may be legally driven
against a hi/lo load and which is used as an input by simply setting it high
and pulling it down against the weakish high drive. I may have detail wrong
but I believe this is the case in essence.

With a high current pin this is illegal (and dangerous to the cpu's health).

So, my ternary reading then goes like this.

10k from pin to ternary input
1M from pin to eg high
100 pF from pin to ground.

10K and 100 pF form a 1uS delay (choose actual value to suit code).
1M and 100 pF form a long (100uS) delay.

So

- Set pin to output
- Drive pin high
- Set pin to input
- Read pin ->Sa
- Set pin to output
- Drive pin high
- Set pin to input
- Read pin -> Sb

10k/100 pF  need to have a delay safely less than time to set pin to read
and read pin.
Values will need to be changed for most processors.

If Sa = high and Sb  = low then input is O/C
If Sa = low and Sb = low then input is low
If Sa = high and Sb = high then input is high.

Because:
A floating pin will retain the last written state due to slow pin time
constant from 1M.
A pin held during 10K will be temporarily driven to the opposite state by a
write but will return to the externally driven state after a few time
constants
The large value pullup returns the pin to an eg high if it left floating as
an input. Not needed if user exercise proper discipline and leaves port as
an output most of the time. This adds power dissipation (depending on input
setting).

Any comments?

Any better ways to do this for a true bidirectional high current capable
port pin.









     Russell McMahon
_____________________________

>From other worlds - http://www.easttimor.com
                               http://www.sudan.com

What can one man* do?
Help the hungry at no cost to yourself!
at  http://www.thehungersite.com/

(* - or woman, child or internet enabled intelligent entity :-))

2000\02\25@062738 by Alan Pearce

face picon face
Read the data sheet for the Motorola MC145026/7/8 remote control transmitter and
receiver chips which implement a ternary scheme. There is a very good
description of how the chips do it.

2000\02\27@193137 by Sean Breheny

face picon face
Russell,

How about this:

Have one pin per ternay input PLUS a single additional pin. Feed your
inputs directly into your ternary input pins, and then have a 10K pull-up
from each pin to the single additional pin. To read your inputs, first pull
all of them high with the pull-ups. Read the values. Then pull all low, and
read the values. The ones that changed when you changed the pull-up state
are tri-state. The ones which were always low are low, and the ones that
were always high are high.

Alternatively, use PORTB or other such port which has internal pull-ups.
You can eliminate the additional pin, just toggle the internal pull-ups.

Sean

At 12:10 AM 2/26/00 +1300, you wrote:
>Roger Hawkins <.....rdhawkinsRemoveMEspamwbmpl.com.au>,bill roberts
<.....billyleebobSTOPspamspam@spam@home.com>, ADR <infoEraseMEspam@spam@adr.co.nz>
>To: RemoveMEPICLISTspamspamBeGoneMITVMA.MIT.EDU
>
>This may be old hat.
>Anyone care to critique my thought processes.
>

|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
spamBeGoneshb7KILLspamspam@spam@cornell.edu ICQ #: 3329174

2000\02\28@013318 by Russell McMahon

picon face
Reading ternary inputs.
Sean suggested applying inputs to pins directly plus resistors from each
input to an "extra i/o pin"

So

Yes - this works with the use of 1 extra pin plus 1xR per pin and no need
for caps or rc timing.

One algorithm could be -

Extra pin hi
Read input to VA
Extra pin low
Read input to VB

VC = Va XOR VB - high bits are tristates

Vd = Va XOR VC - high bits are highs

Vd = Vb XOR Complement(Vc) - high bits are lows


VC, Vd etc aren't necessarily actual registers- just intermediate steps in
process.

Efficiency

Pins                           1    2    3    4
Levels binary            2    4    8    16
Levels ternary           3    9    27  81
Levels as above       -     3    9    27

Better than binary at 3 pins.
Always 1 pin worse than true ternary (of course).





     Russell McMahon

{Original Message removed}


'How can I connect analog inputs to PIC?'
2000\06\14@065539 by Chunhee Song
flavicon
face
Hello,

I am trying to see the DC motor step response and want to connect two
leads from motor to A/D input in PIC. I am using Vdd/Vss as a reference
voltage. When I read the datasheet for pic16f873, the one lead(+) is
connected to PIC input(AN0) and the other lead is connected to Rs(?) that
is again connected to VA(?) to Vss.

 So, can I use 10Kohm that is connected to (-) motor? And what is VA?

       Rs      motor
  ---/\/\/---(-)    (+)---- AN0
  |
  |
 VA(?)
  |
  |
 ___
  _
 VSS

Is that right??

Thanks, Chunhee Song

2000\06\14@082323 by Vasile Surducan

flavicon
face
On Wed, 14 Jun 2000, Chunhee Song wrote:

> Hello,
>
> I am trying to see the DC motor step response and want to connect two
> leads from motor to A/D input in PIC. I am using Vdd/Vss as a refe

  PIC is measuring analogic voltage between analogic inputs and ground.
If you have a unipolar stepper ( or something ) conect a small series
resistor with coil to ground ( through driver) and measure the voltage
across resistor.
Vasile

2000\06\14@093836 by Chunhee Song

flavicon
face
Hi, Vasile. What is driver?
By the way, the voltage comming out of the DC motor(this is my
tachometer) is driven by another motor attatched through shaft.
thank you.

On Wed, 14 Jun 2000, Vasile Surducan wrote:

{Quote hidden}

'[PICLIST] A/D MIn and Max inputs on 12C672'
2000\06\22@202546 by BK2001

flavicon
face
Piclist:
Is there a Min and a Max voltage for a 12C672 port pin that is used as an
analog input?  I understand that going past Vdd or Vss will cause accuracy
problems, but if it is powered with +5V, will 10V at the input cause a
problem?  Will the protection diode get burnt? Or will I need to ensure that
voltages presented to the input stay within a certain range?

Thanks in advance,
Bill Kennedy

2000\06\23@100828 by fernteix

flavicon
face
Hi Bill,

This is a general problem: the start-up of the power supplies with signals
already applied to the chips. I have not yet a final solution, and would
like to read other opinions.
If you read the Ratings you will find (i have not here the data) about 5,5V
and if Vin > Vcc, to protect the input clamping circuit, you must limit the
current to < 20mA.
If you use a resistor in series to  limit the current to a few mA, in each
input, I think ( not 100% sure ) you have protected the device. Of course R
+ parasitic C is a filter and you are limiting the high frequency response.
My .2 cent.
Regards
Fernando

{Original Message removed}

2000\06\23@114512 by Dan Michaels

flavicon
face
Fernando wrote:
>Hi Bill,
>
>This is a general problem: the start-up of the power supplies with signals
>already applied to the chips. I have not yet a final solution, and would
>like to read other opinions.

Yes, this is a problem. The pullup clamping diodes on the PIC I/O pins
provide a sneak pathway for external signals to get onto the Vdd line,
and the PIC will be powered or partially powered. Then, when you turn
on the Vdd supply proper, the chip may not reset correctly. I try not
to do this, but others may have a hard solution. Adding a series R in
I/O will help, but may not solve this problem. A properly-designed
reset ckt may help here.
===============

>If you read the Ratings you will find (i have not here the data) about 5,5V
>and if Vin > Vcc, to protect the input clamping circuit, you must limit the
>current to < 20mA.
>If you use a resistor in series to  limit the current to a few mA, in each
>input, I think ( not 100% sure ) you have protected the device. Of course R
>+ parasitic C is a filter and you are limiting the high frequency response.

I don't believe the RC due to parasitic C will matter very much, given
the frequency range of signals "normally" applied to a PIC. Assuming Cpara
of about 20 pF [high-estimate], and R = 3.3K, F3db = 1/(2*pi*R*C) = 2.4 Mhz.

Series R of 3.3K will protect the PIC to overvoltages in the range of
20 mA * 3.3K = 66V. However, it can also supply ~1.5 mA via the sneak
pathway described above.

Going with a much larger R = 33K, and 20 pF, the time-constant will be
about 0.6 usec, which is pretty fast viz-a-viz the PIC's detecting
signals.

regards,
- DanM

'[PICLIST] A/D MIn and Max inputs on 12C672 [PIC]:'
2000\06\23@124422 by Dan Michaels

flavicon
face
reposted - with [PIC]: thingie added
------------------------------------

Fernando wrote:
>Hi Bill,
>
>This is a general problem: the start-up of the power supplies with signals
>already applied to the chips. I have not yet a final solution, and would
>like to read other opinions.

Yes, this is a problem. The pullup clamping diodes on the PIC I/O pins
provide a sneak pathway for external signals to get onto the Vdd line,
and the PIC will be powered or partially powered. Then, when you turn
on the Vdd supply proper, the chip may not reset correctly. I try not
to do this, but others may have a hard solution. Adding a series R in
I/O will help, but may not solve this problem. A properly-designed
reset ckt may help here.
===============

>If you read the Ratings you will find (i have not here the data) about 5,5V
>and if Vin > Vcc, to protect the input clamping circuit, you must limit the
>current to < 20mA.
>If you use a resistor in series to  limit the current to a few mA, in each
>input, I think ( not 100% sure ) you have protected the device. Of course R
>+ parasitic C is a filter and you are limiting the high frequency response.

I don't believe the RC due to parasitic C will matter very much, given
the frequency range of signals "normally" applied to a PIC. Assuming Cpara
of about 20 pF [high-estimate], and R = 3.3K, F3db = 1/(2*pi*R*C) = 2.4 Mhz.

Series R of 3.3K will protect the PIC to overvoltages in the range of
20 mA * 3.3K = 66V. However, it can also supply ~1.5 mA via the sneak
pathway described above.

Going with a much larger R = 33K, and 20 pF, the time-constant will be
about 0.6 usec, which is pretty fast viz-a-viz the PIC's detecting
signals.

regards,
- DanM

2000\06\23@125907 by w. v. ooijen / f. hanneman

picon face
> Yes, this is a problem. The pullup clamping diodes on the PIC I/O pins
> provide a sneak pathway for external signals to get onto the Vdd line,
> and the PIC will be powered or partially powered. Then, when you turn
> on the Vdd supply proper, the chip may not reset correctly. I try not
> to do this, but others may have a hard solution. Adding a series R in
> I/O will help, but may not solve this problem. A properly-designed
> reset ckt may help here.

I think some problems (latch-up?) are not cured by a reset. On my
breadboard circuits (powered by an 7805 or similar) I often just short the
power to achieve a guaranteed clean start....
Wouter

2000\06\23@133614 by Dan Michaels

flavicon
face
Wouter wrote:
>> Yes, this is a problem. The pullup clamping diodes on the PIC I/O pins
>> provide a sneak pathway for external signals to get onto the Vdd line,
>> and the PIC will be powered or partially powered. Then, when you turn
>> on the Vdd supply proper, the chip may not reset correctly. I try not
>> to do this, but others may have a hard solution. Adding a series R in
>> I/O will help, but may not solve this problem. A properly-designed
>> reset ckt may help here.
>
>I think some problems (latch-up?) are not cured by a reset. On my
>breadboard circuits (powered by an 7805 or similar) I often just short the
>power to achieve a guaranteed clean start....

Ah, the famous [and underutilized] crowbar - be it "manual" or
builtin cktry. Crowbar - the last resort of the thoroughly
thorough engineer.

In the case at hand, I am not sure the problem is "latchup", per
se, but rather the PIC is partially powered by the sneak pathway
and in some indeterminate state. So applying normal full power
doesn't reset it properly, but a reset ckt or PIC brownout feature
might work here <-- conjecture. Maybe someone else has actually
investigated this.

- DanM

2000\06\23@150911 by w. v. ooijen / f. hanneman

picon face
> In the case at hand, I am not sure the problem is "latchup", per
> se, but rather the PIC is partially powered by the sneak pathway
> and in some indeterminate state. So applying normal full power
> doesn't reset it properly, but a reset ckt or PIC brownout feature
> might work here <-- conjecture. Maybe someone else has actually
> investigated this.

But the crowbar (or removing the power and 'crowbarring' with 10 - 100 ohm)
will help against sneaky power too!
Wouter

2000\06\25@073611 by D. Schouten

picon face
Had the same problem once. I solved it using an external
TL7757C TI reset IC. Worked without any problems since then.
I haven't tried the brownout function of the PIC itself yet.
In those days, it wasn't implemented in the PICs I used.

Daniel...

{Original Message removed}


'[EE]: Offset Inputs'
2000\07\02@153218 by Ed Edmondson
picon face
What is the correct way to terminate the offset inputs on an op amp?  I have
an op amp circuit where the offset pins are not used.  The circuit (an App
Note) just has them floating in space.  Is this acceptable or should they be
tied somewhere?  The amp in question is a Maxim ICL7611ACPA.

Ed

http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\07\02@162616 by Bob Blick

face
flavicon
face
Hi Ed,

Unused offset pins can be ignored on all the opamps I've ever used.

-Bob

At 03:31 PM 7/2/2000 EDT, you wrote:
>What is the correct way to terminate the offset inputs on an op amp?  I have
>an op amp circuit where the offset pins are not used.  The circuit (an App
>Note) just has them floating in space.  Is this acceptable or should they be
>tied somewhere?  The amp in question is a Maxim ICL7611ACPA.

http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


'[PIC]:Inputs & Outputs'
2000\09\05@083102 by brah
flavicon
face
       I've read the discussions re port registers and latches where care has
to be taken, and I've noted the necessities.
       However, I wonder if it is common, or even regular, to swap a pin from
input to output and back again repeatedly every mS or so.  i.e. to have
a button and a led on the same pin - with resitors to protect the pin
being shorted to either pos or neg by the button, when it's an output.
       Sort of multiplexed in-out. This would save a few pins on my project,
and maybe get it back from an 877 to an 876.
       Thoughts on this would be appreciated.
       Regards to all
               Howard.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\09\05@095807 by Bob Ammerman

picon face
Sure, this kind of stuff happens all the time. I use this exact technique in
a 16C84 project of mine. It should work fine.

Note that it is often a good idea to make sure you have an R in series with
the button, this limits ESD inrush currents.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2000\09\05@121609 by Dan Michaels

flavicon
face
At 10:36 PM 9/5/00 +1000, you wrote:
>        I've read the discussions re port registers and latches where care has
>to be taken, and I've noted the necessities.
>        However, I wonder if it is common, or even regular, to swap a pin from
>input to output and back again repeatedly every mS or so.  i.e. to have
>a button and a led on the same pin - with resitors to protect the pin
>being shorted to either pos or neg by the button, when it's an output.
..........


This shouldn't cause any problems - as long as the pin is protected
from accidental shorts, as you propose. If you implement an I2C master
on the PIC, you swap the data line input<->output every few usec, so
I imagine it should be ok in general.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\09\05@133052 by Nick Reed

flavicon
face
This type of direction switching is quite common. It is needed in other
aplicaions as well. For example when implementing a master mode IIC bus
device in software.

Take a look Microchips app note number AN615 for an example of what you want
to do.


{Original Message removed}

2000\09\05@173103 by Russell McMahon

picon face
No reason why you shouldn't do this as long as you design what happens under
ALL states.
Depending on the design:
The button will turn the LED on or off directly when pressed unless you are
clever.
.
A simple scheme may be to have the LED with an eg 1K from pin to L:ED Anode
and LED cathode to ground.
Switch goes via 220r say from pin to Vcc.
When LED alone is present pin will look like a low when changed to input.
When button is pressed pin will rise to about (1000/(220+1000)*(5-1.5) +
1.5) = ~ 4.3V which will be seen as a high.
When the pin is an output and is low it would sink about 20mA if the switch
was pressed.
BUT there is never any need for the pin to be an output and low as
- When it is a high output the LED is on.
- The LED can be turned off by making it an input.

You could therefore notionally make this circuit with a LED resistor but NO
button resistor with no risk. I wouldn't!
When the button is pressed the LED will light if it is off at the time. If
it is on it will remain on.
.




     Russell McMahon
_____________________________

What can one man* do?   Help the hungry at no cost to yourself!
at  http://www.thehungersite.com/
(* - or woman, child or internet enabled intelligent entity :-))
From other worlds:
http://www.changingourworld.com    http://www.easttimor.com   http://www.sudan.com


{Original Message removed}

2000\09\05@175949 by Tony Nixon

flavicon
picon face
brah wrote:
>
>         I've read the discussions re port registers and latches where care has
> to be taken, and I've noted the necessities.
>         However, I wonder if it is common, or even regular, to swap a pin from
> input to output and back again repeatedly every mS or so.  i.e. to have
> a button and a led on the same pin - with resitors to protect the pin
> being shorted to either pos or neg by the button, when it's an output.
>         Sort of multiplexed in-out. This would save a few pins on my project,
> and maybe get it back from an 877 to an 876.
>         Thoughts on this would be appreciated.
>         Regards to all
>                 Howard.
>
> --
> http://www.piclist.com hint: The list server can filter out subtopics
> (like ads or off topics) for you. See http://www.piclist.com/#topics

There is no reason that you cannot use the IO ports like that.

Check out App Note AN529
Multiplexing LED drive and a 4 X 4 keypad.

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
salesspam_OUTspam@spam@picnpoke.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\09\05@185200 by David Duffy

flavicon
face
At 10:36 PM 05/09/00 +1000, you wrote:
>         I've read the discussions re port registers and latches where
> care has
>to be taken, and I've noted the necessities.
>         However, I wonder if it is common, or even regular, to swap a pin
> from
>input to output and back again repeatedly every mS or so.  i.e. to have
>a button and a led on the same pin - with resitors to protect the pin
>being shorted to either pos or neg by the button, when it's an output.
>         Sort of multiplexed in-out. This would save a few pins on my project,
>and maybe get it back from an 877 to an 876.
>         Thoughts on this would be appreciated.
>         Regards to all
>                 Howard.

I do this all the time for the illuminated switches I use.
One way to do it is to have the LED anode go to +5 via a 330R resistor.
The LED cathode goes to the PIC pin and also to one side of the switch.
The other side of the switch goes to 0V. This means that the LED will be
on whenever the switch is down but this is OK for most applications.
To turn the LED on, set the PIC pin low and output. To leave the LED off,
set the PIC pin low and input. To read the switches just read the port.
Never set the PIC pin high and output lest the switch be pressed and
short it to 0V. Use a shadow register to hold the LED data and use that
as a mask to TRIS the port. Clear the port before the TRIS instruction.
Hope this makes sense. You may want to include pullup's on the port.
Regards...

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\09\06@150945 by Oliver Broad

flavicon
face
>         However, I wonder if it is common, or even regular, to swap a pin
from
> input to output and back again repeatedly every mS or so.  i.e. to have
> a button and a led on the same pin - with resitors to protect the pin
> being shorted to either pos or neg by the button, when it's an output.

It works.

One snag you may hit is the low input threshold of a normal pin, some
configurations of switches and steering diodes won't pull the pin down well
enough. A simple solution is to make the switch pull up not down.

If the device being driven doesn't load the pic pin appreciably then it is
easy to read a switch through a resistor, say 10k, just insert enough NOPs
after switching to input for it to stabilise. If a small capacitance is
present then it is possible to detect at least three states, pulled low,
pulled high, floating. This was used to add an ID to an existing board by
modifying two control lines that normally drive a multiplexer. Since an LED
to ground shouldn't pull the pin down it may be possible to have one LED and
a three position switch or two exclusive pushbuttons on the same pin.

I vaguely remember a design being described on the old BBS for six LEDs
driven by three pins but I forget how it was done.

Oliver.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\09\07@040213 by Minto Witteveen

flavicon
face
It works indeed.

I use it to simulate a 'poor mans AD input' on a 16f84. - to read out the
analog value of a potmeter.
The output of RA0 is connected to a 1mu cap to ground, in parallel with this
cap i have a 250K potmeter in series with a 100K resistor.
Initially (in an interrupt routine executed every 3.7 ms) I make RA0 an
output (high) - so charging the capacitor to +5v. During the next interrupt
I make RA0 an input and then count the number of interrupts needed for RA0
to read '0' again - this is dependent on the position of the potmeter. In my
case this varies form roughly 2 interrupts to 255..... works like a charm.

Minto.

{Original Message removed}


'[PIC]:Interupt on change and PortB Inputs'
2000\10\05@233215 by Dan Devine
picon face
When a PIC (16F84) is configured for interupt on change of state on the
RB ports (not RB0),  do all of the pins need to be configured as input?

To be more specific,  can I use some of the possible "interupt on
change" pins as output and only configure one of the pins as an input?
When I do this, will changing the output state of the other pins cause
an interupt?  These issues are not covered very will in the Microchip
data.


Thanks

Dan D

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\10\05@235114 by Tony Nixon

flavicon
picon face
Dan Devine wrote:
>
> When a PIC (16F84) is configured for interupt on change of state on the
> RB ports (not RB0),  do all of the pins need to be configured as input?
>
> To be more specific,  can I use some of the possible "interupt on
> change" pins as output and only configure one of the pins as an input?
> When I do this, will changing the output state of the other pins cause
> an interupt?  These issues are not covered very will in the Microchip
> data.
>
> Thanks
>
> Dan D
>
> --
> http://www.piclist.com hint: The list server can filter out subtopics
> (like ads or off topics) for you. See http://www.piclist.com/#topics

Any pin that is set as an output is excluded from the comparison which
causes the interrupt.

You can see this depicted as an AND gate in the RB7:RB4 pins block
diagram.

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
spamBeGonesales@spam@spampicnpoke.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics



'[PIC]: Can PIC's inputs be left floating?'
2000\11\06@073627 by Bala Chandar
flavicon
face
In designing circuits with CMOS chips, the basic rule is that you should not
leave any unused inputs floating. They are tied either to +V or Ground or
there is a pull-up / pull-down resistor. Is the same rule applicable when
you design circuits using PIC micros? If you define a port or a pin as
input, are there internal pull-up / pull-down resistors that are enabled
automatically?

Thanks for helpful responses.

Regards,
Bala Chandar

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistservEraseMEspamKILLspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@082425 by Bob Ammerman

picon face
This has been discussed several times:

You will find the following answers, choose 1 (or more):

- Make your unused pins outputs, and don't connect anything to them

- Make your unused pins inputs, and ....

--- Tie them directly to Vcc
--- Tie them directly to GND
--- Pull them up to Vcc
--- Pull them down to GND
--- Rely on the built in pull-up resistors on PORTB

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)


{Original Message removed}

2000\11\06@090445 by Olin Lathrop

flavicon
face
> In designing circuits with CMOS chips, the basic rule is that you should
not
> leave any unused inputs floating. They are tied either to +V or Ground or
> there is a pull-up / pull-down resistor. Is the same rule applicable when
> you design circuits using PIC micros? If you define a port or a pin as
> input, are there internal pull-up / pull-down resistors that are enabled
> automatically?

PICs generally don't have pullups except for MCLR and optionally on port B.
The best thing to do with unconnected pins is to set them as outputs.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolinspam_OUTspamRemoveMEcognivis.com, http://www.cognivis.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use .....listservspamRemoveMEmitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@091108 by David Kott

flavicon
face
> In designing circuits with CMOS chips, the basic rule is that you should
not
> leave any unused inputs floating. They are tied either to +V or Ground or
> there is a pull-up / pull-down resistor. Is the same rule applicable when
> you design circuits using PIC micros? If you define a port or a pin as
> input, are there internal pull-up / pull-down resistors that are enabled
> automatically?
>

The rule is indeed applicable to PIC processors with I/O configured as
inputs.  The same sorts of high currents flow when a PIC's inputs start
wavering near the bias points of the input transistors.  There are no
internal pull-ups or pull-downs that enable automatically.

There *are* however, internal pull-ups on PortB in most PICs.  You can use
these to pull up any pins configured as inputs and left floating.

Personally, if I don't use a pin in a design, I will configure it as an
output in software.

-d

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use listservspam@spam@mitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@091322 by Kevin Blain

flavicon
face
internal pullup on MCLR? news to me.

> PICs generally don't have pullups except for MCLR and optionally on port
B.
> The best thing to do with unconnected pins is to set them as outputs.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use EraseMElistservRemoveMEspamSTOPspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@100927 by mike

flavicon
face
On Mon, 6 Nov 2000 21:36:01 +0900, you wrote:

>In designing circuits with CMOS chips, the basic rule is that you should not
>leave any unused inputs floating. They are tied either to +V or Ground or
>there is a pull-up / pull-down resistor. Is the same rule applicable when
>you design circuits using PIC micros? If you define a port or a pin as
>input, are there internal pull-up / pull-down resistors that are enabled
>automatically?
There are no automatic pullups. There are about 4 ways to do it, there us no 'best' way - it depends
on the application. 1) tie the pin high or low and set it as an input. This can be handy
if PCB layout is tight as you can route power/ground through the pin. 2) Leave it open and set it as an output. This has the advantage that
you can use the pin to output debugging signals or data, and also
simplifies any 'last minute pcb alterations' if you suddenly find you
need another pin.
This is not such a good idea if ultra-low power consumption is
required over reset or WDT reset as the pins will float briefy before
the  code starts, but it is not normally a problem. 3) Leave it open, set as input and use internal pullups (usually port
B only) if the pullups will not cause problems for other pins (e.g.
due to power draw)
4) Tie it to another pin (input or output) and  set it as an input.
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistservKILLspamspamTakeThisOuTmitvma.mit.edu?bodyT%20PICList%20DIGEST




2000\11\06@115927 by Harold M Hallikainen

picon face
       The unused PIC pin question comes around a lot!  Only portB has internal
pull-ups that can be enabled. Without them enabled, or on other ports,
input pins should not be allowed to float. I always leave unused pins
floating and set them as outputs. I can easily modify my circuit later if
I need those pins.

Harold


On Mon, 6 Nov 2000 21:36:01 +0900 Bala Chandar <spamBeGoneBala.Chandarspam@spam@AVENTIS.COM>
writes:
{Quote hidden}

FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
dl.http://www.juno.com/get/tagj.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use listservspamspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\11\06@120150 by jamesnewton

face picon face
www.piclist.com/../logic/xtrapins.htm

---
James Newton (PICList Admin #3)
spam_OUTjamesnewtonspam_OUTspamspam_OUTpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

{Original Message removed}

2000\11\06@143544 by mike

flavicon
face
On Mon, 6 Nov 2000 14:13:16 -0000, you wrote:

>internal pullup on MCLR? news to me.
PIC12C508/9 - and a real pain it is too if you use simple
zener-resistor brownout ccts!!
>> PICs generally don't have pullups except for MCLR and optionally on port
>B.
>> The best thing to do with unconnected pins is to set them as outputs.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use listservspam_OUTspammitvma.mit.edu?bodyT%20PICList%20DIGEST





'[PIC]: grounding unused inputs'
2001\01\14@074732 by Jose S. Samonte Jr.
picon face
Do unused inputs really need to be connected to ground?
What is the effect if they are not grounded?
Does it affect operation of the PIC?
Thank you very much.

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@090241 by mike

flavicon
face
On Sun, 14 Jan 2001 05:46:58 MST, you wrote:

>Do unused inputs really need to be connected to ground?
>What is the effect if they are not grounded?
>Does it affect operation of the PIC?
>Thank you very much.
>
>____________________________________________________________________
>Get free email and a permanent address at http://www.netaddress.com/?N=1
Unused pins should be connected to either 0V or Vdd, or set as
outputs. For PORT B you could also enable pull-ups as an alternative
if this doen't cause problems with other pin usage. If left unconnected,  they may float to intermediate voltages and
cause increased (and erratic) power consumption and  noise.
For a breadboard lash-up it usually doesn't really matter, but any
production circuit should avoid floating inputs.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@111508 by Olin Lathrop

face picon face
>>
Do unused inputs really need to be connected to ground?
What is the effect if they are not grounded?
Does it affect operation of the PIC?
<<

This has been beaten to death several times.  Check the archive.

I leave unused pins open and set them as outputs.  I usually tie unused
input-only pins to ground.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, RemoveMEolinKILLspamspam@spam@embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@124041 by David VanHorn

flavicon
face
At 05:46 AM 1/14/01 -0700, Jose S. Samonte Jr. wrote:
>Do unused inputs really need to be connected to ground?
>What is the effect if they are not grounded?
>Does it affect operation of the PIC?
>Thank you very much.

They don't have to be inputs on the pic, make them outputs, and let them float.

If you leave them as inputs, then yes, they should be connected to a logic
level, either high or low will do. Ground is probably slightly better for EMI.
--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@125936 by Dan Michaels

flavicon
face
Olin Lathrop wrote:
>>>
>Do unused inputs really need to be connected to ground?
>What is the effect if they are not grounded?
>Does it affect operation of the PIC?
><<
>
>This has been beaten to death several times.  Check the archive.
>
>I leave unused pins open and set them as outputs.  I usually tie unused
>input-only pins to ground.
>

To be "safe", it is best to tie unused input pins to ground [or Vcc,
doesn't much matter which] *ONLY* through a resistor, rather than
directly with a short. This is not superstition, as during code
development it is all too easy to accidentally configure a pin
intended as input to output. You then run the risk of
short-circuiting an output.

Furthermore, having a resistor on the pin, rather than a short,
makes it much easier to utilize that pin later on for some useful
function, as the need may arise.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@152445 by Olin Lathrop

face picon face
> To be "safe", it is best to tie unused input pins to ground [or Vcc,
> doesn't much matter which] *ONLY* through a resistor, rather than
> directly with a short. This is not superstition, as during code
> development it is all too easy to accidentally configure a pin
> intended as input to output. You then run the risk of
> short-circuiting an output.

Perhaps in a low volume product.  I wouldn't want to burden a high volume
product with unnecessary parts for a minor debugging convenience.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinspamBeGonespam.....embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@175023 by Dan Michaels

flavicon
face
Olin Lathrop wrote:
>> To be "safe", it is best to tie unused input pins to ground [or Vcc,
>> doesn't much matter which] *ONLY* through a resistor, rather than
>> directly with a short. This is not superstition, as during code
>> development it is all too easy to accidentally configure a pin
>> intended as input to output. You then run the risk of
>> short-circuiting an output.
>
>Perhaps in a low volume product.  I wouldn't want to burden a high volume
>product with unnecessary parts for a minor debugging convenience.
>

Even in a high volume product, personally I would never simply
(a) configure a pin as output and then leave it unterminated, or
(b) set a pin to input and then short straight it to gnd. There are
a number of possible "disastrous" scenarios this way:

1 - with (a), an ESD spike might modify the TRIS register, set an
   output pin to input, and then it would float and pick up noise,
   and possibly affect proper operation.

2 - with (b), an ESD spike might modify the TRIS resgister, set an
   input pin to output, and fry your product.

3 - with (b), on the next go round with code development, you might
   do the TRIS thing yourself by mistake.

4 - with (b), it takes more work if you want to use the pin
   differently in the future.

5 - other circumstances may accidentally mod the TRIS register in
   the field, eg brownouts, lightning crashes, screwy things related
   to general susceptibility of the /MCLR pin, who knows what.

Better to spend a few pennies and tie the unused pins to gnd via
a bussed SIP resistor net, and improve the reliability of your
product. Also, as mentioned several times, it helps saves the butt
of those of us in the subset of non-perfect coders when they screw
up during development. Good practice for code dev, good practice
for field reliability.

In a nice "guaranteed" noise-free field environment, you might be
ok doing it the "quick-and-dirty" way. But, all in all, better
safe than sorry. Experience, yes. Superstition, no.

- danM

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\15@151904 by Dwayne Reid

flavicon
face
At 05:50 PM 1/14/01 -0500, Dan Michaels wrote:

>Even in a high volume product, personally I would never simply
>(a) configure a pin as output and then leave it unterminated, or
>(b) set a pin to input and then short straight it to gnd. There are
>a number of possible "disastrous" scenarios this way:
>
>1 - with (a), an ESD spike might modify the TRIS register, set an
>     output pin to input, and then it would float and pick up noise,
>     and possibly affect proper operation.

Hi there, Dan.

I would agree with your reasoning above *if* I set the TRIS registers only
at the start of code and never touched them again.  But I consider that to
be bad practice.  I refresh all important registers regularly, usually in
the routine that looks after the watchdog timer.  In fact, I will often
*read* the registers to make sure that it is what I expect them to be,
rather than just refreshing them.  If I get a nasty transient that is
enough to disturb the TRIS or INTCON registers, I figure that I had better
re-init everything anyways.  So: I configure un-used pins as output and set
them LO.

Regarding being able to use some of those un-used pins for later changes,
you are correct in that having pads with holes makes those changes easier
to make.  But you don't need to stuff components in those holes.

dwayne



Dwayne Reid   <KILLspamdwaynerspam.....planet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@155730 by David VanHorn

flavicon
face
>
>I would agree with your reasoning above *if* I set the TRIS registers only
>at the start of code and never touched them again.  But I consider that to
>be bad practice.  I refresh all important registers regularly, usually in
>the routine that looks after the watchdog timer.  In fact, I will often
>*read* the registers to make sure that it is what I expect them to be,
>rather than just refreshing them.  If I get a nasty transient that is
>enough to disturb the TRIS or INTCON registers, I figure that I had better
>re-init everything anyways.  So: I configure un-used pins as output and set
>them LO.


Interesting.
I see what you mean here.
On the AVR or Z8, this isn't a problem because the tris-equivalent
registers can't be modified by inputs like this.  I can easily output a 1
into a short to ground (pointless but harmless) and the chip won't decide
to change it on me.

I think the PIC architecture puts a larger burden on you to protect the
processor from output forcing in your designs.

It's an interesting design wrinkle though, that your output bits could be
changed on you at any time. That, plus the weaknesses in the BSF/BCF
instructions wrt pin loading, argue twoard the shadow register approach for
the port registers.

--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservRemoveMEspamEraseMEmitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@192135 by Dan Michaels

flavicon
face
Dwayne Reid wrote:

>I would agree with your reasoning above *if* I set the TRIS registers only
>at the start of code and never touched them again.  But I consider that to
>be bad practice.  I refresh all important registers regularly, usually in
>the routine that looks after the watchdog timer.


Also a good idea - back when I worked with 6805, Motorola actually
recommended in their databooks to periodically refresh the TRIS
registers [whatever they called them], just in case they are
changed by ESD/noise/etc. This should be easy to do in the outermost
code loop, since the TRIS are usually set on bootup and rarely changed,
in most cases.

- danM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservspamspamBeGonemitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@194035 by Dwayne Reid

flavicon
face
At 03:55 PM 1/15/01 -0500, David VanHorn wrote:

>Interesting.
>I see what you mean here.
>On the AVR or Z8, this isn't a problem because the tris-equivalent
>registers can't be modified by inputs like this.

Hi there, Dave.

Something you wrote puzzles me - maybe there is yet another PIC wrinkle
that I am not aware of.  Is there any condition where the TRIS register can
be changed by something happening on the port pins?  If so, this is a new
problem to me!

The only port related problem I can think of right now is the
read-modify-write issue - its not a problem since I am aware of it.  But I
am not aware of a TRIS register susceptibility.  Is there a problem
there?  What causes it and what does it do?

I always check or refresh TRIS and other important registers simply because
I can't predict what a nasty ESD or EMI event might do to me - all I can do
is deal with the problem if it happens.  But it sure doesn't happen during
normal operation.

dwayne




Dwayne Reid   <dwaynerspamspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspamBeGonespamRemoveMEmitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@214016 by David VanHorn

flavicon
face
At 05:10 PM 1/15/01 -0700, Dwayne Reid wrote:
>At 03:55 PM 1/15/01 -0500, David VanHorn wrote:
>
>>Interesting.
>>I see what you mean here.
>>On the AVR or Z8, this isn't a problem because the tris-equivalent
>>registers can't be modified by inputs like this.
>
>Hi there, Dave.
>
>Something you wrote puzzles me - maybe there is yet another PIC wrinkle
>that I am not aware of.  Is there any condition where the TRIS register can
>be changed by something happening on the port pins?  If so, this is a new
>problem to me!

Sorry, I meant port not tris :)

--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2001\01\16@014433 by yansong gu

flavicon
face
Has anyone used a dragonball for palm alike development?  I just received
some literature from big M.  Wonder where is a good start from a picer's
point.

Yansong


{Original Message removed}

'[PIC]: Reading Outputs as Inputs'
2001\01\17@173040 by Shawn Yates

flavicon
face
> Hello all,
>
>       I remember from the tech data that if you read an output pin it will
> read as the physical state of the pin rather than the output buffer.  SO,
> if I were to set a pin as an output and set it, then pull it low, I would
> read a low.  I am trying to reuse an existing board without any
> 'engineering modifications' (read as CLUDGE).  Can I set a pin as an
> output, drive it high and short it to ground with a jumper without
> damaging the processor?  Current overhead is not a big deal, I just dont
> want to cook my processor.
>
> TIA
>
> Shawn

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\18@073830 by Simon Nield

flavicon
face
shawn:
>Can I set a pin as an
> output, drive it high and short it to ground with a jumper without
> damaging the processor?

I wouldn't recommend it, but you can limit the likelyhood of damage by having the pin tristated off
most of the time and only enabling the drive a few cycles before reading the pin and disabling the
drive straight afterwards.

Regards,
Simon

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@085942 by Bob Ammerman

picon face
> >Can I set a pin as an
> > output, drive it high and short it to ground with a jumper without
> > damaging the processor?
>
> I wouldn't recommend it, but you can limit the likelyhood of damage by
having the pin tristated off
> most of the time and only enabling the drive a few cycles before reading
the pin and disabling the
> drive straight afterwards.

Yes, this will work, and probably safely. Watch out for the current spike on
Vdd, though. You need to check the decoupling and make sure you won't get a
malfunction because of this.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@103444 by mike

flavicon
face
On Thu, 18 Jan 2001 10:11:43 +0000, you wrote:

>shawn:
>>Can I set a pin as an
>> output, drive it high and short it to ground with a jumper without
>> damaging the processor?
>
>I wouldn't recommend it, but you can limit the likelyhood of damage by having the pin tristated off
>most of the time and only enabling the drive a few cycles before reading the pin and disabling the
>drive straight afterwards.
This can be a useful method to avoid pullup R's (or re-use existing
output pins) in applications where a very occasional input only is
needed, e.g. to enter a factory calibration/test mode. You can
minimise possible damage by only pulsing the output high for a few
cycles if you expect it to be shorted (e.g. after powerup, to enter a
test mode)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@121041 by Simon Nield

flavicon
face
me:
>pin tristated off

downside of this is having the pin tristated if it is not pulled low -> possible source of noise
into the chip.

might be a good opportunity to make use of the usually irritating lack of a shadow register for the
port states:

; pin0 of port D is either connected to ground, vcc, or open circuit
; if o/c or vcc pin0 is driven high, if connected to ground pin0 is driven low
bsf   PORTD, 0    ; try and pull the pin high
clrw              ; (and wait a bit to let the voltage rise)
xorwf PORTD, F    ; read state of port D and drive it that way
                 ; if pin0 was pulled low it will now be driven low
                 ; if pin0 was floating or high it will now be driven high

then again, no obvious advantages to that over:

; pin0 of port D is either connected to ground or open circuit
; if o/c C will be set, if connected to ground C will be cleared
bsf   PORTD, 0    ; try and pull the pin high
nop               ; wait a bit to let the voltage rise
rrf   PORTD, W    ; state of pin0 port D into Carry
bcf   PORTD, 0    ; pull the pin low



oh well... probably just pointless rambling, but the use of 'clrw/ xorwf portX, F' does feel like it
_should_ be really useful.

Regards,
Simon

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@123834 by Shawn Yates

flavicon
face
Sounds like something to try.  I will give it a go.  Any other insights or
thoughts are welcome.

Thanks

Shawn

{Original Message removed}

2001\01\18@132406 by Barry Gershenfeld

picon face
>       I remember from the tech data that if you read an output pin it will
> read as the physical state of the pin rather than the output buffer.  SO,
> if I were to set a pin as an output and set it, then pull it low, I would
> read a low.  I am trying to reuse an existing board without any
> 'engineering modifications' (read as CLUDGE).  Can I set a pin as an
> output, drive it high and short it to ground with a jumper without
> damaging the processor?

(suggestions posted...)

>Sounds like something to try.  I will give it a go.  Any other insights or
>thoughts are welcome.
>Thanks
>Shawn

Depending on what the external circuitry is, perhaps you could
arrange for this line to be normally 'high' anyway (use a pullup
resistor.)  The you can set the pin as an input and read it
normally.  After all, if you can't be sure the external circuitry
will leave that line high, then you can't be sure that a low
that you read back has come from this shorting switch you want
to add.

Barry

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@133235 by Shawn Yates

flavicon
face
Barry,

I am trying to avoing the adding of a pull-up.  Till now, the pin had no
purpose.  It is not connected to any circuitry except for a header.  Now I
want to use that pin as an input to allow the user to select a setting (by
shorting or not shorting the header to power or ground.

Thanks

Shawn

> read a low.  I am trying to reuse an existing board without any
> 'engineering modifications' (read as CLUDGE).  Can I set a pin as an

Depending on what the external circuitry is, perhaps you could
arrange for this line to be normally 'high' anyway (use a pullup
resistor.)  The you can set the pin as an input and read it
normally.  After all, if you can't be sure the external circuitry
will leave that line high, then you can't be sure that a low
that you read back has come from this shorting switch you want
to add.

Barry

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@134535 by Barry Gershenfeld

picon face
>Barry,
>
>I am trying to avoing the adding of a pull-up.  Till now, the pin had no
>purpose.  It is not connected to any circuitry except for a header.  Now I
>want to use that pin as an input to allow the user to select a setting (by
>shorting or not shorting the header to power or ground.
>Thanks
>Shawn

After I sent the message, I remembered, "without modifying the board". But
I figured if you had to add a switch, you'd have something to attach
a resistor to.  Now I know you're just shorting a connection.

If you're fortunate enough to be using a chip like a 16x74 and haven't
used port B, you can set 'weak pullups' internally and get exactly
what you want.

Well, it was a nice thought, anyway :)

Barry

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@145833 by Bob Ammerman

picon face
> Barry,
>
> I am trying to avoing the adding of a pull-up.  Till now, the pin had no
> purpose.  It is not connected to any circuitry except for a header.  Now I
> want to use that pin as an input to allow the user to select a setting (by
> shorting or not shorting the header to power or ground.

Ah, the light goes on.

Ok, so the pin is connected to either ground, high or nothing.

I am assuming that the pin's connection does _not_ change while the program
is running.

Here is how I would handle it at initialization.

Set pin high
Read pin
if pin is low then
   it is grounded externally
   leave it an input
   goto done.
end if

Set pin low
Read pin
if pin is high then
   it is tied high externally
   leave it an input
   goto done.
endif

if we get here the pin is floating. configure it as an output so it doesn't
float.

done:

Note that this tecnhique lets you detect you three possible states for the
pin (high, low, float).

At worst, you are only driving it for an instruction time or two against the
opposite value.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@154511 by Dan Michaels

flavicon
face
Shawn Yates wrote:

>I am trying to avoing the adding of a pull-up.  Till now, the pin had no
>purpose.  It is not connected to any circuitry except for a header.  Now I
>want to use that pin as an input to allow the user to select a setting (by
>shorting or not shorting the header to power or ground.
>

Shawn, you have now discovered the reason I always recommend
tying a pulldown [or pullup] on every single unused pin on a
processor, rather than using one of the alternate schemes
[config as output/short to gnd/etc/etc/etc/etc] others have
mentioned recently on other threads.

Additionally, I would strongly recommend using a [small value]
series R inline in pins going to a header. Otherwise, too
durn easy to fry a pin with overvoltage or ESD, or short
an output. Been there, done that, replaced chips [not
superstition].

- danM

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@160942 by Shawn Yates

flavicon
face
Thanks for the heads up.

-----Original Message-----
From: Dan Michaels [@spam@oricomSTOPspamspam@spam@USWEST.NET]
Sent: Thursday, January 18, 2001 3:45 PM
To: PICLISTspamBeGonespamspamBeGoneMITVMA.MIT.EDU
Subject: Re: [PIC]: Reading Outputs as Inputs


Shawn Yates wrote:

>I am trying to avoing the adding of a pull-up.  Till now, the pin had no
>purpose.  It is not connected to any circuitry except for a header.  Now I
>want to use that pin as an input to allow the user to select a setting (by
>shorting or not shorting the header to power or ground.
>

Shawn, you have now discovered the reason I always recommend
tying a pulldown [or pullup] on every single unused pin on a
processor, rather than using one of the alternate schemes
[config as output/short to gnd/etc/etc/etc/etc] others have
mentioned recently on other threads.

Additionally, I would strongly recommend using a [small value]
series R inline in pins going to a header. Otherwise, too
durn easy to fry a pin with overvoltage or ESD, or short
an output. Been there, done that, replaced chips [not
superstition].

- danM

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@162052 by Germain Morbe

flavicon
face
> I am trying to avoing the adding of a pull-up.  Till now, the pin had no
> purpose.  It is not connected to any circuitry except for a header.  Now I
> want to use that pin as an input to allow the user to select a setting (by
> shorting or not shorting the header to power or ground.
>

Shawn,
one thing i frequently use in such situations, even in greater volumes and
without any problems is the following. If the port is totally tristate and
can only be shorted to ground by a jumper, i use the pin and pcb capacity to
examine the jumpers position with this few steps:

1. Have the pin configured as an output and leave it cleared all the time.
2. To read the pin set it to high and configure it as an input within two
consecutive steps.
   Usually you drive current out of the pin for just 2 cycles that way.
3. If open, the pin reads high for AT LEAST 10 to 20 cycles at 4MHz., if
shorted it reads low     just the very next instruction.
You can use a scope to examine the decay time when open. Its pretty slow.

This method is not an idea, it is actually in use on lots of different
series production boards.

Germain Morbe

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\19@035833 by Roman Black

flavicon
face
Bob Ammerman wrote:
{Quote hidden}

I'm surprised at this! With all the professionals
on this list, I have become used to the "never go
outside the spec" attitude, like never exceeding
clock frequency etc. I really don't like the idea
of driving a pin against a voltage source or sink,
at 5v or 0v, this is as bad as driving a pin into
a short circuit - which I wouldn't do either!

Doing it only for "an instruction or two" doesn't
seem to make it any better, it is still so far
out of spec to be scary. I would much prefer to
overclock a PIC at 1.5x its clock freqency than to
do something like this!
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@043553 by Bob Ammerman

picon face
> Bob Ammerman wrote:
> >
> > > Barry,
> > >
> > > I am trying to avoing the adding of a pull-up.  Till now, the pin had
no
> > > purpose.  It is not connected to any circuitry except for a header.
Now I
> > > want to use that pin as an input to allow the user to select a setting
(by
> > > shorting or not shorting the header to power or ground.
> >
> > Ah, the light goes on.
> >
> > Ok, so the pin is connected to either ground, high or nothing.
> >
> > I am assuming that the pin's connection does _not_ change while the
program
{Quote hidden}

doesn't
> > float.
> >
> > done:
> >
> > Note that this tecnhique lets you detect you three possible states for
the
> > pin (high, low, float).
> >
> > At worst, you are only driving it for an instruction time or two against
the
{Quote hidden}

Roman,

I agree that this is _not_ a really good idea, but it isn't as awful as not
being able to perform a required function at all. The original post
indicated that no changes to the board were permitted.

Also, we have to think about the consequences of driving into a short. There
are three that I can think of:

1: Meeting Voh / Vol specs. This isn't  an issue here, or course.

2: Idd spike with attendent Vdd glitch with all kinds of possible trouble -
that's why I mentioned checking for this.

3: Chip damage. This is a thermal issue.

The first question you have to ask: what is the short circuit current.
Looking at a 16F84A as an example (I don't recall what the original poster
was using):

Max output current (low) = 25ma

Max output current (high) = 20ma

Vol @ 8ma = 0.6V (max)

Voh @ 3ma = Vdd - 0.7V (min)

Ok, from the latter two values we can compute a max value for Rdson of the
output FETs of:

0.6V/8ma == 75 ohms (low side)
0.7V/3ma == 233 ohms (high side)

Given that Microchip isn't in the business of giving away silicon, and that
they probably have a pretty good handle on their process, I'm going to go
out on a limb and assume that the minimum Rdson is at least 33% of the max
Rsdon.

Thus:

Rdson (min, low side) = 25 ohms
Rdson (min, high side) = about 80 ohms

Lets take the worst case, the low side.

5V / 25 ohm = 200 ma

Assume we use this code (to minimize the drive time):

   movlw   TRISB,FSR    ; Point at TRIS register
   bcf    PORTB,x             ; Get ready to drive a low
   bcf    INDF,x                  ; Start the short in this instruction
   movf PORTB,W           ; Get the value
   bsf    INDF,x                 ; Clear the short in this instruction
   <now check the value in PORTB at our leisure>

Thus, we are in the shorted condition for only 2 instructions, or 2
microseconds at 4Mhz (the clock rate is another assumption, of course).

So, we are drawing 200ma for 2 microseconds.

Thermally this is the same as 20ma for 20microseconds.

But, we are allowed to draw 20ma indefinitely.

So, unless the thermal time constant of the output driver is less than about
20microseconds, we are not going to thermally damage the output.

Now, I admit that some of the above analysis is not 'worst case', but it is
reasoned, not just a 'try it and see if it works' attitude.

And no, I didn't do this analysis before posting my orignal response, my
answer was based on a 'seat of the pants' engineering judgement (ie: I've
been here before).

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@045746 by Alan B. Pearce

face picon face
> I'm surprised at this! With all the professionals
> on this list, I have become used to the "never go
> outside the spec" attitude, like never exceeding
> clock frequency etc. I really don't like the idea

Is it really that different to driving directly into the base of a transistor?
The impression I have is most people on this list would do that to drive a relay
or other high current load without a resistor between the output from the PIC
and the base of the transistor - we get enough messages on the list about
reading back the port state when doing this.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@054842 by Simon Nield

flavicon
face
following on from bob's suggestion of detecting the open circuit state too, how about:

; if pin n port x is pulled high  => result = 0xfe, pin is driven high
; if pin n port x is pulled low   => result = 0x00, pin is driven low
; if pin n port x is open circuit => result = 0xff, pin is driven high
; i.e. bit0 set => open circuit, bits7..1 = pin state
bsf    PORTx, n
clrf   result     ; h:00 o:00 l:00
btfsc  PORTx, n
decf   result, f  ; h:ff o:ff l:00

bcf    PORTx, n
decf   result, f  ; h:fe o:fe l:ff
btfss  PORTx, n
incfsz result, f  ; h:fe o:ff l:00
bsf    PORTx, n   ; set pin high to match state


regards,
Simon

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@083507 by mike

flavicon
face
On Fri, 19 Jan 2001 19:54:39 +1100, you wrote:

>Bob Ammerman wrote:
>>
>> > Barry,
>> >
>> > I am trying to avoing the adding of a pull-up.  Till now, the pin had no
>> > purpose.  It is not connected to any circuitry except for a header.  Now I
>> > want to use that pin as an input to allow the user to select a setting (by
>> > shorting or not shorting the header to power or ground.
<snip>
{Quote hidden}

When you've seen a JW pic with bond wires GLOWING and it still works
afterwards you have a lot of faith in the PICs robustness.
>Doing it only for "an instruction or two" doesn't
>seem to make it any better, it is still so far
>out of spec to be scary. It does make a big difference - the only damage mechanism is thermal
heating. If you limit it to a few microseconds there isn't much chance
of heating even something as small as an on-chip transistor enough to
burn it. Also, a short pulse will be supplied by the decoupling cap, so you
don;t risk causing a brownout.

>I would much prefer to
>overclock a PIC at 1.5x its clock freqency than to
>do something like this!
I would disagree - overclockability will be more dependent on
part-to-part differences than the heating effect of a few
microseconds' output short. I would still only use it for 'very occasional' use - things like
production test though.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@094642 by Roman Black

flavicon
face
Bob Ammerman wrote:

{Quote hidden}

Hi Bob, I hear everything you're saying, and I didn't
question your (or the other person's) professionality
for a second. :o)

It just seems somewhat un-"piclist like" to discuss the
correct way to drive a pic pin into a dead short as
a "normal" way of measuring the pin state. It surprised
me!

Your argument is sound re the input and output impedances,
although I do question the calc based on max sourcing and
sinking as these are recommended max I, not actual max I.
I'm sure the PIC pin will drive more than 20-25mA if
driven into a short...

But it still raises the point, why are people so harsh
re the overclocking argument but quite happy to discuss
the "correct" method of driving a PIC pin into a dead
short. You could probably come up with some good arguments
why overclocking by 20% will probably perform great too,
but I'm not going to rush to try either grey area.
Out of spec is out of spec. Next we'll be discussing the
best way to drive a 10amp load with a 3amp transistor,
using time constants and such as our argument??? ;o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@121104 by Bob Ammerman

picon face
> Your argument is sound re the input and output impedances,
> although I do question the calc based on max sourcing and
> sinking as these are recommended max I, not actual max I.
> I'm sure the PIC pin will drive more than 20-25mA if
> driven into a short...

My thinking, as I mentioned, is that these values are based on the Rdson
with determines max specced output current. Mchip isn't about to give you a
lot more silicon than they need to to get the Vol and Voh values, therefore
Rdson can't be much smaller than the numbers I gave. If you really wanted to
be sure, you could measure Rdson across a range of temps and Vcc values.

> But it still raises the point, why are people so harsh
> re the overclocking argument but quite happy to discuss
> the "correct" method of driving a PIC pin into a dead
> short. You could probably come up with some good arguments
> why overclocking by 20% will probably perform great too,
> but I'm not going to rush to try either grey area.

No, overclocking is a very different thing. At a given clock speed,
temperature, Vcc, aging of chip, etc. a signal inside the chip is either on
time or not on time. If they test to a given limit I would _not_ want to go
beyond it (unless I was willing to test to my new limits myself). This
disregards the thermal issues in overclocking, which are probably pretty
small for modest overclocking rates.

> Out of spec is out of spec. Next we'll be discussing the
> best way to drive a 10amp load with a 3amp transistor,
> using time constants and such as our argument??? ;o)

This is often legitimately done. Some transistors are specced at other than
100% duty cycle just for this reason.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@122006 by Alan B. Pearce

face picon face
>> Out of spec is out of spec. Next we'll be discussing the
>> best way to drive a 10amp load with a 3amp transistor,
>> using time constants and such as our argument??? ;o)

>This is often legitimately done. Some transistors are specced at other than
>100% duty cycle just for this reason.

Certainly power diodes and LED's are. I cannot recall seeing transistors spec'd
this way, but then have not really wanted to try this sort of trick with them.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@133804 by Dan Michaels

flavicon
face
Alan B. Pearce wrote:
>> I'm surprised at this! With all the professionals
>> on this list, I have become used to the "never go
>> outside the spec" attitude, like never exceeding
>> clock frequency etc. I really don't like the idea
>
>Is it really that different to driving directly into the base of a transistor?
>The impression I have is

most

people on this list would do that to drive a relay
>or other high current load without a resistor between the output from the PIC
>and the base of the transistor - we get enough messages on the list about
>reading back the port state when doing this.
>

I think you should change "most" here to "some".

It always gives me spinal-willies to hear about people doing
this sort of thing. I always assume [perhaps wrongly] that
these people are simply not trained as EE's.

- danM

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\19@160214 by Dwayne Reid

flavicon
face
At 09:57 AM 1/19/01 +0000, Alan B. Pearce wrote:
> > I'm surprised at this! With all the professionals
> > on this list, I have become used to the "never go
> > outside the spec" attitude, like never exceeding
> > clock frequency etc. I really don't like the idea
>
>Is it really that different to driving directly into the base of a transistor?
>The impression I have is most people on this list would do that to drive a
>relay
>or other high current load without a resistor between the output from the PIC
>and the base of the transistor - we get enough messages on the list about
>reading back the port state when doing this.

Nope - you missed the point in that discussion, which involved only the
open drain pin RA4.  It is quite legal and safe to use a pullup resistor on
pin RA4 and connect the pin directly to the base of a transistor (emitter
to ground).  The drawback in doing so is that R-M-W instructions read back
a logic 0 on RA4 - that is what the discussion was about.

dwayne



Dwayne Reid   <spamBeGonedwaynerspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\20@023508 by Roman Black

flavicon
face
Dan Michaels wrote:
{Quote hidden}

I agree Dan, the bulk of my practical experience is from
repairing things, although I have done a lot of design
over the years. The things I have to repair are always
due to engineers pushing the spec. Like using a 5amp
transistor to switch 5amps.

So if your little car has 150hp you are going to drive
everywhere with the motor screaming at peak hp at
redline towing a big caravan?? How long would it last?
About as long as your new Taiwanese VCR power supply does.

After my initial trade as an industrial electrician
I did a couple of years of industrial electronics,
a very practical training mainly about microprocessors
and how to interface them with everything from special
sensors to huge motors. We were taught that good
design over-rates parts at 10x. So you use a 10w
resistor if it is known to dissipate 1w. This gives
a long term reliability guaranteed to work 24 hours
7 days, even in a hot environment.

So anything less is simply trading reliability for
cost, if you don't care that a large percentage
of your product will fail within a couple of years
that's fine. Some poor sucker like me will end up
being paid to fix it, or should I say improve it,
because I will be putting a decent sized transistor
in it. ;o)

Back on topic, I feel uneasy driving a PIC pin
more than 10mA, I prefer about 5mA if I can.
I don't want it to fail in two years. Driving it
into a short gives me the heebie jeebies. How
much does a resistor cost? 1 cent?
-Roman

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservSTOPspamspammitvma.mit.edu with SET PICList DIGEST in the body


'[PIC]: grounding unused inputs'
2001\01\21@222546 by Richard Sloan

flavicon
face
Does not seem to matter if an unused output is fried.

-----Original Message-----
From: pic microcontroller discussion list
[RemoveMEPICLISTspamspamMITVMA.MIT.EDU]On Behalf Of Olin Lathrop
Sent: Sunday, January 14, 2001 3:19 PM
To: TakeThisOuTPICLISTspamspamRemoveMEMITVMA.MIT.EDU
Subject: Re: [PIC]: grounding unused inputs


> To be "safe", it is best to tie unused input pins to ground [or Vcc,
> doesn't much matter which] *ONLY* through a resistor, rather than
> directly with a short. This is not superstition, as during code
> development it is all too easy to accidentally configure a pin
> intended as input to output. You then run the risk of
> short-circuiting an output.

Perhaps in a low volume product.  I wouldn't want to burden a high volume
product with unnecessary parts for a minor debugging convenience.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, KILLspamolinspamspamspam_OUTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestRemoveMEspammitvma.mit.edu


2001\01\22@041944 by Russell McMahon

picon face
>Does not seem to matter if an unused output is fried.

There is a fate WORSE than a cleanly fried output waiting for an in service
device that accidentally flips a grounded unused input to a high and unused
output (or whatever).

This is MUCH higher current drain. I have had a PIC in a micropower
application suddenly draw 100 mA from a  3 volt supply ! :-)
That was from gross inattention (ie stupidity) (5 x inputs connected to VCC
driven as grounded outputs) but it could happen in real life.



     Russell McMahon
_____________________________

What can one man* do?
Donate food daily free !!! -  http://www.thehungersite.com/
Donate Vitamin A!  http://www.thechildsurvivalsite.com/
http://www.rawa.com  - one perspective on Afghanistan
http://www.changingourworld.com    http://www.easttimor.com   http://www.sudan.com

(* - or woman, child or internet enabled intelligent entity :-))


>> To be "safe", it is best to tie unused input pins to ground [or Vcc,
>> doesn't much matter which] *ONLY* through a resistor, rather than
>> directly with a short. This is not superstition, as during code
>> development it is all too easy to accidentally configure a pin
>> intended as input to output. You then run the risk of
>> short-circuiting an output.
>
>Perhaps in a low volume product.  I wouldn't want to burden a high volume
>product with unnecessary parts for a minor debugging convenience.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads



'[PICLIST] Floating Inputs in 12CE519?'
2001\02\13@130241 by Mark Bishop
flavicon
face
Let me preface this message by stating that all of the code work fine in the
emulator (whatever that is worth).

I have a 74HC148 (8 Line to 3 Line Encoder) hooked up to input pins 7, 6,
and 4 (GP0, GP1, and GP3 resp.)

Now when using the emulator I get 0-5 volt transitions on these input pins.
When I burn the chip I get 1.4 - 5.0 volts on the bi-directional pins only,
which isn't enough to register a 0.  These inputs are straight from the
74HC148 with no pull-ups or pull-downs.  I shouldn't think that this would
matter, but hey, I'm not an exact expert on these things yet.

Any help you could provide might save some hair on my head.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\13@140429 by Mark Bishop

flavicon
face
Let me preface this message by stating that all of the code work fine in the
emulator (whatever that is worth).

I have a 74HC148 (8 Line to 3 Line Encoder) hooked up to input pins 7, 6,
and 4 (GP0, GP1, and GP3 resp.)

Now when using the emulator I get 0-5 volt transitions on these input pins.
When I burn the chip I get 1.4 - 5.0 volts on the bi-directional pins only,
which isn't enough to register a 0.  These inputs are straight from the
74HC148 with no pull-ups or pull-downs.  I shouldn't think that this would
matter, but hey, I'm not an exact expert on these things yet.

Any help you could provide might save some hair on my head.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


'[PIC]: Need help using capture inputs on 16F877'
2001\02\14@165941 by Fred Bailey

flavicon
face
I'm having trouble with the capture input CCP1. I have capture input CCP2
working (finally).
I have tested the Port C - I/O by disabling both capture modules and reading
port C.
All bits work OK (Hi and Low). But, I can't get CCP1 (RC2 input) to capture. I
have also tried
using CCP1 and CCP2 together and separately Only CCP2 works.

I initialize the CCP1 as follows:
Setup_capture  ; RC1input pulse, 50uSec wide every 16.6mSec, use capture2 (CCP2)
    BANK0
    movlw     0x3D
    movwf     T1CON          ; set up timer1 for internal clock,1:8
Prescale,timer Enabled
    BANK1
    bcf  PIE2, CCP2IE   ; dissable interrupt from capture
    BANK0
    clrf CCP1CON
    clrf CCP2CON   ; Clear prescaler, turn off CCP2 module
    movlw     0x05
    movwf     CCP2CON   ; set up Capture Mode on every rising edge
    BANK1
    bsf  PIE1,CCP2IE    ; enable interrupts from capture
    BANK0
    clrf CCPR2L    ; clear capture registers
    clrf CCPR2H

I run the program an the interrupt never occurs. The input voltage is 5.0 volts
when the pulse is high.
There is about 25usec rise and 25usec fall time.

I am using a Tech-tools Clearview Mathius emulator. I have tried replacing the
member module.

I can't find any code in the archives that uses capture.

Any help would be appreciated.

Best Regards, Fred Bailey (soon to be fired!)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservSTOPspamspamRemoveMEmitvma.mit.edu with SET PICList DIGEST in the body


2001\02\14@202850 by Dan Michaels

flavicon
face
Fred Bailey wrote:
>I'm having trouble with the capture input CCP1. I have capture input CCP2
>working (finally).
>I have tested the Port C - I/O by disabling both capture modules and reading
>port C.
> All bits work OK (Hi and Low). But, I can't get CCP1 (RC2 input) to capture. I
>have also tried
>using CCP1 and CCP2 together and separately Only CCP2 works.
>
>I initialize the CCP1 as follows:
>Setup_capture  ; RC1input pulse, 50uSec wide every 16.6mSec, use capture2
(CCP2)
{Quote hidden}

Hi Fred, I have some suggestions here.

1 - I don't see you configuring the port direction bits.

2 - I don't see you doing a global interrupt enable, or resetting
   the relevant intr flag.

3 - I would not turn on Timer 1 until everything else was setup and ready
   to go. You do this in your first couple statements.

4 - Timer 1 is going to clock out very fast, probably < 1 sec, depending
   upon the xtal in use, so you have to get right on the job with your
   input signal soon as you run this code, else you will miss the event.

5 - You also have to jump thru a few hoops in order to avoid false captures,
   as detailed in the spec sheet.

6 - During development, I would first get this code working correctly
   in polled mode rather than interrupt mode - ie, simply poll the
   interrupt flag, and read the register. Fewer things to get confused
   about.

hope this helps,
- dan michaels
http://www.oricomtech.com
==================

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservRemoveMEspamEraseMEmitvma.mit.edu with SET PICList DIGEST in the body


'[PIC] Using both capture inputs on PIC16F877'
2001\02\21@094133 by Fred Bailey

flavicon
face
I have not been able to get capture CCP1 to work. CCP2 works fine.

I am using both capture inputs on PIC16F877 to set the PIR1 and PIR2 flags. I
have portC as inputs as the TRISC is 0xFF. I have both CCP1CON and CCP2CON set
for 0x05. Timer 1 is enabled with TICON bit 0 set.
I have PIE1, CCP1IE and PIE2,CCP2IE bits set.

I must have messed up something because the signal input to RC1 is inverted and
outputed on RCO even though TRISC is 0xFF. I did not output the signal to any
pin.

I have tried the code on a PIC16C74B with the exact same results.

When I use my emulator (Techtools Clearview Mathius) I can set the PIR2 flag and
the interrupt occurs. But I can't get the RC1 input to set the PIR2 flag.

Any suggestions?

Best Regards, Fred

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\21@112420 by Dan Michaels

flavicon
face
At 09:28 AM 2/21/01 -0500, you wrote:

>I must have messed up something because the signal input to RC1 is inverted and
>outputed on RCO even though TRISC is 0xFF. I did not output the signal to any
>pin.
>

Do you possibly have the T1OSC oscillator enabled?

Also, as indicated previously, it is generally "much" easier
if you first get these things running in polled I/O mode,
instead of interrupt mode. Fewer things to go wrong.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\21@131437 by Fred Bailey

flavicon
face
Thanks Dan,

You got it.

I did have T1OSC set and that is why I had the problem.
I did try to poll RC1 in I/O Mode but had the same problem.
Now it works !!!

Thank you very very much.

Best Regards, Fred

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\21@134154 by Dan Michaels

flavicon
face
Fred Bailey <TakeThisOuTbaile_fRemoveMEspam@spam@TDIPOWER.COM> wrote:
>Thanks Dan,
>
>You got it.
>
>I did have T1OSC set and that is why I had the problem.
>I did try to poll RC1 in I/O Mode but had the same problem.
>Now it works !!!
>
>Thank you very very much.
>
>Best Regards, Fred
>

de nada.

[TDIPOWER.COM - shucks, your own resident expert, AndyK,
could have found this problem in 2 shakes].

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads



'[PIC]: Switching INPUTS<->OUTPUTS (was I2C pullups'
2001\03\16@081126 by Bob Ammerman
picon face
Roman,

You said:

> I don't like changing from in to outs as I am a
> hardware guy. I like to design the input and output
> circuits as best as I can and that means making them
> dedicated with whatever capacitance and filtering
> is best for their exact purpose.

and also:

> Many guys who know PICs much better than me always
> design stuff to constantly switch between inputs and
> outputs. Must be a personality thing?? I just like
> the least possible things that can go wrong. ;o)

Well, I certainly don't think I know PICs much better than you, and I
emphatically don't know as much electronics as you do, but....

If you look at the pin circuit inside the PIC, as described in the data
sheet, you can see exactly what is happening when you set the TRIS bit for a
pin: specifically neither the pull-up or pull-down FET can be turned on.

There is no 'magic' here, and everything is well defined. Why are you
uncomfortable using this capability to simulate an open-drain?

What possible things do you see that can go wrong?

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservRemoveMEspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\16@085018 by Roman Black

flavicon
face
Bob Ammerman wrote:
{Quote hidden}

It's not really the inside of the PIC that scares
me, more the external hardware. Most of my inputs
have RC filtering or such, and many of my outputs
are very specific again with high loads or PWM
RC networks etc.

Just a general attitude that I like to make inputs
be inputs and outputs should be outputs. I do make
use of the RC analog converter trick, pulling a cap
low and then switching pin to input and then timing
how long it takes to charge, but I also use dead
periods in software before I start checking the input
and if I'm being extra paranoid I even write to the
TRIS register twice.

Possible problems:
* Read/mod/write does exist with tris change, imagine
a capacitive load at 5v, you change to an input, input
pin reads 5v, it may take microseconds before that
capacitive load drops to the proper 0v of the actual
input signal. A port read reads the pin, the pin
voltage can be very affected by external circuitry.
Hence a settling delay in software is nice.

* Switching an output to input may cause the ouptut
load to turn on/off. This could cause power or inductive
spike depending on load type, causing cmos register
corruption, etc. I like to bring the port output to a
known "safe" condition before swithing to an input,
and I often write to TRIS, wait a nop or two and write
to TRIS again. Just in case. Little cost, little
probability but high consequence. :o)

So i'm paranoid and a safety nut! Pretty funny that I
get real safe and conservative about my hardware, then
on weekends jump on a 150hp motorcycle and blast around
a racetrack. Maybe it's a yin/yang balance thing?? ;o)
-Roman

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamlistserv.....spamspammitvma.mit.edu with SET PICList DIGEST in the body



'[PIC]: Trouble w/multiple AD inputs (F877)'
2001\04\03@022555 by Brian Reed
flavicon
face
I've been using one A/D input for months and have now expanded
to 3.  I must really have something goofy in my code, because the
channels interact with each other.  Normally I'd do more testing
before asking here, but I'm going to try and run it at the SME robot
competion this Saturday (near Pittsburgh), so I wanted to ask if my
error is obvious...

This is what use to work, with the ICD demo board and the pot on RA0:
  void AD_init(void)
  {
    OPTION = 0x87;             // Set TMR0 prescaler, and 1:256
    ADCON1 = 0x0E;           // Left justify result, 1 analog channel
  }
and
  unsigned char AD_RA0(void)
  {
    ADCON0 = 0x41;           // Fosc/8, A/D enabled
    ADGO = 1;                    // Set the bit to start the conversion
    while (ADGO)                // Wait for the conversion to complete
      continue;                     //
    return ADRESH;            // Return the AD value (just the top 8 bits)
  }

Problem is, now that I've taken ADCON1 to 0x02 (for 5 D/A inputs and
3 digital I/Os, with Vdd&Vss as Vref's), the output of AD_RA0() does not
vary through the full range, and is greatly affected by input on RA1.
Yipes!  Only when I turn RA0 and RA1 all the way up do I get a full-scale
A/D reading on RA0.

Here's the current code - likely this has the problem --->

 /// PICLIST: note the change in ADCON1
 void AD_init(void)
 {
   OPTION = 0x87;             // Set TMR0 prescaler, and 1:256
   ADCON1 = 0x02;           // Left justify result, 3 analog channels
 }

 /// PICLIST: note the only difference between AD_RAx() routines is ADCON0
 unsigned char AD_RA1(void)
 {
   ADCON0 = 0x49;             // Fosc/8, A/D enabled
   ADGO = 1;                  // Set the bit to start the conversion
   while (ADGO)               // Wait for the conversion to complete
     continue;                //
   //// could/should disable A/D here?  (w/ADCON0)
   return ADRESH;             // Return the AD value (just the top 8 bits)
 }

 unsigned char AD_RA2(void)
 {
   ADCON0 = 0x51;             // Fosc/8, A/D enabled
   ADGO = 1;                  // Set the bit to start the conversion
   while (ADGO)               // Wait for the conversion to complete
     continue;                //
   //// could/should disable A/D here?  (w/ADCON0)
   return ADRESH;             // Return the AD value (just the top 8 bits)
 }

 while (1) {
   uctmp1 = AD_RA1();  //  sensor
   uctmp2 = AD_RA2();  //  sensor
   PORTC = AD_RA0();  //  Turn on LEDs per POT on ICD demo board
 }

Thanks,

- Bri

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\03@025537 by Dwayne Reid

flavicon
face
At 01:47 AM 4/3/01 -0400, Brian Reed wrote:
>I've been using one A/D input for months and have now expanded
>to 3.  I must really have something goofy in my code, because the
>channels interact with each other.  Normally I'd do more testing
>before asking here, but I'm going to try and run it at the SME robot
>competion this Saturday (near Pittsburgh), so I wanted to ask if my
>error is obvious...

It sure looks as if you are not allowing adequate sample time.  You have to
select the desired input channel, then wait for a short while (30 uS or so)
before starting the a/d conversion.  The sample time allows the charge at
the input to be stored on the a/d convertors's sample and hold
capacitor.  The minimum amount of time required is specified in the data
sheet but 30 uS should be lots.

Give it a try and see what happens.

dwayne



Dwayne Reid   <dwaynerspam_OUTspam@spam@planet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\03@030829 by Michael Rigby-Jones

flavicon
face
The answer is pretty simple.  After setting the AD Channel, you *MUST* wait
for a predetermined amount of time while the ADC internal capacitances
charge.  This is covered in detail in the data book,  page 125/126.

The time depends on your source impedance (i.e. how much current the thing
you are measuring can supply), the internal switch resistance (which depends
on the PIC's operating voltage), and internal leakage currents which depend
on temperature.

The formula is Tacq = 2us + Tc +((Temp - 25C) * 0.05)

where Tc = CHold * (Ric + Rss + Rs) * LN(1/2047)

CHold = 120pf
Ric (interconnect resistance) = typically 1k ohms
Rss (switch resistance depends on supply voltage) = 7k ohms at 5volts.
Rs is the source impedance of the circuit you have connected to the A/D pin.
Should always be less than 10k.

This delay is the minimum delay you should use in order to ensure the A/D
gives accurate results.

Hope that helps.

Mike

> {Original Message removed}

2001\04\03@034432 by Vasile Surducan

flavicon
face
It's sure that's the problem. But is enough 20uS.
Vasile

On Tue, 3 Apr 2001, Dwayne Reid wrote:

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\03@073346 by Bob Ammerman

picon face
You must insert a delay between selecting the channel and starting the
conversion to allow the sampling capacitor to charge to the selected input.
You have leftovers from the other channel on the cap when you start the
conversion.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2001\04\03@094757 by Don Hyde

flavicon
face
Often with multiple channels, you will be sampling then all at the same
rate, which you would like to be as high as possible.

Now that you know you need to allow for sampling time, reread the data sheet
carefully and you will find that you can overlap the sampling time of the
next channel with the conversion time of the current channel.

So the highest sample rate can be achieved by:

       Start conversion of current channel
       <Very short delay needed>
       Switch the input mux to the next channel
       Wait for the conversion to complete (Maybe doing something useful
along the way, like
               processing the previous channel's data)
       Store the results of the conversion
       <If your conversion time and the settling rate of your analog inputs
happen to match,
               then at this point, no further delays are needed, and you
can go right back to the
               top and sample the next channel, otherwise you may need to
delay a little while
               before going on to the next channel.>

> {Original Message removed}

2001\04\03@164409 by Brian Reed

flavicon
face
Thanks to everyone for their help in this thread ... A-OK now!

>You must insert a delay between selecting the channel and starting the
>conversion to allow the sampling capacitor to charge to the selected input.
>You have leftovers from the other channel on the cap when you start the
>conversion.

- Bri


>
>Bob Ammerman
>RAm Systems
>(contract development of high performance, high function, low-level
>software)
>
>{Original Message removed}


'[PICLIST] Unconnected A/D Inputs'
2001\09\23@031138 by Wesley Moore
flavicon
picon face
I'm developing a project that uses A/D inputs on an F877. I was wondering
whether is was safe to have them configured as A/D inputs without anything
connected or do the same rules apply as for a unconnected digital input. The
reason being, the module that connects to the A/D pins is being developed by a
friend and isn't ready to to be connected yet but I want to test my PIC code.

--
Wesley Moore      http://yallara.cs.rmit.edu.au/~wmoore/
RMIT - BEng (Comp Sys Eng)/BApp.Sc. (Comp Sci)  3rd Year

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestKILLspamspamEraseMEmitvma.mit.edu


2001\09\23@111431 by Herbert Graf

flavicon
face
AFAIK it hould be OK, if you look at what an analog input is ist's pretty
much a switch, a resistor and a cap, I don't personally see a problem if
that is left disconnected. TTYL

> {Original Message removed}

2001\09\23@134050 by fernteix

flavicon
face
Hi

A/D input has a high impedance so will pick all 50Hz noise, but will not be
a danger to the pic.

Best Regards

Fernando

{Original Message removed}


'[PIC]: IIc and analog inputs'
2001\11\30@115559 by Micro Eng
picon face
ok..im lookin for a solution where I have some analog inputs and need to
send out values via IIC. Now, I am pretty sure there is a PIC that has both
analog inputs and the IIC interface, but question is, in addressing via IIC,
can each analog pots register have a unique address for the IIC bus? Or does
the PIC have one address.

I've never used IIC before, so just investigating it now for this app

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@132151 by Gerhard Fiedler

flavicon
face
At 08:57 11/30/2001 -0700, Micro Eng wrote:
>ok..im lookin for a solution where I have some analog inputs and need to
>send out values via IIC. Now, I am pretty sure there is a PIC that has both
>analog inputs and the IIC interface, but question is, in addressing via IIC,
>can each analog pots register have a unique address for the IIC bus? Or does
>the PIC have one address.
>
>I've never used IIC before, so just investigating it now for this app

You can't use the high level I2C functions, because these do the address
comparison for you and work only with a single slave address in slave mode.

But if you use just the low level I2C functions (like start/stop bit
detection) or do it bit-banging by yourself, then there's nothing that
would prevent you from acting as either many slaves in one unit or as many
(multi-) masters in one unit.

If you want to send out the data without request from a master, you have to
use the multi-master mode anyway.

ge

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@142458 by Micro Eng

picon face
So, if I understand this correctly....I can't just hang this on a I2C bus
and have it polled for the A/D data?
Guess I don't understand exactly how this I2C connection works on it.


{Quote hidden}

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@150043 by Gerhard Fiedler

flavicon
face
Yes, you can.

I2C has two basic modes: one master and various slaves or multi master. One
master mode means that no collisions happen, because all slaves wait until
they get polled. Multi master mode means that each master has to watch out
for collisions. The PIC mid-range handbook explains this.

Some PICs provide support for a pretty automated handlig of the slave
protocol, but only for one slave address. If you want to use multiple slave
addresses in one device, you can't use this mode. But you could instead use
just one slave address (thus taking advantage of this mode) and use an
additional data byte to select the value to return.

If you tell us more details about what you want to do, it gets easier. And
perhaps read the I2C section of the mid-range manual; it should give you a
good overview over the differet modes.

ge

At 11:31 11/30/2001 -0700, Micro Eng wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@155109 by Chris Carr

flavicon
face
MicroEng hiding behind a Hotmail Account wrote :

> So, if I understand this correctly....I can't just hang this on a I2C bus
> and have it polled for the A/D data?
> Guess I don't understand exactly how this I2C connection works on it.
>

Perhaps it might help if you read and understood the specification.
You can find it along with other information here

http://www.semiconductors.philips.com/i2c/facts/


Chris Carr

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@155744 by Drew Vassallo

picon face
>can each analog pots register have a unique address for the IIC bus? Or
>does
>the PIC have one address.

I'm not sure what you're asking.  But, the PIC doesn't have an address...
it's the master.  Only slaves on the bus have addresses.  If you're using
the PIC as a slave, then it would have one address only, not separate
addresses for each pin.

I'm assuming what you want is for each analog input to have separate
registers to hold the results, then output those over I2C.  However, the
analog input pins have really nothing to do with the I2C addresses.  If you
want to send each pin's result to a different slave on the bus, then you can
simply read the analog input and send it to the particular slave that
matches the whatever pin you're reading.

I suppose this could be used as a data storage method whereby each analog
input's data is stored in a separate I2C memory chip or something.

--Andrew

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\30@175920 by Micro Eng

picon face
yep...from what I gather....I have much reading to do AND then...ask some
more questions. But thanks to all that have at least given me some hope on
this.

have a good weekend

{Quote hidden}

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.



'[PIC]: inputs alive while PIC powered down'
2002\05\03@131656 by Micro Eng
picon face
There was some discussion about this a lil while back and I don't recall the
final thoughts.  From what I remember, if you have inputs that are coming
from a device that is not on the same power source as the PIC, that it could
actually power it up thru the ports. Was this the case?  Assumption that it
applies whether its an analog or digital port looking at these.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\05\03@165131 by Jinx

face picon face
> from a device that is not on the same power source as
> the PIC, that it could actually power it up thru the ports.
> Was this the case?

Yes, through the port diodes

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\05\03@215902 by Bob Ammerman

picon face
Yes, this can happen because the protection diodes to Vdd turn on.

Bob Ammerman
RAm Systems

----- Original Message -----
From: "Micro Eng" <spammicro_engspamHOTMAIL.COM>
To: <PICLISTSTOPspamspamMITVMA.MIT.EDU>
Sent: Friday, May 03, 2002 12:13 PM
Subject: [PIC]: inputs alive while PIC powered down


> There was some discussion about this a lil while back and I don't recall
the
> final thoughts.  From what I remember, if you have inputs that are coming
> from a device that is not on the same power source as the PIC, that it
could
> actually power it up thru the ports. Was this the case?  Assumption that
it
> applies whether its an analog or digital port looking at these.
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.
>
> --
> http://www.piclist.com hint: The list server can filter out subtopics
> (like ads or off topics) for you. See http://www.piclist.com/#topics
>
>

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics



'[PIC]: Maximum frequency specs for pic inputs'
2002\09\19@142218 by Vis Naicker
flavicon
face
>> Mike Singer PICs could serve as counters up to 50 Mhz.
You could tristate outputs configuring them
as inputs, when values are "1", for example.
<<     Were I to embark on making a frequency counter using
just a PIC ( minumim of external components , prescaler
optional ) which PIC would be the most appropraite ?

I think that the 16Cxx parts were pushed to 50MHz + ,
but can the Flash parts perform as well ? Where can I
find this kind of information ? Not the datasheet ...
Electrical specifications are not entirely clear .

And (  ;-)  ) I don't want exactly the manufacturer's spec's ; I want to know what can I push for in the real
world ? Results of frequcnecy achieved may vary amongst PIC's from the same batch etc regardless ? Push it to the
Max , let me get burned .

Vis Naicker

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@145349 by Olin Lathrop

face picon face
> I think that the 16Cxx parts were pushed to 50MHz + ,
> but can the Flash parts perform as well ? Where can I
> find this kind of information ? Not the datasheet ...

Um, why not?  I'm pretty sure there is a max timer 1 input frequency spec in
there somewhere.

> Electrical specifications are not entirely clear .

What part of "maximum frequency = xxx" is unclear?  Try asking a more
specific question.

> And (  ;-)  ) I don't want exactly the manufacturer's
> spec's ; I want to know what can I push for in the real
> world ?

Let's not waste time on this nonsense.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@163631 by mpoulton

flavicon
face
---- Original message ----
>Date: Thu, 19 Sep 2002 14:52:44 -0400
>From: Olin Lathrop <olin_piclistSTOPspamspamKILLspamEMBEDINC.COM>
>Subject: Re: [PIC]: Maximum frequency specs for pic inputs
>To: @spam@PICLIST.....spamspamMITVMA.MIT.EDU
>
>> I think that the 16Cxx parts were pushed to 50MHz + ,
>> but can the Flash parts perform as well ? Where can I
>> find this kind of information ? Not the datasheet ...
>
>Um, why not?  I'm pretty sure there is a max timer 1 input
frequency spec in
>there somewhere.

See below.

>> Electrical specifications are not entirely clear .
>
>What part of "maximum frequency = xxx" is unclear?  Try
asking a more
>specific question.

The specs is clear, but meaningless in this context.  How
was the spec determined?  What is the reliability of a part
at that frequency?  What is the reliability at 25% above
that frequency?  What is the failure mode if pushed too fast?

>> And (  ;-)  ) I don't want exactly the manufacturer's
>> spec's ; I want to know what can I push for in the real
>> world ?
>
>Let's not waste time on this nonsense.

How is that nonsense?  We all know that parts are
consistenly under- or over-spec'ed by the manufacturer.
Sometimes the data sheet gives wildly
optimistic "information", while other times the "absolute
maximum ratings" are far below the real limits.  You can
guarantee that a PIC spec'ed for 20MHz max will work at 21.
It might even work fine at 25, 30, or more.  At some point,
it will become unreliable.  He wants speed vs. reliability
information for clock speeds beyond those Microchip designed
for.
--
Mike P.
MTP Technologies
KC0LLX

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@173709 by Dale Botkin

flavicon
face
On Thu, 19 Sep 2002, Mike P. wrote:

> The specs is clear, but meaningless in this context.  How
> was the spec determined?  What is the reliability of a part
> at that frequency?

Guaranteed 100.0%, over the full operational range.

> What is the reliability at 25% above
> that frequency?

Somewhere between 0.0% and 100.0%, depending on moon phases, orientation
of dead fish, whatever.  Olin's very valid point is, since it's not tested
or guaranted, you don't know.  If you want to know you'll have to
individually test each chip to whatever your specifications might be,
including the full range of possible temperatures, power supply ranges,
etc.  And of course you won't know how it will work over time.

> What is the failure mode if pushed too fast?

See above.

> >Let's not waste time on this nonsense.
>
> How is that nonsense?  We all know that parts are
> consistenly under- or over-spec'ed by the manufacturer.

Under-spec under certain conditions, probably yes.  But bear in mind that
the published specs are what Microchip will guarantee over the full range
of temperature, voltage, ripple, capacitive load, vibration, etc.

> You can guarantee that a PIC spec'ed for 20MHz max will work at 21.

No, you can't.  I'd bet a few bucks on it for a hobby project, but I'd
never guarantee it, and neither will Microchip.  Again, you'd have to test
each unit individually to know for sure.  After you've tested X number you
can say with some degree of confidence what they'll do, but the next die
shrink or even the next production lot can completely invalidate your
findings.

> It might even work fine at 25, 30, or more.  At some point,
> it will become unreliable.  He wants speed vs. reliability
> information for clock speeds beyond those Microchip designed
> for.

Then he's going to have to get it the hard way, once chip at a time,
because it simply doesn't exist.  Of course you're welcome to prove me
wrong by coming up with any instance where someone has guaranteed,
documented over-spec numbers, but this has been discussed to death
numerous times.  So far I don't think anyone's come up with any.

Dale

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@175250 by Bob Blick

face picon face
On Thu, 19 Sep 2002, Dale Botkin wrote:
> > You can guarantee that a PIC spec'ed for 20MHz max will work at 21.
>
> No, you can't.  I'd bet a few bucks on it for a hobby project, but I'd
> never guarantee it, and neither will Microchip.  Again, you'd have to test
> each unit individually to know for sure.  After you've tested X number you
> can say with some degree of confidence what they'll do, but the next die
> shrink or even the next production lot can completely invalidate your
> findings.

Actually, there are companies that will guarantee it. Connectix used a 20
MHz PIC in the parallel port Quickcam running at 24 MHz. They did it for a
few years with OTP parts over many production lots.

This is a topic that continues to surface, and is off the exact beginning
of this thread, which was the 50MHz spec of the TMR0 external clock input.
I don't know anyone who has tested that spec. Personally I suspect it
won't do too much better than the rated spec.

Cheerful regards,

Bob

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@175603 by mpoulton

flavicon
face
---- Original message ----
>Date: Thu, 19 Sep 2002 16:36:29 -0500
>From: Dale Botkin <spamdale.....spam.....BOTKIN.ORG>
>Subject: Re: [PIC]: Maximum frequency specs for pic inputs
>To: PICLIST.....spamMITVMA.MIT.EDU
<snip>
>>He wants speed vs. reliability
>> information for clock speeds beyond those Microchip
>>designed for.
>
>Then he's going to have to get it the hard way, once chip
at a time,
>because it simply doesn't exist.  Of course you're welcome
to prove me
>wrong by coming up with any instance where someone has
guaranteed,
>documented over-spec numbers, but this has been discussed
to death
>numerous times.  So far I don't think anyone's come up with
>any.

I got the impression he was looking for personal experiences
of people on the list, not numbers from Microchip.  Of
course MC's not going to say anything about it -- if they
were, they would have put it in the data sheet.  I would
imagine that, amongst the vast readership of this list,
there are at least a few people who have overclocked some
PIC's.  I think he wants to hear from them.
--
Mike P.
MTP Technologies
KC0LLX

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\19@234342 by Mike Singer

picon face
Bob Blick wrote:
.
> This is a topic that continues to surface, and is off the
> exact beginning of this thread, which was the 50MHz
> spec of the TMR0 external clock input. I don't know
> anyone who has tested that spec. Personally I suspect it
> won't do too much better than the rated spec.
>

From AN592 (00592d.pdf) :
Frequency Counter Using PIC16C5X:
- Frequency range   50MHz - 10 MHz
- Precise "gate" delay   1ms
- Resolution 10 KHz

Mike.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\09\20@005240 by Dale Botkin

flavicon
face
On Thu, 19 Sep 2002, Bob Blick wrote:

> On Thu, 19 Sep 2002, Dale Botkin wrote:
> > > You can guarantee that a PIC spec'ed for 20MHz max will work at 21.
> >
> > No, you can't.  I'd bet a few bucks on it for a hobby project, but I'd
>
> Actually, there are companies that will guarantee it. Connectix used a 20
> MHz PIC in the parallel port Quickcam running at 24 MHz. They did it for a
> few years with OTP parts over many production lots.

Yes, but my point is that either **THEY** did the characterization,
testing, and took full responsibility, or they cut a special deal with
Microchip.  If YOU OR I run a 20MHz part at 24MHz, nobody's guaranteeing
it will work (unless you want to).

> This is a topic that continues to surface, and is off the exact beginning
> of this thread, which was the 50MHz spec of the TMR0 external clock input.
> I don't know anyone who has tested that spec. Personally I suspect it
> won't do too much better than the rated spec.

I agree with you.

Dale

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\09\20@021826 by Peter L. Peres

picon face
On Thu, 19 Sep 2002, Olin Lathrop wrote:

*>> I think that the 16Cxx parts were pushed to 50MHz + ,
*>> but can the Flash parts perform as well ? Where can I
*>> find this kind of information ? Not the datasheet ...
*>
*>Um, why not?  I'm pretty sure there is a max timer 1 input frequency spec in
*>there somewhere.

No but there is a minimum pulse width which amounts to the same thing. The
16C54(A) specced 20ns (50MHz) but 16F84A has 50ns I think. I built several
counters (most for PLL purposes, others with display, from 16 to 40 bits
resolution). I never used one beyond 20MHz (did not need it), neither with
16C54 nor with 16F84. I did use one for UHF using a prescaler but that put
the counter input frequency under 10MHz.

Peter

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\09\20@062540 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Mike P. [SMTP:KILLspammpoultonspam_OUTspammtptech.com]
> Sent: Thursday, September 19, 2002 10:55 PM
> To:   spam_OUTPICLISTspamTakeThisOuTMITVMA.MIT.EDU
> Subject:      Re: [PIC]: Maximum frequency specs for pic inputs
> I got the impression he was looking for personal experiences
> of people on the list, not numbers from Microchip.  Of
> course MC's not going to say anything about it -- if they
> were, they would have put it in the data sheet.  I would
> imagine that, amongst the vast readership of this list,
> there are at least a few people who have overclocked some
> PIC's.  I think he wants to hear from them.
>
The responses you have been given so far are typical of professional
engineers.  They want to make products that are absolutely 100% reliable,
and to do that you do not exceed the manufacturers specifications.

As a purely "for interest" exercise then fine.  If you take a look at the
archives I'm pretty sure that someone did post the results of "overclocking"
a PIC some time ago (sorry, can't give a specific date, but over a year
ago).  ISTR that they managed something over 30MHz from a 20MHz part.  You
have to consider the implications of running the PIC this fast however.
Timing issues, especially involving RMW problems will cause you no end of
grief and are likely to be voltage/temperature sensitive.

Regards

Mike

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...