en:pfw:reflection-sensors
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:pfw:reflection-sensors [2023-09-04 18:18] – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | en:pfw:reflection-sensors [2023-09-04 18:18] (current) – ↷ Seite von pfw:reflection-sensors nach en:pfw:reflection-sensors verschoben uho | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{pfw: | ||
+ | ====== Reflection sensors ====== | ||
+ | |||
+ | ===== Idea ===== | ||
+ | |||
+ | A reflection sensor is most of the time a sensor that uses (infrared) light to detect the precence of an object. | ||
+ | |||
+ | ===== TCND5000 the demonstrated sensor ===== | ||
+ | |||
+ | |{{https:// | ||
+ | |{{https:// | ||
+ | |||
+ | **Upper left:** The TNCD5000 is a sensitive photo diode and an infrared led in one case.\\ | ||
+ | **Upper right:** A sketch of the TCND5000 driver.\\ | ||
+ | **Lower left:** Five sensors mounted on Cosey' | ||
+ | **Lower Right:** Piece of schematics of the Cosey robot, note that the resistor values have changed! | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Pseudo code ===== | ||
+ | |||
+ | < | ||
+ | Function: REFLECTION | ||
+ | Read adc input ' | ||
+ | |||
+ | Function: FLOOR ( adc -- +s ) | ||
+ | Read adc input ' | ||
+ | |||
+ | Function: RAVINE | ||
+ | Read the three adc inputs from the front of a robot. | ||
+ | Translate the results to the numbers 0 to 3, indicating | ||
+ | which sensor(s) where fired. Zero means non. | ||
+ | |||
+ | Function: BACKWARD? | ||
+ | Test the sensor on the backside of a robot, leave true | ||
+ | if the sensor is fired, otherwise false | ||
+ | </ | ||
+ | |||
+ | ===== Generic Forth ===== | ||
+ | |||
+ | <code forth> | ||
+ | \ Reflection sensor example as used with the Cosey robot | ||
+ | \ | ||
+ | \ Each sensor output is connected to an ADC input with 12-bit resolution | ||
+ | \ | ||
+ | \ Words with hardware dependencies: | ||
+ | \ : **BIS ( mask addr -- ) tuck @ or swap ! ; | ||
+ | \ : **BIC ( mask addr -- ) >r invert | ||
+ | \ : BIT** ( mask addr -- 0|b ) @ and ; | ||
+ | \ | ||
+ | \ Needed an ADC routine like this one for the MSP430FR5949: | ||
+ | \ | ||
+ | \ We need to clear the ENC bit before setting a new input channel | ||
+ | \ ADC can be used with VCC and VREF (2.5V) as reference voltage | ||
+ | \ : ADC ( adc fl -- +n ) | ||
+ | \ 02 800 **bic \ ADC12CTL0 | ||
+ | \ 100 and >r \ Use VREF when fl is true | ||
+ | \ 1F and r> or 820 ! \ ADC12MCTL0 Select input | ||
+ | \ 03 800 **bis \ ADC12CTL0 | ||
+ | \ begin 1 802 bit** 0= until \ ADC12CTL1 | ||
+ | \ 860 @ ; \ ADC12MEM0 | ||
+ | \ | ||
+ | \ Activate an output on a PCA9632 I2C led output driver | ||
+ | \ The routine /MS waits in steps of 0.1 milliseconds | ||
+ | \ It is used here to give the sensor time to settle | ||
+ | \ : > | ||
+ | |||
+ | \ Read sensor level from input ' | ||
+ | : REFLECTION | ||
+ | |||
+ | \ FLOOR sensor result is scaled and gives a number from 0 to 10 | ||
+ | : FLOOR | ||
+ | |||
+ | |||
+ | \ Examples (Cosey' | ||
+ | |||
+ | \ 0 = No ravine | ||
+ | \ 1 = ravine at left | ||
+ | \ 2 = ravine in front | ||
+ | \ 3 = ravine at right | ||
+ | : RAVINE | ||
+ | 01 > | ||
+ | 04 > | ||
+ | 10 > | ||
+ | 0 ; \ No floor sensor at all triggered | ||
+ | |||
+ | \ True if reflection sensor on the backside goes over the edge | ||
+ | : BACKWARD? | ||
+ | </ | ||
+ | |||
+ | More info look at specific implementations, | ||
+ | |||
+ | **Cosey robot V1.0** {{https:// | ||