Searching \ for '[PIC]: Monitoring switch(s) state' 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/microchip/devices.htm?key=pic
Search entire site for: 'Monitoring switch(s) state'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Monitoring switch(s) state'
2003\10\20@161709 by Tal

flavicon
face
Hi All

Did anyone come across a circuit that can monitor the state of some
switches?
The general idea is to monitor the state of any switch (high/low) and
measure the elapsed time that the switch is on or off.
any circuit or idea will be most appreciate.

Thanks

Tal

--
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

2003\10\20@172414 by

picon face
Tal wrote :
> Did anyone come across a circuit that can monitor the state of some
> switches?
> The general idea is to monitor the state of any switch (high/low) and
> measure the elapsed time that the switch is on or off.
> any circuit or idea will be most appreciate.
>
> Thanks

I must be missing something here...

A circuit to measure elapsed time ?
Using a PIC seams in line with the general topic of this maillist :-)
A pin with the internal pullup enabled maybe ?

Is this an old thread ?

Jan-Erik.

--
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

2003\10\20@181026 by Tal

flavicon
face
Jan-Erik

Forget it.
I will look harder on the 'net.

Tal

-----Original Message-----
From: pic microcontroller discussion list
[spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU]On Behalf Of Jan-Erik Soderholm XA
(TN/PAC)
Sent: Tuesday, October 21, 2003 12:24 AM
To: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
Subject: Re: [PIC]: Monitoring switch(s) state


Tal wrote :
> Did anyone come across a circuit that can monitor the state of some
> switches?
> The general idea is to monitor the state of any switch (high/low) and
> measure the elapsed time that the switch is on or off.
> any circuit or idea will be most appreciate.
>
> Thanks

I must be missing something here...

A circuit to measure elapsed time ?
Using a PIC seams in line with the general topic of this maillist :-)
A pin with the internal pullup enabled maybe ?

Is this an old thread ?

Jan-Erik.

--
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

2003\10\20@204652 by Robert Rolf

picon face
Sounds more like a homework assignment.

Not enough detail. Monitor for days, hours, minutes, miliseconds?


R

"Jan-Erik Soderholm XA (TN/PAC)" 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

2003\10\21@101317 by Micro Eng

picon face
ummmm....easy

use TMR0 as an interupt for incrementing time

check flag for status of input bit inside ISR

increment register(s) if bit is on(off)

_________________________________________________________________
Send instant messages to anyone on your contact list with  MSN Messenger
6.0.  Try it now FREE!  http://msnmessenger-download.com

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

2003\10\21@201123 by Tal

flavicon
face
Robert and others

First, I admit that I have no idea how to write a code for pic's. this is
the reason I ask for help.
What I am looking for is very simple, a circuit that start when a switch is
pressed for a brief time I call it "start".
this switch is ignored if pressed again until "reset" switch is activate.
another switch is activating a led while is pressed alternately this I call
it  "running".
the "reset" switch function in this way: if the switch is pressed for lets
say 10 seconds (no less) then a buzzer is activate. any time less then 10
sec will keep the circuit running (led is blinking while "running" is
alternately pressed) and "start" switch is ignored.
if "reset" is activated more than 10 sec then "start" switch can start the
circuit all over again, and so on. like a loop.

hope I explain my self coherently.

I'll appreciate any help!

Tal



{Original Message removed}

2003\10\21@201607 by Liam O'Hagan

flavicon
face
sounds like you want to debounce a switch for 10 seconds! why so long? How
accurate does it need to be?

> {Original Message removed}

2003\10\21@202021 by Tal

flavicon
face
Liam

No, I try to monitor a machine that's move and to know when it's returning
to home position.

Tal

{Original Message removed}

2003\10\21@203928 by Jinx
face picon face
> What I am looking for is very simple, a circuit that start when a switch
is
> pressed for a brief time I call it "start"

Detect Start switch (I presume a pushbutton)

Assuming switches connected to Port A and active high

#define start_sw   porta,0
#define reset_sw  porta,1

In your code

test_sw        btfss  start_sw    ;wait for a "1" to appear on porta,0
                   goto  test_sw      ;else loop while "0"

> this switch is ignored if pressed again until "reset" switch is activate

So don't test start_sw again until reset

============================

> another switch is activating a led while is pressed alternately this I
call
> it  "running"

Don't quite understand that function.

============================

> the "reset" switch function in this way: if the switch is pressed for lets
> say 10 seconds (no less) then a buzzer is activated

reset           btfss   reset_sw      ;wait for a "1" to appear on porta,1
                   goto   reset             ;else loop while "0"

