Introduction Conclusion The Control Program (GUI)
GUI Fonts Communications.pm Subroutine Return Status Design NotesIntroduction
The project uses an Arduino to control a servo and ultrasound sensor to collect data that can be used to locate objects in a grid of cells. Essentially it is a radar (sonar) sweep of the grid cells to locate objects. The Arduino receives commands from a control program (written in Perl) and returns raw data for processing.See the other web pages for more documentation.
Conclusion
- The project was interesting and I had fun developing it.
- The premise the project was based on seems to be valid. The current cell and grid sizes give a rough estimate of which cells are occupied. Of course, I could not see behind objects. (See "What Next" on the main page.)
- There needs to be testing to determine the best grid and cell size to get the most accurate readings.
- Because of the uncertainty in the detection angle (15°), testing need to be done to determine the most efficient subdivision of the detection angle to use. (± 7 or ± 7 and ± 3 or ...)
Perhaps the farther away an object is from the sensor the more subdivisions you need? Perhaps dynamic subdivisions based on the distance from the sensor to the object?
- There is much more testing to be done, but basically it works.
The Control Program (GUI)
The control program GUI is kind of clunky, but that is OK. After all, the GUI is not the point of the project.
The GUI contains:
- a set of buttons that execute actions
- an area that displays the cell occupied counts from ping sweeps
- operating parameters that can be modified by the users
- a text area where messages are displayed
- the source code also has a flag (TESTFLAG) that, if set to a non-zero value, will display extra buttons. These buttons were used for testing and debugging.
See the project's control program and Arduino sketch source code for documentation, comments, and other information.
![]()
GUI Fonts
The fonts used by the GUI are defined in the control program source code. To change the fonts, change these variables:$btfont - button font
$gdfont - grid display font
$plfont - parameter label font
$pvfont - parameter entry font
$txfont - text window font
$wtfont - window title fontCommunications.pm
All of the communications "stuff" is in the Perl module communications.pm. The control program creates a communications object using the module and "talks" to the Arduino with it.
Documentation, such as it is, is found in the module's source code. There are test Perl scripts that demonstrate the use of the communications.pm module and the window's Win32::SerialPort module.
Subroutine Return Status
Some of the subroutines in the communication.pm and the control program return an array rather than just a status. The first element in the array is a status and the second is information related to the status. (See the source code for examples.)Note: Some people may not be familiar with this style of coding.
Design Notes
The ping sweep subroutine in the control program is a Tkx callback routine. It runs for a long time and will lock the GUI until it is finished. I was too lazy to code this differently so you will just have to wait. After all the GUI is not the point of the project.
Because the GUI locks up, the messages generated by the ping sweep will not be displayed until after it finishes.- Commands and messages used by the Arduino and control program are documented in the Project Arduino Sketch code.
- The size of the grid cells and the number of rows and columns in the grid are defined as constants at the top of the control program source code.
- Cell dimensions, coordinates, distances, etc. are in inches. This is determined by the ultrasound sensor which is currently set to return inches.