14.11.2012 Views

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.3. PWM Control 49<br />

mentioned previously, by limiting <strong>the</strong> minimum and maximum PWM values<br />

<strong>of</strong> <strong>the</strong> motors and by introducing <strong>the</strong> fuzzy-like control to introduce different<br />

limits for <strong>the</strong> different distances to target. Even though <strong>the</strong> lack <strong>of</strong> <strong>the</strong><br />

encoders reduced <strong>the</strong> performance, we were able to produce an acceptable<br />

configuration.<br />

Ano<strong>the</strong>r step is initialization <strong>of</strong> <strong>the</strong> motors. The corresponding pins in<br />

<strong>the</strong> microcontroller for <strong>the</strong> motors are set to control <strong>the</strong> direction <strong>of</strong> motors<br />

and PWM generation. The PWM generation is made by using <strong>the</strong> timers<br />

available in <strong>the</strong> microcontroller. Output compare mode <strong>of</strong> <strong>the</strong> timers is<br />

usedinordertocreate <strong>the</strong>PWMneededtorun<strong>the</strong>motors. Outputcompare<br />

function is used to control <strong>the</strong> output waveform and indicates when a period<br />

<strong>of</strong> time has elapsed. When a match is found between <strong>the</strong> output compare<br />

register and <strong>the</strong> counter, <strong>the</strong> output compare function:<br />

• Assigns a value to pins<br />

• Sets a flag in <strong>the</strong> status register<br />

• Generates an interrupt<br />

Using <strong>the</strong> described output comparison, we created <strong>the</strong> desired PWM<br />

wave to run <strong>the</strong> motors. At, first <strong>the</strong> timer clock is set to 8 mHZ. Then<br />

output compare register 1 is set for <strong>the</strong> desired motor speed as some percentage<br />

<strong>of</strong> <strong>the</strong> full period <strong>of</strong> <strong>the</strong> cycle. Output compare register 2 is set<br />

to full cycle that will set <strong>the</strong> pin to HIGH, and update <strong>the</strong> desired motor<br />

speed <strong>of</strong> <strong>the</strong> output compare register 1. When counter reaches <strong>the</strong> defined<br />

value, <strong>the</strong> motor speeds will be updated and <strong>the</strong> pins will be reset. It will<br />

remain LOW until output compare register 2 value (which is <strong>the</strong> full period)<br />

is reached. Using that algorithm we generate <strong>the</strong> PWM signal to run <strong>the</strong><br />

motor. For each motor, we decided to use a separate timer, since <strong>the</strong> timers<br />

are available to use and not needed by o<strong>the</strong>r applications. It is also possible<br />

to use only one timer to generate <strong>the</strong> PWM’s for all <strong>the</strong> motors using <strong>the</strong><br />

interrupts and output compare registers, but we decided not to use like this<br />

for <strong>the</strong> simplicity <strong>of</strong> <strong>the</strong> algorithm, since this will need a better synchronization,<br />

and optimization to run efficiently.<br />

The control <strong>of</strong> <strong>the</strong> servo that is changing <strong>the</strong> camera head pointing direction<br />

is also implemented using PWM signals. For <strong>the</strong> servo PWM, we don’t<br />

have <strong>the</strong> problem <strong>of</strong> control that we faced with <strong>the</strong> motors. So, no tunings

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!