PAW_Sensor: This library control the PAW sensor. This library get sensor values from the PAW sensor, and send these values to PC through serial-communication. And you need to convert these values to delta h using some module on PC. I create sample python module for this library. If you want to get this module, please access below page, https://github.com/HiroakiMatsuda/PAW-Sensor The PAW Sensor is developed by RT. If you need to get information about this sensors, please access below page. http://www.rt-shop.jp/index.php?main_page=product_info&cPath=42&products_id=1303

Dependents:   PAW_Sensor_HelloWorld

Committer:
matsu
Date:
Sun Nov 09 08:17:01 2014 +0000
Revision:
1:6ec3794072de
Parent:
0:ebd7c54059ae
Child:
2:6a493f73860c
Fix comments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matsu 0:ebd7c54059ae 1 #ifndef PAW_H
matsu 0:ebd7c54059ae 2 #define PAW_H
matsu 0:ebd7c54059ae 3
matsu 0:ebd7c54059ae 4 #include "mbed.h"
matsu 0:ebd7c54059ae 5
matsu 0:ebd7c54059ae 6 #define STATE_1 0
matsu 0:ebd7c54059ae 7 #define STATE_2 1
matsu 0:ebd7c54059ae 8 #define STATE_3 2
matsu 0:ebd7c54059ae 9 #define STATE_4 3
matsu 0:ebd7c54059ae 10
matsu 0:ebd7c54059ae 11
matsu 0:ebd7c54059ae 12 /** PAW_Sensor Library
matsu 0:ebd7c54059ae 13 *
matsu 0:ebd7c54059ae 14 * Example:
matsu 0:ebd7c54059ae 15 * @code
matsu 0:ebd7c54059ae 16 *
matsu 0:ebd7c54059ae 17 #include "mbed.h"
matsu 0:ebd7c54059ae 18 #include "paw.h"
matsu 0:ebd7c54059ae 19
matsu 0:ebd7c54059ae 20 Serial pc( USBTX, USBRX );
matsu 0:ebd7c54059ae 21 const unsigned long baudrate = 115200;
matsu 0:ebd7c54059ae 22
matsu 0:ebd7c54059ae 23 // paw( LED1, LED2, PHOTO1, PHOTO2 )
matsu 0:ebd7c54059ae 24 PAW paw( p8, p9, p16, p17 );
matsu 0:ebd7c54059ae 25 paw_value g_value;
matsu 0:ebd7c54059ae 26
matsu 0:ebd7c54059ae 27 PAW paw_2( p10, p11, p18, p19 );
matsu 0:ebd7c54059ae 28 paw_value g_value_2;
matsu 0:ebd7c54059ae 29
matsu 0:ebd7c54059ae 30 Ticker run;
matsu 0:ebd7c54059ae 31
matsu 0:ebd7c54059ae 32
matsu 0:ebd7c54059ae 33 void run_paw_sensor()
matsu 0:ebd7c54059ae 34 {
matsu 0:ebd7c54059ae 35 if( paw.process_paw() == STATE_1 )
matsu 0:ebd7c54059ae 36 {
matsu 0:ebd7c54059ae 37 paw.print( &pc );
matsu 0:ebd7c54059ae 38 }
matsu 0:ebd7c54059ae 39 }
matsu 0:ebd7c54059ae 40
matsu 0:ebd7c54059ae 41 int main()
matsu 0:ebd7c54059ae 42 {
matsu 0:ebd7c54059ae 43 // Initializing Serial Communication
matsu 0:ebd7c54059ae 44 pc.baud( baudrate );
matsu 0:ebd7c54059ae 45 pc.format( 8, Serial::None, 1 );
matsu 0:ebd7c54059ae 46
matsu 0:ebd7c54059ae 47 run.attach_us(&run_paw_sensor, 500);
matsu 0:ebd7c54059ae 48
matsu 0:ebd7c54059ae 49 while(1);
matsu 0:ebd7c54059ae 50 }
matsu 0:ebd7c54059ae 51
matsu 0:ebd7c54059ae 52 * @endcode
matsu 0:ebd7c54059ae 53 */
matsu 0:ebd7c54059ae 54
matsu 0:ebd7c54059ae 55 struct paw_value
matsu 0:ebd7c54059ae 56 {
matsu 0:ebd7c54059ae 57 public:
matsu 0:ebd7c54059ae 58 short ch_1;
matsu 0:ebd7c54059ae 59 short ch_2;
matsu 0:ebd7c54059ae 60 short ch_3;
matsu 0:ebd7c54059ae 61 short ch_4;
matsu 0:ebd7c54059ae 62 short initial_photo_1;
matsu 0:ebd7c54059ae 63 short initial_photo_2;
matsu 0:ebd7c54059ae 64
matsu 0:ebd7c54059ae 65 paw_value()
matsu 0:ebd7c54059ae 66 {
matsu 0:ebd7c54059ae 67 ch_1 = 0;
matsu 0:ebd7c54059ae 68 ch_2 = 0;
matsu 0:ebd7c54059ae 69 ch_3 = 0;
matsu 0:ebd7c54059ae 70 ch_4 = 0;
matsu 0:ebd7c54059ae 71 initial_photo_1 = 0;
matsu 0:ebd7c54059ae 72 initial_photo_2 = 0;
matsu 0:ebd7c54059ae 73 }
matsu 0:ebd7c54059ae 74 };
matsu 0:ebd7c54059ae 75
matsu 0:ebd7c54059ae 76 class PAW {
matsu 0:ebd7c54059ae 77
matsu 0:ebd7c54059ae 78 public:
matsu 0:ebd7c54059ae 79
matsu 0:ebd7c54059ae 80 /** Create a PAW Sensor instance
matsu 0:ebd7c54059ae 81 *
matsu 0:ebd7c54059ae 82 * @param led_1 PAW Sensor's Pin 5
matsu 0:ebd7c54059ae 83 * @param led_2 PAW Sensor's Pin 4
matsu 0:ebd7c54059ae 84 * @param photo_1 PAW Sensor's Pin 3
matsu 0:ebd7c54059ae 85 * @param photo_2 PAW Sensor's Pin 2
matsu 0:ebd7c54059ae 86 */
matsu 0:ebd7c54059ae 87 PAW( PinName led_1, PinName led_2, PinName photo_1, PinName photo_2 );
matsu 0:ebd7c54059ae 88
matsu 0:ebd7c54059ae 89 /** Get values of PAW Sensor
matsu 0:ebd7c54059ae 90 *
matsu 0:ebd7c54059ae 91 * @return Return values of photosensor's voltage.
matsu 0:ebd7c54059ae 92 */
matsu 0:ebd7c54059ae 93 paw_value get_value();
matsu 0:ebd7c54059ae 94
matsu 0:ebd7c54059ae 95 /** Processing of Paw sensor. This fucntion must be performed periodically.
matsu 0:ebd7c54059ae 96 *
matsu 0:ebd7c54059ae 97 * @return Return current processing-state.
matsu 0:ebd7c54059ae 98 */
matsu 0:ebd7c54059ae 99 unsigned char process_paw();
matsu 0:ebd7c54059ae 100
matsu 0:ebd7c54059ae 101 /** Get current processing-state.
matsu 0:ebd7c54059ae 102 *
matsu 0:ebd7c54059ae 103 * @return Return current processing-state.
matsu 0:ebd7c54059ae 104 */
matsu 0:ebd7c54059ae 105 bool get_state();
matsu 0:ebd7c54059ae 106
matsu 0:ebd7c54059ae 107 /** Send values of PAW Sensor through serial-communication.
matsu 0:ebd7c54059ae 108 *
matsu 0:ebd7c54059ae 109 * @param Reference to serial object.
matsu 0:ebd7c54059ae 110 */
matsu 0:ebd7c54059ae 111 void print( Serial* );
matsu 0:ebd7c54059ae 112
matsu 0:ebd7c54059ae 113 protected:
matsu 0:ebd7c54059ae 114 DigitalOut _led_1;
matsu 0:ebd7c54059ae 115 DigitalOut _led_2;
matsu 0:ebd7c54059ae 116 AnalogIn _photo_1;
matsu 0:ebd7c54059ae 117 AnalogIn _photo_2;
matsu 0:ebd7c54059ae 118
matsu 0:ebd7c54059ae 119 unsigned char _state;
matsu 0:ebd7c54059ae 120
matsu 0:ebd7c54059ae 121 paw_value _value;
matsu 0:ebd7c54059ae 122 };
matsu 0:ebd7c54059ae 123
matsu 0:ebd7c54059ae 124 #endif /*** PAW_H ***/