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:
Wed Nov 19 16:40:32 2014 +0000
Revision:
6:a58ad4e085af
Parent:
5:eae61a2a67b0
Deleted a test line.

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