voltage-reading #13

Closed
Inamr wants to merge 0 commits from voltage-reading into main
Owner

closes #2

closes #2
Inamr added 17 commits 2024-03-13 09:40:14 +00:00
sebgab requested review from Athamantis 2024-03-13 09:40:49 +00:00
Athamantis requested changes 2024-03-13 10:11:42 +00:00
@ -19,3 +25,2 @@
while (1) {
printf("Hello, world!\n");
_delay_ms(500);
uint16_t adcVal = ADC0_read();
Owner

Make this to its own function.

Make this to its own function.
Author
Owner

Fixed in commit efe623936a

Fixed in commit efe623936a9364d75d10e1a08dd21f499664b56c
Inamr marked this conversation as resolved
@ -0,0 +1,29 @@
#include "voltage.h"
void sensor_init(void) {
Owner

what does this function do? anything at all?

what does this function do? anything at all?
Author
Owner

Where the sensor set up wil be

Where the sensor set up wil be
Inamr marked this conversation as resolved
@ -0,0 +3,4 @@
/* Disable digital input buffer */
}
void ADC0_init(void) {
Owner

Description of what the function does

Description of what the function does
Author
Owner

Fixed in 25050d4500

Fixed in 25050d45000355a522cd289bfd84ece295682cfd
Inamr marked this conversation as resolved
@ -0,0 +16,4 @@
ADC0.MUXPOS = ADC_MUXPOS_AIN6_gc;
}
uint16_t ADC0_read(void) {
Owner

Here too

Here too
Author
Owner

Fixed in 25050d4500

Fixed in 25050d45000355a522cd289bfd84ece295682cfd
Inamr marked this conversation as resolved
Inamr added 1 commit 2024-03-13 10:45:58 +00:00
Inamr added 1 commit 2024-03-13 12:58:57 +00:00
Athamantis added 1 commit 2024-03-20 13:18:51 +00:00
uint8_t -> uint16_t
Inamr added 1 commit 2024-03-20 14:45:16 +00:00
Inamr added 2 commits 2024-03-20 15:10:25 +00:00
Inamr added 1 commit 2024-03-20 15:10:50 +00:00
Inamr added 1 commit 2024-03-26 12:35:23 +00:00
sebgab requested changes 2024-04-09 10:36:40 +00:00
sebgab left a comment
Owner

Needs overhaul.

Needs overhaul.
@ -0,0 +1,53 @@
#include "voltage.h"
#include "uart.h"
void ADC0_init(void) {
Owner

We need to be able to read three different analog voltages.

  • Photodiode 1
  • Photodiode 2
  • Thermistor

As far as I can see this code only allows for reading one analog voltage.

We need to be able to read three different analog voltages. - Photodiode 1 - Photodiode 2 - Thermistor As far as I can see this code only allows for reading one analog voltage.
Owner

Fix in a9f5c42243

Fix in a9f5c422432c5f24050baa53bab98b60778f8025
Athamantis marked this conversation as resolved
@ -0,0 +40,4 @@
VREF.ADC0REF = VREF_REFSEL_VDD_gc;
}
uint16_t diode_voltage_read(){
Owner

diode_voltage_read() is defined twice. It is also defined on line 30.

diode_voltage_read() is defined twice. It is also defined on line 30.
Owner

Fixed in a9f5c42243

Fixed in a9f5c422432c5f24050baa53bab98b60778f8025
Athamantis marked this conversation as resolved
@ -0,0 +45,4 @@
uint8_t adcVal = ADC0_read();
return adcVal;
}
uint16_t internal_voltage_read() {
Owner

Internal voltage read defined twice. Also defined on line 37.

Internal voltage read defined twice. Also defined on line 37.
Owner

Fixed in a9f5c42243

Fixed in a9f5c422432c5f24050baa53bab98b60778f8025
Athamantis marked this conversation as resolved
@ -0,0 +20,4 @@
*/
/*
* File:
Owner

This information should be filled out.

This information should be filled out.
Athamantis marked this conversation as resolved
@ -0,0 +54,4 @@
uint16_t ADC0_read(void);
// Gets the value from sensor and internal voltage
uint16_t internal_voltage_read();
uint16_t diode_voltage_read();
Owner

It is not clear what diode is.

Is diode the photodiode for the fan?

It is not clear what diode is. Is diode the photodiode for the fan?
Owner

Fixed in a9f5c42243

Fixed in a9f5c422432c5f24050baa53bab98b60778f8025
Athamantis marked this conversation as resolved
Athamantis added 1 commit 2024-04-09 11:37:45 +00:00
Athamantis requested review from sebgab 2024-04-09 11:39:22 +00:00
Athamantis requested review from Athamantis 2024-04-09 11:39:32 +00:00
Athamantis changed title from voltage-reading to WIP: voltage-reading 2024-04-09 11:40:22 +00:00
Athamantis approved these changes 2024-04-09 11:41:03 +00:00
Athamantis added 1 commit 2024-04-09 11:50:10 +00:00
sebgab requested changes 2024-04-09 12:03:50 +00:00
@ -0,0 +33,4 @@
return ADC0.RES;
}
uint16_t photodiode_voltage_read() {
Owner

This is no longer required, re-purpose for thermistor?

This should likely also configure the ADC MUX so it reads from the correct pin before reading the value.
Datasheet: 33.3.3.7

This is no longer required, re-purpose for thermistor? This should likely also configure the ADC MUX so it reads from the correct pin before reading the value. Datasheet: 33.3.3.7
Owner

Fixed in ae28be55d3

Fixed in ae28be55d3ede4b0a31ef47226460e6b88941418
Athamantis marked this conversation as resolved
@ -0,0 +44,4 @@
/* Gets value for the internal voltage reffreance*/
VREF.ADC0REF = VREF_REFSEL_VDD_gc;
}
Owner

Does this function return anything?
It does not look like it returns anything.

Does this function return anything? It does not look like it returns anything.
Owner

Fixed in ae28be55d3

Fixed in ae28be55d3ede4b0a31ef47226460e6b88941418
Owner

This does not look correct, you are returning a variable assignment.

This does not look correct, you are returning a variable assignment.
Owner

91ee8b1af8 fixed her

91ee8b1af8b802a6d3904454ca1117ba5e1c3a46 fixed her
Owner

Delete the line that sets ADC0REF. This is redundant as this is set in init.

Delete the line that sets ADC0REF. This is redundant as this is set in init.
Owner

b0c0efa4fc fixed here

b0c0efa4fc24b9ef0c58aa588e837bc4f3f8fa03 fixed here
sebgab marked this conversation as resolved
@ -0,0 +55,4 @@
// Gets the value from sensor and internal voltage
uint16_t internal_voltage_read();
uint16_t photodiode_voltage_read();
#ifdef __cplusplus
Owner

We're missing a function to read the thermistor voltage.

We're missing a function to read the thermistor voltage.
Owner

Fixed in ae28be55d3

Fixed in ae28be55d3ede4b0a31ef47226460e6b88941418
Owner

This has the wrong function name, and is identical to the function on line 56.

Please make the function for the external voltage. It also needs to be in voltage.c

This has the wrong function name, and is identical to the function on line 56. Please make the function for the external voltage. It also needs to be in `voltage.c`
Owner

fixed 91ee8b1af8

fixed 91ee8b1af8b802a6d3904454ca1117ba5e1c3a46
sebgab marked this conversation as resolved
Athamantis requested review from sebgab 2024-04-09 12:04:22 +00:00
Athamantis added 1 commit 2024-04-09 12:36:19 +00:00
Athamantis removed review request for sebgab 2024-04-09 12:37:16 +00:00
Athamantis requested review from sebgab 2024-04-09 12:37:18 +00:00
Athamantis requested review from Athamantis 2024-04-09 12:44:39 +00:00
Athamantis added 1 commit 2024-04-09 12:56:21 +00:00
Athamantis removed review request for sebgab 2024-04-09 12:57:16 +00:00
Athamantis requested review from sebgab 2024-04-09 12:57:18 +00:00
Athamantis added 1 commit 2024-04-09 13:29:40 +00:00
Athamantis removed review request for sebgab 2024-04-09 13:30:04 +00:00
Athamantis requested review from sebgab 2024-04-09 13:30:07 +00:00
sebgab added the
enhancement
label 2024-04-09 13:54:37 +00:00
Athamantis added 1 commit 2024-04-09 13:54:49 +00:00
Athamantis added 1 commit 2024-04-09 13:58:24 +00:00
sebgab requested changes 2024-04-09 14:01:50 +00:00
@ -0,0 +41,4 @@
return adc_val;
}
uint16_t external_voltage_read(){
Owner

Not defined in voltage.h

Not defined in `voltage.h`
Owner

Fixed in ca28e23b70

Fixed in ca28e23b70411d5cd75c5e03527847b123f3b4b9
Athamantis marked this conversation as resolved
@ -0,0 +42,4 @@
}
uint16_t external_voltage_read(){
ADC0.MUXPOS = 0x02;
Owner

Externale voltage pin is PD6 in init function, but PD2 here.

Externale voltage pin is PD6 in init function, but PD2 here.
Owner

ca28e23b70 fixed

ca28e23b70411d5cd75c5e03527847b123f3b4b9 fixed
Athamantis marked this conversation as resolved
Athamantis added 1 commit 2024-04-09 14:13:13 +00:00
Athamantis requested review from sebgab 2024-04-09 14:13:48 +00:00
sebgab approved these changes 2024-04-09 14:19:05 +00:00
sebgab left a comment
Owner

LGTM

LGTM
Athamantis refused to review 2024-04-09 14:19:24 +00:00
Athamantis requested review from Athamantis 2024-04-09 14:19:26 +00:00
Athamantis approved these changes 2024-04-09 14:19:37 +00:00
sebgab changed title from WIP: voltage-reading to voltage-reading 2024-04-10 11:21:34 +00:00
Owner

Merged in 1b8ca0c7f6

Merged in 1b8ca0c7f6f6071fa86f82213f951a8a84d378c8
sebgab closed this pull request 2024-04-10 11:21:58 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Mikrokontrollersystemer-gruppe-4/mikrokontrollersystemer-prosjekt#13
No description provided.