In this sprint, the sonar sensor is used to detect person within the range of the beam transmitted from the sonar sensor towards the target. From the data sheet the main disadvantage is the beams are directed which cannot be used to detect wider field of view unless it is mounted in rotator shift to send continuous waves.
During the integration process for the phase tracking, servo, and sonar, several problems have occurred. The reading of the sonar sensor is fluctuated although it was working fine when I designed the codes in the previous blog. The first step is to make sure the wire connection is done properly. The second step check the compiler is working or not. Then I started by commenting (disable) the threads from the main thread until I found that the serial thread helps to get the result more correct. We were thinking that the load of threads causes the controller busy which not allowing the sonar read the echoes pulse correctly. That leads to set the sonar thread as priority thread which the RTOS service it before the other threads. Even with But still the problem exists. Then we try to mutex the reading of the sonar sensor, this helps improving the stability of the reading and more repeatability of the reading comparing with the previous setup. The problem starts shrink step by step, although the problem still exist which does not mean that we are not progressing to get desired operation. From the above description we notice the microcontroller reads from the serial port and nothing is sent to the serial, checking before reading from the serial port could solve the problem. A command “pc.readable( )” is added to the serial thread before reading from the serial port. At the end, the procedure followed to work with serial port was incorrect by this I mean checking the status of the serial port first for any character in there and then start reading from the serial port.
Several ideas rose where sonar sensor should be placed. The first option is to put the sonar in the table. This option was argued that the reading of the sonar sensor is affected by the cone of the lamp movement. The second option is to place the sonar in the front. In this configuration we can avoid the destruction caused by the movement of the lamp cone and especially the space available is short. However, an angle bracket is used to place the sonar on the front of the table as shown below.