mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Correct adc gain
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
|
||||
// These control the period's of time used for the PWM
|
||||
const uint16_t powerPWM = 255;
|
||||
const uint8_t holdoffTicks = 3; // This is the tick delay
|
||||
const uint8_t tempMeasureTicks = 4;
|
||||
const uint8_t holdoffTicks = 5; // This is the tick delay
|
||||
const uint8_t tempMeasureTicks = 5;
|
||||
|
||||
uint16_t totalPWM = 255; // Total length of the cycle's ticks
|
||||
|
||||
|
||||
@@ -173,16 +173,10 @@ bool getFUS302IRQLow() {
|
||||
// Return true if the IRQ line is still held low
|
||||
return !gpio_read(FUSB302_IRQ_Pin);
|
||||
}
|
||||
uint16_t rescaleADC(const uint16_t value) {
|
||||
// TODO This can be removed once we figure out final op-amp scaling
|
||||
// return value;
|
||||
uint32_t temp = value * 33;
|
||||
uint16_t res = temp / 32;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint16_t getADCHandleTemp(uint8_t sample) { return ADC_Temp.average(); }
|
||||
|
||||
uint16_t getADCVin(uint8_t sample) { return ADC_Vin.average(); }
|
||||
|
||||
// Returns either average or instant value. When sample is set the samples from the injected ADC are copied to the filter and then the raw reading is returned
|
||||
uint16_t getTipRawTemp(uint8_t sample) { return rescaleADC(ADC_Tip.average() >> 1); }
|
||||
uint16_t getTipRawTemp(uint8_t sample) { return ADC_Tip.average() >> 1; }
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
#define TIP_TEMP_Pin GPIO_PIN_19
|
||||
#define TIP_TEMP_ADC_CHANNEL ADC_CHAN9
|
||||
|
||||
#define Debug_Pin GPIO_PIN_14
|
||||
#define Debug2_Pin GPIO_PIN_15
|
||||
|
||||
#define VIN_Pin GPIO_PIN_18
|
||||
#define VIN_ADC_CHANNEL ADC_CHAN8
|
||||
#define OLED_RESET_Pin GPIO_PIN_3
|
||||
#define KEY_A_Pin GPIO_PIN_25
|
||||
#define PWM_Out_Pin GPIO_PIN_21
|
||||
#define PWM_Channel PWM_CH1
|
||||
#define SCL_Pin GPIO_PIN_11
|
||||
#define SDA_Pin GPIO_PIN_10
|
||||
#define TIP_RESISTANCE_SENSE GPIO_PIN_24
|
||||
#define VIN_Pin GPIO_PIN_18
|
||||
#define VIN_ADC_CHANNEL ADC_CHAN8
|
||||
#define OLED_RESET_Pin GPIO_PIN_3
|
||||
#define KEY_A_Pin GPIO_PIN_25
|
||||
#define PWM_Out_Pin GPIO_PIN_21
|
||||
#define PWM_Channel PWM_CH1
|
||||
#define SCL_Pin GPIO_PIN_11
|
||||
#define SDA_Pin GPIO_PIN_10
|
||||
|
||||
#define USB_DM_Pin GPIO_PIN_8
|
||||
#define QC_DP_LOW_Pin GPIO_PIN_5
|
||||
|
||||
@@ -29,8 +29,7 @@ void hardware_init() {
|
||||
gpio_set_mode(TMP36_INPUT_Pin, GPIO_INPUT_MODE);
|
||||
gpio_set_mode(TIP_TEMP_Pin, GPIO_INPUT_MODE);
|
||||
gpio_set_mode(VIN_Pin, GPIO_INPUT_MODE);
|
||||
gpio_set_mode(Debug_Pin, GPIO_OUTPUT_MODE);
|
||||
gpio_set_mode(Debug2_Pin, GPIO_OUTPUT_MODE);
|
||||
gpio_set_mode(TIP_RESISTANCE_SENSE, GPIO_INPUT_MODE);
|
||||
|
||||
setup_timer_scheduler();
|
||||
setup_adc();
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
#define ANIMATION_LOOP 1 // 0: off 1: on
|
||||
#define ANIMATION_SPEED settingOffSpeed_t::MEDIUM
|
||||
|
||||
#define OP_AMP_Rf_Pinecil 850 * 1000 // 750 Kilo-ohms -> From schematic, R1
|
||||
#define OP_AMP_Rf_Pinecil 866 * 1000 // 750 Kilo-ohms -> From schematic, R1
|
||||
#define OP_AMP_Rin_Pinecil 2370 // 2.37 Kilo-ohms -> From schematic, R2
|
||||
|
||||
#define OP_AMP_GAIN_STAGE_PINECIL (1 + (OP_AMP_Rf_Pinecil / OP_AMP_Rin_Pinecil))
|
||||
@@ -114,6 +114,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef MODEL_Magic
|
||||
#define ADC_VDD_MV 3200 // ADC max reading millivolts
|
||||
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
|
||||
#define VOLTAGE_DIV 600 // 290 - Default divider from schematic
|
||||
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "BSP.h"
|
||||
#include "Settings.h"
|
||||
#include "Utils.h"
|
||||
#include "configuration.h"
|
||||
#include "main.hpp"
|
||||
#include "power.hpp"
|
||||
/*
|
||||
@@ -32,7 +33,7 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski
|
||||
// This takes the raw ADC samples, converts these to uV
|
||||
// Then divides this down by the gain to convert to the uV on the input to the op-amp (A+B terminals)
|
||||
// Then remove the calibration value that is stored as a tip offset
|
||||
uint32_t vddRailmVX10 = 33000; // The vreg is +-2%, but we have no higher accuracy available
|
||||
uint32_t vddRailmVX10 = ADC_VDD_MV * 10; // The vreg is +-2%, but we have no higher accuracy available
|
||||
// 4096 * 8 readings for full scale
|
||||
// Convert the input ADC reading back into mV times 10 format.
|
||||
uint32_t rawInputmVX10 = (rawADC * vddRailmVX10) / (4096 * 8);
|
||||
|
||||
Reference in New Issue
Block a user