Merge branch 'master' into powerPulses

This commit is contained in:
Thomas Gimpel
2019-12-24 10:10:24 +01:00
34 changed files with 5589 additions and 5524 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Ignore all differences in line endings
* -crlf

7
.gitignore vendored
View File

@@ -58,3 +58,10 @@ workspace/TS100/src/Translation.cpp
*.list
workspace/TS100/Release/
workspace/TS100/Hexfile/
workspace/RemoteSystemsTempFiles/
workspace/TS100/.settings/
workspace/TS100/TS80/
ci/artefacts/
ci/secrets/unencrypted/
codeship.aes
.vscode/settings.json

27
Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
FROM ubuntu:rolling
MAINTAINER Ben V. Brown <ralim@ralimtek.com>
WORKDIR /build
# Setup the ARM GCC toolchain
# Install any needed packages specified in requirements.txt
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
make \
git \
bzip2 \
git \
golang \
python3 \
wget && \
apt-get clean && \
wget -qO- https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 | tar -xj
# Add compiler to the path
ENV PATH "/build/gcc-arm-none-eabi-9-2019-q4-major/bin:$PATH"
# Get the github release tool
RUN go get -u github.com/aktau/github-release
COPY . /build/source
COPY ./ci /build/ci

2
Flashing/flash_ts100_linux.sh Normal file → Executable file
View File

