From 9ec12521300f1d09404d1a1ae2f6d5632b15bce8 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 16 May 2012 17:23:30 +0200 Subject: digital/beacon: add raw2radians codewheel conversion --- digital/beacon/src/codewheel.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'digital/beacon/src/codewheel.c') diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index fb8914c2..e53fef63 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -25,6 +25,7 @@ #include #include +#include #include "debug_avr.h" #include "codewheel.h" @@ -92,6 +93,12 @@ float codewheel_convert_angle_raw2degrees(uint16_t raw_value) return (float)raw_value*(float)360/(float)CODEWHEEL_CPR; } +/* This function converts the angle value from row format to radians */ +float codewheel_convert_angle_raw2radians(uint16_t raw_value) +{ + return (float)raw_value*(float)(2*M_PI)/(float)CODEWHEEL_CPR; +} + /* Codewheel complete turn IRQ vector for CodeWheel*/ ISR(TIMER3_COMPA_vect) { -- cgit v1.2.3 From c076c82d5952f52488561858ff0614fc627ff23e Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 16 May 2012 17:23:45 +0200 Subject: digital/beacon: fix include order --- digital/beacon/src/codewheel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'digital/beacon/src/codewheel.c') diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index e53fef63..235643f4 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -23,8 +23,8 @@ * * }}} */ -#include #include +#include #include #include "debug_avr.h" #include "codewheel.h" -- cgit v1.2.3 From f79e9854b9aa5dd4099facb036c5e6845c6e2447 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 16 May 2012 17:24:31 +0200 Subject: digital/beacon: add {} to an else --- digital/beacon/src/codewheel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'digital/beacon/src/codewheel.c') diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index 235643f4..205c2e2b 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -108,5 +108,7 @@ ISR(TIMER3_COMPA_vect) codewheel_set_state(CODEWHEEL_REBASED); } else - OCR3A = CODEWHEEL_CPR; + { + OCR3A = CODEWHEEL_CPR; + } } -- cgit v1.2.3 From b4d8344ae068467679c733998ef9e0a2cbb6956c Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 16 May 2012 17:31:53 +0200 Subject: digital/beacon: sending angle management --- digital/beacon/src/codewheel.c | 3 +++ digital/beacon/src/laser.c | 24 +++++++++++++++++++++++- digital/beacon/src/laser.h | 5 ++++- 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'digital/beacon/src/codewheel.c') diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index 205c2e2b..b28f756c 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -28,6 +28,8 @@ #include #include "debug_avr.h" #include "codewheel.h" +#include "laser.h" +#include "network.h" codewheel_s codewheel; @@ -111,4 +113,5 @@ ISR(TIMER3_COMPA_vect) { OCR3A = CODEWHEEL_CPR; } + laser_reset_angle_id(); } diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c index 888589ad..bf77cdd9 100644 --- a/digital/beacon/src/laser.c +++ b/digital/beacon/src/laser.c @@ -28,7 +28,9 @@ #include "debug_avr.h" #include "laser.h" #include "servo.h" +#include "network.h" #include "codewheel.h" +#include "calibration.h" laser_s laser; @@ -37,6 +39,7 @@ void laser_init(void) { /* Init laser structiure */ laser_set_angle(0); + laser_reset_angle_id(); /* Configure Input compare interrupts for Laser Interrupt*/ TCCR3B |= (1< 30) && (laser_get_angle_degree() < 70)) + { + uprintf("angle[%d] = %f\r\n",laser.angle_id,laser_get_angle_degree()); + laser.angle_id++; + } } /* Disable the interrupt */ diff --git a/digital/beacon/src/laser.h b/digital/beacon/src/laser.h index f50c5b07..f0d32d93 100644 --- a/digital/beacon/src/laser.h +++ b/digital/beacon/src/laser.h @@ -64,6 +64,9 @@ uint16_t laser_get_angle_raw(void); float laser_get_angle_degrees(void); /* This function sets the angle value in raw format */ -void laser_set_angle_raw(uint16_t angle); +void laser_set_angle(uint16_t angle); + +/* This function resets the angle id variable */ +void laser_reset_angle_id(void); #endif -- cgit v1.2.3 From 18904c9fd8c88aaf355c0586095f932b205a764c Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 16 May 2012 17:34:06 +0200 Subject: digital/beacon: add debug print --- digital/beacon/src/codewheel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'digital/beacon/src/codewheel.c') diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index b28f756c..283439d6 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -108,6 +108,7 @@ ISR(TIMER3_COMPA_vect) { OCR3A = codewheel_get_rebase_offset(); codewheel_set_state(CODEWHEEL_REBASED); + uprintf("Rebased\r\n"); } else { -- cgit v1.2.3