Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rising edge of detection
#7
Hello,
thank you, it works. I do a code to print the speed of the encoder bu it does'nt works, the max that he prints is 4, i think it's a probleme like the speed of python to detect rising edge. Can you help me because i need the speed but i dont know how to do now. My first idea is mesuring the time between two riing edge and after calculate the speed but it doesn't works. Do you have other idea of code that could works?
# coding: utf-_
import RPi.GPIO as GPIO
import time

lasttime=0
 
def callback_up(channel):
    global lasttime
    if lasttime==0:
        lasttime=time.time()
    else:
        now = time.time()
        gap=now-lasttime
        vitesse=(1/(gap*256))*257
        print(vitesse)
        lasttime=now
    
 
GPIO.setmode(GPIO.BCM)
PIR = 23
GPIO.setup(PIR, GPIO.IN)
try:
    GPIO.add_event_detect(PIR, GPIO.RISING, callback=callback_up)
    while 1:
        time.sleep(10)
exept KeyboardInterrupt:
   print("fin")
Reply


Messages In This Thread
rising edge of detection - by peter14 - Dec-19-2018, 03:46 PM
RE: rising edge of detection - by Larz60+ - Dec-19-2018, 03:56 PM
RE: rising edge of detection - by peter14 - Dec-19-2018, 08:08 PM
RE: rising edge of detection - by Larz60+ - Dec-20-2018, 01:05 AM
RE: rising edge of detection - by peter14 - Dec-20-2018, 09:20 AM
RE: rising edge of detection - by Larz60+ - Dec-20-2018, 03:52 PM
RE: rising edge of detection - by peter14 - Dec-23-2018, 07:09 PM
RE: rising edge of detection - by peter14 - Dec-27-2018, 10:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Networkx: Visualize an edge weight with a bubble/circle uvw 0 2,031 Sep-01-2021, 06:26 AM
Last Post: uvw
Photo Setting Marker Edge Color In Plotting JoeDainton123 0 2,751 Oct-26-2020, 10:48 PM
Last Post: JoeDainton123
  How do I apply a Gaussian blur to a particular edge of geometry in Matplotlib? hbolandi 0 2,025 Feb-02-2020, 06:08 PM
Last Post: hbolandi
  Randomise network while maintaining topology of nodes using edge-swap approach Tom1988 3 4,161 May-25-2017, 10:59 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020