Position sensor: Difference between revisions
No edit summary |
No edit summary |
||
| Line 47: | Line 47: | ||
[[Category:Sensors]] | [[Category:Sensors]] | ||
[[Category:Missing images]] | |||
Revision as of 22:22, 9 October 2023

The Smart Sense position sensor will indicate rotational movement over a 360° range. The sensor connects to any one of the analogue sensor inputs. Once connected the Smart Move software will display the name of the sensor and label the appropriate input ‘Position’. The screen will display the current reading from the sensor, a complete rotation of the spindle will cover the range from 0 to 255. The reading can be converted to degrees by multiplying by 1.41. i.e. PRINT POSITION * 1.41
Responding to position
The sensor can be used as an input device to a system which responds to changes in position. The example procedure "Compass" uses the sensor to produce an electronic ‘compass’. One of the outputs will switch on as the sensor moves through each quarter of a turn.
Procedure: Compass
REPEAT IF POSITION >= 0 AND POSITION <=63 THEN SWITCH ON 0 ELSE SWITCH OFF 0 IF POSITION >= 64 AND POSITION <=127 THEN SWITCH ON 1 ELSE SWITCH OFF 1 IF POSITION >= 128 AND POSITION <=191 THEN SWITCH ON 2 ELSE SWITCH OFF 2 IF POSITION >= 192 AND POSITION <=255 THEN SWITCH ON 3 ELSE SWITCH OFF 3 FOREVER
How it works
The first and last lines of the procedure form a loop which continues until the user escapes from the procedure. Each line within the loop checks if the sensor reading is within a certain range and switches on or off the appropriate output.
Measuring rotation
The second example uses the sensor to gather data as a pendulum swings. The procedure "Pendulum" will wait until the user presses the space bar. At this point the pendulum should be released and the readings from the sensor are stored to a disk file. Once the pendulum has come to rest the space bar is pressed and the readings are saved to disk. This file can then be used with a spreadsheet to produce results as in the figure. This example compares results from two pendulums of different length.
Procedure: Pendulum
FILE 1,"data" WAIT UNTIL GET = 32 PRINT "sampling" REPEAT STORE 1,POSITION UNTIL INKEY = 32 CLOSE 1