Therefore, we planned to use a smart car instead of encoder. The smart car we built before has a component can achieve the same function as encoder. In this way, we can show that the code we wrote is correct. Unfortunately, the sensor on the car did not work, it cannot detect the wheel’s speed.
As a result, we had to buy a new motor with an encoder, and the encoder was fixed on the motor so that we could use it directly (shown in Figure 1).
Figure 1
We bought online on Friday, it will send to us on nest Tuesday. After receiving the motor, we built the whole circuit (shown in Figure 2).
Figure 2
We tested it and result was positive: it worked properly. Then we linked the motor with the wheel to test the code. We counted the pulse during each time period on behalf of measure speed of the motor directly; we set four gears: 1/4 speed, half speed, 3/4 speeds and full speed. We set a theoretical pulse, and use a PID controller to form a close loop and adjust the real time speed. We tested the code first, the motor worked well. Then we connected it to the serialchart to print the real time speed. At first time, there was no graph drawn on the screen, thus, we adjust the minimum and maximum value of y-axis, the graph was shown on the screen correctly (shown in Figure 3).
Figure 3
In the data section, in the same line, the first data is the real time speed, the second data is the theoretical speed, the red line in the graph is the theoretical speed and the black line is represent the real time speed. The real
values were close to the theoretical value, which means our project was
accomplished successfully!