What you could do hear is start a timer interrupt that can be used to
measure how long reset_sw is depressed. The settings will depend
on which PIC and how fast

For example, an F6228 running at 3.2768MHz

Timer1 free-running will generate 12.5 interrupts/second = 125 in
10 seconds

Enable the interrupts on the first detection of reset_sw being pushed
and each time there's an interrupt, test for both reset_sw depressed
and interrupt counter = 125. If reset_sw is not depressed then 0 the
counter. If counter = 125 then do the reset. Having reset_sw on portb,0
or other external interrupt source might make it easier to detect a press,
depending on your code

Simplistic but that's a way it could be done

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

2003\10\22@052100 by Tal

flavicon
face
Jinx Thanks it's a start for me!

about the "running" switch: the machine have a part that move alternately
all the time (forward - backward) so each time the moving part is crossing
the middle of it's travel it press a switch (can be a reed relay or
something else..) so I want to see by light from a distance that the part is
moving and doesn't in hold/stop position. Ex.: monitoring a turning plate
that finish each turn by activating the switch/reed relay etc...

Tal

{Original Message removed}

2003\10\22@052722 by

picon face
Tal wrote:
> ... so I want to see by light from a distance that the part is
moving and doesn't in hold/stop position...

Tal,
I don't know the details, but,

Would it not be better to have some kind of lamp or alarm
that shows that the part is *NOT* moving ?

Like a siren or a rotating flashing light.

What is the most likely status, "moving" or "not moving" ?

Jan-Erik.

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

2003\10\22@055040 by Jinx

face picon face
> about the "running" switch: the machine have a part that
> move alternately all the time (forward - backward) so each
> time the moving part is crossing the middle of it's travel it
> press a switch

OK, that's something that an external interrupt pin would be
useful for. When the switch is activated by this moving piece
of machinery it can alert the PIC a couple of ways.

One is to use the INT flag to store this event. Whether or not
the external interrupt is enabled, INTF will be set by a switch
transition until your code resets it. You could look for this flag
as part of the Timer1 ISR. If it's set, turn a LED on for a Timer1
interrupt period. An 80ms flash is quite noticeable, but you
could keep the LED on for the duration of a counter driven by
Timer1 IRQs

#define led porta,2

ISR
-----

bcf    led                                ;turn LED off by default
btfss  intcon,intf                    ;test for external event
goto  process_timer1_irq   ;no, carry on with no LED lit

bcf    intcon,intf                     ;yes, clear flag
bsf led                                   ;light LED

bcf    tmr1if                           ;clear Timer1 flag
process_timer1_irq            ;continue

retfie

The other way would be to have Timer0 as a counter and set it
to 0xFF. A pulse coming into RA4 will cause Timer0 to rollover
to 0x00 and set T0IF, which you can check for

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

2003\10\22@060535 by Jinx

face picon face
> useful for. When the switch is activated by this moving piece
> of machinery it can alert the PIC a couple of ways.

Oh, another way I meant to mention was using an RC to store
the event. That way you could use a general purpose I/O pin

Set the pin as an input, C to ground and R to 5V via the switch.
When the switch closes the C will charge up and record the
closure. You can read this when your code has time. Set the
pin to an output and "0" to discharge the cap. It shouldn't need
a very big cap to do this, maybe a few nF. It depends on how
long the switch is closed for. Discharging C through a resistor,
a couple of hundred ohms, would be safe

                    R to 5V through switch
                     I
pin --- R ---- C to 0V

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

2003\10\22@061537 by Jinx

face picon face
Slight correction to previous code snippet, sorry, put flag clear
before the label

bcf    led                                ;turn LED off by default
btfss  intcon,intf                    ;test for external event
goto  process_timer1_irq   ;no, carry on with no LED lit

bcf    intcon,intf                     ;yes, clear flag
bsf led                                   ;light LED

process_timer1_irq            ;continue

bcf    tmr1if                           ;clear Timer1 flag

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

2003\10\22@180402 by Tal

flavicon
face
Jan-Eric

Yes, you are right. finally I will attach to the led a power stage to drive
a turning/flashing light.

But first, I have to take Jinx's code and try to put it inside a pic to
active the led :-))

Tal

{Original Message removed}

2003\10\22@180817 by Tal

flavicon
face
Jinx

Thanks very much for your help.

Can anyone recommend a simulator,  so I can try and see if it working ??

Tal

{Original Message removed}

2003\10\23@032007 by

picon face
Tal wrote:

> Jinx
>
> Thanks very much for your help.
>
> Can anyone recommend a simulator,  so I can try and see if it working ??
>
> Tal



SW or HW simulator ?

Maybe MPLAB/MPSIM ?

Jan-Erik.

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

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