Searching \ for 'What is the best way to sense a pushbutton press??' 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/index.htm?key=what+best+way+sense
Search entire site for: 'What is the best way to sense a pushbutton press??'.

Truncated match.
PICList Thread
'What is the best way to sense a pushbutton press??'
1997\10\16@011034 by ndie Ohtsji [4555]

flavicon
face
Hello,

What is the best way to sense a push button press?  I am multiplexing the
PORTB data lines as a data bus and using PORTA as chip select as shown
to me by Steve Smith.  Will the below circuit work?

An HC74 D Flip-Flop is used to capture a push button press since inputs
will only be scanned briefly and I don't want to miss the press.

The inputs are selected by selecting RD1 and storing to a register.
If PB0 reads as set then I know that the button was pressed.  I then
reset the F/F by selecting WR1 and tickling PB7.

Is there a better way to achieve this???  I need to multiplex the pins
since there are many inputs and outputs (LCD display, ISD voice chip etc)

All comments are appreciated (but go easy on me -- I am also a newbie!)

Thanks in advance!

-Randie Ohtsji
spam_OUTrohtsjiTakeThisOuTspamglenayre.com

PS  I hope my crude schematic shows what I am doing.



                                               Vcc
  +--------------To PIC16F84                    |
  |                 PORTB0-7                    /
  |                                             \
  |                                             /
  |                                             \
  |                                             /      | N.O. Push button
  |                                             |     _|_
  |               __________                    |
  |              |          |                   +-----0 0-------Gnd
  |     8        |        Q0|----               |
  +----/---------| HC373  Q1|----               |
  |              | __     Q2|----           ____0___
  |      GND-----0 OE     Q3|----          |    _   |
  |              |        Q4|----     +----|D   S  Q|------------+
  |              |        Q5|----     |    |  HC74  |            |
  |              |        Q6|----     |    |       _|            |
  |       WR1----|LAT     Q7|-------------->CLK _  Q|-----+      |
  |              |__________|         |    |____R___|     |      |
  |                                   |         0         |      |
  |                                   |         |         |      |
  |                                   +-------------------+      |
  |                                             |                |
  |               __________                    \                |
  |              |          |                   /                |
  |              |        A0|------------------ \ ---------------+
  |      8       |  HC244 A1|                   /
  +-----/--------|        A2|                   \
                 | ___    A3|                   /
       RD1--+----0 OE1    A4|                   |
            |    | ___    A5|                   Vcc
            +----0 OE2    A6|
                 |        A7|
                 |__________|

                  __________
                 | __       |
         WR1-----0 Y0     A0|-------    \
                 | __HC138  |            \
         RD1-----0 Y1     A1|-------      \ To PIC16F84
                 | __       |             / PORTA0-2
                 0 Y2     A2|-------     /
                 | __       |
                 0 Y3    CS1|-----/\/\/\----Vcc
                 | __    ___|
                 0 Y4    CS20---+------GND
                 | __    ___|   |
                 0 Y5    CS30---+
                 | __       |
                 0 Y6       |
                 | __       |
                 0 Y7       |
                 |__________|

1997\10\16@083016 by Mike Smith

flavicon
face
-----Original Message-----
From: Randie Ohtsji [4555] <.....rohtsjiKILLspamspam@spam@GLENVAN.GLENAYRE.COM>
To: PICLISTspamKILLspamMITVMA.MIT.EDU <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Date: Thursday, 16 October 1997 14:42
Subject: What is the best way to sense a pushbutton press???


{Quote hidden}

Use the B lines(1) in interrupt mode, with the soft pullups (downs?)
enabled.  If you've got an array of switches to multiplex, try and arrange
them in a regular shape.  the other side of the switch goes to some more
pins(2), that are set to the opposite sense.  When any button is pushed, it
will trigger an interrupt.  In the ISR, you clear
lines(2), and then set one at a time, reading the lines(1) to find out which
switch caused it.  Some debounce is necessary.

Sorry about the awkward description - haven't a data source nearby!!

1997\10\16@123130 by ndie Ohtsji [4555]

flavicon
face
Mike,

Thanks for the response!

The B lines (PB0 - PB7) are used as both inputs and outputs (with HC373
and HC244 chips) so I can't dedicate them to trigger an interrupt from
a switch.  There will be about 4x HC373 and 2x HC244 used (chip selected
by the HC138) so the B lines sequence will go something like: Output1,
Output2, Input1, Output3, Output4, Input2.  The switch will be on Input2.
......err I hope you are getting what I am trying to say.

Since the B lines will only look at Input2 (the switch input) a minimum
of 1/6 of the time, I need to capture the switch press by using the
Flip-flop.

Is the circuit and logic of what I am attempting to do the best way to
capture a switch press????

