Not finished. This is my first attemp to make an autonomous vehicle for the Sparkfun Autonomous Competition (https://avc.sparkfun.com/) of June 2015.

Dependencies:   FXOS8700CQ SDFileSystem mbed

Fork of AVC_Robot_Controled_Navigation by AVR Competition

  • For my autonomous robot I will use a GPS, magnometer, accelerometer, and encoders.
  • I control my robot with a remote control to save the GPS points (detect turns) using a xBee radio and save them to a file in a SD card.

my_libraries/encoders.cpp

Committer:
gerardo_carmona
Date:
2014-11-07
Revision:
5:b384cf06de76
Parent:
3:bd16e43ad7be

File content as of revision 5:b384cf06de76:

// ----- Libraries ------------------------------------------------------------------
#include "mbed.h"
#include "encoders.h"

// ----- I/O Pins -------------------------------------------------------------------
InterruptIn interrupt_encoder_der(D2);
InterruptIn interrupt_encoder_izq(D3);


int flanco_bajada_rigth;
int flanco_bajada_left;

// ----- Functions ------------------------------------------------------------------
void encoders_to_zero(){
    flanco_bajada_rigth = 0;
    flanco_bajada_left = 0;
}

void falling_encoder_rigth(void){
    flanco_bajada_rigth++;
}
 
void falling_encoder_left(void){
    flanco_bajada_left++;
}

void init_encoders(){
    interrupt_encoder_der.fall(&falling_encoder_rigth);
    interrupt_encoder_izq.fall(&falling_encoder_left);
}

float encoder(int sensor_encoder){
        int read_encoder = 0;
        float distancia;
        
        if(sensor_encoder==encoder_rigth){ 
            read_encoder= flanco_bajada_rigth;
                        
        }else if(sensor_encoder==encoder_left){
            read_encoder= flanco_bajada_left;
                    
        }
        distancia= (read_encoder/5)*2.2580;
        
        return distancia; 
}