fanspeed-comparator #19
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
Dependencies
No dependencies set.
Reference: Mikrokontrollersystemer-gruppe-4/mikrokontrollersystemer-prosjekt#19
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fanspeed-comparator"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
compare a sett value to two fans
Just a couple things
@ -0,0 +1,113 @@//#include <avr/ioavr128db48.h>Remove commented out include.
ac5a054f8b@ -0,0 +4,4 @@#include "uart.h"uint16_t timer_period_ms = 1;uint16_t fan_speed;Variable should be initialized to a value.
e.g.
uint16_t fan_speed = 0;ac5a054f8b@ -0,0 +7,4 @@uint16_t fan_speed;volatile uint16_t falling_edge_counter_1 = 0;volatile uint16_t falling_edge_counter_2 = 0;#define MAX_PER 0x50Remove unused define
ac5a054f8b@ -0,0 +14,4 @@TCA0.SINGLE.INTCTRL = TCA_SINGLE_OVF_bm ;TCA0.SINGLE.CTRLA = TCA_SINGLE_ENABLE_bm | TCA_SINGLE_CLKSEL_DIV1024_gc ; /* Sysclk /1024 */TCA0.SINGLE.PERBUF = 3906;//TCA0_update_period_ms();The function should be used based on the variable set earlier, rather than the perbuf being hardcoded.
ac5a054f8b@ -0,0 +17,4 @@//TCA0_update_period_ms();}void TCA0_update_period_ms() {This function should be used and it should calculate the ms with the formula from the øving.
ac5a054f8b@ -0,0 +21,4 @@TCA0.SINGLE.PERBUF = (F_CPU * (1 / timer_period_ms) / 1024); /* F_CPU * F_IRQ / TCA_prescaler */}uint16_t RPM_calculation(uint16_t fancounter, uint16_t time) {Add comments explaining the math.
ac5a054f8b@ -0,0 +99,4 @@// TIMER INTERUPTISR (TCA0_OVF_vect) {cli();RPM_calculation(falling_edge_counter_1,1);Time should use the variable and not be hardcoded.
ac5a054f8b@ -0,0 +108,4 @@}//-----------------------------------------------------------------------------------------------------This setup comment should likely be removed(?)
ac5a054f8b@ -0,0 +1,51 @@/** File: fanseeeed.h* Author: inamiYou should likely add yourself to the authors.
ac5a054f8b@ -0,0 +27,4 @@// INITALICE TIMER COUNTERvoid init_TCA0();// UPDATE TIMER PERIODEThe last
Eshould be removed.ac5a054f8b@ -0,0 +35,4 @@uint16_t RPM_calculation(uint16_t fancounter, uint16_t time);// INITIALISING FAN PORTSvoid init_fanports();fanports is a bit confusing, maybe rename to
fan_gpio?ac5a054f8b@ -0,0 +38,4 @@void init_fanports();// INIT AC0 TO COMPARE PD6 AND PD7void init_ac0();ac0andac1should be captialized, such that they areAC0.ac5a054f8b@ -16,0 +17,4 @@#include <stdio.h>#include <stdlib.h>#include "uart.h"#include <util/delay.h>Remove duplicate include
ac5a054f8b@ -18,0 +26,4 @@#include <avr/io.h>#include <avr/interrupt.h>#include <util/delay.h>Remove duplicate include
ac5a054f8b@ -25,3 +46,2 @@while (1) {uint16_t adcVal = voltage_values();printf("The values: \n%u , %u\n",VREF_REFSEL_VDD_gc , adcVal);//printf("loop")Delete commented out code
ac5a054f8bJust some small things
@ -0,0 +2,4 @@#include "uart.h"uint16_t timer_period_ms = 1;uint16_t timer_period = 0.01;We should not have both timer period and timer period ms. ms should be calculated from seconds, or the other way around.
fix
772960d046@ -0,0 +11,4 @@void init_TCA0() {TCA0.SINGLE.INTCTRL = TCA_SINGLE_OVF_bm ;TCA0.SINGLE.CTRLA = TCA_SINGLE_ENABLE_bm | TCA_SINGLE_CLKSEL_DIV1024_gc ; /* Sysclk /1024 *///TCA0.SINGLE.PERBUF = 3906;Remove commented out code
fix
772960d046@ -0,0 +15,4 @@TCA0_update_period();}void TCA0_update_period() {This function should still take in the variable, not use a global variable.
fix
772960d046Pull request closed