Richard Irons March 11, 2003

91.548 Robotics I

Lab 2: The Handy Cricket

For Exercise 5 of Lab 2, I created a Cricket Logo program that sent photocell sensor data to the serial port. I also created an OpenGL program using the OpenGL toolkit GLUT to open the serial port COM1, read the photocell sensor data that the Cricket was sending, and to display the sensor data in a graphical fashion. The program created numerous filled circles on the XY plane and rotated then together around the Z axis centered at the middle of the window. The number of circles created was determined by the size of the window. Only enough circles to fill the OpenGL window were created.

The effect that the sensor data had on the circles was that the circles would increase in scale with sensor values indicating increasing amounts of light. The circles would decrease in scale with sensor values indicating decreasing amounts of light. The photocell sensor data read from the Cricket was inverted so that the sensor values that indicated the absence of light were made low and the sensor values that indicated the presence of light were made high. The scale of the circles would be changing while at the same time all of the circles would be rotating around the Z axis.

I calculate a scale for the circles by dividing the inverted sensor value by 192. This produces a circle scale in the range of 0 to approximately 1.3. Also, all of the serial port communication code within the program (open serial port, setting attributes of serial port, and reading from the serial port) was copied from Microsoft online help.

I thought the display was interesting, but the performance of the animation could get slow.

 

Steps for Constructing Exercise (Win32 only):

  1. Attach photocell sensor to a Cricket.
  2. Compile Cricket Logo program to the Cricket.
  3. Exit the Cricket Logo editor.
  4. If the GLUT toolkit is not installed on your system. Go to Nate Robins web page, download the GLUT 3.7.6 binaries, and unzip the files. Copy glut32.dll to \WINDOWS\SYSTEM.
  5. Create a Microsoft Visual C++ workspace for a console application. Create a project and add the OpenGL program to the project.
  6. Add glut32.lib and opengl32.lib to the Project/Settings/Link/Library Modules input panel.
  7. Add the directory of the downloaded GLUT include file to Tools/Options/Directories/Include Files or copy the GLUT include file to the Microsoft Visual C++ include directory.
  8. Add the directory of the downloaded GLUT library file to Tools/Options/Directories/Library Files or copy the GLUT library file to the Microsoft Visual C++ library directory.
  9. Build the C program.
  10. Run the Logo program on the Cricket.
  11. Run the C program.
  12. Press the right mouse button then "Exit" to exit program.