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.

B.1. Microprocessor Code 103<br />

}<br />

void Init_Motors() {<br />

GPIO_InitTypeDef GPIO_InitStructure;<br />

GPIO_StructInit(&GPIO_InitStructure);<br />

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;<br />

GPIO_InitStructure.GPIO_Pin = MOTOR1_Pin | MOTOR2_Pin<br />

| MOTOR3_Pin;<br />

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;<br />

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;<br />

GPIO_Init(MOTOR_GPIO, &GPIO_InitStructure);<br />

/* Config Servo PIN */<br />

GPIO_StructInit(&GPIO_InitStructure);<br />

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;<br />

GPIO_InitStructure.GPIO_Pin = SERVO_Pin;<br />

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;<br />

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;<br />

GPIO_Init(SERVO_GPIO, &GPIO_InitStructure);<br />

GPIO_StructInit(&GPIO_InitStructure);<br />

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;<br />

GPIO_InitStructure.GPIO_Pin = MOTOR1_DIRECTION_A<br />

| MOTOR1_DIRECTION_B | MOTOR2_DIRECTION_A<br />

| MOTOR2_DIRECTION_B | MOTOR3_DIRECTION_A<br />

| MOTOR3_DIRECTION_B;<br />

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;<br />

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;<br />

GPIO_Init(MOTOR_DIRECTION_GPIO , &GPIO_InitStructure);<br />

TIM_InitTypeDef TIM_InitStructure;<br />

TIM_StructInit(&TIM_InitStructure);<br />

TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_12; //for both use 12<br />

TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING;<br />

TIM_InitStructure.TIM_OC2_Modes = TIM_TIMING;<br />

TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB;<br />

TIM_InitStructure.TIM_Prescaler = 47; //127<br />

TIM_InitStructure.TIM_Pulse_Length_1 = 50;<br />

TIM_InitStructure.TIM_Pulse_Length_2 = 200;<br />

TIM_InitStructure.TIM_Pulse_Level_1 = TIM_HIGH;<br />

TIM_InitStructure.TIM_Pulse_Level_2 = TIM_HIGH;<br />

TIM_InitStructure.TIM_Period_Level = TIM_LOW;<br />

TIM_Init(TIM0, &TIM_InitStructure);<br />

TIM_Init(TIM1, &TIM_InitStructure);<br />

TIM_Init(TIM3, &TIM_InitStructure);

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

Saved successfully!

Ooh no, something went wrong!