Friday, May 1, 2015

Arduino Day 5: Brightness Sensor

The Assignment: 
Our challenge was to get the sciborg to follow a white line using a brightness sensor first using bang bang control and then using proportional control.

Bang Bang:
The line following code proved to be very difficult to write. Our initial thought was to have the sciborg know the values for light and for dark so that if it detected dark then it would execute one part of the code and if it saw light then it would execute another. We thought that if it was on a light (white) section then the sciborg would travel forward and if it detected dark, then we wanted the sciborg to "sweep" the area by turning one way for a little bit then another way for a little bit, but then the sciborg would stop the "sweep" if it detected white and then it would move forward. In our initial code the sciborg was very jerky and would not follow the white line if it turned.

Our final code shown below allowed the sciborg to complete the course in about 3 minutes.

The idea behind this code was to make the sciborg "sweep" left and right in order to find the line. We set the value that the sciborg traveled straight on as edge of the line, rather than the line itself because it is very difficult to get the sciborg to detect the white line for long enough to move effectively.


Proportional:
This code was also very difficult to write. We had a lot of trouble getting the sciborg to travel forward and sometimes it would just turn in a circle not even behaving as if it sensed the line at all. Kat helped us try to fix it, but she couldn't figure out why it wasn't working either. We played around with the gain, the speed, and with the range of sensor values but nothing made it travel the entire way down. We did get one code to travel almost all the way down the path. It got stuck on the very last part, but otherwise it was successful. I have included that code and the video below.



Reflection:
The thing which this exercise reminded me over and over again is that what we think the code is doing is often very different from what it is actually doing. Also, when it comes to sensors, it is very difficult to set limits on the numbers the sensors read definitively to make an effective code. For example, when the although the lights were always on in the room while we ran the sciborg it made a slight difference whether or not there was ambient light from outside. Also, the distance of the sensor from the ground played a huge role in the accuracy of our code. All these little real world variations made coding difficult.

It also makes me wonder about the difficulties in creating an actual product using sensors that must operate under many variant conditions. This is actually a problem which my neuroscience professor has talked about before. For example, as humans we take for granted that we are able to tell whether something is dark or light based on comparisons our brain makes without our knowledge. A computer system, for all its complexity, does not have the same ability to integrate information as the human brain. The arduinos we are using have a similar problem. They read a single number without comparing it to the surroundings and adjusting it.

1 comment:

  1. I like (and agree with) your reflection a lot. I did think about how the light sensor changes its reading values when I was playing around with the boundary values, but I think you voiced the thought, or problem, very well in your reflection.

    ReplyDelete