Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT Monitoring Module
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
DIOT Monitoring Module
Commits
972b05bc
Commit
972b05bc
authored
Sep 18, 2023
by
Alén Arias Vázquez
😎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added counter to check how many times exceed the TH and request to hydra a reset
parent
494ccbf9
Pipeline
#4871
passed with stage
in 1 minute and 35 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
main.c
main_fw/src/main.c
+34
-4
No files found.
main_fw/src/main.c
View file @
972b05bc
...
...
@@ -53,10 +53,13 @@ static uint16_t fan_ramp_up_count __xMR = 0;
#endif
/* MAX Speed Datasheet: 3600.0 */
#define FAN_MAX_RPMS 4000.0
#define FAN_MAX_RPMS 1500.0
#define FAN_MAX_FAIL_CNT 100
#define FAN_DEAD_WORD 0xFFFF
static
volatile
uint16_t
tacho_cnt
[
3
]
__xMR
;
static
volatile
uint16_t
tacho_rpm
[
3
]
__xMR
;
static
volatile
uint16_t
tacho_rpm_prev
[
3
]
__xMR
;
static
volatile
uint16_t
tacho_rpm_fail_cnt
[
3
]
__xMR
;
// when fan_cmdrpm is 0, setfrpms and temp_curve_points_y represent
// duty cycle (0 to 1000)
...
...
@@ -233,14 +236,22 @@ int16_t sign(int16_t x)
void
__xMR
update_rpm
()
{
// 2 sensor periods = 1 revolution
/* FAN 0 Control */
if
(
fan_installed
[
0
])
{
tacho_rpm
[
0
]
=
60
*
tacho_cnt
[
0
]
/
(
1
+
fan_ppr
[
0
]);
tacho_cnt
[
0
]
=
0
;
if
(
tacho_rpm
[
0
]
<=
FAN_MAX_RPMS
)
{
frpms_lin
[
0
]
=
float_to_linear
(
tacho_rpm
[
0
]);
tacho_rpm_prev
[
0
]
=
tacho_rpm
[
0
];
tacho_rpm_fail_cnt
[
0
]
=
0
;
}
else
{
frpms_lin
[
0
]
=
float_to_linear
(
tacho_rpm_prev
[
0
]);
tacho_rpm_fail_cnt
[
0
]
++
;
if
(
tacho_rpm_fail_cnt
[
0
]
>=
FAN_MAX_FAIL_CNT
)
{
frpms_lin
[
0
]
=
float_to_linear
(
FAN_DEAD_WORD
);
}
else
{
frpms_lin
[
0
]
=
float_to_linear
(
tacho_rpm_prev
[
0
]);
}
tacho_rpm
[
0
]
=
tacho_rpm_prev
[
0
];
}
}
else
{
tacho_rpm
[
0
]
=
0
;
...
...
@@ -248,14 +259,22 @@ void __xMR update_rpm()
frpms_lin
[
0
]
=
float_to_linear
(
0
);
}
/* FAN 1 Control */
if
(
fan_installed
[
1
])
{
tacho_rpm
[
1
]
=
60
*
tacho_cnt
[
1
]
/
(
1
+
fan_ppr
[
1
]);
tacho_cnt
[
1
]
=
0
;
if
(
tacho_rpm
[
1
]
<=
FAN_MAX_RPMS
)
{
frpms_lin
[
1
]
=
float_to_linear
(
tacho_rpm
[
1
]);
tacho_rpm_prev
[
1
]
=
tacho_rpm
[
1
];
tacho_rpm_fail_cnt
[
1
]
=
0
;
}
else
{
frpms_lin
[
1
]
=
float_to_linear
(
tacho_rpm_prev
[
1
]);
tacho_rpm_fail_cnt
[
1
]
++
;
if
(
tacho_rpm_fail_cnt
[
1
]
>=
FAN_MAX_FAIL_CNT
)
{
frpms_lin
[
1
]
=
float_to_linear
(
FAN_DEAD_WORD
);
}
else
{
frpms_lin
[
1
]
=
float_to_linear
(
tacho_rpm_prev
[
1
]);
}
tacho_rpm
[
1
]
=
tacho_rpm_prev
[
1
];
}
}
else
{
tacho_rpm
[
1
]
=
0
;
...
...
@@ -263,14 +282,22 @@ void __xMR update_rpm()
frpms_lin
[
1
]
=
float_to_linear
(
0
);
}
/* FAN 2 Control */
if
(
fan_installed
[
2
])
{
tacho_rpm
[
2
]
=
60
*
tacho_cnt
[
2
]
/
(
1
+
fan_ppr
[
2
]);
tacho_cnt
[
2
]
=
0
;
if
(
tacho_rpm
[
2
]
<=
FAN_MAX_RPMS
)
{
frpms_lin
[
2
]
=
float_to_linear
(
tacho_rpm
[
2
]);
tacho_rpm_prev
[
2
]
=
tacho_rpm
[
2
];
tacho_rpm_fail_cnt
[
2
]
=
0
;
}
else
{
frpms_lin
[
2
]
=
float_to_linear
(
tacho_rpm_prev
[
2
]);
tacho_rpm_fail_cnt
[
2
]
++
;
if
(
tacho_rpm_fail_cnt
[
2
]
>=
FAN_MAX_FAIL_CNT
)
{
frpms_lin
[
2
]
=
float_to_linear
(
FAN_DEAD_WORD
);
}
else
{
frpms_lin
[
2
]
=
float_to_linear
(
tacho_rpm_prev
[
2
]);
}
tacho_rpm
[
2
]
=
tacho_rpm_prev
[
2
];
}
}
else
{
tacho_rpm
[
2
]
=
0
;
...
...
@@ -600,6 +627,9 @@ int main(void)
tacho_rpm_prev
[
0
]
=
0
.
0
;
tacho_rpm_prev
[
1
]
=
0
.
0
;
tacho_rpm_prev
[
2
]
=
0
.
0
;
tacho_rpm_fail_cnt
[
0
]
=
0
;
tacho_rpm_fail_cnt
[
1
]
=
0
;
tacho_rpm_fail_cnt
[
2
]
=
0
;
/* Initializes MCU, drivers and middleware */
atmel_start_init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment