Prusa MINI Firmware overview
sim_bed.c File Reference
#include "sim_bed.h"
#include <inttypes.h>
#include <stdlib.h>

Classes

struct  sim_bed_t
 

Functions

void sim_bed_init (void)
 
float sim_bed_cycle (float dt)
 
void sim_bed_set_power (float P)
 

Variables

sim_bed_t sim_bed
 

Function Documentation

◆ sim_bed_init()

void sim_bed_init ( void  )
26  {
27  sim_bed.C = 150.0F; // [J/K] total heat capacity of entire heat block
28  sim_bed.R = 0.8F; // [K/W] absolute thermal resistance between heat block and ambient
29  sim_bed.Cs = 0.2F; // [J/K] total heat capacity of sensor
30  sim_bed.Rs = 50.0F; // [K/W] absolute thermal resistance between sensor and heat block
31  sim_bed.Ta = 298.15F; // [K] ambient temperature
32  sim_bed.T = sim_bed.Ta; // [K] heat block temperature (avg)
33  sim_bed.Ts = sim_bed.T; // [K] sensor temperature (avg)
34  sim_bed.P = 0; // [W] heater power
35 }

◆ sim_bed_cycle()

float sim_bed_cycle ( float  dt)
37  {
38  float E = sim_bed.C * sim_bed.T; //[J] total heat energy stored in heater block
39  float Es = sim_bed.Cs * sim_bed.Ts; //[J] total heat energy stored in sensor
40  float Pl = (sim_bed.T - sim_bed.Ta) / sim_bed.R; //[W] power from heater block to ambient (leakage power)
41  float Ps = (sim_bed.T - sim_bed.Ts) / sim_bed.Rs; //[W] power from heater to sensor
42  float Ed = (sim_bed.P - (Pl + Ps)) * dt; //[J] heater block energy increase
43  float Esd = (Ps * dt); //[J] sensor energy increase
44  E += Ed; //[J] heater block result total heat energy
45  Es += Esd; //[J] sensor result total heat energy
46  sim_bed.T = E / sim_bed.C; //[K] result heater temperature
47  sim_bed.Ts = Es / sim_bed.Cs; //[K] result sensor temperature
48  return sim_bed.Ts;
49 }

◆ sim_bed_set_power()

void sim_bed_set_power ( float  P)
51  {
52  sim_bed.P = P;
53 }
Here is the caller graph for this function:

Variable Documentation

◆ sim_bed

sim_bed_t sim_bed
sim_bed_t::C
float C
Definition: sim_bed.c:12
sim_bed_t::Ta
float Ta
Definition: sim_bed.c:16
sim_bed_t::Rs
float Rs
Definition: sim_bed.c:15
sim_bed
sim_bed_t sim_bed
Definition: sim_bed.c:24
sim_bed_t::P
float P
Definition: sim_bed.c:19
sim_bed_t::R
float R
Definition: sim_bed.c:13
sim_bed_t::T
float T
Definition: sim_bed.c:17
sim_bed_t::Ts
float Ts
Definition: sim_bed.c:18
sim_bed_t::Cs
float Cs
Definition: sim_bed.c:14