home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.sys.raspberry-pi      Raspberry Pi computers & related hardwar      26,127 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 24,356 of 26,127   
   =?UTF-8?Q?Bj=C3=B6rn_Lundin?= to The Natural Philosopher   
   Re: Need help with PI PICO...   
   28 Mar 24 09:35:39   
   
   From: bnl@nowhere.com   
      
   On 2024-03-25 16:57, The Natural Philosopher wrote:   
   > That is, some asynchrounous event in this sequence   
   >   
   >      gpio_put(ULTRASONIC_OUT,1);   
   >      sleep_us(10);   
   >      gpio_put(ULTRASONIC_OUT,0); //reset the input   
   > //if asynch event lasting more than 100uS occurs here...   
   >      // wait for echo pulse start   
   >      while(!gpio_get(ULTRASONIC_IN))   
   >          ;   
   > //then the low-high-low echo pulse will never be detected.   
      
      
   if you change the wait body to include a counter then you could realize   
   that when the counter had reached a high number - you missed the pulse.   
   Just try again then. Getting a reading is not that time sensitive - or?   
      
   :START   
          int cnt = 0;   
          gpio_put(ULTRASONIC_OUT,1);   
          sleep_us(10);   
          gpio_put(ULTRASONIC_OUT,0); //reset the input   
     //if asynch event lasting more than 100uS occurs here...   
          // wait for echo pulse start   
          while(TRUE) {   
      
            if (! gpio_get(ULTRASONIC_IN)) {   
               cnt++   
            } else {   
              break;   
            }   
      
            if (cnt >= TOO_HIGH_VALUE) {   
               goto START;   
            }   
      
      
          }   
      
   --   
   /Björn   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca