Photo

Photo

Sunday, March 27, 2016

SciBorgs Part 4 – Proportion Control

Now that we've gotten a pretty good on handle on Bang Bang control, Amy introduced us to proportional control. Instead of an all on or all of system, proportional control allows us access to a whole range of intermediate settings.

GoStraight

For the GoStraight code based on proportional values, we based the speed of the motors off of the difference in encoder values.

We knew we wanted our speed, if there was no error, to be at 160 because 160 is roughly halfway between 70 and 255. In doing this, there would be enough "room" for the motor value to fluctuate without hitting the bounds of 70 or 255, or worse going negative.

Through some trial and error and the help of print lines and the monitor, we were able to find a reasonable constant to be multiplied to the error such that there would be a visible fluctuation in speed.

In this scenario, I personally prefer using bang bang code over proportion control because I felt that the bang bang code is, conceptually, less complicated. Proportional control requires a carefully thought out equation and some trial and error, whereas the bang bang code only requires you to have a basic understanding of the feedback and control system involved. The proportional control code is more sophisticated than the bang bang control and in theory, should produce a smoother straight line path, but it isn't very noticeable.



10Feet

For the 10 feet proportional code, we based the speed of the SciBorg off the distance away from the 10 feet destination. The further the SciBorg is from the 10 feet mark the faster it goes. The closer it gets, the slower it goes, until it should theoretically stop right at the 10 feet mark.

We found that this kind of code works more poorly when the SciBorg is running on surfaces with more friction. For example, the SciBorg was extremely off the mark when it was driving up the ramp because it became really hard for the SciBorg to drive off the last few inches when it had such a small motor value.

When the SciBorg ran down the ramp, the slower speed didn't prevent the SciBorg from reaching the 10 foot mark, but instead, we saw that it propelled the SciBorg past the 10 feet mark. This occured since the force of gravity is now pulling the SciBorg in the same direction as it's momentum, which then also decreases the effects of the force of friction.

When it comes to traveling across inclines, it is best to stick with bang bang control code instead of proportional code.


The SciBorg made it <1cm away from the 10ft mark!


TheSciBorg didn't fare as well on the carpet


FollowOtherSciBorgs

For the proportional follow SciBorg code, we based the speed of the SciBorg's motors off the distance between it and either the Delrin in front of it or the SciBorg in front of it. To figure out the correct constant, we took advantage of the slope equation. We didn't want the SciBorg to get any close to the object in front of it when the ultra sonic sensor produced a value of 13, so we need the speed to be stopping speed, 70 at 13. At a reasonably far distance away, we wanted the SciBorg to be at max speed, 255. So we just set up the equations 13A + K = 70 and 76A +  K = 255 and subtracted one equation from the other in order to solve for A, which we then used to find K.

We did use a bit of bang bang, but it's not really necessary. On the occasion that our SciBorg is further from the object in front than at the value we set, instead of trying to run at a speed of 265 or 300, it defaults back to 255. This doesn't really seem necessary since it should just run at max speed regardless of this line of code, but just in case, we kept this line in.

We found that using this code versus using the bang bang code didn't really make too much of a difference.

























FollowPath

For the follow path proportional code, we decided to base the speed of the motors off of the SciBorg's distance from the tape. This one is a little more difficult than the other codes because we had to figure out a way to have only one motor at running speed at a given time and be able to switch without using a bang bang code.

To do this we needed to have two separate equations denoting the respective speeds of the motor. One equation needs to subtract the product of the constant and the sensor value, while the other needs to add to the product, in order to get the alternating speeds. This took a lot more plugging and chugging of data using a similar equations to the one in the above code.

Overall, proportional code requires a little more trial and error and attention to sensor values, but it takes less lines of code than bang bang control and, as you can in the video, it allows the SciBorg to travel more smoothly!


































1 comment:

  1. It's great that you are able to nudge according to the speed of the Sciborg!

    ReplyDelete