Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59055 > unrolled thread

Implementing a multivibrator function with python

Started byJL <lightaiyee@gmail.com>
First post2013-11-11 01:41 -0800
Last post2013-11-11 15:00 +0100
Articles 9 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  Implementing a multivibrator function with python JL <lightaiyee@gmail.com> - 2013-11-11 01:41 -0800
    Re: Implementing a multivibrator function with python Dave Angel <davea@davea.name> - 2013-11-11 04:56 -0600
      Re: Implementing a multivibrator function with python JL <lightaiyee@gmail.com> - 2013-11-12 06:44 -0800
        Re: Implementing a multivibrator function with python unknown <unknown@unknown.com> - 2013-11-12 16:04 +0000
        Re: Implementing a multivibrator function with python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-12 17:37 +0100
        Re: Implementing a multivibrator function with python Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-12 11:47 -0500
        Re: Implementing a multivibrator function with python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-12 19:42 -0500
    Re: Implementing a multivibrator function with python Terry Reedy <tjreedy@udel.edu> - 2013-11-11 05:58 -0500
    Re: Implementing a multivibrator function with python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-11 15:00 +0100

#59055 — Implementing a multivibrator function with python

FromJL <lightaiyee@gmail.com>
Date2013-11-11 01:41 -0800
SubjectImplementing a multivibrator function with python
Message-ID<c763cc2a-83d2-4ed7-9df6-83371e83d841@googlegroups.com>
I am trying to implement a multivibrator function with python. This is how it works; 

- An trigger event happens
- Upon receiving the event, a variable goes high for 5secs, then go low.
- If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. This works like a retriggerable multivibrator for those who are into electronics. 

Is there some sample code for this problem or can someone point me to using the right library for this feature?

Thank you very much.

[toc] | [next] | [standalone]


#59062

FromDave Angel <davea@davea.name>
Date2013-11-11 04:56 -0600
Message-ID<mailman.2367.1384167379.18130.python-list@python.org>
In reply to#59055
On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL <lightaiyee@gmail.com> 
wrote:
> - If the event happens again before the 5secs expire, the high 
duration will be extended by another 5 secs. This works like a 
retriggerable multivibrator for those who are into electronics.

More precisely a retriggerable monostable multivibrator.

The question makes little sense unless you're running in an event 
driven environment, such as a gui. Name the environment and somebody 
can probably help.

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#59200

FromJL <lightaiyee@gmail.com>
Date2013-11-12 06:44 -0800
Message-ID<895644e2-cf9c-45fe-a908-0391b65e8614@googlegroups.com>
In reply to#59062
I am actually running python on raspberry pi. The trigger event is a button-press.

On Monday, November 11, 2013 6:56:03 PM UTC+8, Dave Angel wrote:
> On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL <lightaiyee@gmail.com> 
> 
> wrote:
> 
> > - If the event happens again before the 5secs expire, the high 
> 
> duration will be extended by another 5 secs. This works like a 
> 
> retriggerable multivibrator for those who are into electronics.
> 
> 
> 
> More precisely a retriggerable monostable multivibrator.
> 
> 
> 
> The question makes little sense unless you're running in an event 
> 
> driven environment, such as a gui. Name the environment and somebody 
> 
> can probably help.
> 
> 
> 
> -- 
> 
> DaveA

[toc] | [prev] | [next] | [standalone]


#59214

Fromunknown <unknown@unknown.com>
Date2013-11-12 16:04 +0000
Message-ID<Cksgu.53487$F07.50558@fx06.am4>
In reply to#59200
On Tue, 12 Nov 2013 06:44:05 -0800, JL wrote:

> I am actually running python on raspberry pi. The trigger event is a
> button-press.
> 
> On Monday, November 11, 2013 6:56:03 PM UTC+8, Dave Angel wrote:
>> On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL <lightaiyee@gmail.com>
>> 
>> wrote:
>> 
>> > - If the event happens again before the 5secs expire, the high
>> 
>> duration will be extended by another 5 secs. This works like a
>> 
>> retriggerable multivibrator for those who are into electronics.
>> 
>> 
>> 
>> More precisely a retriggerable monostable multivibrator.
>> 
>> 
>> 
>> The question makes little sense unless you're running in an event
>> 
>> driven environment, such as a gui. Name the environment and somebody
>> 
>> can probably help.
>> 
>> 
>> 
>> --
>> 
>> DaveA

How critical is the output pulse time?
is it a state that can be polled to regularly & changed if the timeout 
has been exceeded or does it need to switch in the background?

if you need to trigger & switch in the background you will probably need 
to start playing with threads or multiprocessing.

greater detail on what you are trying to achieve project wise may assist 
here

[toc] | [prev] | [next] | [standalone]


#59220

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2013-11-12 17:37 +0100
Message-ID<mailman.2481.1384274301.18130.python-list@python.org>
In reply to#59200
Op 12-11-13 15:44, JL schreef:
> I am actually running python on raspberry pi. The trigger event is a button-press.

That doesn't help. What does that button-press cause in terms of the OS. Does
it cause a signal? Does it produce a number of bytes that can be read from
some file like object? Something else?

This is not python specific, the answer to those questions is needed no matter
what language you use to implement your function.

-- 
Antoon Pardon


[toc] | [prev] | [next] | [standalone]


#59221

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-11-12 11:47 -0500
Message-ID<mailman.2482.1384274849.18130.python-list@python.org>
In reply to#59200
On Tue, Nov 12, 2013 at 11:37 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> wrote:
> Op 12-11-13 15:44, JL schreef:
>> I am actually running python on raspberry pi. The trigger event is a button-press.
>
> That doesn't help. What does that button-press cause in terms of the OS. Does
> it cause a signal? Does it produce a number of bytes that can be read from
> some file like object? Something else?
>
> This is not python specific, the answer to those questions is needed no matter
> what language you use to implement your function.

This interests me because I started out in Electrical engineering
school in college.  I'm intrigued by raspberry pi.  I bet you would
find specific answers reading about how the hardware works.  Does
Raspberry pi come with push buttons that are connected to some io
ports or a usb port or a keyboard or?

If there is no physical switch, one of the gui frameworks for python
certainly will have hooks to invoke code when a (virtual) button is
pressed.

Maybe find a Raspberry pi newsgroup?


>
> --
> Antoon Pardon
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#59270

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-11-12 19:42 -0500
Message-ID<mailman.2515.1384303508.18130.python-list@python.org>
In reply to#59200
On Tue, 12 Nov 2013 11:47:21 -0500, Joel Goldstick
<joel.goldstick@gmail.com> declaimed the following:


>
>Maybe find a Raspberry pi newsgroup?
>
	comp.sys.raspberry-pi perhaps?
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#59063

FromTerry Reedy <tjreedy@udel.edu>
Date2013-11-11 05:58 -0500
Message-ID<mailman.2368.1384167526.18130.python-list@python.org>
In reply to#59055
On 11/11/2013 4:41 AM, JL wrote:
> I am trying to implement a multivibrator function with python. This is how it works;
>
> - An trigger event happens
> - Upon receiving the event, a variable goes high for 5secs, then go low.
> - If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. This works like a retriggerable multivibrator for those who are into electronics.
>
> Is there some sample code for this problem or can someone point me to using the right library for this feature?

Python 3.4 will have a new asyncio package that includes an event loop 
module. It will be in the forthcoming 3.4.b0 release; it might be in 
3.4.a4 but I have not installed that yet. In any case, I believe it 
should make the above easy.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#59076

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2013-11-11 15:00 +0100
Message-ID<mailman.2378.1384178523.18130.python-list@python.org>
In reply to#59055
Op 11-11-13 10:41, JL schreef:
> I am trying to implement a multivibrator function with python. This is how it works; 
> 
> - An trigger event happens
> - Upon receiving the event, a variable goes high for 5secs, then go low.
> - If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. This works like a retriggerable multivibrator for those who are into electronics. 
> 
> Is there some sample code for this problem or can someone point me to using the right library for this feature?
> 
> Thank you very much.
> 
The problem is that it depnds on the kind of trigger event. Is it a signal?
Is it a character that arrives through a pipe or socket?

I would take a look at the signal module and see if it can get you started.

-- 
Antoon Pardon

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web