Project

General

Profile

Revision 890

Changed some odometry stuff. Interrupt is called now.
Still some problem that is not updating x and y data.

View differences:

trunk/code/behaviors/smart_run_around_fsm/Makefile
14 14
# USE_WIRELESS = 1
15 15

  
16 16
# com1 = serial port. Use lpt1 to connect to parallel port.
17
AVRDUDE_PORT = com4
17
AVRDUDE_PORT = /dev/ttyUSB0
18 18
#
19 19
#
20 20
###################################
trunk/code/projects/mapping/odometry/encoders.c
1 1
#include "encoders.h" 
2
#include "dragonfly_lib.h"
2 3
#include "spi.h" 
3
#include <dragonfly_lib.h> 
4 4
#include "ring_buffer.h" 
5 5

  
6 6
unsigned short int left_data_buf;
trunk/code/projects/mapping/odometry/odometry.c
25 25
void odometry_init(void){
26 26
	encoder_init();
27 27
	odometry_reset();
28
	
29
	//CTC Mode. CLK / 1024
30
	TCCR2 = 0; // (Fully disconnected)
31
	TCCR2 = _BV(WGM21) | _BV(CS22) | _BV(CS20); //CLK/1024 , CTC Mode.
32

  
33
	TIMSK |= _BV(OCIE2);
34

  
35
	OCR2 = ODOMETRY_CLK;
28 36
}
29 37

  
30 38
void odometry_reset(void){
31 39
	diff_x = 0;
32 40
	diff_y = 0;
33 41
	angle = 0.0;
34
	
35
	//CTC Mode. CLK / 1024
36
	TCCR2 = 0; // (Fully disconnected)
37
	TCCR2 = _BV(WGM32) | _BV(CS32) | _BV(CS30); //CLK/1024 , CTC Mode.
38

  
39
	OCR2 = ODOMETRY_CLK;
40 42
}
41 43

  
42 44
void odometry_run(void){
43
	usb_puts("*");
44 45
	int v_l, v_r;
45 46
	float omega;
46 47
	int encoder_left, encoder_right;	
trunk/code/projects/mapping/odometry/odometry.h
3 3
#define __ODOMETRY_C__
4 4

  
5 5
//Odometry resolution, *64 microseconds.
6
#define ODOMETRY_CLK 160  //= approx. 10 ms
6
#define ODOMETRY_CLK 1600  //= approx. 10 ms
7 7

  
8 8
//Wheel = 2.613 in.  
9 9
//Circumference = 208.508133 mm
trunk/code/projects/mapping/odometry/Makefile
4 4

  
5 5
# Relative path to the root directory (containing lib directory)
6 6
ifndef COLONYROOT
7
COLONYROOT = ../../..
7
COLONYROOT = ../../../..
8 8
endif
9 9

  
10 10
# Target file name (without extension).
......
14 14
USE_WIRELESS = 1
15 15

  
16 16
# com1 = serial port. Use lpt1 to connect to parallel port.
17
AVRDUDE_PORT = /dev/tty.usbserial-A4001hAG
17
AVRDUDE_PORT = /dev/ttyUSB0
18 18
#
19 19
#
20 20
###################################
trunk/code/projects/libdragonfly/encoders.c
1 1
#include "encoders.h"
2 2
#include "spi.h"
3
#include <dragonfly_lib.h>
3
#include "dragonfly_lib.h"
4 4
#include "ring_buffer.h"
5 5

  
6 6
unsigned int left_data_buf;
......
39 39
inline unsigned int right_data_array_bottom(void);
40 40

  
41 41

  
42
void encoder_recv_complete(){
42
void encoder_recv_complete(void){
43 43
  	encoder_buf_index = 0;
44 44
	data_ready++;
45 45
  

Also available in: Unified diff