Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:software:homelab:library:module:sensor [2010/12/30 13:57]
allan.pettai
en:software:homelab:library:module:sensor [2018/12/27 12:53] (current)
Line 31: Line 31:
     * Returns distance in centimeters or -1 if it cannot be calculated.     * Returns distance in centimeters or -1 if it cannot be calculated.
  
-  * **//​unsigned short ultrasonic_measure(pin trigger, pin echo)//** \\ +  * **//​unsigned short ultrasonic_measure_srf04(pin trigger, pin echo)//** \\ 
-    Measures distance with ultrasonic distance sensor. ​Functions generate ​a trigger pulse on one pin and measures the time of echo pulse on another pin. Distance is calculated from the time. Function expects a 14.7456 MHz clock frequency. Measuring may take up to 36 ms. Parameters:+    Measures distance with ultrasonic distance sensor ​SRF04Function generates ​a trigger pulse on one pin and measures the time of echo pulse on another pin. Distance is calculated from the time. Function expects a 14.7456 MHz clock frequency. Measuring may take up to 36 ms. Parameters:
     * //trigger// - Trigger pin variable.     * //trigger// - Trigger pin variable.
     * //echo// - Echo pin variable.     * //echo// - Echo pin variable.
 +    * Returns distance in centimeters or 0 when measuring failed.
 +  * **//​unsigned short ultrasonic_measure_srf05(pin trigger_echo)//​** \\
 +    Measures distance with ultrasonic distance sensor SRF05 in one wire regime. Function generates a trigger pulse on the pin and measures the time of echo pulse on the same pin. Distance is calculated from the time. Function expects a 14.7456 MHz clock frequency. Measuring may take up to 36 ms. Parameters:
 +    * //​trigger_echo//​ - Trigger/​Echo combined pin variable.
     * Returns distance in centimeters or 0 when measuring failed.     * Returns distance in centimeters or 0 when measuring failed.
  
 ===== Example ===== ===== Example =====
  
-The following program demonstrates usage of IR and ultrasonic distance ​sensors.+The following program demonstrates usage of IR and ultrasonic distance ​sensor SRF05.
  
 <code c> <code c>
Line 45: Line 49:
  
 // Ultrasonic distance sensor control pins. // Ultrasonic distance sensor control pins.
-pin pin_trigger = PIN(G, 1); +pin pin_triggerecho ​   = PIN(G, 0);
-pin pin_echo ​   = PIN(G, 0);+
  
 int main(void) int main(void)
Line 57: Line 60:
  
  // Measuring with ultrasonic distance sensor.  // Measuring with ultrasonic distance sensor.
- distance = ultrasonic_measure(pin_trigger,​ pin_echo);+ distance = ultrasonic_measure_srf05(pin_triggerecho);
 } }
 </​code>​ </​code>​
- 
en/software/homelab/library/module/sensor.1293710247.txt.gz · Last modified: 2013/03/26 23:02 (external edit)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0