Electronic Load  1.0
Programmable Constant Current Sink
config.h
Go to the documentation of this file.
1 
20 #ifndef CONFIG_H_
21 #define CONFIG_H_
22 
23 #include <stdbool.h>
24 #include <stdio.h>
25 #include "eload.h"
26 
27 #define CONF_MAGIC 0x0151
28 
29 // Definition of the Resistors according to the Schematics
30 #define R12 8200.0
31 #define R13 2200.0
32 #define R16 120000.0
33 #define R18 1000.0
34 #define R23 0.1
35 #define R25 3.3
36 
37 #define SPIVREF (2.5/(R12+R13)*R13)
38 #define SPIADCVOLTSPERLSB (SPIVREF/65536)
39 #define SPIDIFFVOLTSPERLSB (SPIADCVOLTSPERLSB/R18*(R16+R18))
40 #define SPIHIGHAMPSPERLSB (SPIADCVOLTSPERLSB/R23)
41 #define SPILOWAMPSPERLSB (SPIADCVOLTSPERLSB/R25)
42 
43 // Presets in A
44 #define PRESET0 0.0
45 #define PRESET1 0.001
46 #define PRESET2 0.0015
47 #define PRESET3 0.005
48 #define PRESET4 0.01
49 #define PRESET5 0.05
50 #define PRESET6 0.1
51 #define PRESET7 0.5
52 #define PRESET8 1.0
53 #define PRESET9 4.0
54 
55 /*#define SOA_PMAX 80.0 ///< The maximum allowable Power Dissipation
56 #define SOA_V2 25.0 ///< The Voltage at the upper Margin of const Pv
57 #define SOA_IMAX 4.0 ///< The absolute maximum Current
58 #define SOA_I2 3.2 ///< The Current at the upper Margin of const Pv
59 #define SOA_I3 0.35 ///< The allowable Current at 60V*/
60 #define SOA_PMAX 80.0
61 #define SOA_V2 25.0
62 #define SOA_IMAX 4.0
63 #define SOA_I2 3.2
64 #define SOA_I3 0.35
65 #define TEMP_MAX 80
66 
67 typedef struct
68 {
69  uint8_t tempMax;
70  double pMax;
71  double v2;
72  double iMax;
73  double i2;
74  double i3;
75 } soa_t;
76 
82 typedef struct
83 { uint16_t magic;
84  uint8_t LCDV0;
85  uint8_t LCDBright;
86  double P5VoltsPerLSB;
87  double P12VoltsPerLSB;
89  uint8_t backlightOnTime;
90  double preset[10];
97  #ifdef USE_RTS
98  uint8_t useRts;
99  #endif
100 } confStruct_t;
101 extern bool configDirty;
102 
109 typedef struct
110 { double Rlow;
111  double Rhigh;
112  double RchanP;
113  double dacHighAdj;
114  double rangeHighLimit;
115  double rangeLowLimit;
116  double VImax;
117  double SBa;
118  double SBb;
120 
121 extern confStruct_t config;
123 extern void ReadConfig(void);
124 extern void WriteConfig(void);
125 extern void DumpConfigSignal(uint8_t number);
126 extern void DumpConfig(void);
127 extern double SOAGetImax(double v);
128 
129 #endif /* CONFIG_H_ */
double i2
Current Limit for Pv-Area (3.5A for TIP102)
Definition: config.h:73
double DACHighAmpsPerLSB
Amperes per LSB in High Current Range.
Definition: config.h:95
double dacHighAdj
A factor considering RchanP.
Definition: config.h:113
uint8_t tempMax
Definition: config.h:69
void WriteConfig(void)
Writes the Config-Struct to EEPROM.
Definition: config.c:148
double i3
Current Limit for 60V (350mA for TIP102)
Definition: config.h:74
Holds all Configuration Data stored in EEPROM.
Definition: config.h:82
void DumpConfigSignal(uint8_t number)
double rangeLowLimit
Below this Current, Eload switches to low current Range.
Definition: config.h:115
volatileConfStruct_t volatileConfig
Configuration Values that can be calculated.
Definition: config.c:38
Definition: config.h:67
double iMax
The absolute maximum Current. Eload will not allow currents more than this.
Definition: config.h:72
uint8_t LCDV0
Control Voltage for LCD Contrast.
Definition: config.h:84
double Rhigh
Value of the Sense Resistor for High Current Range.
Definition: config.h:111
double ADCHighAmpsPerLSB
Amperes per LSB in High Current Range.
Definition: config.h:92
double pMax
Up to this Voltage, 4A are allowable (20V for TIP102)
Definition: config.h:70
double SBa
Definition: config.h:117
double Rlow
Value of the Sense Resistor for Low Current Range.
Definition: config.h:110
void DumpConfig(void)
Lists the current configuration values.
Definition: config.c:186
double VImax
Maximum Voltage at IMax.
Definition: config.h:116
uint16_t magic
Used to discover unprogrammed Devices.
Definition: config.h:83
double DACLowAmpsPerLSB
Amperes per LSB in Low Current Range.
Definition: config.h:94
These values will be calculated by ReadConfig() and/or on-the-fly by measurement.
Definition: config.h:109
bool configDirty
Set to true by routines affecting configuration if config memory needs to be saved to the EEPROM.
Definition: config.c:116
double SBb
Definition: config.h:118
confStruct_t config
The Configuration. It is read on startup from the EEPROM.
Definition: config.c:37
double rangeHighLimit
Above this Current, Eload switches to high current Range.
Definition: config.h:114
bool backlightAlwaysOn
True if the Backlight should stay on forever.
Definition: config.h:88
double P5VoltsPerLSB
Calibration Value for 5V.
Definition: config.h:86
void ReadConfig(void)
Reads the Config-Struct from EEPROM into config.
Definition: config.c:125
double ADCDiffVoltsPerLSB
Volts per LSB for differential Voltage measurement.
Definition: config.h:93
double ADCLowAmpsPerLSB
Amperes per LSB in Low Current Range.
Definition: config.h:91
double RchanP
Calculated Channel Resistance of the FET shorting Rhigh || Rhigh.
Definition: config.h:112
uint8_t backlightOnTime
Time the Backlight will stay on after Key Press in Seconds.
Definition: config.h:89
uint8_t LCDBright
LCD Brightness.
Definition: config.h:85
soa_t soa
The Safe Operating Area.
Definition: config.h:96
double P12VoltsPerLSB
Calibration Value for Unreg.
Definition: config.h:87
double v2
Voltage Limit for Pv-Area (25V for TIP102)
Definition: config.h:71
double SOAGetImax(double v)
Calculate maximum allowable Current at a given Voltage.
Definition: config.c:165