I thought the Flip-Flop could be used for de-bounce.

Thanks!


-Randie

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
*/ Randie Ohtsji                                                     /*
/* Glenayre R&D, Vancouver, BC  CANADA   Phone: (604) 293-1611 x4555 */
*/ Email: EraseMErohtsjispam_OUTspamTakeThisOuTglenayre.com           Fax:   (604) 293-4317       /*
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/



{Quote hidden}

> {Original Message removed}

1997\10\16@175744 by Steve Smith

picon face
part 0 6338 bytes content-type:text/plainIn a message dated 16/10/97  05:11:42, you write:

<< What is the best way to sense a push button press?  I am multiplexing the
PORTB data lines as a data bus and using PORTA as chip select as shown
to me by Steve Smith.  Will the below circuit work?
 >>
In the circuit I sent The HC244 for the inputs is scanned once every 10mS and
if button is down for three scans then it is valid Check out the debounce
routiene by Scott Dattalo its on his website
www.interstice.com/~sdattalo/technical/software/pic/debounce.html
This will debounce a whole 8 bits and you can loose the flip flop just
continue scanning the input register.

Also if you are working at 4Mhz you can do lots between reading an input
buffer to get keys every 10mS  The section to read keys will take less than
10uS

movlw b'11111111'       ;Set port b to input.
Tris port_b
movlw b'00000111'        ;Select an input buffer by seting b,4 address is
b,0,1,2
movwf port_a
movfw port_b                ;Read port B
movlw b'00010111'         ;Deselect input buffer turn off hc138

The read needs only take 1uS to open the 244 and read the key status just do
it every 10mS
software should be able to handle it all If you want send mail and I will
return a chunk of code for '84 that works in that circuit also attached are
the LCD handlers for that module.


Cheers Steve.......

some software extracts fo the board
CONOFF  EQU     B'00010000'     ; CONTROL PORT OFF STATE

;---------------PORT ASSIGNMENTS A IS ALWAYS OUTPUT--------
;---------------B IS BIDIRECTIONAL AND HAS ASSESS TO-------
;---------------UP TO 64 IO LINES VIA 138------------------

CON     EQU     PORTA   ; PORT A IS CONTROL
DTA     EQU     PORTB   ; PORT B IS DATA

;---------------138 LOCATION ASSIGNMENTS------------------

OUT1    EQU     B'00000000'     ; OUTPUTS 0-7
OUT2    EQU     B'00000001'     ; OUTPUTS 8-15
OUT3    EQU     B'00000010'     ; OUTPUTS 15-23
OUT4    EQU     B'00000011'     ; OUTPUTS 16-29 AND BUZZER AND LCD CONT
INP1    EQU     B'00000100'     ; INPUTS 0-7
INP2    EQU     B'00000101'     ; INPUTS 8-15
INP3    EQU     B'00000110'     ; INPUTS 16-23
INP4    EQU     B'00000111'     ; INPUTS 24-29 AND TEST SW AND CONT SW


Content-ID: <RemoveME0_7383_877034365TakeThisOuTspamemout06.mail.aol.com.10764>> Content-type: text/plain;
       name="106-LCD.INC"

;************* LCD FUNCTIONS ******************************
;---------------LCD TEXT OUTPUTER-----------
STRING  
       MOVWF   STRNUM      ; SAVE STRING NUMBER
       MOVLW   b'11111111' ; NEEDS TO BE FF BEFORE ENTERING STRING  
       MOVWF   TABOFF      ; SAVE IN CHR COUNTER
       MOVLW   LCDRS       ; SET TO DATA
       CALL    LCD_TXT     ; DO IT
DOSTR   PAGE1               ; SET PAGE MARKER
       CALL    CALLSTR     ; GET STRING CHARTER POINTED TO IN TABOFF
       PAGE0               ; RESET PAGE MARKER
       MOVWF   LCDCH       ; SAVE CHAR
       ANDLW   B'01111111' ; MASK END BIT (END OF STRING MARKER)
       CALL    LCD_OUT      
       BTFSS   LCDCH,7     ; CHECK LAST
       GOTO    DOSTR       ; NOT FINISHED DO SOME MORE
       RETLW   0           ; CONTINUE PROGRAM
;--------------LCDRS-----------------------------------------------
LCD_RS  
       MOVLW   BUZ             ; LCD IN CONTROL MODE NO BUZ
LCD_TXT MOVWF   DTA             ; INFO ON PORT
       MOVLW   OUT4            ; SELECT ADDRESS
       ADDLW   CONOFF          ; ADD THE OFF LOCATION TO PORT LOCATION
       MOVWF   CON             ; SET CONTROL PORT
       BCF     IOEN            ; CLOCK DATA OUT
       BSF     IOEN            ; RETURN TO NON SELECTED
       RETLW   0               ; EXIT
;---------------LCD PAUSE------------------
LCD_OUT  
       MOVWF   DTA             ; PUT LCD CONTROL DATA ON BUS
       BSF     LCDEN           ; Lcd enable HIGH
       BCF     LCDEN           ; Lcd enable LOW                ; SEND IT
       MOVLW   .19             ; DELAY FOR LCD TO CATCH UP
       CALL    SHORT           ; DO TIME
       RETLW   0               ; EXIT
;--------------LCD CLEAR DISPLAY-----------------------------------
LCDCLR  
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   01h             ; CLEAR DISPLAY
       CALL    LCD_OUT         ; SHORT TIME DELAY
       MOVLW   .5              ; TIME FOR LCD TO CATCH UP
       CALL    LONG            ; DO TIME
       RETLW   0               ; EXIT
;--------------LCD LINE 1 SELECT---------------------------------
L1  
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'10000000'     ; LINE 1 SET
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;--------------LCD LINE 2 SELECT---------------------------------
L2  
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'11000000'     ; LINE 2 SET
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;-------------LCD BACK 1 SPACE----------------------------------
BACK1  
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'00010000'     ; BACK ONE SPACE
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;------------LCD LINE 2 POS 12----------------------------------
L1_8    
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'10001000'     ; LINE 1 POS 8
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;------------LCD LINE 2 POS 8------------------------------------
L2_8    
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'11001000'     ; LINE 2 POS 8
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;------------CUSOR BLINK-----------------------------------------
BLINK  
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'00001110'     ; CURSOR BLINK
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;------------CURSOR NORMAL---------------------------------------
NO_BLINK
       CALL    LCD_RS          ; CONTROL MODE
       MOVLW   B'00001100'     ; CURSOR NORMAL
       GOTO    LCD_OUT         ; SHORT TIME DELAY
;-------------LCD INSERT SPACE W CONTAINS NUMBER OF-------------
SPACE_0
       MOVWF   GP3             ; SAVE NUMBER OF SPACES
SPACE_1 MOVLW   .10             ; SPACE LOCATION
       CALL    STRING          ; GO DO IT
       DECFSZ  GP3,F           ; FINISHED
       GOTO    SPACE_1         ; DO SOME MORE
       RETLW   0               ; EXIT      
;************* END LCD FUNCTIONS ************************



1997\10\16@202325 by Bob Lunn

flavicon
face
Bob Lunn
10/17/97 10:24 AM


> Since the B lines will only look at Input2 (the switch input)
> a minimum of 1/6 of the time, I need to capture the switch
> press by using the Flip-flop.

    Only if you need to capture a keypress that is less
    than your key polling time.

    For a 4MHz pic you should be able scan all your inputs
    at 1kHz without raising a sweat.  I doubt that you need
    to detect keypresses that last for less than 1ms...

    In any case, I suspect your real problem is not ensuring
    that you don't MISS keypresses, but rather ensuring that
    you don't detect FALSE keypresses.

    For this you need to debounce they keys, and in general
    this means going slow, not fast.

___Bob

1997\10\17@003908 by Mike Keitz

picon face
On Thu, 16 Oct 1997 09:29:33 -0700 "Randie Ohtsji [4555]"
<spamBeGonerohtsjispamBeGonespamGLENVAN.GLENAYRE.COM> writes:

>The B lines (PB0 - PB7) are used as both inputs and outputs (with
>HC373
>and HC244 chips) so I can't dedicate them to trigger an interrupt from
>a switch.  There will be about 4x HC373 and 2x HC244 used (chip
>selected
>by the HC138) so the B lines sequence will go something like: Output1,
>Output2, Input1, Output3, Output4, Input2.  The switch will be on
>Input2.

Do all the outputs first, then all the inputs, so it doesn't need to
adjust the TRIS register every time.  Set up an 8-byte block of RAM to
keep the last output values and the most recent input values.  Unless the
project requres very fast responses to something, do all the I/O at once
periodically.  The program examines and changes the RAM.  This will keep
from scattering I/O routines all over the program should you decide to
use a different I/O arrangement later.

>......err I hope you are getting what I am trying to say.
>
>Since the B lines will only look at Input2 (the switch input) a
>minimum
>of 1/6 of the time, I need to capture the switch press by using the
>Flip-flop.
>
No you don't. You just need to go in the input2 mode and read the
switches at least as often as the shortest time the user is likely to
hold the switch down.  This is about 40 ms.  Store the switch reading in
RAM.  The program can then look at it any time.  Usually it is useful to
detect when a switch was open but is now closed (when it is first
pressed).  This can be done by ANDing the new value with the complement
of the old value.   The somewhat cryptic code below does this with 2 RAM
locations.  Location switches must be preserved between uses of the
routine, location dswitches doesn't need to be.

[Set hardware so PORTB is routed to switches]
       comf    PORTB,w         ;Get new switch settings
(bit=1 if pressed).
       xorwf   switches,w      ;Form difference with old value.
       xorwf   switches,f      ;Update old value to be new.
; Now we have switches = new reading, and W = change from old
;  to new reading.  If a switch has changed since it was last read,
;  the bit in dswitches will be 1.  But the only change we care about
;  is pressing the switch, not releasing it.  So adjust W to
;  clear the bits for any switches that are now released.
       andwf   switches,w      ;And with  present reading
1=pressed.
       movwf   dswitches       ;Fix so only newly pressed are
ones.

The program can now examine switches and dswitches and make decisions
accordingly.  The routine should be executed only evey 20 ms or so to
prevent bounce problems.


>Is the circuit and logic of what I am attempting to do the best way to
>capture a switch press????

All you need for circuitry is a switch to ground, resistor to Vcc,
connect that to the input of the 244, output of 244 to PIC.

>
>I thought the Flip-Flop could be used for de-bounce.

You don't need any explicit debounce if you don't read the switch too
often.  About every 20 ms works out well.  Most switches will not bounce
for longer than 10ms or so.

1997\10\17@134015 by ndie Ohtsji [4555]

flavicon
face
Hi Mike,

Sorry about the CC (are you getting two of this message, if so please
let me know and I will stop CCing you).

Yes, I am using an old version of OrCAD (v4.???).  I'm very new to
the PIC, but I have a 16C84-04 and a 16F84-10 to play with.  This
PIC list is great -- I found out a lot from all the email bouncing
around (but I still have a LOT to learn).  I would appreciate
any hints, circuits, starting points, etc.

I want to connect a 2x16 line LCD (8 data lines + 3 control lines),
a fully addressed ISD voice chip (10 address lines + 3 control
lines + 2 status lines), compass module (1 data line + 4 control
lines), serial communication (PIC to PIC: 1 data line + gnd).
3 or 4 push buttons, Hex rotary switch - BCD format (4 lines)
and 2 or 3 misc I/O (2 or 3 lines?). Also maybe some motor control
lines and a data line for hall effect sensor (to keep track of motor).
If there is enough I/O, then maybe control the LCD contrast with
digital pot (4 lines?).  Digital volume control would be nice too
(4 control lines - using a digital pot???).

Does the PIC need to read data FROM the LCD.  I know that bit 7 needs
to be read for the LCD busy flag, but do the rest of the lines need
to be accessed???  I wish to do a few custom graphic characters in the
LCD (an Up and Down arrow.....funny that they don't have these, as
there is a left and right arrow in the character set).  I think that I
am allowed to create up to 8 custom characters????

More questions:

A) I wish to use:       1) The internal watchdog
                       2) The timer for PIC to PIC serial
                          communication
                       3) The timer for frequency measurement (20KHz
                          to 80KHz)

                       Can I do this?

                       I was thinking that if I can't, then maybe
                       using an external watchdog & power sense
                       chip (Dallas DS1232).

B) How can I isolate the lines to implement in-circuit-programming (ICP)?
  I wish to use have access to the MCRL line for reset from external
  watchdog & power sense chip and also a pushbutton manual reset.
  How can I isolate the B lines (PB6 & PB7 used for programming)?

  I was think of using an HC245 and disabling the chip (Z state) when
  using ICP but then I would need to enable the chip when using it for
  the real circuit.

  I can use a PNP transistor to isolate the PIC and HC245 chip power
  so that they are the only ones powered up during ICP.


Comments????  .....please!

Thanks

-Randie

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
*/ Randie Ohtsji                                                     /*
/* Glenayre R&D, Vancouver, BC  CANADA   Phone: (604) 293-1611 x4555 */
*/ Email: TakeThisOuTrohtsjiEraseMEspamspam_OUTglenayre.com           Fax:   (604) 293-4317       /*
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/



{Quote hidden}

> {Original Message removed}

1997\10\18@160915 by Eric van Es

flavicon
face
Randie Ohtsji [4555] wrote:

> Hi Mike,
>
> Sorry about the CC (are you getting two of this message, if so please
> let me know and I will stop CCing you).
>

Exactly what does CC do? I haven't used it, but would like to know what it does.

> Yes, I am using an old version of OrCAD (v4.???).

Ah Another one....

{Quote hidden}

That's a load of stuff! You'll be busy a while with port-expansion!

> Does the PIC need to read data FROM the LCD.  I know that bit 7 needs
> to be read for the LCD busy flag, but do the rest of the lines need
> to be accessed???  I wish to do a few custom graphic characters in the
> LCD (an Up and Down arrow.....funny that they don't have these, as
> there is a left and right arrow in the character set).  I think that I
> am allowed to create up to 8 custom characters????
>

I don't think you need to read the LCD. You can save one i/o that way (R/W).You
don't need to read the busy flag - you can use delays. Slower though (not much).
You can save 4 I/O lines by simply using the LCD in nibble mode (slower again)

> More questions:
>

snip

> B) How can I isolate the lines to implement in-circuit-programming (ICP)?
>    I wish to use have access to the MCRL line for reset from external
>    watchdog & power sense chip and also a pushbutton manual reset.
>    How can I isolate the B lines (PB6 & PB7 used for programming)?
>

How serious are you about this? Can you use a jumper for running/programming? Or
will your unit be totally enclosed?

{Quote hidden}

> > {Original Message removed}

1997\10\20@124045 by ndie Ohtsji [4555]

flavicon
face
Hullo Mike!

> Wow!!  Can I suggest a rethink.  Look at an I2C (pronounced eye-
> squared-see) data book.  The I2C is a 2wire protocol that supports

I'm a little confused about I2C.  Is this an actual IC chip that I
need to connect to the PIC?  Or do I use this instead of the PIC?
Can you recommend any web-sites or manufacturers of this (if it is
a chip) please.


> on writes.  What sort of motor control? stepper/servo? can do in i2c.

Not quite sure if I'm going to use a stepper motor or a regular motor
with a hall effect sensor.  I want to spin a plate around and send
out burst of data (PIC to PIC communication) 45 or 90 degree increments
(ie send out a burst at: 0 degrees, 90 degrees, 180 degrees, 270 degress)
I was think of using the hall effect sensor to sync up when I reach
0 degrees (cheaper than a stepper motor....I think).


> Urr, are you using an integrated chip/display?  These offer differing
> address modes serial/nibble/byte sometimes.   Only other reason to read
> would be to do a dump of the contents of the display, or the char gen - with
> a view to doing read/modify/write to either one.

I would be using a standard integrated chip/display (Sharp or Seiko or
Optrex 2 x 16 LCD display)


> clear wdt.  eg latter case - if you have noise prone design micro can latch
> up so a s/w reset won't fix - or brownouts will stop it working too.  If its
> a life or death thing (and it better not be - it can't checksum itself) then
> an external wdt is the way to go.

The DS1232 is a micromonitor chip which will provide 3 functions:
       1) Power monitor for brown outs.
       2) Watchdog
       3) Push button reset
Any of the 3 conditions will produce a 250mS reset pulse.  I wish to do
all three.


>> 2) The timer for PIC to PIC serial
>>    communication
>
> Async (RS232) or sync?  The latter is probably easier and faster.  If you
> dont need speed, you could put both on i2c bus - it is multi-master. (but,

I will be doing sync communication.  I just want to use 2 lines (data & gnd)
as I may want to do this over an RF link in the future.  I not using RS232.
Speed is not really a concern.  I bought "Easy Pic'n" and "Pic'n up the Pace"
and PIC to PIC communication is implemented by using the timer.  I thought
perhaps I could use this.  But of course I am open to better or alternate
ways of achieving this.


I guess my main question was can I do all three items as they all use
the timer in some way.


> You're using a connector to connect to your ICP, right?  How about making it
> something like a 10 way dil ribbon connector.  When not in program mode use
> links to route thru to your regular cct.  Its a lo tech soln, but sometimes
> they are ok.  Depends on skill of assemblers.

I guess I'm going overboard.  I was thinking of the circuit automatically
switching to ICP mode once the connector was plugged in and switching back
to normal mode with the connector removed.  I'm using an 8 position RJ45
connector as the ICP port.

I have since given up the automatic mode and installed 2-position jumpers
to isolate the circuit.


> What IS it?

If I tell you....... I will have to kill you!  ;)
Just kidding, it is actually a remote data logger/transmitter.


> If i2c is not for you, let me know, and I'll see where the mux techniques
> lead.

Still thinking about mux as I don't know too much about I2C.  Can you
send info please.

Thanks in advance!

-Randie

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
*/ Randie Ohtsji                                                     /*
/* Glenayre R&D, Vancouver, BC  CANADA   Phone: (604) 293-1611 x4555 */
*/ Email: RemoveMErohtsjiKILLspamspamglenayre.com           Fax:   (604) 293-4317       /*
*/                ________                                           /*
/*               / ____/ /__  ____  ____ ___  _________              */
*/              / /___/ / _ \/ __ \/ __ `/ / / / __/ _ \             /*
/*             / /_\ / /  __/ / / / /_/ / /_/ / / /  __/             */
*/             \____/_/\___/_/ /_/\__,_/\__  /_/  \___/              /*
/*                ________________________/ /                        */
*/               /_________________________/                         /*
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

1997\10\20@162314 by Herbert Graf

flavicon
face
On Mon, 20 Oct 1997, Randie Ohtsji [4555] wrote:


> I'm a little confused about I2C.  Is this an actual IC chip that I
> need to connect to the PIC?  Or do I use this instead of the PIC?
> Can you recommend any web-sites or manufacturers of this (if it is
> a chip) please.
>
       I2C is a protocol that can be implemented in software, the reason
it is popular is because it is two wire, multimaster, can address alot of
devices and because there are quite a few devices out there that conform
to the standard. TTYL

1997\10\20@184337 by ndie Ohtsji [4555]

flavicon
face
Can anyone direct me to where I can get a copy of the I2C protocol
definition.  Is I2C better than SPI??   What are the differences
between the two?  Does anyone have any examples of I2C or SPI code
using a 16F84?

Thanks!

-Randie
....so many questions, one little brain.......where am I going to
find room to stuff in the answers??

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
*/ Randie Ohtsji                                                     /*
/* Glenayre R&D, Vancouver, BC  CANADA   Phone: (604) 293-1611 x4555 */
*/ Email: rohtsjiSTOPspamspamspam_OUTglenayre.com           Fax:   (604) 293-4317       /*
*/                ________                                           /*
/*               / ____/ /__  ____  ____ ___  _________              */
*/              / /___/ / _ \/ __ \/ __ `/ / / / __/ _ \             /*
/*             / /_\ / /  __/ / / / /_/ / /_/ / / /  __/             */
*/             \____/_/\___/_/ /_/\__,_/\__  /_/  \___/              /*
/*                ________________________/ /                        */
*/               /_________________________/                         /*
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/


P.S. [OT] I just met with our Microchip rep and he was saying other Flash
parts are due in 2Q98 - 3Q98.  He's never heard of Scenix.



> > I'm a little confused about I2C.  Is this an actual IC chip that I
> > need to connect to the PIC?  Or do I use this instead of the PIC?
> > Can you recommend any web-sites or manufacturers of this (if it is
> > a chip) please.
> >
>         I2C is a protocol that can be implemented in software, the reason
> it is popular is because it is two wire, multimaster, can address alot of
> devices and because there are quite a few devices out there that conform
> to the standard. TTYL
>

1997\10\20@200703 by Bob Lunn

flavicon
face
Bob Lunn
10/21/97 10:08 AM


> Can anyone direct me to where I can get a copy of the
> I2C protocol definition.

    Look at a datasheet for any pic that supports
    SPI/IIC comms, such as the 16C74.  These provide
    quite good descriptions of the protocols.

    Alternatively, look at the datasheets for any
    serial eeprom that uses either of these protocols
    (eg: 24C01 for IIC or 25LC040 for SPI).

    All of these datasheets are available from the
    Microchip web site.

> Is I2C better than SPI??

    As usual, it depends.

    'Standard' IIC only provides data transfer rates
    up to 100kHz, though 'fast' IIC goes to 400kHz.

    In contrast, standard SPI goes to 2MHz.

    The choice is usually based on the hardware that
    you want to use.  If your hardware requires SPI
    then you use that; if it requires IIC ditto.

    In the absence of a hardware constraint I always
    choose IIC.

> What are the differences between the two?

    SPI is owned by Motorola.

    IIC is owned by Philips.

    :)

> Does anyone have any examples of I2C or SPI code using
> a 16F84?

    I believe there are appnotes showing bit-banged IIC
    on the Microchip web site, but I don't know the number.
___Bob

1997\10\20@233419 by Rick Watson
flavicon
face
Get:

http://www-us.semiconductors.philips.com/acrobat/3114.pdf

"The I2C-Bus and How to Use It (including specifications).

Also, search on their www page for other references.

http://www-us.semiconductors.philips.com/search/

For code, goto http://www.microchip.com and look for AN578 and AN554.

Rick Watson
The University of Texas, ACITS Networking Services, 512/475-9220
spamBeGoner.watsonSTOPspamspamEraseMEutexas.edu

Randie Ohtsji [4555] wrote:
{Quote hidden}

1997\10\21@091518 by Mike Smith

flavicon
face
-----Original Message-----
From: Randie Ohtsji [4555] <EraseMErohtsjispamEraseMEGLENVAN.GLENAYRE.COM>
To: @spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU <spamBeGonePICLISTspamKILLspamMITVMA.MIT.EDU>
Date: Tuesday, 21 October 1997 8:14
Subject: Re: What is the best way to sense a pushbutton press???

<snip>

>P.S. [OT] I just met with our Microchip rep and he was saying other Flash
>parts are due in 2Q98 - 3Q98.  He's never heard of Scenix.

An ostrich, methinks.

MikeS
<.....mikesmith_ozspam_OUTspamrelaymail.net>

1997\10\21@092530 by Mike Smith

flavicon
face
-----Original Message-----
From: Randie Ohtsji [4555] <TakeThisOuTrohtsji.....spamTakeThisOuTGLENVAN.GLENAYRE.COM>
To: TakeThisOuTPICLISTKILLspamspamspamMITVMA.MIT.EDU <.....PICLISTspamRemoveMEMITVMA.MIT.EDU>
Date: Tuesday, 21 October 1997 2:13
Subject: Re: What is the best way to sense a pushbutton press???


{Quote hidden}

No, I2C is a serial communication standard that allows low-medium speed
communications to occur over 2 wires, Phillips invented it, and there are a
lot of peripheral chips out there that utilise this protocol.  You don't
need a special chip to generate it at the PIC end, you just twiddle two
lines.  (actually, you set the port bits you are going to use low, and
twiddle the data direction bits if you do it properly - the lines have 2
pullup resistors)  The PIC apps manual explains it somewhat, although I've
seen better.  Maybe the Phillips site?  Anyone else know??

>
>> on writes.  What sort of motor control? stepper/servo? can do in i2c.
>
>Not quite sure if I'm going to use a stepper motor or a regular motor
>with a hall effect sensor.  I want to spin a plate around and send
>out burst of data (PIC to PIC communication) 45 or 90 degree increments
>(ie send out a burst at: 0 degrees, 90 degrees, 180 degrees, 270 degress)
>I was think of using the hall effect sensor to sync up when I reach
>0 degrees (cheaper than a stepper motor....I think).

Probably.

>
>
>> Urr, are you using an integrated chip/display?  These offer differing
>> address modes serial/nibble/byte sometimes.   Only other reason to read
>> would be to do a dump of the contents of the display, or the char gen -
with
>> a view to doing read/modify/write to either one.
>
>I would be using a standard integrated chip/display (Sharp or Seiko or
>Optrex 2 x 16 LCD display)
>

Minimise io by using in nibble or serial mode.  Don't know the specs on
those displays off the top of my head.

>
>> clear wdt.  eg latter case - if you have noise prone design micro can
latch
>> up so a s/w reset won't fix - or brownouts will stop it working too.  If
its
>> a life or death thing (and it better not be - it can't checksum itself)
then
>> an external wdt is the way to go.
>
>The DS1232 is a micromonitor chip which will provide 3 functions:
>        1) Power monitor for brown outs.
>        2) Watchdog
>        3) Push button reset
>Any of the 3 conditions will produce a 250mS reset pulse.  I wish to do
>all three.

I wouldn't assume that a reset would reset.  As I saw someone observe about
*a* microcontroller (no names)
- "The reset is sort of a software request for a reset" ...

>
>
>>> 2) The timer for PIC to PIC serial
>>>    communication
>>
>> Async (RS232) or sync?  The latter is probably easier and faster.  If you
>> dont need speed, you could put both on i2c bus - it is multi-master.
(but,
>
>I will be doing sync communication.  I just want to use 2 lines (data &
gnd)
>as I may want to do this over an RF link in the future.  I not using RS232.
>Speed is not really a concern.  I bought "Easy Pic'n" and "Pic'n up the
Pace"
>and PIC to PIC communication is implemented by using the timer.  I thought
>perhaps I could use this.  But of course I am open to better or alternate
>ways of achieving this.
>
>
>I guess my main question was can I do all three items as they all use
>the timer in some way.

Possible, but difficult.  You can sometimes use the timers for more than one
thing in an application, but you've got to do some switching of values and
adding fudge factor sometimes.  I'd say avoid unless you really need to,
counting cycles to achieve timing is easy on the PIC.

>
>
>> You're using a connector to connect to your ICP, right?  How about making
it
>> something like a 10 way dil ribbon connector.  When not in program mode
use
>> links to route thru to your regular cct.  Its a lo tech soln, but
sometimes
>> they are ok.  Depends on skill of assemblers.
>
>I guess I'm going overboard.  I was thinking of the circuit automatically
>switching to ICP mode once the connector was plugged in and switching back
>to normal mode with the connector removed.  I'm using an 8 position RJ45
>connector as the ICP port.

Expensive once use socket.  Still, I guess tinsel cable is robust.

>
>I have since given up the automatic mode and installed 2-position jumpers
>to isolate the circuit.
>
>
>> What IS it?
>
>If I tell you....... I will have to kill you!  ;)

Or get an Oz Piclist member to do it for you.

>Just kidding, it is actually a remote data logger/transmitter.

Duh!  Deja Vu from some of my past occupations!

>
>
>> If i2c is not for you, let me know, and I'll see where the mux techniques
>> lead.
>
>Still thinking about mux as I don't know too much about I2C.  Can you
>send info please.
>

Don't expect it till the weekend.  Working fulltime days now, which
restricts somewhat.  But have a think about I2C it would probably save you a
lot of 'glue' logic chips...

MikeS
<RemoveMEmikesmith_ozspamspamBeGonerelaymail.net>

1997\10\21@092746 by tjaart

flavicon
face
Mike Smith wrote:
>
> -----Original Message-----
> From: Randie Ohtsji [4555] <spamBeGonerohtsji@spam@spamspam_OUTGLENVAN.GLENAYRE.COM>
> To: TakeThisOuTPICLISTspamspamMITVMA.MIT.EDU <PICLISTEraseMEspamMITVMA.MIT.EDU>
> Date: Tuesday, 21 October 1997 8:14
> Subject: Re: What is the best way to sense a pushbutton press???
>
> <snip>
>
> >P.S. [OT] I just met with our Microchip rep and he was saying other Flash
> >parts are due in 2Q98 - 3Q98.  He's never heard of Scenix.
>
> An ostrich, methinks.

They are following the ostrich *principle* (head under the ground) until
next year, when they'll need an *obstetrician* to get the Flash out of
them.
So, until then, it is our duty to ostracize them at every opportunity.

--
Friendly Regards

Tjaart van der Walt
RemoveMEtjaartEraseMEspamspam_OUTwasp.co.za
_____________________________________________________________
| WASP International http://www.wasp.co.za/~tjaart/index.html |
|       R&D Engineer : GSM peripheral services development    |
|   Vehicle tracking | Telemetry systems | GSM data transfer  |
|    Voice : +27-(0)11-622-8686 | Fax : +27-(0)11-622-8973    |
|              WGS-84 : 26010.52'S 28006.19'E                 |
|_____________________________________________________________|

1997\10\28@124136 by Marc Heuler

flavicon
face
Hi Randie (Randie Ohtsji [4555]), in
<@spam@199710171738.KAA15419RemoveMEspamEraseMEglenvan.glenayre.com> on Oct 17 you wrote:

> Yes, I am using an old version of OrCAD (v4.???).  I'm very new to
> the PIC, but I have a 16C84-04 and a 16F84-10 to play with.  This
> PIC list is great -- I found out a lot from all the email bouncing
> around (but I still have a LOT to learn).  I would appreciate
> any hints, circuits, starting points, etc.
>
> I want to connect a 2x16 line LCD (8 data lines + 3 control lines),
> a fully addressed ISD voice chip (10 address lines + 3 control
> lines + 2 status lines), compass module (1 data line + 4 control
> lines), serial communication (PIC to PIC: 1 data line + gnd).
> 3 or 4 push buttons, Hex rotary switch - BCD format (4 lines)
> and 2 or 3 misc I/O (2 or 3 lines?). Also maybe some motor control
> lines and a data line for hall effect sensor (to keep track of motor).
> If there is enough I/O, then maybe control the LCD contrast with
> digital pot (4 lines?).  Digital volume control would be nice too
> (4 control lines - using a digital pot???).

I don't want to disappoint you but your requirements of IOs superceeds the
'84 capabilities.  Also considering that you probably want to display some
text messages on your display (which have to be stored somewhere with your
program) I'd head for an 8051 or AT89C52 (if internal program memory is
required).  There are lots of free development tools and the AT89C52 can
store up to 8kb of program (lots of space for text messages compared to '84
1kb).

If you insist on using a PIC, there are some TTL serial to parallel
converters that you can use to interface lots of IO to few port pins.  Or
you can use latches.

I think the '84 is underpowered for your project.

> Does the PIC need to read data FROM the LCD.  I know that bit 7 needs
> to be read for the LCD busy flag, but do the rest of the lines need
> to be accessed???

You usually don't need to read, or even poll the busy flag.  Just use the
max timing from your datasheet.

> I wish to do a few custom graphic characters in the
> LCD (an Up and Down arrow.....funny that they don't have these, as
> there is a left and right arrow in the character set).  I think that I
> am allowed to create up to 8 custom characters????

Usually you can define the arrows (btw 8 custom chars already require 1/16
of '84 code space, not including upload code).

> A) I wish to use:       1) The internal watchdog

>                         I was thinking that if I can't, then maybe
>                         using an external watchdog & power sense
>                         chip (Dallas DS1232).

The internal watchdog does not protect you from brownouts.  If your device
is to work unattended you should use a 1232!

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...