#ifndef SONAR_DISTANCE_H #define SONAR_DISTANCE_H //Polaroid sonar ranging sensor class interface header file. //Using serial Input and Output to the Handyboard /* Program Filename: sonar_distance.h (Version 1.1) Title: Polaroid sonar ranging sensor Class interface file Date: May 1, 2003 Compilers: Visual C++ 6.0 (Windows console application .exe) Authors: Created for Lawrence Tech. Laptop Robot use by Maurice Tedder Description: Header file for Lawrence Tech. Laptop Robot motion control class. Designed for the Polaroid 6500 Series sonar ranging module driven by Handyboard motor outputs. */ //Sonar distance sensor class definition class SONAR_DISTANCE { public: SONAR_DISTANCE(); //Defualt constructor. SONAR_DISTANCE(HANDLE comporthandle); //initialization constructor. Takes comport handle ~SONAR_DISTANCE(); //Defualt destructor. int readSonarSensor(void);//Activate sonar range sensor and return distance value in sensor units int readSonarPacket(void); //Reads serial port and grabs sonar data packet and returns data value in packet //and also stores the return value in the distance private member variable //you can also call getSonarDistance(void) after this function returns and //get the sonar distance value. //!!!CAUTION THIS FUCTION WILL CONTINOUSLY LOOP UNTIL A PACKET IS RECIEVED- //THEREFORE MAKE SURE SONAR DATA PACKETS ARE BEING TRANSMITTED BEFORE //USING THIS FUNCTION int getSonarDistance(void);//Returns sonar sensor value stored in distance private member variable void activateSonar(bool mode); //Activates sonar sensor to transmit data continously //(mode = true) or single data packet (mode = false) // Public member functions. short Check_sum(short *packet, int length);// Check_sum - This function calculates the chech sum of a packet and ///////////////////////////////////////////////////////// // Start DMC member functions. ///////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// void Send_packet(char * packet); // Send_packet - Write/send contents of packet to serial port // one byte at a time - takes pointer to the packet array as a parameter private: int distance; // Sonar sensor distance value (-1 = time out or open space) //Serial port globals //HANDLE porthnd2;// Handle to Com port file HANDLE comport_handle;//Handle to currently opened comport DWORD numberrd2; // Number of bytes read. char speed_packet[11];//Packet array to send commands to handyboard // int OpenComPort(void); // Open com port handle to recieve data packets from handyboard // void CloseComPort(void);// Close com port handle }; #include "sonar_distance.cpp" #endif