Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SolderStationMk2_SW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flax
SolderStationMk2_SW
Commits
55015040
Commit
55015040
authored
1 year ago
by
Flax
Browse files
Options
Downloads
Patches
Plain Diff
STM32L011K4 : Added temperature regulation (draft).
parent
126b6819
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SolderStationMk2_NucleoSTM32L011K4/Core/Inc/register.h
+9
-0
9 additions, 0 deletions
SolderStationMk2_NucleoSTM32L011K4/Core/Inc/register.h
SolderStationMk2_NucleoSTM32L011K4/Core/Src/temperatureRegulation.c
+55
-11
55 additions, 11 deletions
...ionMk2_NucleoSTM32L011K4/Core/Src/temperatureRegulation.c
with
64 additions
and
11 deletions
SolderStationMk2_NucleoSTM32L011K4/Core/Inc/register.h
+
9
−
0
View file @
55015040
...
...
@@ -101,4 +101,13 @@
#define mREGInputsENC2ExtiEnableIT() (LL_EXTI_EnableIT_0_31(mREGInputsENC1ExtiLine))
#define mREGInputsENC2ExtiClearFlag() (LL_EXTI_ClearFlag_0_31(mREGInputsENC1ExtiLine))
/* ADC --------------------------------------------------------*/
#define mREGAdcHandle ADC1
#define mREGAdcStartConversion() (LL_ADC_REG_StartConversion(mREGAdcHandle))
#define mREGAdcStopConversion() (LL_ADC_REG_StopConversion(mREGAdcHandle))
#define mREGAdcReadValue() (LL_ADC_REG_ReadConversionData12(mREGAdcHandle))
/* PWM --------------------------------------------------------*/
#define mREGPwmSetCompareValue(val) (LL_TIM_OC_SetCompareCH1(TIM2, (uint32_t)val))
#endif
/* INC_REGISTER_H_ */
This diff is collapsed.
Click to expand it.
SolderStationMk2_NucleoSTM32L011K4/Core/Src/temperatureRegulation.c
+
55
−
11
View file @
55015040
...
...
@@ -11,6 +11,7 @@
// Local includes
// ==============
#include
"temperatureRegulation.h"
#include
"register.h"
// ===============
// Local constants
...
...
@@ -18,22 +19,31 @@
#define cREGTempSPTMax (400U)
#define cREGTempSPTMin (50U)
#define cREGPwmMax (65535)
#define cRegPIDProp (10)
#define cRegPIDInteg (10)
#define cRegPIDDeriv (10)
// ===============
// Local variables
// ===============
bool
RegOffState_B
;
bool
RegStandbyState_B
;
bool
RegErrorState_B
;
static
bool
RegOffState_B
;
static
bool
RegStandbyState_B
;
static
bool
RegErrorState_B
;
uint16_t
RegTempSPT_U16
;
uint16_t
RegTempMeas_U16
;
static
uint16_t
RegTempSPT_U16
;
static
uint16_t
RegTempMeas_U16
[
2U
];
static
uint16_t
RegTempMeasBuffer_U16A
[
2U
];
static
int32_t
RegPwmDyc_S32
;
static
uint32_t
RegPwmDyc_U32
;
// PID
static
int32_t
RegEpsilon_S32A
[
2U
];
// ==========================
// Local functions prototypes
// ==========================
static
void
RegGetInputs
(
void
);
static
void
RegUpdate
(
void
);
static
void
RegSetOutputs
(
void
);
// ===========================
// Local functions definitions
...
...
@@ -51,17 +61,51 @@ void REGInit (void)
void
REGStart
(
void
)
{
mREGAdcStartConversion
();
}
void
REGStop
(
void
)
{
mREGAdcStopConversion
();
}
void
REGCyclicTask
(
void
)
{
uint8_t
cnt_u8
;
// Read ADC input
RegTempMeasBuffer_U16A
[
1
]
=
mREGAdcReadValue
();
// Calculate average
RegTempMeasBuffer_U16A
[
0
]
+=
RegTempMeasBuffer_U16A
[
1
];
RegTempMeasBuffer_U16A
[
0
]
>>
1U
;
RegTempMeas_U16
[
1
]
=
RegTempMeas_U16
[
0
];
// Memorise previous value
RegTempMeas_U16
[
0
]
=
RegTempMeasBuffer_U16A
[
0
];
// PID
RegEpsilon_S32A
[
1
]
=
RegEpsilon_S32A
[
0
];
// Memorise previous value
RegEpsilon_S32A
[
0
]
=
RegTempSPT_U16
-
RegTempMeas_U16
[
0
];
RegPwmDyc_S32
=
(
RegEpsilon_S32A
[
0
]
*
cRegPIDProp
)
+
((
RegEpsilon_S32A
[
0
]
-
RegEpsilon_S32A
[
1
])
*
cRegPIDDeriv
)
+
(((
RegEpsilon_S32A
[
0
]
+
RegEpsilon_S32A
[
1
])
>>
1U
)
*
cRegPIDInteg
);
// Only keep positive values
if
(
RegPwmDyc_S32
>
0
)
{
RegPwmDyc_U32
=
RegPwmDyc_S32
;
}
else
if
(
RegPwmDyc_S32
<
(
uint32_t
)
cREGPwmMax
)
{
RegPwmDyc_U32
=
(
uint32_t
)
cREGPwmMax
;
}
else
{
RegPwmDyc_U32
=
0U
;
}
// Set PWM output duty cycle
mREGPwmSetCompareValue
(
RegPwmDyc_U32
);
}
bool
REGIsError
(
void
)
...
...
@@ -122,5 +166,5 @@ uint16_t REGSPTGet (void)
uint16_t
REGTempGet
(
void
)
{
return
RegTempMeas_U16
;
return
RegTempMeas_U16
[
0
]
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment