Made a bool for error and high temp
This commit is contained in:
parent
8e58925dd1
commit
24190f1f15
@ -1,180 +1,180 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configurationDescriptor version="65">
|
<configurationDescriptor version="65">
|
||||||
<logicalFolder name="root" displayName="root" projectFiles="true">
|
<logicalFolder name="root" displayName="root" projectFiles="true">
|
||||||
<logicalFolder name="HeaderFiles"
|
<logicalFolder name="HeaderFiles"
|
||||||
displayName="Header Files"
|
displayName="Header Files"
|
||||||
projectFiles="true">
|
projectFiles="true">
|
||||||
<itemPath>eeprom.h</itemPath>
|
<itemPath>eeprom.h</itemPath>
|
||||||
<itemPath>themistor-temp.h</itemPath>
|
<itemPath>themistor-temp.h</itemPath>
|
||||||
</logicalFolder>
|
</logicalFolder>
|
||||||
<logicalFolder name="LinkerScript"
|
<logicalFolder name="ExternalFiles"
|
||||||
displayName="Linker Files"
|
displayName="Important Files"
|
||||||
projectFiles="true">
|
projectFiles="true">
|
||||||
</logicalFolder>
|
<itemPath>Makefile</itemPath>
|
||||||
<logicalFolder name="SourceFiles"
|
</logicalFolder>
|
||||||
displayName="Source Files"
|
<logicalFolder name="LinkerScript"
|
||||||
projectFiles="true">
|
displayName="Linker Files"
|
||||||
<itemPath>main.c</itemPath>
|
projectFiles="true">
|
||||||
<itemPath>eeprom.c</itemPath>
|
</logicalFolder>
|
||||||
<itemPath>thermistor-temp.c</itemPath>
|
<logicalFolder name="SourceFiles"
|
||||||
</logicalFolder>
|
displayName="Source Files"
|
||||||
<logicalFolder name="ExternalFiles"
|
projectFiles="true">
|
||||||
displayName="Important Files"
|
<itemPath>main.c</itemPath>
|
||||||
projectFiles="false">
|
<itemPath>eeprom.c</itemPath>
|
||||||
<itemPath>Makefile</itemPath>
|
<itemPath>thermistor-temp.c</itemPath>
|
||||||
</logicalFolder>
|
</logicalFolder>
|
||||||
</logicalFolder>
|
</logicalFolder>
|
||||||
<projectmakefile>Makefile</projectmakefile>
|
<projectmakefile>Makefile</projectmakefile>
|
||||||
<confs>
|
<confs>
|
||||||
<conf name="default" type="2">
|
<conf name="default" type="2">
|
||||||
<toolsSet>
|
<toolsSet>
|
||||||
<developmentServer>localhost</developmentServer>
|
<developmentServer>localhost</developmentServer>
|
||||||
<targetDevice>AVR128DB48</targetDevice>
|
<targetDevice>AVR128DB48</targetDevice>
|
||||||
<targetHeader></targetHeader>
|
<targetHeader></targetHeader>
|
||||||
<targetPluginBoard></targetPluginBoard>
|
<targetPluginBoard></targetPluginBoard>
|
||||||
<platformTool>nEdbgTool</platformTool>
|
<platformTool>nEdbgTool</platformTool>
|
||||||
<languageToolchain>XC8</languageToolchain>
|
<languageToolchain>XC8</languageToolchain>
|
||||||
<languageToolchainVersion>2.45</languageToolchainVersion>
|
<languageToolchainVersion>2.46</languageToolchainVersion>
|
||||||
<platform>2</platform>
|
<platform>2</platform>
|
||||||
</toolsSet>
|
</toolsSet>
|
||||||
<packs>
|
<packs>
|
||||||
<pack name="AVR-Dx_DFP" vendor="Microchip" version="2.3.272"/>
|
<pack name="AVR-Dx_DFP" vendor="Microchip" version="2.3.272"/>
|
||||||
</packs>
|
</packs>
|
||||||
<ScriptingSettings>
|
<ScriptingSettings>
|
||||||
</ScriptingSettings>
|
</ScriptingSettings>
|
||||||
<compileType>
|
<compileType>
|
||||||
<linkerTool>
|
<linkerTool>
|
||||||
<linkerLibItems>
|
<linkerLibItems>
|
||||||
</linkerLibItems>
|
</linkerLibItems>
|
||||||
</linkerTool>
|
</linkerTool>
|
||||||
<archiverTool>
|
<archiverTool>
|
||||||
</archiverTool>
|
</archiverTool>
|
||||||
<loading>
|
<loading>
|
||||||
<useAlternateLoadableFile>false</useAlternateLoadableFile>
|
<useAlternateLoadableFile>false</useAlternateLoadableFile>
|
||||||
<parseOnProdLoad>false</parseOnProdLoad>
|
<parseOnProdLoad>false</parseOnProdLoad>
|
||||||
<alternateLoadableFile></alternateLoadableFile>
|
<alternateLoadableFile></alternateLoadableFile>
|
||||||
</loading>
|
</loading>
|
||||||
<subordinates>
|
<subordinates>
|
||||||
</subordinates>
|
</subordinates>
|
||||||
</compileType>
|
</compileType>
|
||||||
<makeCustomizationType>
|
<makeCustomizationType>
|
||||||
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
|
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
|
||||||
<makeUseCleanTarget>false</makeUseCleanTarget>
|
<makeUseCleanTarget>false</makeUseCleanTarget>
|
||||||
<makeCustomizationPreStep></makeCustomizationPreStep>
|
<makeCustomizationPreStep></makeCustomizationPreStep>
|
||||||
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
|
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
|
||||||
<makeCustomizationPostStep></makeCustomizationPostStep>
|
<makeCustomizationPostStep></makeCustomizationPostStep>
|
||||||
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
|
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
|
||||||
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
|
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
|
||||||
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
|
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
|
||||||
</makeCustomizationType>
|
</makeCustomizationType>
|
||||||
<HI-TECH-COMP>
|
<HI-TECH-COMP>
|
||||||
<property key="additional-warnings" value="true"/>
|
<property key="additional-warnings" value="true"/>
|
||||||
<property key="asmlist" value="true"/>
|
<property key="asmlist" value="true"/>
|
||||||
<property key="call-prologues" value="false"/>
|
<property key="call-prologues" value="false"/>
|
||||||
<property key="default-bitfield-type" value="true"/>
|
<property key="default-bitfield-type" value="true"/>
|
||||||
<property key="default-char-type" value="true"/>
|
<property key="default-char-type" value="true"/>
|
||||||
<property key="define-macros" value=""/>
|
<property key="define-macros" value=""/>
|
||||||
<property key="disable-optimizations" value="false"/>
|
<property key="disable-optimizations" value="false"/>
|
||||||
<property key="extra-include-directories" value=""/>
|
<property key="extra-include-directories" value=""/>
|
||||||
<property key="favor-optimization-for" value="-speed,+space"/>
|
<property key="favor-optimization-for" value="-speed,+space"/>
|
||||||
<property key="garbage-collect-data" value="true"/>
|
<property key="garbage-collect-data" value="true"/>
|
||||||
<property key="garbage-collect-functions" value="true"/>
|
<property key="garbage-collect-functions" value="true"/>
|
||||||
<property key="identifier-length" value="255"/>
|
<property key="identifier-length" value="255"/>
|
||||||
<property key="local-generation" value="false"/>
|
<property key="local-generation" value="false"/>
|
||||||
<property key="operation-mode" value="free"/>
|
<property key="operation-mode" value="free"/>
|
||||||
<property key="opt-xc8-compiler-strict_ansi" value="false"/>
|
<property key="opt-xc8-compiler-strict_ansi" value="false"/>
|
||||||
<property key="optimization-assembler" value="true"/>
|
<property key="optimization-assembler" value="true"/>
|
||||||
<property key="optimization-assembler-files" value="true"/>
|
<property key="optimization-assembler-files" value="true"/>
|
||||||
<property key="optimization-debug" value="false"/>
|
<property key="optimization-debug" value="false"/>
|
||||||
<property key="optimization-invariant-enable" value="false"/>
|
<property key="optimization-invariant-enable" value="false"/>
|
||||||
<property key="optimization-invariant-value" value="16"/>
|
<property key="optimization-invariant-value" value="16"/>
|
||||||
<property key="optimization-level" value="-O1"/>
|
<property key="optimization-level" value="-O1"/>
|
||||||
<property key="optimization-speed" value="false"/>
|
<property key="optimization-speed" value="false"/>
|
||||||
<property key="optimization-stable-enable" value="false"/>
|
<property key="optimization-stable-enable" value="false"/>
|
||||||
<property key="preprocess-assembler" value="true"/>
|
<property key="preprocess-assembler" value="true"/>
|
||||||
<property key="short-enums" value="true"/>
|
<property key="short-enums" value="true"/>
|
||||||
<property key="tentative-definitions" value="-fno-common"/>
|
<property key="tentative-definitions" value="-fno-common"/>
|
||||||
<property key="undefine-macros" value=""/>
|
<property key="undefine-macros" value=""/>
|
||||||
<property key="use-cci" value="false"/>
|
<property key="use-cci" value="false"/>
|
||||||
<property key="use-iar" value="false"/>
|
<property key="use-iar" value="false"/>
|
||||||
<property key="verbose" value="false"/>
|
<property key="verbose" value="false"/>
|
||||||
<property key="warning-level" value="-3"/>
|
<property key="warning-level" value="-3"/>
|
||||||
<property key="what-to-do" value="ignore"/>
|
<property key="what-to-do" value="ignore"/>
|
||||||
</HI-TECH-COMP>
|
</HI-TECH-COMP>
|
||||||
<HI-TECH-LINK>
|
<HI-TECH-LINK>
|
||||||
<property key="additional-options-checksum" value=""/>
|
<property key="additional-options-checksum" value=""/>
|
||||||
<property key="additional-options-code-offset" value=""/>
|
<property key="additional-options-code-offset" value=""/>
|
||||||
<property key="additional-options-command-line" value=""/>
|
<property key="additional-options-command-line" value=""/>
|
||||||
<property key="additional-options-errata" value=""/>
|
<property key="additional-options-errata" value=""/>
|
||||||
<property key="additional-options-extend-address" value="false"/>
|
<property key="additional-options-extend-address" value="false"/>
|
||||||
<property key="additional-options-trace-type" value=""/>
|
<property key="additional-options-trace-type" value=""/>
|
||||||
<property key="additional-options-use-response-files" value="false"/>
|
<property key="additional-options-use-response-files" value="false"/>
|
||||||
<property key="backup-reset-condition-flags" value="false"/>
|
<property key="backup-reset-condition-flags" value="false"/>
|
||||||
<property key="calibrate-oscillator" value="false"/>
|
<property key="calibrate-oscillator" value="false"/>
|
||||||
<property key="calibrate-oscillator-value" value="0x3400"/>
|
<property key="calibrate-oscillator-value" value="0x3400"/>
|
||||||
<property key="clear-bss" value="true"/>
|
<property key="clear-bss" value="true"/>
|
||||||
<property key="code-model-external" value="wordwrite"/>
|
<property key="code-model-external" value="wordwrite"/>
|
||||||
<property key="code-model-rom" value=""/>
|
<property key="code-model-rom" value=""/>
|
||||||
<property key="create-html-files" value="false"/>
|
<property key="create-html-files" value="false"/>
|
||||||
<property key="data-model-ram" value=""/>
|
<property key="data-model-ram" value=""/>
|
||||||
<property key="data-model-size-of-double" value="24"/>
|
<property key="data-model-size-of-double" value="24"/>
|
||||||
<property key="data-model-size-of-double-gcc" value="no-short-double"/>
|
<property key="data-model-size-of-double-gcc" value="no-short-double"/>
|
||||||
<property key="data-model-size-of-float" value="24"/>
|
<property key="data-model-size-of-float" value="24"/>
|
||||||
<property key="data-model-size-of-float-gcc" value="no-short-float"/>
|
<property key="data-model-size-of-float-gcc" value="no-short-float"/>
|
||||||
<property key="display-class-usage" value="false"/>
|
<property key="display-class-usage" value="false"/>
|
||||||
<property key="display-hex-usage" value="false"/>
|
<property key="display-hex-usage" value="false"/>
|
||||||
<property key="display-overall-usage" value="true"/>
|
<property key="display-overall-usage" value="true"/>
|
||||||
<property key="display-psect-usage" value="false"/>
|
<property key="display-psect-usage" value="false"/>
|
||||||
<property key="extra-lib-directories" value=""/>
|
<property key="extra-lib-directories" value=""/>
|
||||||
<property key="fill-flash-options-addr" value=""/>
|
<property key="fill-flash-options-addr" value=""/>
|
||||||
<property key="fill-flash-options-const" value=""/>
|
<property key="fill-flash-options-const" value=""/>
|
||||||
<property key="fill-flash-options-how" value="0"/>
|
<property key="fill-flash-options-how" value="0"/>
|
||||||
<property key="fill-flash-options-inc-const" value="1"/>
|
<property key="fill-flash-options-inc-const" value="1"/>
|
||||||
<property key="fill-flash-options-increment" value=""/>
|
<property key="fill-flash-options-increment" value=""/>
|
||||||
<property key="fill-flash-options-seq" value=""/>
|
<property key="fill-flash-options-seq" value=""/>
|
||||||
<property key="fill-flash-options-what" value="0"/>
|
<property key="fill-flash-options-what" value="0"/>
|
||||||
<property key="format-hex-file-for-download" value="false"/>
|
<property key="format-hex-file-for-download" value="false"/>
|
||||||
<property key="initialize-data" value="true"/>
|
<property key="initialize-data" value="true"/>
|
||||||
<property key="input-libraries" value="libm"/>
|
<property key="input-libraries" value="libm"/>
|
||||||
<property key="keep-generated-startup.as" value="false"/>
|
<property key="keep-generated-startup.as" value="false"/>
|
||||||
<property key="link-in-c-library" value="true"/>
|
<property key="link-in-c-library" value="true"/>
|
||||||
<property key="link-in-c-library-gcc" value=""/>
|
<property key="link-in-c-library-gcc" value=""/>
|
||||||
<property key="link-in-peripheral-library" value="false"/>
|
<property key="link-in-peripheral-library" value="false"/>
|
||||||
<property key="managed-stack" value="false"/>
|
<property key="managed-stack" value="false"/>
|
||||||
<property key="opt-xc8-linker-file" value="false"/>
|
<property key="opt-xc8-linker-file" value="false"/>
|
||||||
<property key="opt-xc8-linker-link_startup" value="false"/>
|
<property key="opt-xc8-linker-link_startup" value="false"/>
|
||||||
<property key="opt-xc8-linker-serial" value=""/>
|
<property key="opt-xc8-linker-serial" value=""/>
|
||||||
<property key="program-the-device-with-default-config-words" value="false"/>
|
<property key="program-the-device-with-default-config-words" value="false"/>
|
||||||
<property key="remove-unused-sections" value="true"/>
|
<property key="remove-unused-sections" value="true"/>
|
||||||
</HI-TECH-LINK>
|
</HI-TECH-LINK>
|
||||||
<Tool>
|
<Tool>
|
||||||
<property key="debugoptions.useswbreakpoints" value="true"/>
|
<property key="debugoptions.useswbreakpoints" value="true"/>
|
||||||
</Tool>
|
</Tool>
|
||||||
<XC8-CO>
|
<XC8-CO>
|
||||||
<property key="coverage-enable" value=""/>
|
<property key="coverage-enable" value=""/>
|
||||||
<property key="stack-guidance" value="false"/>
|
<property key="stack-guidance" value="false"/>
|
||||||
</XC8-CO>
|
</XC8-CO>
|
||||||
<XC8-config-global>
|
<XC8-config-global>
|
||||||
<property key="advanced-elf" value="true"/>
|
<property key="advanced-elf" value="true"/>
|
||||||
<property key="constdata-progmem" value="true"/>
|
<property key="constdata-progmem" value="true"/>
|
||||||
<property key="gcc-opt-driver-new" value="true"/>
|
<property key="gcc-opt-driver-new" value="true"/>
|
||||||
<property key="gcc-opt-std" value="-std=c99"/>
|
<property key="gcc-opt-std" value="-std=c99"/>
|
||||||
<property key="gcc-output-file-format" value="dwarf-3"/>
|
<property key="gcc-output-file-format" value="dwarf-3"/>
|
||||||
<property key="mapped-progmem" value="false"/>
|
<property key="mapped-progmem" value="false"/>
|
||||||
<property key="omit-pack-options" value="false"/>
|
<property key="omit-pack-options" value="false"/>
|
||||||
<property key="omit-pack-options-new" value="1"/>
|
<property key="omit-pack-options-new" value="1"/>
|
||||||
<property key="output-file-format" value="-mcof,+elf"/>
|
<property key="output-file-format" value="-mcof,+elf"/>
|
||||||
<property key="smart-io-format" value=""/>
|
<property key="smart-io-format" value=""/>
|
||||||
<property key="stack-size-high" value="auto"/>
|
<property key="stack-size-high" value="auto"/>
|
||||||
<property key="stack-size-low" value="auto"/>
|
<property key="stack-size-low" value="auto"/>
|
||||||
<property key="stack-size-main" value="auto"/>
|
<property key="stack-size-main" value="auto"/>
|
||||||
<property key="stack-type" value="compiled"/>
|
<property key="stack-type" value="compiled"/>
|
||||||
<property key="user-pack-device-support" value=""/>
|
<property key="user-pack-device-support" value=""/>
|
||||||
<property key="wpo-lto" value="false"/>
|
<property key="wpo-lto" value="false"/>
|
||||||
</XC8-config-global>
|
</XC8-config-global>
|
||||||
<nEdbgTool>
|
<nEdbgTool>
|
||||||
<property key="debugoptions.useswbreakpoints" value="true"/>
|
<property key="debugoptions.useswbreakpoints" value="true"/>
|
||||||
</nEdbgTool>
|
</nEdbgTool>
|
||||||
</conf>
|
</conf>
|
||||||
</confs>
|
</confs>
|
||||||
</configurationDescriptor>
|
</configurationDescriptor>
|
||||||
|
|||||||
@ -1,38 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* File: themistor-temp.h
|
* File: themistor-temp.h
|
||||||
* Author: athamantis
|
* Author: athamantis
|
||||||
*
|
*
|
||||||
* Created on 08 March 2024, 11:46
|
* Created on 08 March 2024, 11:46
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef THEMISTOR_TEMP_H
|
#ifndef THEMISTOR_TEMP_H
|
||||||
#define THEMISTOR_TEMP_H
|
#define THEMISTOR_TEMP_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <float.h>
|
||||||
#include <stdint.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <stdlib.h>
|
||||||
#define R_t0 10000
|
#include <stdint.h>
|
||||||
#define T_0 298.15
|
#include <math.h>
|
||||||
#define B 3950
|
#define R_t0 10000
|
||||||
#define R_1 1000
|
#define T_0 298.15
|
||||||
|
#define B 3950
|
||||||
// Takes inn messured value
|
#define R_1 1000
|
||||||
// Calculates the temperature in celcius
|
|
||||||
// Returns the thermistor themperature
|
// Takes inn messured value
|
||||||
float calculate_thermistor_temp(float readValue);
|
// Calculates the temperature in celcius
|
||||||
|
// Returns the thermistor themperature
|
||||||
|
float calculate_thermistor_temp(float readValue);
|
||||||
|
|
||||||
|
bool error_message(float thermistor_temp);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif /* THEMISTOR_TEMP_H */
|
#endif
|
||||||
|
|
||||||
|
#endif /* THEMISTOR_TEMP_H */
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +1,37 @@
|
|||||||
#include "themistor-temp.h"
|
#include "themistor-temp.h"
|
||||||
|
|
||||||
|
float calculate_thermistor_temp(float readValue){
|
||||||
float calculate_thermistor_temp(float readValue){
|
float R_therm;
|
||||||
float R_therm;
|
float V_1;
|
||||||
float V_1;
|
float ln;
|
||||||
float ln;
|
float T_therm;
|
||||||
float T_therm;
|
float V_therm;
|
||||||
float V_therm;
|
uint8_t V_tot = 5;
|
||||||
uint8_t V_tot = 5;
|
// Calculate Voltage over thermistor
|
||||||
// Calculate Voltage over thermistor
|
V_therm = (V_tot/1024)*readValue;
|
||||||
V_therm = (V_tot/1024)*readValue;
|
|
||||||
|
// Voltage accross R_1
|
||||||
// Voltage accross R_1
|
V_1 = V_tot - V_therm;
|
||||||
V_1 = V_tot - V_therm;
|
|
||||||
|
// Calculate Thermistor resistanse
|
||||||
// Calculate Thermistor resistanse
|
R_therm = (V_therm)/ (V_1 / R_1);
|
||||||
R_therm = (V_therm)/ (V_1 / R_1);
|
|
||||||
|
// Steinhart-Harts formula
|
||||||
// Steinhart-Harts formula
|
ln = log(R_therm/R_t0);
|
||||||
ln = log(R_therm/R_t0);
|
T_therm = (1/ ((ln/B) + (1/T_0)));
|
||||||
T_therm = (1/ ((ln/B) + (1/T_0)));
|
|
||||||
|
// Temperatur in celcius
|
||||||
// Temperatur in celcius
|
T_therm -= 273.15;
|
||||||
T_therm -= 273.15;
|
|
||||||
|
return T_therm;
|
||||||
return T_therm;
|
}
|
||||||
}
|
|
||||||
|
bool error_message(float thermistor_temp){
|
||||||
|
int high_temp = 0;
|
||||||
|
if (thermistor_temp > high_temp){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user