Owl Code Evolution V.01 Part I
So I wanted to go through my code's evolution a little bit. I think it's always important to see how changes occur and for me personally to see why I decided to save a file as v.02 as opposed keeping them in v.01.
V.01 - http://pastebin.com/s1SV6qtd
So based on what this saved version looks like. I have two cogs starting up - one for the Servo and one for the Ping and Compass modules. I had to place the start of the serial terminal up in the main section because previously, the Ping module started a terminal, and the Compass started a terminal. The two conflicted. Instead of letting them fight I just wrote, start at the beginning, before everything else!
The servo cog looks similar to the original code I devised for the rc servo, where it'd turn clockwise, then counterclockwise, then clockwise, etc. This code however has an additional variable "b" and incorporates a bit of ramping. So if we only look at:
You'll see that the pulse width controlling the RC servo speed (phsa := -b) is being determined by "repeat b from tCtr to tCw step (tInc * 4)". This statement is saying, ramp from a stopped speed to a clockwise speed by incrementing the value by 4 * tInc (tInc = clkfreq/1_000_000). So if I were to write out what the pulse widths being sent to the rc servo were, they'd be:
Given that tInc = 80, tCtr = 1510 * 80 or 120800, tCw = 1300 * 80 or 104000 the equivalent pulse widths would be:
120800 -> 120480 -> 120160 -> .... -> 104000
Then the subsequent line is "repeat b from tCw to tCtr step (tInc*4)" This would give us the opposite ramping from 104000 to 120800 in steps of 320. Of course, the smaller the steps, the slower the ramping. The larger the steps, the faster the ramping.
Next post, we'll look at ascii tables and how to make things slightly prettier/neater in code.
@atdiy/@tymkrs