@@ -37,7 +37,7 @@ function enable_gautomount {
}
function is_attached {
output=`lsblk -b --raw --output NAME,MODEL | grep 'DFU\\\\x20Disk'`
output=`lsblk -b --raw --output NAME,MODEL | grep 'DFU.*Disk'`
if [ $? -ne 0 ]; then
return 1
fi

View File

@@ -1,5 +1,8 @@
[![Codeship Status for ts100](https://app.codeship.com/projects/c77dbfe0-0764-0138-9520-3eb35bdb2b2c/status?branch=master)](https://app.codeship.com/projects/379118)
# TS100 & TS80 Firmware
This firmware is a fresh start for these soldering irons. Designed from the ground up as fully featured control software that leaves nothing to be desired.
It originally started back at the end of 2016 and has since seen vast improvements, especially some very smart work by community members.

View File

@@ -176,7 +176,6 @@ def getLetterCounts(defs, lang):
constants = getConstants()
for x in constants:
textList.append(x[1])
textList.extend(getDebugMenuHeaders())
textList.extend(getTipModelEnumTS100())
textList.extend(getTipModelEnumTS80())
textList.extend(getDebugMenu())
@@ -193,7 +192,7 @@ def getLetterCounts(defs, lang):
symbolCounts[letter] = symbolCounts.get(letter, 0) + 1
symbolCounts = sorted(
symbolCounts.items(),
key=lambda kv: kv[1]) # swap to Big -> little sort order
key=lambda kv: (kv[1],kv[0])) # swap to Big -> little sort order
symbolCounts = list(map(lambda x: x[0], symbolCounts))
symbolCounts.reverse()
return symbolCounts

2
build.sh Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker-compose run --rm builder /bin/bash /build/ci/buildAll.sh

13
ci/buildAll.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
set -u
mkdir -p /build/ci/artefacts
# Build STM code
cd /build/source/workspace/TS100/
bash ./build.sh || exit 1
echo "All Firmware built"
# Copy out all the final resulting files we would like to store for the next op
cp -r /build/source/workspace/TS100/Hexfile/*.hex /build/ci/artefacts/
cp -r /build/source/workspace/TS100/Hexfile/*.bin /build/ci/artefacts/

16
ci/secrets/decrypt.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SECRETS="$DIR/encrypted/*.encrypted"
KEY="$DIR/../../codeship.aes"
mkdir -p $DIR/unencrypted
for f in $SECRETS
do
out="${f/.encrypted/.secret}"
out="${out/encrypted/unencrypted}"
echo $out
jet decrypt $f $out --key-path $KEY
done
echo "Done"

View File

@@ -0,0 +1,2 @@
codeship:v2
DUgOERb8iPVn95/DKIw9M7sgNjJlIlsaeE4PFV58tmmBu2sD1ooR7Y0L23bimC9a

8
codeship-services.yml Normal file
View File

@@ -0,0 +1,8 @@
builder:
build:
context: .
dockerfile: Dockerfile
cached: true
encrypted_env_file: ci/secrets/encrypted/deployment.encrypted
volumes:
- ./ci:/ci

6
codeship-steps.yml Normal file
View File

@@ -0,0 +1,6 @@
- type: parallel
name: Build the firmware
steps:
- name: build
service: builder
command: /build/ci/buildAll.sh

11
docker-compose.yml Normal file
View File

@@ -0,0 +1,11 @@
version: '3'
services:
builder:
stdin_open: true
tty: true
build:
context: .
command: /bin/bash
volumes:
- ./ci:/build/ci
- ./:/build/source

2
start_dev.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker-compose run --rm builder

View File

@@ -31,7 +31,7 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1236938233" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1567896324" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1567896324" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="MODEL_TS100"/>
<listOptionValue builtIn="false" value="STM32F103xB"/>
@@ -99,11 +99,11 @@
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1902507185" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script.752998" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script" useByScannerDiscovery="false" value="/home/ralim/source/ts100/workspace/TS100/LinkerScript.ld" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script.752998" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script" useByScannerDiscovery="false" value="C:\Users\Ralim.DESKTOP-R877O7F\Documents\GitHub\ts100\workspace\TS100\LinkerScript.ld" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags.329644110" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-flto"/>
</option>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref.145186443" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref.145186443" name="Add symbol cross reference table to map file (-Wl,--cref)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.input.1684195922" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
@@ -129,6 +129,134 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.980996604.1040839551">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.980996604.1040839551" moduleId="org.eclipse.cdt.core.settings" name="TS80">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.980996604.1040839551" name="TS80" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.980996604.1040839551." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.119279677" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
<option id="com.st.stm32cube.ide.mcu.option.internal.toolchain.type.849152425" name="Internal Toolchain Type" superClass="com.st.stm32cube.ide.mcu.option.internal.toolchain.type" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.option.internal.toolchain.version.159605979" name="Internal Toolchain Version" superClass="com.st.stm32cube.ide.mcu.option.internal.toolchain.version" useByScannerDiscovery="false" value="7-2018-q2-update" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1536164180" name="Mcu" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="false" value="STM32F103T8Ux" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1370739571" name="CpuId" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.295605019" name="CpuCoreId" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.973266354" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.464348240" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.0 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32F103T8Ux || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Drivers/CMSIS/Device/ST/STM32F1xx/Include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | ../Drivers/STM32F1xx_HAL_Driver/Inc | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 || ../ || || USE_HAL_DRIVER | STM32F103xB || || Startup || Drivers | Middlewares | Core || || ${workspace_loc:/${ProjName}/STM32F103T8UX_FLASH.ld} || true" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1607101911" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1970014216" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/TS100}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1807978370" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.832589290" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.2021461351" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1740040757" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1866744147" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="MODEL_TS80"/>
<listOptionValue builtIn="false" value="STM32F103xB"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1978031483" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1462185687" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1548601111" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.457682077" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1260353799" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="MODEL_TS80"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F103xB"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.540768214" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/CMSIS/Device/ST/STM32F1xx/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/CMSIS/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Core/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/STM32F1xx_HAL_Driver/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3}&quot;"/>
</option>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.extra.1574359913" name="Enable extra warning flags (-Wextra)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.extra" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.otherflags.1077707594" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-Wno-write-strings"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1813870546" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1660249714" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.16251983" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1224833714" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.1599760897" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="MODEL_TS80"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F103xB"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.925084011" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/CMSIS/Device/ST/STM32F1xx/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/CMSIS/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Core/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Drivers/STM32F1xx_HAL_Driver/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3}&quot;"/>
</option>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.warnings.extra.110760609" name="Enable extra warning flags (-Wextra)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.warnings.extra" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags.834159935" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-fno-rtti"/>
<listOptionValue builtIn="false" value="-Wno-write-strings"/>
<listOptionValue builtIn="false" value="-fno-exceptions"/>
<listOptionValue builtIn="false" value="-fno-non-call-exceptions"/>
<listOptionValue builtIn="false" value="-fno-use-cxa-atexit"/>
<listOptionValue builtIn="false" value="-fno-strict-aliasing"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.input.cpp.1576964672" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.input.cpp"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1130643119" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.215123120" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F103T8UX_FLASH.ld}" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.300729142" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.227435340" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script.830347551" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script" useByScannerDiscovery="false" value="C:\Users\Ralim.DESKTOP-R877O7F\Documents\GitHub\ts100\workspace\TS100\LinkerScript.ld" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags.2106114007" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-flto"/>
</option>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref.1223102617" name="Add symbol cross reference table to map file (-Wl,--cref)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.input.1693496005" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1793875206" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.2031511845" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1883149988" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1503571164" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1574630014" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.948380741" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.260468267" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.984915652" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Startup"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="TS100.null.5136256" name="TS100"/>

View File

@@ -6,7 +6,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="712310659903196406" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-348041022799175818" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@@ -11,7 +11,7 @@
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f1xx_hal.h"
#define SETTINGSVERSION ( 0x19 )
#define SETTINGSVERSION ( 0x1A )
/*Change this if you change the struct below to prevent people getting \
out of sync*/
@@ -39,18 +39,13 @@ typedef struct {
uint8_t descriptionScrollSpeed :1; // Description scroll speed
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
int16_t CalibrationOffset; // This stores the temperature offset for this tip
// in the iron.
uint8_t PID_P; // PID P Term
uint8_t PID_I; // PID I Term
uint8_t PID_D; // PID D Term
uint8_t version; // Used to track if a reset is needed on firmware upgrade
uint16_t CalibrationOffset; // This stores the temperature offset for this tip
// in the iron.
uint8_t customTipGain; // Tip gain value if custom tuned, or 0 if using a
// tipType param
uint8_t tipType;
#ifdef MODEL_TS80
uint8_t pidPowerLimit;
#endif
uint8_t version; // Used to track if a reset is needed on firmware upgrade
uint32_t padding; // This is here for in case we are not an even divisor so
// that nothing gets cut off
} systemSettingsType;

View File

@@ -0,0 +1,24 @@
/*
* expMovingAverage.h
*
* Created on: 8 Oct 2019
* Author: ralim
*/
#ifndef INC_EXPMOVINGAVERAGE_H_
#define INC_EXPMOVINGAVERAGE_H_
// max size = 127
template<class T, uint8_t weighting>
struct expMovingAverage {
int32_t sum;
void update(T const val) {
sum = ((val * weighting) + (sum * (256 - weighting))) / 256;
}
T average() const {
return sum;
}
};
#endif /* INC_EXPMOVINGAVERAGE_H_ */

View File

@@ -11,25 +11,25 @@
#include <stdint.h>
// max size = 127
template <class T, uint8_t SIZE>
template<class T, uint8_t SIZE>
struct history {
static const uint8_t size = SIZE;
static const uint8_t size = SIZE;
T buf[size];
int32_t sum;
uint8_t loc;
void update(T const val) {
// step backwards so i+1 is the previous value.
loc = (size+loc-1) % size;
sum -= buf[loc];
sum += val;
buf[loc] = val;
loc = (loc + 1) % size;
}
T operator[] (uint8_t i) const {
T operator[](uint8_t i) const {
// 0 = newest, size-1 = oldest.
i = (i+loc) % size;
i = (i + loc) % size;
return buf[i];
}

View File

@@ -5,7 +5,7 @@
#include "OLED.hpp"
#include "Setup.h"
extern uint8_t PCBVersion;
extern uint32_t currentlyActiveTemperatureTarget;
extern uint32_t currentTempTargetDegC;
enum ButtonState {
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
BUTTON_F_SHORT = 1, /* User has pressed the front button*/

View File

@@ -8,6 +8,7 @@
#include "stdint.h"
#include <history.hpp>
#include "hardware.h"
#include "expMovingAverage.h"
#ifndef POWER_HPP_
#define POWER_HPP_
@@ -18,22 +19,21 @@
// Once we have feed-forward temp estimation we should be able to better tune this.
#ifdef MODEL_TS100
const uint16_t tipMass = 450; // divide here so division is compile-time.
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
const uint8_t tipResistance = 85; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
#endif
#ifdef MODEL_TS80
const uint16_t tipMass = 450;
const uint32_t tipMass = 40;
const uint8_t tipResistance = 45; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
#endif
const uint8_t oscillationPeriod = 6 * PID_TIM_HZ; // I term look back value
extern history<uint32_t, oscillationPeriod> milliWattHistory;
int32_t tempToMilliWatts(int32_t rawTemp, uint8_t rawC);
void setTipMilliWatts(int32_t mw);
uint8_t milliWattsToPWM(int32_t milliWatts, uint8_t divisor,
uint8_t sample = 0);
int32_t PWMToMilliWatts(uint8_t pwm, uint8_t divisor, uint8_t sample = 0);
const uint8_t wattHistoryFilter = 24; // I term look back weighting
extern expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory;
int32_t tempToX10Watts(int32_t rawTemp);
void setTipX10Watts(int32_t mw);
uint8_t X10WattsToPWM(int32_t milliWatts, uint8_t sample = 0);
int32_t PWMToX10Watts(uint8_t pwm, uint8_t sample = 0);
uint32_t availableW10(uint8_t sample) ;
#endif /* POWER_HPP_ */

View File

@@ -16,9 +16,10 @@
#include "stdlib.h"
#include "stm32f1xx_hal.h"
#include "string.h"
#include "TipThermoModel.h"
extern uint8_t PCBVersion;
// File local variables
extern uint32_t currentlyActiveTemperatureTarget;
extern uint32_t currentTempTargetDegC;
extern uint32_t lastMovementTime;
extern int16_t idealQCVoltage;
uint32_t lastButtonTime = 0;
@@ -53,12 +54,12 @@ void GUIDelay() {
}
void gui_drawTipTemp(bool symbol) {
// Draw tip temp handling unit conversion & tolerance near setpoint
uint16_t Temp = getTipRawTemp(0);
uint16_t Temp = 0;
if (systemSettings.temperatureInF)
Temp = tipMeasurementToF(Temp);
Temp = TipThermoModel::getTipInF();
else
Temp = tipMeasurementToC(Temp);
Temp = TipThermoModel::getTipInC();
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
if (symbol) {
@@ -200,7 +201,7 @@ static bool checkVoltageForExit() {
}
OLED::refresh();
currentlyActiveTemperatureTarget = 0;
currentTempTargetDegC = 0;
waitForButtonPress();
return true;
}
@@ -215,17 +216,17 @@ static void gui_drawBatteryIcon() {
// we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.cutoutSetting + 2;
uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0)
/ cellCount;
/ cellCount;
// Should give us approx cell voltage X10
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
if (cellV < 33)
cellV = 33;
cellV -= 33;// Should leave us a number of 0-9
cellV = 33;
cellV -= 33; // Should leave us a number of 0-9
if (cellV > 9)
cellV = 9;
cellV = 9;
OLED::drawBattery(cellV + 1);
} else
OLED::drawSymbol(15); // Draw the DC Logo
OLED::drawSymbol(15); // Draw the DC Logo
#else
// On TS80 we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show duals
@@ -249,7 +250,7 @@ static void gui_drawBatteryIcon() {
}
static void gui_solderingTempAdjust() {
uint32_t lastChange = xTaskGetTickCount();
currentlyActiveTemperatureTarget = 0;
currentTempTargetDegC = 0;
uint32_t autoRepeatTimer = 0;
uint8_t autoRepeatAcceleration = 0;
for (;;) {
@@ -316,7 +317,7 @@ static void gui_solderingTempAdjust() {
#ifdef MODEL_TS80
if (!OLED::getRotation())
#else
if (OLED::getRotation())
if (OLED::getRotation())
#endif
OLED::print(SymbolMinus);
else
@@ -332,7 +333,7 @@ static void gui_solderingTempAdjust() {
#ifdef MODEL_TS80
if (!OLED::getRotation())
#else
if (OLED::getRotation())
if (OLED::getRotation())
#endif
OLED::print(SymbolPlus);
else
@@ -353,24 +354,23 @@ static int gui_SolderingSleepingMode() {
|| (xTaskGetTickCount() - lastButtonTime < 100))
return 0; // user moved or pressed a button, go back to soldering
#ifdef MODEL_TS100
if (checkVoltageForExit())
if (checkVoltageForExit())
return 1; // return non-zero on error
#endif
if (systemSettings.temperatureInF) {
currentlyActiveTemperatureTarget = ftoTipMeasurement(
currentTempTargetDegC = TipThermoModel::convertFtoC(
min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
} else {
currentlyActiveTemperatureTarget = ctoTipMeasurement(
min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
currentTempTargetDegC = (min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
}
// draw the lcd
uint16_t tipTemp;
if (systemSettings.temperatureInF)
tipTemp = tipMeasurementToF(getTipRawTemp(0));
tipTemp = TipThermoModel::getTipInF();
else
tipTemp = tipMeasurementToC(getTipRawTemp(0));
tipTemp = TipThermoModel::getTipInC();
OLED::clearScreen();
OLED::setCursor(0, 0);
@@ -402,7 +402,7 @@ static int gui_SolderingSleepingMode() {
if (((uint32_t) (xTaskGetTickCount() - lastMovementTime))
> (uint32_t) (systemSettings.ShutdownTime * 60 * 100)) {
// shutdown
currentlyActiveTemperatureTarget = 0;
currentTempTargetDegC = 0;
return 1; // we want to exit soldering mode
}
OLED::refresh();
@@ -494,7 +494,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setFont(0);
uint16_t tipTemp = getTipRawTemp(0);
if (tipTemp > 32700) {
badTipCounter++; // Use a counter so that error has to persist for > 1 second continious so that peak errors dont trip it
badTipCounter++; // Use a counter so that error has to persist for > 1 second continuous so that peak errors dont trip it
} else {
badTipCounter = 0;
}
@@ -502,9 +502,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (systemSettings.detailedSoldering) {
OLED::setFont(1);
OLED::print(SolderingAdvancedPowerPrompt); // Power:
OLED::printNumber(milliWattHistory[0] / 1000, 2);
OLED::printNumber(x10WattHistory.average() / 10, 2);
OLED::print(SymbolDot);
OLED::printNumber(milliWattHistory[0] / 100 % 10, 1);
OLED::printNumber(x10WattHistory.average()% 10, 1);
OLED::print(SymbolWatts);
if (systemSettings.sensitivity && systemSettings.SleepTime) {
@@ -514,6 +514,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString);
//OLED::printNumber(
// TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
gui_drawTipTemp(true);
OLED::print(SymbolSpace);
printVoltage();
@@ -535,14 +538,10 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::print(SymbolSpace);
// Draw heating/cooling symbols
OLED::drawHeatSymbol(
milliWattsToPWM(milliWattHistory[0],
systemSettings.voltageDiv));
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
} else {
// Draw heating/cooling symbols
OLED::drawHeatSymbol(
milliWattsToPWM(milliWattHistory[0],
systemSettings.voltageDiv));
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
// We draw boost arrow if boosting, or else gap temp <-> heat
// indicator
if (boostModeOn)
@@ -560,9 +559,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (badTipCounter > 128) {
OLED::print(BadTipString);
OLED::refresh();
currentlyActiveTemperatureTarget = 0;
currentTempTargetDegC = 0;
waitForButtonPress();
currentlyActiveTemperatureTarget = 0;
currentTempTargetDegC = 0;
return;
}
OLED::refresh();
@@ -570,19 +569,17 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
// Update the setpoints for the temperature
if (boostModeOn) {
if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement(
currentTempTargetDegC = TipThermoModel::convertFtoC(
systemSettings.BoostTemp);
else
currentlyActiveTemperatureTarget = ctoTipMeasurement(
systemSettings.BoostTemp);
currentTempTargetDegC = (systemSettings.BoostTemp);
} else {
if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement(
currentTempTargetDegC = TipThermoModel::convertFtoC(
systemSettings.SolderingTemp);
else
currentlyActiveTemperatureTarget = ctoTipMeasurement(
systemSettings.SolderingTemp);
currentTempTargetDegC = (systemSettings.SolderingTemp);
}
#ifdef MODEL_TS100
@@ -647,11 +644,17 @@ void showDebugMenu(void) {
break;
case 6:
//Raw Tip
OLED::printNumber(getTipRawTemp(0), 6);
{
uint32_t temp = systemSettings.CalibrationOffset;
systemSettings.CalibrationOffset = 0;
OLED::printNumber(
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
systemSettings.CalibrationOffset = temp;
}
break;
case 7:
//Temp in C
OLED::printNumber(tipMeasurementToC(getTipRawTemp(0)), 5);
OLED::printNumber(TipThermoModel::getTipInC(1), 5);
break;
case 8:
//Handle Temp
@@ -707,7 +710,7 @@ void startGUITask(void const *argument __unused) {
gui_solderingMode(1);
}
#if ACCELDEBUG
#ifdef ACCELDEBUG
for (;;) {
HAL_IWDG_Refresh(&hiwdg);
@@ -755,15 +758,14 @@ void startGUITask(void const *argument __unused) {
enterSettingsMenu(); // enter the settings menu
saveSettings();
buttonLockout = true;
setCalibrationOffset(systemSettings.CalibrationOffset); // ensure cal offset is applied
break;
default:
break;
}
currentlyActiveTemperatureTarget = 0; // ensure tip is off
currentTempTargetDegC = 0; // ensure tip is off
getInputVoltageX10(systemSettings.voltageDiv, 0);
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(0));
uint16_t tipTemp = TipThermoModel::getTipInC();
// Preemptively turn the display on. Turn it off if and only if
// the tip temperature is below 50 degrees C *and* motion sleep
@@ -771,9 +773,11 @@ void startGUITask(void const *argument __unused) {
// button presses) in a while.
OLED::setDisplayState(OLED::DisplayState::ON);
if ((tipTemp < 50) && systemSettings.sensitivity &&
(((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) &&
((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
if ((tipTemp < 50) && systemSettings.sensitivity
&& (((xTaskGetTickCount() - lastMovementTime)
> MOVEMENT_INACTIVITY_TIME)
&& ((xTaskGetTickCount() - lastButtonTime)
> BUTTON_INACTIVITY_TIME))) {
OLED::setDisplayState(OLED::DisplayState::OFF);
}
@@ -800,7 +804,7 @@ void startGUITask(void const *argument __unused) {
#ifdef MODEL_TS80
if (!OLED::getRotation()) {
#else
if (OLED::getRotation()) {
if (OLED::getRotation()) {
#endif
OLED::drawArea(12, 0, 84, 16, idleScreenBG);
OLED::setCursor(0, 0);
@@ -821,7 +825,7 @@ void startGUITask(void const *argument __unused) {
#ifdef MODEL_TS80
if (!OLED::getRotation()) {
#else
if (OLED::getRotation()) {
if (OLED::getRotation()) {
#endif
// in right handed mode we want to draw over the first part
OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp

View File

@@ -11,11 +11,11 @@
#include "Translation.h"
#include "cmsis_os.h"
const uint8_t* OLED::currentFont; // Pointer to the current font used for
const uint8_t *OLED::currentFont; // Pointer to the current font used for
// rendering to the buffer
uint8_t* OLED::firstStripPtr; // Pointers to the strips to allow for buffer
uint8_t *OLED::firstStripPtr; // Pointers to the strips to allow for buffer
// having extra content
uint8_t* OLED::secondStripPtr; // Pointers to the strips
uint8_t *OLED::secondStripPtr; // Pointers to the strips
bool OLED::inLeftHandedMode; // Whether the screen is in left or not (used for
// offsets in GRAM)
OLED::DisplayState OLED::displayState;
@@ -81,7 +81,7 @@ void OLED::initialize() {
setDisplayState(DisplayState::ON);
FRToSI2C::Transmit(DEVICEADDR_OLED, &OLED_Setup_Array[0],
sizeof(OLED_Setup_Array));
sizeof(OLED_Setup_Array));
}
/*
@@ -98,7 +98,7 @@ void OLED::drawChar(char c) {
return;
}
uint16_t index = c - 2; //First index is \x02
uint8_t* charPointer;
uint8_t *charPointer;
charPointer = ((uint8_t*) currentFont)
+ ((fontWidth * (fontHeight / 8)) * index);
drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer);
@@ -132,7 +132,7 @@ void OLED::setRotation(bool leftHanded) {
}
// print a string to the current cursor location
void OLED::print(const char* str) {
void OLED::print(const char *str) {
while (str[0]) {
drawChar(str[0]);
str++;
@@ -185,7 +185,14 @@ void OLED::printNumber(uint16_t number, uint8_t places) {
}
buffer[0] = 2 + number % 10;
number /= 10;
//Removing the leading zero's by swapping them to SymbolSpace
for (int i = 0; i < 7; i++) {
if (buffer[i] == 2) {
buffer[i] = SymbolSpace[0];
} else {
break;
}
}
print(buffer);
}
@@ -212,7 +219,7 @@ void OLED::drawSymbol(uint8_t symbolID) {
// Draw an area, but y must be aligned on 0/8 offset
void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
const uint8_t* ptr) {
const uint8_t *ptr) {
// Splat this from x->x+wide in two strides
if (x <= -wide)
return; // cutoffleft

View File

@@ -97,25 +97,23 @@ void resetSettings() {
systemSettings.ShutdownTime =
10; // How many minutes until the unit turns itself off
systemSettings.boostModeEnabled =
1; // Default to having boost mode on as most people prefer itF
1; // Default to having boost mode on as most people prefer it
systemSettings.BoostTemp = 420; // default to 400C
systemSettings.autoStartMode = 0; // Auto start off for safety
systemSettings.coolingTempBlink =
0; // Blink the temperature on the cooling screen when its > 50C
systemSettings.temperatureInF = 0; // default to 0
systemSettings.descriptionScrollSpeed = 0; // default to slow
systemSettings.PID_P = 42; // PID tuning constants
systemSettings.PID_I = 50;
systemSettings.PID_D = 15;
systemSettings.CalibrationOffset = 1400; // the adc offset
systemSettings.customTipGain =
0; // The tip type is either default or a custom gain
#ifdef MODEL_TS100
systemSettings.tipType = TS_B2; // Default to the B2 Tip
systemSettings.CalibrationOffset = 850; // the adc offset in uV
systemSettings.pidPowerLimit=70; // Sets the max pwm power limit
#endif
#ifdef MODEL_TS80
systemSettings.pidPowerLimit=24; // Sets the max pwm power limit
systemSettings.tipType = TS_B02; // Default to the B2 Tip
systemSettings.CalibrationOffset = 300; // the adc offset in uV
#endif
saveSettings(); // Save defaults
}

View File

@@ -136,7 +136,7 @@ static void MX_ADC1_Init(void) {
*/
sConfig.Channel = TMP36_ADC1_CHANNEL;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
/**Configure Regular Channel
@@ -197,11 +197,10 @@ static void MX_ADC2_Init(void) {
*/
sConfig.Channel = TIP_TEMP_ADC2_CHANNEL;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
sConfig.Channel = VIN_ADC2_CHANNEL;
sConfig.Rank = ADC_REGULAR_RANK_2;
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
/**Configure Injected Channel

View File

@@ -0,0 +1,121 @@
/*
* TipThermoModel.cpp
*
* Created on: 7 Oct 2019
* Author: ralim
*/
#include "TipThermoModel.h"
#include "Settings.h"
#include "hardware.h"
/*
* The hardware is laid out as a non-inverting op-amp
* There is a pullup of 39k(TS100) from the +ve input to 3.9V (1M pulup on TS100)
*
* The simplest case to model this, is to ignore the pullup resistors influence, and assume that its influence is mostly constant
* -> Tip resistance *does* change with temp, but this should be much less than the rest of the system.
*
* When a thermocouple is equal temperature at both sides (hot and cold junction), then the output should be 0uV
* Therefore, by measuring the uV when both are equal, the measured reading is the offset value.
* This is a mix of the pull-up resistor, combined with tip manufacturing differences.
*
* All of the thermocouple readings are based on this expired patent
* - > https://patents.google.com/patent/US6087631A/en
*
* This was bought to my attention by <Kuba Sztandera>
*/
// TIP_GAIN = TIP_GAIN/1000 == uV per deg C constant of the tip
#ifdef MODEL_TS100
#define OP_AMP_Rf 750*1000 /*750 Kilo-ohms -> From schematic, R1*/
#define OP_AMP_Rin 2370 /*2.37 Kilo-ohms -> From schematic, R2*/
#define TIP_GAIN 405
#else
#define OP_AMP_Rf 180*1000 /*180 Kilo-ohms -> From schematic, R6*/
#define OP_AMP_Rin 2000 /*2.0 Kilo-ohms -> From schematic, R3*/
#define TIP_GAIN 115
#endif
#define op_amp_gain_stage (1+(OP_AMP_Rf/OP_AMP_Rin))
uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC) {
// 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; //TODO use ADC Vref to calculate this
// 4096 * 8 readings for full scale
// Convert the input ADC reading back into mV times 10 format.
uint32_t rawInputmVX10 = (rawADC * vddRailmVX10) / (4096 * 8);
uint32_t valueuV = rawInputmVX10 * 100; // shift into uV
//Now to divide this down by the gain
valueuV = (valueuV) / op_amp_gain_stage;
//Remove uV tipOffset
if (valueuV >= systemSettings.CalibrationOffset)
valueuV -= systemSettings.CalibrationOffset;
else
valueuV = 0;
return valueuV;
}
uint32_t TipThermoModel::convertTipRawADCToDegC(uint16_t rawADC) {
return convertuVToDegC(convertTipRawADCTouV(rawADC));
}
uint32_t TipThermoModel::convertTipRawADCToDegF(uint16_t rawADC) {
return convertuVToDegF(convertTipRawADCTouV(rawADC));
}
//Table that is designed to be walked to find the best sample for the lookup
//Extrapolate between two points
// [x1, y1] = point 1
// [x2, y2] = point 2
// x = input value
// output is x's extrapolated y value
int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
int32_t x) {
return y1 + (((((x - x1) * 1000) / (x2 - x1)) * (y2 - y1))) / 1000;
}
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
//based on new measurements, tip is quite linear at 24.9uV per deg C = 2.49 per 0.1C
//
tipuVDelta *= TIP_GAIN;
tipuVDelta /= 10000;
return tipuVDelta;
}
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) {
tipuVDelta *= TIP_GAIN;
tipuVDelta /= 1000;
return ((tipuVDelta * 9) / 50) + 32;
//(Y °C × 9/5) + 32 =Y°F
}
uint32_t TipThermoModel::convertCtoF(uint32_t degC) {
//(Y °C × 9/5) + 32 =Y°F
return 32 + ((degC * 9) / 5);
}
uint32_t TipThermoModel::convertFtoC(uint32_t degF) {
//(Y°F 32) × 5/9 = Y°C
if (degF < 32)
return 0;
return ((degF - 32) * 5) / 9;
}
uint32_t TipThermoModel::getTipInC(bool sampleNow) {
uint32_t currentTipTempInC = TipThermoModel::convertTipRawADCToDegC(
getTipRawTemp(sampleNow));
currentTipTempInC += getHandleTemperature() / 10; //Add handle offset
return currentTipTempInC;
}
uint32_t TipThermoModel::getTipInF(bool sampleNow) {
uint32_t currentTipTempInF = TipThermoModel::convertTipRawADCToDegF(
getTipRawTemp(sampleNow));
currentTipTempInF += convertCtoF(getHandleTemperature() / 10); //Add handle offset
return currentTipTempInF;
}

View File

@@ -0,0 +1,31 @@
/*
* TipThermoModel.h
*
* Created on: 7 Oct 2019
* Author: ralim
*/
#ifndef SRC_TIPTHERMOMODEL_H_
#define SRC_TIPTHERMOMODEL_H_
#include "stdint.h"
#include "hardware.h"
class TipThermoModel {
public:
//These are the main two functions
static uint32_t getTipInC(bool sampleNow=false);
static uint32_t getTipInF(bool sampleNow=false);
static uint32_t convertTipRawADCToDegC(uint16_t rawADC);
static uint32_t convertTipRawADCToDegF(uint16_t rawADC);
//Returns the uV of the tip reading before the op-amp compensating for pullups
static uint32_t convertTipRawADCTouV(uint16_t rawADC);
static uint32_t convertCtoF(uint32_t degC);
static uint32_t convertFtoC(uint32_t degF);
private:
static uint32_t convertuVToDegC(uint32_t tipuVDelta);
static uint32_t convertuVToDegF(uint32_t tipuVDelta);
};
#endif /* SRC_TIPTHERMOMODEL_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@
#include "Translation.h"
#include "cmsis_os.h"
#include "main.hpp"
#include "TipThermoModel.h"
#include "string.h"
extern uint32_t lastButtonTime;
void gui_Menu(const menuitem* menu);
@@ -50,19 +50,11 @@ static void settings_setCoolingBlinkEnabled(void);
static void settings_displayCoolingBlinkEnabled(void);
static void settings_setResetSettings(void);
static void settings_displayResetSettings(void);
static void settings_setTipModel(void);
static void settings_displayTipModel(void);
static void settings_setCalibrate(void);
static void settings_displayCalibrate(void);
static void settings_setCalibrateVIN(void);
static void settings_displayCalibrateVIN(void);
// Calibration Menu
static void calibration_displaySimpleCal(void); // Hot water cal
static void calibration_enterSimpleCal(void);
static void calibration_displayAdvancedCal(void); // two point cal
static void calibration_enterAdvancedCal(void);
// Menu functions
static void settings_displaySolderingMenu(void);
static void settings_enterSolderingMenu(void);
@@ -197,8 +189,6 @@ const menuitem advancedMenu[] = {
settings_displayAdvancedSolderingScreens } }, /* Advanced soldering screen*/
{ (const char*) SettingsDescriptions[13], { settings_setResetSettings }, {
settings_displayResetSettings } }, /*Resets settings*/
{ (const char*) SettingsDescriptions[17], { settings_setTipModel }, {
settings_displayTipModel } }, /*Select tip Model */
{ (const char*) SettingsDescriptions[12], { settings_setCalibrate }, {
settings_displayCalibrate } }, /*Calibrate tip*/
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
@@ -206,13 +196,6 @@ const menuitem advancedMenu[] = {
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
};
const menuitem calibrationMenu[] { { (const char*) SettingsDescriptions[6], {
calibration_enterSimpleCal }, { calibration_displaySimpleCal } },
/* Simple Cal*/
{ (const char*) SettingsDescriptions[6], { calibration_enterAdvancedCal }, {
calibration_displayAdvancedCal } }, /* Advanced Cal */
{ NULL, { NULL }, { NULL } } };
static void printShortDescriptionSingleLine(uint32_t shortDescIndex) {
OLED::setFont(0);
OLED::setCharCursor(0, 0);
@@ -305,7 +288,7 @@ static void settings_displayInputVRange(void) {
printShortDescription(0, 6);
if (systemSettings.cutoutSetting) {
OLED::printNumber(2 + systemSettings.cutoutSetting,1);
OLED::printNumber(2 + systemSettings.cutoutSetting, 1);
OLED::print(SymbolCellCount);
} else {
OLED::print(SymbolDC);
@@ -574,202 +557,41 @@ static void settings_displayResetSettings(void) {
printShortDescription(13, 7);
}
static void settings_setTipModel(void) {
systemSettings.tipType++;
if(systemSettings.tipType==Tip_MiniWare)
systemSettings.tipType++;
#ifdef MODEL_TS100
if(systemSettings.tipType==Tip_Hakko)
systemSettings.tipType++;
#endif
systemSettings.tipType %= (Tip_Custom + 1); // Wrap after custom
}
static void settings_displayTipModel(void) {
printShortDescription(17, 4);
// Print in small text the tip model
OLED::setFont(1);
// set the cursor
// Print the mfg
OLED::setCursor(55, 0);
if (systemSettings.tipType == Tip_Custom) {
OLED::print(TipModelStrings[Tip_Custom]);
} else if (systemSettings.tipType < Tip_MiniWare) {
OLED::print(TipModelStrings[Tip_MiniWare]);
}
#ifdef MODEL_TS100
else if (systemSettings.tipType < Tip_Hakko) {
OLED::print(TipModelStrings[Tip_Hakko]);
}
#endif
OLED::setCursor(55, 8);
if (systemSettings.tipType != Tip_Custom)
OLED::print(TipModelStrings[systemSettings.tipType]);
}
static void calibration_displaySimpleCal(void) {
printShortDescription(18, 5);
}
static void setTipOffset() {
setCalibrationOffset(0); // turn off the current offset
systemSettings.CalibrationOffset = 0;
// If the thermocouple at the end of the tip, and the handle are at
// equalibrium, then the output should be zero, as there is no temperature
// If the thermo-couple at the end of the tip, and the handle are at
// equilibrium, then the output should be zero, as there is no temperature
// differential.
uint32_t offset = 0;
for (uint8_t i = 0; i < 15; i++) {
offset += getTipRawTemp(0);
// cycle through the filter a fair bit to ensure we're stable.
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(SymbolDot);
for (uint8_t x = 0; x < i / 4; x++)
while (systemSettings.CalibrationOffset == 0) {
uint32_t offset = 0;
for (uint8_t i = 0; i < 16; i++) {
offset += getTipRawTemp(1);
// cycle through the filter a fair bit to ensure we're stable.
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(SymbolDot);
OLED::refresh();
osDelay(100);
for (uint8_t x = 0; x < (i / 4); x++)
OLED::print(SymbolDot);
OLED::refresh();
osDelay(100);
}
systemSettings.CalibrationOffset = TipThermoModel::convertTipRawADCTouV(
offset / 16);
}
systemSettings.CalibrationOffset = offset / 15;
// Need to remove from this the ambient temperature offset
uint32_t ambientoffset = getHandleTemperature(); // Handle temp in C x10
ambientoffset *= 100;
ambientoffset /= tipGainCalValue;
systemSettings.CalibrationOffset -= ambientoffset;
setCalibrationOffset(systemSettings.CalibrationOffset); // store the error
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::drawCheckbox(true);
OLED::printNumber(systemSettings.CalibrationOffset, 4);
OLED::refresh();
osDelay(1000);
osDelay(1200);
}
static void calibration_enterSimpleCal(void) {
// User has entered into the simple cal routine
if (userConfirmation(SettingsCalibrationWarning)) {
// User has confirmed their handle is at ambient
// So take the offset measurement
setTipOffset();
// Next we want the user to put the tip into 100C water so we can calculate
// their tip's gain Gain is the m term from rise/run plot of raw readings vs
// (tip-handle) Thus we want to calculate
// ([TipRawHot-TipRawCold])/(ActualHot-HandleHot)-(ActualCold-HandleCold)
// Thus we first need to store ->
// TiprawCold,HandleCold,ActualCold==HandleCold -> RawTipCold
uint32_t RawTipCold = getTipRawTemp(0) * 10;
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::setFont(1);
OLED::print("Please Insert Tip\nInto Boiling Water");
OLED::refresh();
osDelay(200);
waitForButtonPress();
// Now take the three hot measurements
// Assume water is boiling at 100C
uint32_t RawTipHot = getTipRawTemp(0) * 10;
uint32_t HandleTempHot = getHandleTemperature() / 10;
uint32_t gain = (RawTipHot - RawTipCold) / (100 - HandleTempHot);
// Show this to the user
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(YourGainMessage);
OLED::printNumber(gain, 6);
OLED::refresh();
osDelay(2000);
waitForButtonPress();
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(SymbolPlus);
OLED::printNumber(RawTipHot, 8);
OLED::setCursor(0, 8);
OLED::print(SymbolMinus);
OLED::printNumber(RawTipCold, 8);
OLED::refresh();
osDelay(2000);
waitForButtonPress();
}
}
static void calibration_displayAdvancedCal(void) {
printShortDescription(19, 5);
}
static void calibration_enterAdvancedCal(void) {
//Advanced cal
if (userConfirmation(SettingsCalibrationWarning)) {
//User has confirmed their handle is at ambient
//So take the offset measurement
setTipOffset();
//The tip now has a known ADC offset
//Head up until it is at 350C
//Then let the user adjust the gain value until it converges
systemSettings.customTipGain = 160; // start safe and high
bool exit = false;
while (exit == false) {
//Set tip to 350C
setTipType(Tip_Custom, systemSettings.customTipGain);
currentlyActiveTemperatureTarget = ctoTipMeasurement(350);
//Check if user has pressed button to change the gain
ButtonState buttons = getButtonState();
switch (buttons) {
case BUTTON_NONE:
break;
case BUTTON_BOTH:
case BUTTON_B_LONG:
case BUTTON_F_LONG:
exit = true;
break;
case BUTTON_F_SHORT:
systemSettings.customTipGain++;
break;
case BUTTON_B_SHORT: {
systemSettings.customTipGain--;
}
break;
default:
break;
}
if (systemSettings.customTipGain > 200)
systemSettings.customTipGain = 200;
else if (systemSettings.customTipGain <= 100)
systemSettings.customTipGain = 100;
OLED::setCursor(0, 0);
OLED::clearScreen();
OLED::setFont(0);
if (OLED::getRotation())
OLED::print(SymbolMinus);
else
OLED::print(SymbolPlus);
OLED::print(SymbolSpace);
OLED::printNumber(systemSettings.customTipGain, 4);
OLED::print(SymbolSpace);
if (OLED::getRotation())
OLED::print(SymbolPlus);
else
OLED::print(SymbolMinus);
OLED::refresh();
GUIDelay();
}
// Wait for the user to confirm the exit message that the calibration is done
userConfirmation(SettingsCalibrationDone);
}
}
//Provide the user the option to tune their own tip if custom is selected
//If not only do single point tuning as per usual
static void settings_setCalibrate(void) {
if (systemSettings.tipType == Tip_Custom) {
// Two types of calibration
// 1. Basic, idle temp + hot water (100C)
// 2. Advanced, 100C + 350C, we keep PID tracking to a temperature target
return gui_Menu(calibrationMenu);
}
// Else
// Ask user if handle is at the tip temperature
// Any error between handle and the tip will be a direct offset in the control
// loop
else if (userConfirmation(SettingsCalibrationWarning)) {
if (userConfirmation(SettingsCalibrationWarning)) {
// User confirmed
// So we now perform the actual calculation
setTipOffset();

View File

@@ -9,17 +9,7 @@
#include "hardware.h"
#include "history.hpp"
volatile uint16_t PWMSafetyTimer = 0;
volatile int16_t CalibrationTempOffset = 0;
uint16_t tipGainCalValue = 0;
void setTipType(enum TipType tipType, uint8_t manualCalGain) {
if (manualCalGain)
tipGainCalValue = manualCalGain;
else
tipGainCalValue = lookupTipDefaultCalValue(tipType);
}
void setCalibrationOffset(int16_t offSet) {
CalibrationTempOffset = offSet;
}
uint16_t getHandleTemperature() {
// We return the current handle temperature in X10 C
// TMP36 in handle, 0.5V offset and then 10mV per deg C (0.75V @ 25C for
@@ -36,34 +26,6 @@ uint16_t getHandleTemperature() {
result /= 993;
return result;
}
uint16_t tipMeasurementToC(uint16_t raw) {
//((Raw Tip-RawOffset) * calibrationgain) / 1000 = tip delta in CX10
// tip delta in CX10 + handleTemp in CX10 = tip absolute temp in CX10
// Div answer by 10 to get final result
uint32_t tipDelta = ((raw - CalibrationTempOffset) * tipGainCalValue)
/ 1000;
tipDelta += getHandleTemperature();
return tipDelta / 10;
}
uint16_t ctoTipMeasurement(uint16_t temp) {
//[ (temp-handle/10) * 10000 ]/calibrationgain = tip raw delta
// tip raw delta + tip offset = tip ADC reading
int32_t TipRaw = ((temp - (getHandleTemperature() / 10)) * 10000)
/ tipGainCalValue;
TipRaw += CalibrationTempOffset;
return TipRaw;
}
uint16_t tipMeasurementToF(uint16_t raw) {
// Convert result from C to F
return (tipMeasurementToC(raw) * 9) / 5 + 32;
}
uint16_t ftoTipMeasurement(uint16_t temp) {
// Convert the temp back to C from F
return ctoTipMeasurement(((temp - 32) * 5) / 9);
}
uint16_t getTipInstantTemperature() {
uint16_t sum = 0; // 12 bit readings * 8 -> 15 bits
@@ -79,60 +41,15 @@ uint16_t getTipInstantTemperature() {
readings[5] = hadc2.Instance->JDR2;
readings[6] = hadc2.Instance->JDR3;
readings[7] = hadc2.Instance->JDR4;
uint8_t minID = 0, maxID = 0;
for (int i = 0; i < 8; i++) {
if (readings[i] < readings[minID])
minID = i;
else if (readings[i] > readings[maxID])
maxID = i;
sum += readings[i];
}
for (int i = 0; i < 8; i++) {
if (i != maxID)
sum += readings[i];
}
sum += readings[minID]; //Duplicate the min to make up for the missing max value
return sum; // 8x over sample
}
/*
* Loopup table for the tip calibration values for
* the gain of the tip's
* This can be found by line of best fit of TipRaw on X, and TipTemp-handle on
* Y. Then take the m term * 10000
* */
uint16_t lookupTipDefaultCalValue(enum TipType tipID) {
#ifdef MODEL_TS100
switch (tipID) {
case TS_D24:
return 141;
break;
case TS_BC2:
return (133 + 129) / 2;
break;
case TS_C1:
return 133;
break;
case TS_B2:
return 133;
default:
return 132; // make this the average of all
break;
}
#else
switch (tipID) {
case TS_D25:
return 154;
break;
case TS_B02:
return 154;
break;
default:
return 154; // make this the average of all
break;
}
#endif
}
//2 second filter (ADC is PID_TIM_HZ Hz)
history<uint16_t, PID_TIM_HZ*4> rawTempFilter = { { 0 }, 0, 0 };
history<uint16_t, PID_TIM_HZ > rawTempFilter = { { 0 }, 0, 0 };
uint16_t getTipRawTemp(uint8_t refresh) {
if (refresh) {
@@ -333,54 +250,7 @@ void startQC(uint16_t divisor) {
if (QCTries > 10)
QCMode = 0;
}
// Get tip resistance in milliohms
uint32_t calculateTipR() {
static uint32_t lastRes = 0;
if (lastRes)
return lastRes;
// We inject a small current into the front end of the iron,
// By measuring the Vdrop over the tip we can calculate the resistance
// Turn PA0 into an output and drive high to inject (3.3V-0.6)/(6K8+Rtip)
// current PA0->Diode -> 6K8 -> Tip -> GND So the op-amp will amplify the
// small signal across the tip and convert this into an easily read voltage
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET); // Set low first
setTipPWM(0);
vTaskDelay(1);
uint32_t offReading = getTipRawTemp(1);
for (uint8_t i = 0; i < 49; i++) {
vTaskDelay(1); // delay to allow it to stabilize
HAL_IWDG_Refresh(&hiwdg);
offReading += getTipRawTemp(1);
}
// Turn on
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET); // Set hgih
vTaskDelay(1); // delay to allow it too stabilize
uint32_t onReading = getTipInstantTemperature();
for (uint8_t i = 0; i < 49; i++) {
vTaskDelay(1); // delay to allow it to stabilize
HAL_IWDG_Refresh(&hiwdg);
onReading += getTipRawTemp(1);
}
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET); // Turn the output off finally
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
uint32_t difference = onReading - offReading;
// V = IR, therefore I = V/R
// We can divide this reading by a known "gain" to get the resulting
// resistance This was determined emperically This tip is 4.688444162 ohms,
// 4688 milliohms (Measured using 4 terminal measurement) 25x oversampling
// reads this as around 47490 Almost perfectly 10x the milliohms value This
// will drift massively with tip temp However we really only need 10x ohms
lastRes = (difference / 21) + 1; // ceil
return lastRes;
}
static unsigned int sqrt32(unsigned long n) {
unsigned int c = 0x8000;
unsigned int g = 0x8000;
@@ -398,7 +268,7 @@ int16_t calculateMaxVoltage(uint8_t useHP) {
// This measures the tip resistance, then it calculates the appropriate
// voltage To stay under ~18W. Mosfet is "9A", so no issues there
// QC3.0 supports up to 18W, which is 2A @9V and 1.5A @12V
uint32_t milliOhms = calculateTipR();
uint32_t milliOhms = 4500;
// Check no tip
if (milliOhms > 10000)
return -1;
@@ -475,7 +345,6 @@ void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
}
}
void vApplicationIdleHook(void) {
HAL_IWDG_Refresh(&hiwdg);
}

View File

@@ -11,10 +11,10 @@
#include "stdlib.h"
#include "stm32f1xx_hal.h"
#include "string.h"
#include "TipThermoModel.h"
uint8_t PCBVersion = 0;
// File local variables
uint32_t currentlyActiveTemperatureTarget = 0;
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
uint32_t lastMovementTime = 0;
int16_t idealQCVoltage = 0;
// FreeRTOS variables
@@ -41,8 +41,8 @@ void startMOVTask(void const *argument);
// End FreeRTOS
static const int maxPowerIdleTicks = 1000;
static const int powerPulseTicks = 500;
static const int powerPulseMilliWatts = 5000;
static const int powerPulseTicks = 50;
static const int x10PowerPulseWatts = 3;
// Main sets up the hardware then hands over to the FreeRTOS kernel
int main(void) {
@@ -51,7 +51,7 @@ int main(void) {
HAL_Init();
Setup_HAL(); // Setup all the HAL objects
HAL_IWDG_Refresh(&hiwdg);
setTipMilliWatts(0); // force tip off
setTipX10Watts(0); // force tip off
FRToSI2C::init(&hi2c1);
OLED::initialize(); // start up the LCD
OLED::setFont(0); // default to bigger font
@@ -75,9 +75,7 @@ int main(void) {
}
HAL_IWDG_Refresh(&hiwdg);
restoreSettings(); // load the settings from flash
setCalibrationOffset(systemSettings.CalibrationOffset);
setTipType((enum TipType) systemSettings.tipType,
systemSettings.customTipGain); // apply tip type selection
HAL_IWDG_Refresh(&hiwdg);
/* Create the thread(s) */
@@ -112,11 +110,10 @@ void startPIDTask(void const *argument __unused) {
* We take the current tip temperature & evaluate the next step for the tip
* control PWM.
*/
setTipMilliWatts(0); // disable the output driver if the output is set to be off
setTipX10Watts(0); // disable the output driver if the output is set to be off
#ifdef MODEL_TS80
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
#endif
uint8_t rawC = ctoTipMeasurement(101) - ctoTipMeasurement(100); // 1*C change in raw.
#ifdef MODEL_TS80
//Set power management code to the tip resistance in ohms * 10
@@ -125,32 +122,31 @@ void startPIDTask(void const *argument __unused) {
#else
#endif
history<int32_t, 16> tempError = { { 0 }, 0, 0 };
currentlyActiveTemperatureTarget = 0; // Force start with no output (off). If in sleep / soldering this will
// be over-ridden rapidly
history<int32_t, PID_TIM_HZ> tempError = { { 0 }, 0, 0 };
currentTempTargetDegC = 0; // Force start with no output (off). If in sleep / soldering this will
// be over-ridden rapidly
pidTaskNotification = xTaskGetCurrentTaskHandle();
for (;;) {
if (ulTaskNotifyTake(pdTRUE, 2000)) {
// This is a call to block this thread until the ADC does its samples
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
int32_t milliWattsOut = 0;
if (currentlyActiveTemperatureTarget) {
int32_t x10WattsOut = 0;
// Do the reading here to keep the temp calculations churning along
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
if (currentTempTargetDegC) {
// Cap the max set point to 450C
if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) {
if (currentTempTargetDegC > (450)) {
//Maximum allowed output
currentlyActiveTemperatureTarget = ctoTipMeasurement(450);
} else if (currentlyActiveTemperatureTarget > 32400) {
//Cap to max adc reading
currentlyActiveTemperatureTarget = 32400;
currentTempTargetDegC = (450);
}
// Convert the current tip to degree's C
// As we get close to our target, temp noise causes the system
// to be unstable. Use a rolling average to dampen it.
// We overshoot by roughly 1/2 of 1 degree Fahrenheit.
// We overshoot by roughly 1 degree C.
// This helps stabilize the display.
int32_t tError = currentlyActiveTemperatureTarget - rawTemp
+ (rawC / 4);
int32_t tError = currentTempTargetDegC - currentTipTempInC + 1;
tError = tError > INT16_MAX ? INT16_MAX : tError;
tError = tError < INT16_MIN ? INT16_MIN : tError;
tempError.update(tError);
@@ -164,24 +160,17 @@ void startPIDTask(void const *argument __unused) {
// This is necessary because of the temp noise and thermal lag in the system.
// Once we have feed-forward temp estimation we should be able to better tune this.
#ifdef MODEL_TS100
const uint16_t mass = 2020 / 20; // divide here so division is compile-time.
#endif
#ifdef MODEL_TS80
const uint16_t mass = 2020 / 50;
#endif
int32_t milliWattsNeeded = tempToMilliWatts(tempError.average(),
mass);
int32_t x10WattsNeeded = tempToX10Watts(tError);
// tempError.average());
// note that milliWattsNeeded is sometimes negative, this counters overshoot
// from I term's inertia.
milliWattsOut += milliWattsNeeded;
x10WattsOut += x10WattsNeeded;
// I term - energy needed to compensate for heat loss.
// We track energy put into the system over some window.
// Assuming the temp is stable, energy in = energy transfered.
// (If it isn't, P will dominate).
milliWattsOut += milliWattHistory.average();
x10WattsOut += x10WattHistory.average();
// D term - use sudden temp change to counter fast cooling/heating.
// In practice, this provides an early boost if temp is dropping
@@ -191,24 +180,23 @@ void startPIDTask(void const *argument __unused) {
}
#ifdef MODEL_TS80
//If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on
if (((xTaskGetTickCount() - lastPowerPulse) > maxPowerIdleTicks) &&
(milliWattsOut < powerPulseMilliWatts)) {
milliWattsOut = powerPulseMilliWatts;
}
if (((xTaskGetTickCount() - lastPowerPulse) > (maxPowerIdleTicks + powerPulseTicks)) &&
(milliWattsOut >= powerPulseMilliWatts)) {
lastPowerPulse = xTaskGetTickCount();
}
//If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on
if (((xTaskGetTickCount() - lastPowerPulse) > maxPowerIdleTicks) &&
(x10WattsOut < x10PowerPulseWatts)) {
x10WattsOut = x10PowerPulseWatts;
}
if (((xTaskGetTickCount() - lastPowerPulse) > (maxPowerIdleTicks + powerPulseTicks)) &&
(x10WattsOut >= x10PowerPulseWatts)) {
lastPowerPulse = xTaskGetTickCount();
}
#endif
setTipMilliWatts(milliWattsOut);
setTipX10Watts(x10WattsOut);
HAL_IWDG_Refresh(&hiwdg);
} else {
asm("bkpt");
//ADC interrupt timeout
setTipMilliWatts(0);
setTipPWM(0);
}
}
@@ -239,7 +227,7 @@ void startMOVTask(void const *argument __unused) {
int32_t avgx = 0, avgy = 0, avgz = 0;
if (systemSettings.sensitivity > 9)
systemSettings.sensitivity = 9;
#if ACCELDEBUG
#ifdef ACCELDEBUG
uint32_t max = 0;
#endif
Orientation rotation = ORIENTATION_FLAT;
@@ -286,9 +274,9 @@ void startMOVTask(void const *argument __unused) {
osDelay(100); // Slow down update rate
#ifdef MODEL_TS80
if (currentlyActiveTemperatureTarget) {
seekQC(idealQCVoltage, systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop
}
// if (currentlyActiveTemperatureTarget) {
// seekQC(idealQCVoltage, systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop
// }
#endif
}
}

View File

@@ -12,33 +12,30 @@
const uint16_t powerPWM = 255;
const uint16_t totalPWM = 255 + 17; //htim2.Init.Period, the full PWM cycle
history<uint32_t, oscillationPeriod> milliWattHistory = { { 0 }, 0, 0 };
expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory = { 0 };
int32_t tempToMilliWatts(int32_t rawTemp, uint8_t rawC) {
int32_t tempToX10Watts(int32_t rawTemp) {
// mass is in milliJ/*C, rawC is raw per degree C
// returns milliWatts needed to raise/lower a mass by rawTemp
// degrees in one cycle.
int32_t milliJoules = tipMass*10 * (rawTemp / rawC);
int32_t milliJoules = tipMass * rawTemp;
return milliJoules;
}
void setTipMilliWatts(int32_t mw) {
//Enforce Max Watts Limiter # TODO
int32_t output = milliWattsToPWM(mw, systemSettings.voltageDiv , 1);
void setTipX10Watts(int32_t mw) {
int32_t output = X10WattsToPWM(mw, 1);
setTipPWM(output);
uint32_t actualMilliWatts = PWMToMilliWatts(output,
systemSettings.voltageDiv , 0);
uint32_t actualMilliWatts = PWMToX10Watts(output, 0);
milliWattHistory.update(actualMilliWatts);
x10WattHistory.update(actualMilliWatts);
}
int32_t availableW10(uint8_t divisor, uint8_t sample) {
uint32_t availableW10(uint8_t sample) {
//P = V^2 / R, v*v = v^2 * 100
// R = R*10
// P therefore is in V^2*100/R*10 = W*10.
int32_t v = getInputVoltageX10(divisor, sample); // 100 = 10v
int32_t availableWattsX10 = (v * v) / tipResistance;
uint32_t v = getInputVoltageX10(systemSettings.voltageDiv, sample); // 100 = 10v
uint32_t availableWattsX10 = (v * v) / tipResistance;
//However, 100% duty cycle is not possible as there is a dead time while the ADC takes a reading
//Therefore need to scale available milliwats by this
@@ -50,27 +47,26 @@ int32_t availableW10(uint8_t divisor, uint8_t sample) {
return availableWattsX10;
}
uint8_t milliWattsToPWM(int32_t milliWatts, uint8_t divisor, uint8_t sample) {
// Scale input milliWatts to the pwm rate
if (milliWatts < 10) // no pint driving tip
uint8_t X10WattsToPWM(int32_t milliWatts, uint8_t sample) {
// Scale input milliWatts to the pwm range available
if (milliWatts < 1) {
//keep the battery voltage updating the filter
getInputVoltageX10(systemSettings.voltageDiv, sample);
return 0;
}
// if (milliWatts > (int(systemSettings.pidPowerLimit) * 10))
// milliWatts = (int(systemSettings.pidPowerLimit) * 10);
//Calculate desired milliwatts as a percentage of availableW10
int32_t pwm = (powerPWM * milliWatts) / availableW10(divisor, sample);
uint32_t pwm = (powerPWM * milliWatts) / availableW10(sample);
if (pwm > powerPWM) {
pwm = powerPWM; //constrain to max PWM counter, shouldnt be possible, but small cost for safety to avoid wraps
} else if (pwm < 0) { //cannot go negative
pwm = 0;
}
return pwm;
}
int32_t PWMToMilliWatts(uint8_t pwm, uint8_t divisor, uint8_t sample) {
int32_t maxMW = availableW10(divisor, sample); //Get the milliwatts for the max pwm period
int32_t PWMToX10Watts(uint8_t pwm, uint8_t sample) {
uint32_t maxMW = availableW10(sample); //Get the milliwatts for the max pwm period
//Then convert pwm into percentage of powerPWM to get the percentage of the max mw
int32_t res = (pwm * maxMW) / powerPWM;
if (res < 0)
res = 0;
return res;
return (((uint32_t) pwm) * maxMW) / powerPWM;
}

View File

@@ -26,7 +26,7 @@
*
*----------------------------------------------------------------------------
*
* Portions Copyright <20> 2016 STMicroelectronics International N.V. All rights reserved.
* Portions Copyright <20> 2016 STMicroelectronics International N.V. All rights reserved.
* Portions Copyright (c) 2013 ARM LIMITED
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
@@ -462,7 +462,7 @@ const osThreadDef_t os_thread_def_##name = \
#define osThreadStaticDef(name, thread, priority, instances, stacksz, buffer, control) \
const osThreadDef_t os_thread_def_##name = \
{ #name, (thread), (priority), (instances), (stacksz), (buffer), (control) }
{(char*) #name, (thread), (priority), (instances), (stacksz), (buffer), (control) }
#else //configSUPPORT_STATIC_ALLOCATION == 0
#define osThreadDef(name, thread, priority, instances, stacksz) \

View File

@@ -133,7 +133,9 @@ then
checkLastCommand
echo "Cleaning previous builds"
make clean 1>/dev/null
rm -rf Hexfile/ >/dev/null
rm -rf Objects/ >/dev/null
make clean >/dev/null
checkLastCommand
for model in "${BUILD_MODELS[@]}"
@@ -141,9 +143,10 @@ then
for lang in "${BUILD_LANGUAGES[@]}"
do
echo "Building firmware for $model in $lang"
make -j16 lang="$lang" model="$model" 1>/dev/null
make -j lang="$lang" model="$model" >/dev/null
checkLastCommand
rm -rf Objects >/dev/null
checkLastCommand
rm -rf Objects/src 1>/dev/null
done
done
else