User:Jyouri/project3

Project Preferences
1- Autonomous Power wheel

2- Mobile Robot

3- Smart Shoe

Week 1 Narrative
This week my task focused on researching the Ultrasonic Sensor HC-SR04 and finding a way to implement it with the current arduino code. The sensor is basically sends out an ultra sound form one end and that ultra sound reflects on a object and is brought back to the other end of the sensor. Using the example codes, I could see that the serial output changed with the distance in front of the sensors. On my own I was not able to to fully compile but I figured out the commands I want to use to be on the right path. Using the DoWhile command from the arduino:

example:

do

{

delay(50);         // wait for sensors to stabilize

x = readSensors; // check the sensors

} while (x < 100);

The arduino will power the steering wheel and gas pedal actuators in a predetermined path while there the unltrasonic sensor return a distance of 30 cm or greater. If the distance is less than 30 cm it will stop the arduino from powering the actuators.

Week 2 Narrative
My tasks this week was to work on the code for the pre determined path. To be able to do this I had to get a better understanding of how the code works, specially when it comes with dealing with timing and changing values as we go. I spent a couple hours tuesday working with the power wheel lifted on boxes to modify our previous code. Again I only focus on the while statement that affects the motors, I realized that it was confusing to read, so I erased unnecessary lines of code and unnecessary delays. I rewrote that part to make it easier to read and comprehend and also easier edit the values on the fly. I already knew our predetermined path was right-straight-left-right so I pre coded the path so that on thursday we would only have to change delays. On thursday, we realized there were some details that we did not factor in our planning. Some: We were able to find temporary solutions such as putting the power wheel on a low gear for the speed and putting it on a carpet so it gets maximum traction when it starts.
 * The speed: the power wheel was going faster than our linear actuator could handle making it difficult for us to turn
 * The spin: Because of the speed and concrete the wheel would spin on itself making us a few milliseconds behind on the code

The different timings we had to play around with:

Doing these different test trials became really important for my understanding of how the code works. Before I used to think we had to stop the PW before every turn because of how the code was sequenced, but after the help form our professor I now fully understand how to make both motors work simultaneously. The APW now only presses the gas pedal once verses 4+ times, for example. The code below is the final code we used for our quad run which went perfectly. https://www.youtube.com/watch?v=2a6_Pu9uJX4&feature=youtu.be. The commands that are indented control the gas pedal actuator and the ones that aren't indented control the steering actuator.

http://forum.arduino.cc/index.php/topic,40989.0.html

Week 3 Narrative
This week my task was to focus on the arduino programing for the ultrasonic sensor. We finished the building side of the implementation of the ultrasonic sensor on the power wheel. I am still working on the code and finding out ways to tweak the bugs we run into. This was the first code I worked on, it was an implementation of the original sensor code with the led on pin 13. To test our concept, I created a simple circuit which had our arduino duelminalove + ultrasonic sensor + pin 13 LED. In this block of code the goal is t have the led turn off when the range is less than 100 cm.

Here we ran into a problem where the output would return 0cm only once and the LED would stay on indefinitly and blink once. Also the for loop did not benefit what we were trying to do. So here we tried a whiel statement:

In this block of code, we have the led sensor turn on for 5 secs. During the 5 secs, the elapsedtime records those 5 seconds, if anything comes in contact with the sensor (less than 100 cm). the pauseduaration is going to calculate how long does the object stay in front of the sensor. Once the object moves away, the pauseduration value is gonna be subtracted from the elapsed to have an accurate drive time. I ran into a problem where the pauseduration would be substracted from the elapsed time but the elapsed time would ran back to the prior time clock it was going. I am planning on exploring this issue more this upcoming week.

Week 4 Narrative
This week the focus was to fix the code, upload it and test it. From last week, I already had the Ultra Sonic sensor code working with the LED and returning the values it was suppose to. In the updated code below, we were running into a problem where the main loop would restart from the beginning when an object moved away from the Ultra Sonic Sensor. It took us a while to figure out the cause of the problem, to help us we followed Mr. Edelen's suggestion of having debugging statements at different steps in the code. These statements would give us a real time update on whats going on as the code is running. After a few tests we realized that we had a ";" at a wrong place "if (distance<10);{" It stalled the code by making it refresh some of the output value.

The code above turns off an led fora certain amount of time, during that time if an object is less than a meter away from the Ultra Sonic sensor, the led will turn on for that period of time, when the purson moves away it will consider that elapsed time and factor it in the amount of time the led was programed to be off. To better understand, this process follow this flowchart:

The code below is from implementing the sensor code to the motor shield code. It is basically working in parallel with the LED light, the apw starts driving if theres an obstacle in front of it it stops and the LED turns on. I decided to keep the LED with the Motor code because it acts as a visual debugging item as we test our code outdoors.

We have been experimenting and tweaking around the code above for the sensor. So far we have successfully gotten the Ultra Sonic sensor to work with the previous code with had with the motors. We are still running into small reliability bugs, one being the Ultra Sonic sensor sensing a moving object twice which causes the pedal to retract twice backwards. Here is an indoor test I conducted with trashcans as obstacles: https://www.youtube.com/watch?v=_Y0ypspLeMU One of the things we kept playing around with was the sensing in parallel with stopping distance. Since we tested in different floors, the sensing number would always change from 1 m on ceramic to 2.5m on concrete. Another test we conducted with some HCC students who were willing to risk their lives to https://www.youtube.com/watch?v=7n-2xBpbiekhelp us test our implentation: