shepherd-core 2025.4.2__py3-none-any.whl → 2025.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. shepherd_core/data_models/__init__.py +2 -0
  2. shepherd_core/data_models/base/content.py +4 -13
  3. shepherd_core/data_models/content/_external_fixtures.yaml +43 -43
  4. shepherd_core/data_models/content/energy_environment.py +2 -2
  5. shepherd_core/data_models/content/virtual_harvester.py +245 -16
  6. shepherd_core/data_models/content/virtual_harvester_fixture.yaml +2 -2
  7. shepherd_core/data_models/content/virtual_source.py +5 -2
  8. shepherd_core/data_models/content/virtual_source_fixture.yaml +3 -3
  9. shepherd_core/data_models/experiment/experiment.py +8 -8
  10. shepherd_core/data_models/experiment/observer_features.py +129 -18
  11. shepherd_core/data_models/experiment/target_config.py +5 -0
  12. shepherd_core/data_models/task/__init__.py +6 -3
  13. shepherd_core/data_models/task/emulation.py +21 -5
  14. shepherd_core/data_models/task/harvest.py +3 -2
  15. shepherd_core/data_models/task/observer_tasks.py +5 -4
  16. shepherd_core/data_models/task/programming.py +3 -1
  17. shepherd_core/data_models/task/testbed_tasks.py +3 -2
  18. shepherd_core/data_models/testbed/cape_fixture.yaml +8 -0
  19. shepherd_core/data_models/testbed/gpio.py +7 -0
  20. shepherd_core/data_models/testbed/mcu_fixture.yaml +4 -4
  21. shepherd_core/data_models/testbed/observer_fixture.yaml +17 -0
  22. shepherd_core/data_models/testbed/target_fixture.yaml +13 -0
  23. shepherd_core/data_models/testbed/testbed_fixture.yaml +11 -0
  24. shepherd_core/data_models/virtual_source_doc.txt +3 -3
  25. shepherd_core/fw_tools/converter.py +6 -3
  26. shepherd_core/fw_tools/validation.py +8 -4
  27. shepherd_core/reader.py +77 -47
  28. shepherd_core/testbed_client/client_abc_fix.py +2 -3
  29. shepherd_core/testbed_client/fixtures.py +15 -17
  30. shepherd_core/testbed_client/user_model.py +3 -6
  31. shepherd_core/version.py +1 -1
  32. shepherd_core/vsource/virtual_harvester_simulation.py +1 -1
  33. shepherd_core/vsource/virtual_source_simulation.py +1 -1
  34. shepherd_core/writer.py +8 -8
  35. {shepherd_core-2025.4.2.dist-info → shepherd_core-2025.5.3.dist-info}/METADATA +1 -1
  36. {shepherd_core-2025.4.2.dist-info → shepherd_core-2025.5.3.dist-info}/RECORD +39 -39
  37. {shepherd_core-2025.4.2.dist-info → shepherd_core-2025.5.3.dist-info}/WHEEL +1 -1
  38. {shepherd_core-2025.4.2.dist-info → shepherd_core-2025.5.3.dist-info}/top_level.txt +0 -0
  39. {shepherd_core-2025.4.2.dist-info → shepherd_core-2025.5.3.dist-info}/zip-safe +0 -0
@@ -31,6 +31,7 @@ from .experiment.observer_features import GpioLevel
31
31
  from .experiment.observer_features import GpioTracing
32
32
  from .experiment.observer_features import PowerTracing
33
33
  from .experiment.observer_features import SystemLogging
34
+ from .experiment.observer_features import UartLogging
34
35
  from .experiment.target_config import TargetConfig
35
36
 
36
37
  __all__ = [
@@ -54,6 +55,7 @@ __all__ = [
54
55
  "ShpModel",
55
56
  "SystemLogging",
56
57
  "TargetConfig",
58
+ "UartLogging",
57
59
  "VirtualHarvesterConfig",
58
60
  "VirtualSourceConfig",
59
61
  "Wrapper",
@@ -1,21 +1,16 @@
1
1
  """Base-Model for all content."""
2
2
 
3
- import hashlib
4
3
  from datetime import datetime
5
4
  from typing import Annotated
6
5
  from typing import Optional
7
- from typing import Union
8
6
  from uuid import uuid4
9
7
 
10
- from pydantic import UUID4
11
8
  from pydantic import Field
12
9
  from pydantic import StringConstraints
13
10
  from pydantic import model_validator
14
11
  from typing_extensions import Self
15
- from typing_extensions import deprecated
16
12
 
17
13
  from .shepherd import ShpModel
18
- from .timezone import local_now
19
14
 
20
15
  # constr -> to_lower=True, max_length=16, regex=r"^[\w]+$"
21
16
  # ⤷ Regex = AlphaNum
@@ -26,24 +21,20 @@ SafeStr = Annotated[str, StringConstraints(pattern=r"^[ -~]+$")]
26
21
  # ⤷ Regex = All Printable ASCII-Characters with Space
27
22
 
28
23
 
29
- @deprecated("use UUID4 instead")
30
24
  def id_default() -> int:
31
25
  """Generate a unique ID - usable as default value.
32
26
 
33
- Note: IdInt has space for 128 bit, so 128/4 = 32 hex-chars
27
+ Note: IdInt in mongoDB can currently handle 8 bytes (16 hex-values)
34
28
  """
35
- time_stamp = str(local_now()).encode("utf-8")
36
- time_hash = hashlib.sha3_224(time_stamp).hexdigest()[-32:]
37
- return int(time_hash, 16)
29
+ return int(uuid4().hex[-15:], 16)
38
30
 
39
31
 
40
32
  class ContentModel(ShpModel):
41
33
  """Base-Model for content with generalized properties."""
42
34
 
43
- # id: UUID4 = Field( # TODO: db-migration - temp fix for documentation
44
- id: Union[UUID4, int] = Field(
35
+ id: int = Field(
45
36
  description="Unique ID",
46
- default_factory=uuid4,
37
+ default_factory=id_default,
47
38
  )
48
39
  name: NameStr
49
40
  description: Annotated[Optional[SafeStr], Field(description="Required when public")] = None
@@ -1,7 +1,7 @@
1
1
  - datatype: EnergyEnvironment
2
- created: 2024-02-25 12:45:58.488609+02:00
2
+ created: 2025-05-12 17:28:39.756999+02:00
3
3
  parameters:
4
- id: 2639560972524229652
4
+ id: 263956097252422
5
5
  name: eenv_static_2000mV_10mA_3600s
6
6
  description: Artificial static Energy Environment, 2000mV, 10mA, 3600s
7
7
  comment: null
@@ -22,9 +22,9 @@
22
22
  indoor: true
23
23
  location: Lab-VSrc
24
24
  - datatype: EnergyEnvironment
25
- created: 2024-02-25 12:45:58.497654+02:00
25
+ created: 2025-05-12 17:28:39.764595+02:00
26
26
  parameters:
27
- id: 9823394105967169626
27
+ id: 98233941059
28
28
  name: eenv_static_2000mV_1mA_3600s
29
29
  description: Artificial static Energy Environment, 2000mV, 1mA, 3600s
30
30
  comment: null
@@ -45,9 +45,9 @@
45
45
  indoor: true
46
46
  location: Lab-VSrc
47
47
  - datatype: EnergyEnvironment
48
- created: 2024-02-25 12:45:58.506739+02:00
48
+ created: 2025-05-12 17:28:39.772144+02:00
49
49
  parameters:
50
- id: 3900615675169501222
50
+ id: 39006156751
51
51
  name: eenv_static_2000mV_50mA_3600s
52
52
  description: Artificial static Energy Environment, 2000mV, 50mA, 3600s
53
53
  comment: null
@@ -68,9 +68,9 @@
68
68
  indoor: true
69
69
  location: Lab-VSrc
70
70
  - datatype: EnergyEnvironment
71
- created: 2024-02-25 12:45:58.515790+02:00
71
+ created: 2025-05-12 17:28:39.779737+02:00
72
72
  parameters:
73
- id: 14796673729431137386
73
+ id: 1479667372943113
74
74
  name: eenv_static_2000mV_5mA_3600s
75
75
  description: Artificial static Energy Environment, 2000mV, 5mA, 3600s
76
76
  comment: null
@@ -91,9 +91,9 @@
91
91
  indoor: true
92
92
  location: Lab-VSrc
93
93
  - datatype: EnergyEnvironment
94
- created: 2024-02-25 12:45:58.524761+02:00
94
+ created: 2025-05-12 17:28:39.787329+02:00
95
95
  parameters:
96
- id: 6648482606607441403
96
+ id: 664848260660744
97
97
  name: eenv_static_3000mV_10mA_3600s
98
98
  description: Artificial static Energy Environment, 3000mV, 10mA, 3600s
99
99
  comment: null
@@ -114,9 +114,9 @@
114
114
  indoor: true
115
115
  location: Lab-VSrc
116
116
  - datatype: EnergyEnvironment
117
- created: 2024-02-25 12:45:58.533513+02:00
117
+ created: 2025-05-12 17:28:39.794922+02:00
118
118
  parameters:
119
- id: 13566000951043177991
119
+ id: 1356600095104317
120
120
  name: eenv_static_3000mV_1mA_3600s
121
121
  description: Artificial static Energy Environment, 3000mV, 1mA, 3600s
122
122
  comment: null
@@ -137,9 +137,9 @@
137
137
  indoor: true
138
138
  location: Lab-VSrc
139
139
  - datatype: EnergyEnvironment
140
- created: 2024-02-25 12:45:58.542278+02:00
140
+ created: 2025-05-12 17:28:39.802410+02:00
141
141
  parameters:
142
- id: 7977778327156610158
142
+ id: 797777832715661
143
143
  name: eenv_static_3000mV_50mA_3600s
144
144
  description: Artificial static Energy Environment, 3000mV, 50mA, 3600s
145
145
  comment: null
@@ -160,9 +160,9 @@
160
160
  indoor: true
161
161
  location: Lab-VSrc
162
162
  - datatype: EnergyEnvironment
163
- created: 2024-02-25 12:45:58.550974+02:00
163
+ created: 2025-05-12 17:28:39.810147+02:00
164
164
  parameters:
165
- id: 4900162978999238419
165
+ id: 490016297899923
166
166
  name: eenv_static_3000mV_5mA_3600s
167
167
  description: Artificial static Energy Environment, 3000mV, 5mA, 3600s
168
168
  comment: null
@@ -183,7 +183,7 @@
183
183
  indoor: true
184
184
  location: Lab-VSrc
185
185
  - datatype: Firmware
186
- created: 2024-02-25 12:45:58.568363+02:00
186
+ created: 2025-05-12 17:28:39.825659+02:00
187
187
  parameters:
188
188
  id: 3000
189
189
  name: msp430_deep_sleep
@@ -198,10 +198,10 @@
198
198
  mcu:
199
199
  id: 1002
200
200
  name: MSP430FR
201
- description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
201
+ description: 16MHz Ultra-Low-Pwr MCU with 256 KB FRAM
202
202
  comment: null
203
203
  platform: MSP430
204
- core: MSP430FR5962
204
+ core: MSP430FR5994
205
205
  prog_protocol: SBW
206
206
  prog_voltage: 3.0
207
207
  prog_datarate: 500000
@@ -211,7 +211,7 @@
211
211
  data_hash: null
212
212
  data_local: false
213
213
  - datatype: Firmware
214
- created: 2024-02-25 12:45:58.578594+02:00
214
+ created: 2025-05-12 17:28:39.834276+02:00
215
215
  parameters:
216
216
  id: 3001
217
217
  name: msp430_spi_fram
@@ -226,10 +226,10 @@
226
226
  mcu:
227
227
  id: 1002
228
228
  name: MSP430FR
229
- description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
229
+ description: 16MHz Ultra-Low-Pwr MCU with 256 KB FRAM
230
230
  comment: null
231
231
  platform: MSP430
232
- core: MSP430FR5962
232
+ core: MSP430FR5994
233
233
  prog_protocol: SBW
234
234
  prog_voltage: 3.0
235
235
  prog_datarate: 500000
@@ -239,7 +239,7 @@
239
239
  data_hash: null
240
240
  data_local: false
241
241
  - datatype: Firmware
242
- created: 2024-02-25 12:45:58.589223+02:00
242
+ created: 2025-05-12 17:28:39.842993+02:00
243
243
  parameters:
244
244
  id: 3002
245
245
  name: msp430_testable
@@ -254,10 +254,10 @@
254
254
  mcu:
255
255
  id: 1002
256
256
  name: MSP430FR
257
- description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
257
+ description: 16MHz Ultra-Low-Pwr MCU with 256 KB FRAM
258
258
  comment: null
259
259
  platform: MSP430
260
- core: MSP430FR5962
260
+ core: MSP430FR5994
261
261
  prog_protocol: SBW
262
262
  prog_voltage: 3.0
263
263
  prog_datarate: 500000
@@ -267,9 +267,9 @@
267
267
  data_hash: null
268
268
  data_local: false
269
269
  - datatype: Firmware
270
- created: 2024-02-25 12:45:58.599274+02:00
270
+ created: 2025-05-12 17:28:39.851412+02:00
271
271
  parameters:
272
- id: 7163917825449888392
272
+ id: 716391782544988
273
273
  name: nrf52_deep_sleep
274
274
  description: practically turned off MCU with the lowest possible consumption
275
275
  comment: null
@@ -282,20 +282,20 @@
282
282
  mcu:
283
283
  id: 1001
284
284
  name: nRF52
285
- description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
285
+ description: MCU with RF, 802.15.4, Bluetooth v5.0, 2.4GHz
286
286
  comment: null
287
287
  platform: nRF52
288
288
  core: nRF52840
289
289
  prog_protocol: SWD
290
290
  prog_voltage: 3.0
291
291
  prog_datarate: 500000
292
- fw_name_default: nrf52_demo_rf
292
+ fw_name_default: nrf52_deep_sleep
293
293
  data: /var/shepherd/content/fw/nes_lab/nrf52_deep_sleep/build.elf
294
294
  data_type: path_elf
295
295
  data_hash: null
296
296
  data_local: false
297
297
  - datatype: Firmware
298
- created: 2024-02-25 12:45:58.609313+02:00
298
+ created: 2025-05-12 17:28:39.859962+02:00
299
299
  parameters:
300
300
  id: 2000
301
301
  name: nrf52_demo_rf
@@ -310,22 +310,22 @@
310
310
  mcu:
311
311
  id: 1001
312
312
  name: nRF52
313
- description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
313
+ description: MCU with RF, 802.15.4, Bluetooth v5.0, 2.4GHz
314
314
  comment: null
315
315
  platform: nRF52
316
316
  core: nRF52840
317
317
  prog_protocol: SWD
318
318
  prog_voltage: 3.0
319
319
  prog_datarate: 500000
320
- fw_name_default: nrf52_demo_rf
320
+ fw_name_default: nrf52_deep_sleep
321
321
  data: /var/shepherd/content/fw/nes_lab/nrf52_demo_rf/build.elf
322
322
  data_type: path_elf
323
323
  data_hash: null
324
324
  data_local: false
325
325
  - datatype: Firmware
326
- created: 2024-02-25 12:45:58.619155+02:00
326
+ created: 2025-05-12 17:28:39.868340+02:00
327
327
  parameters:
328
- id: 3174430733058172825
328
+ id: 317443073305817
329
329
  name: nrf52_rf_survey
330
330
  description: Link Matrix Generator - TX-Unit - sends packet with every possible
331
331
  P_TX, loops until stopped
@@ -339,22 +339,22 @@
339
339
  mcu:
340
340
  id: 1001
341
341
  name: nRF52
342
- description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
342
+ description: MCU with RF, 802.15.4, Bluetooth v5.0, 2.4GHz
343
343
  comment: null
344
344
  platform: nRF52
345
345
  core: nRF52840
346
346
  prog_protocol: SWD
347
347
  prog_voltage: 3.0
348
348
  prog_datarate: 500000
349
- fw_name_default: nrf52_demo_rf
349
+ fw_name_default: nrf52_deep_sleep
350
350
  data: /var/shepherd/content/fw/nes_lab/nrf52_rf_survey/build.elf
351
351
  data_type: path_elf
352
352
  data_hash: null
353
353
  data_local: false
354
354
  - datatype: Firmware
355
- created: 2024-02-25 12:45:58.628815+02:00
355
+ created: 2025-05-12 17:28:39.876819+02:00
356
356
  parameters:
357
- id: 16381936580724580968
357
+ id: 1638193658072458
358
358
  name: nrf52_rf_test
359
359
  description: sends out 1 BLE-Packet per second (verify with an app like 'RaMBLE')
360
360
  comment: null
@@ -367,20 +367,20 @@
367
367
  mcu:
368
368
  id: 1001
369
369
  name: nRF52
370
- description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
370
+ description: MCU with RF, 802.15.4, Bluetooth v5.0, 2.4GHz
371
371
  comment: null
372
372
  platform: nRF52
373
373
  core: nRF52840
374
374
  prog_protocol: SWD
375
375
  prog_voltage: 3.0
376
376
  prog_datarate: 500000
377
- fw_name_default: nrf52_demo_rf
377
+ fw_name_default: nrf52_deep_sleep
378
378
  data: /var/shepherd/content/fw/nes_lab/nrf52_rf_test/build.elf
379
379
  data_type: path_elf
380
380
  data_hash: null
381
381
  data_local: false
382
382
  - datatype: Firmware
383
- created: 2024-02-25 12:45:58.638812+02:00
383
+ created: 2025-05-12 17:28:39.885271+02:00
384
384
  parameters:
385
385
  id: 2002
386
386
  name: nrf52_testable
@@ -396,14 +396,14 @@
396
396
  mcu:
397
397
  id: 1001
398
398
  name: nRF52
399
- description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
399
+ description: MCU with RF, 802.15.4, Bluetooth v5.0, 2.4GHz
400
400
  comment: null
401
401
  platform: nRF52
402
402
  core: nRF52840
403
403
  prog_protocol: SWD
404
404
  prog_voltage: 3.0
405
405
  prog_datarate: 500000
406
- fw_name_default: nrf52_demo_rf
406
+ fw_name_default: nrf52_deep_sleep
407
407
  data: /var/shepherd/content/fw/nes_lab/nrf52_testable/build.elf
408
408
  data_type: path_elf
409
409
  data_hash: null
@@ -15,8 +15,8 @@ from shepherd_core.testbed_client import tb_client
15
15
  class EnergyDType(str, Enum):
16
16
  """Data-Type-Options for energy environments."""
17
17
 
18
- ivsample = ivsamples = "ivsample"
19
- ivcurve = ivcurves = ivsurface = "ivcurve"
18
+ ivtrace = ivsample = ivsamples = "ivsample"
19
+ ivsurface = ivcurve = ivcurves = "ivcurve"
20
20
  isc_voc = "isc_voc"
21
21
 
22
22
 
@@ -24,53 +24,282 @@ class AlgorithmDType(str, Enum):
24
24
  """Options for choosing a harvesting algorithm."""
25
25
 
26
26
  direct = disable = neutral = "neutral"
27
+ """
28
+ Reads an energy environment as is without selecting a harvesting
29
+ voltage.
30
+
31
+ Used to play "constant-power" energy environments or simple
32
+ "on-off-patterns". Generally, not useful for virtual source
33
+ emulation.
34
+
35
+ Not applicable to real harvesting, only emulation with IVTrace / samples.
36
+ """
37
+
27
38
  isc_voc = "isc_voc"
28
- ivcurve = ivcurves = ("ivcurve",)
39
+ """
40
+ Short Circuit Current, Open Circuit Voltage.
41
+
42
+ This is not relevant for emulation, but used to configure recording of
43
+ energy environments.
44
+
45
+ This mode samples the two extremes of an IV curve, which may be
46
+ interesting to characterize a transducer/energy environment.
47
+
48
+ Not applicable to emulation - only recordable during harvest-recording ATM.
49
+ """
50
+
51
+ ivcurve = ivcurves = ivsurface = "ivcurve"
52
+ """
53
+ Used during harvesting to record the full IV surface.
54
+
55
+ When configuring the energy environment recording, this algorithm
56
+ records the IV surface by repeatedly recording voltage and current
57
+ while ramping the voltage.
58
+
59
+ Cannot be used as output of emulation.
60
+ """
61
+
29
62
  constant = cv = "cv"
63
+ """
64
+ Harvest energy at a fixed predefined voltage ('voltage_mV').
65
+
66
+ For harvesting, this records the IV samples at the specified voltage.
67
+ For emulation, this virtually harvests the IV surface at the specified voltage.
68
+
69
+ In addition to constant voltage harvesting, this can be used together
70
+ with the 'feedback_to_hrv' flag to implement a "Capacitor and Diode"
71
+ topology, where the harvesting voltage depends dynamically on the
72
+ capacitor voltage.
73
+ """
74
+
30
75
  # ci .. constant current -> is this desired?
76
+
31
77
  mppt_voc = "mppt_voc"
78
+ """
79
+ Emulate a harvester with maximum power point (MPP) tracking based on
80
+ open circuit voltage measurements.
81
+
82
+ This MPPT heuristic estimates the MPP as a constant ratio of the open
83
+ circuit voltage.
84
+
85
+ Used in conjunction with 'setpoint_n', 'interval_ms', and 'duration_ms'.
86
+ """
87
+
32
88
  mppt_po = perturb_observe = "mppt_po"
89
+ """
90
+ Emulate a harvester with perturb and observe maximum power point
91
+ tracking.
92
+
93
+ This MPPT heuristic adjusts the harvesting voltage by small amounts and
94
+ checks if the power increases. Eventually, the tracking changes the
95
+ direction of adjustments and oscillates around the MPP.
96
+ """
97
+
33
98
  mppt_opt = optimal = "mppt_opt"
99
+ """
100
+ A theoretical harvester that identifies the MPP by reading it from the
101
+ IV curve during emulation.
34
102
 
103
+ Note that this is not possible for real-world harvesting as the system would
104
+ not know the entire IV curve. In that case a very fast and detailed mppt_po is
105
+ used.
106
+ """
35
107
 
36
- class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
37
- """A vHrv makes a source-characterization (i.e. ivcurve) usable for the vSrc.
38
108
 
39
- Mostly used when the file-based energy environment of the virtual source
40
- is not already supplied as pre-harvested ivsample-stream.
109
+ class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
110
+ """The virtual harvester configuration characterizes usage of an energy environment.
111
+
112
+ It is used to both harvesting during emulation and to record
113
+ energy environments (sometimes referred to as "harvesting traces").
114
+
115
+ For emulation:
116
+
117
+ The virtual harvester configuration describes how energy from a recorded
118
+ energy environment is harvested. Typically, the energy environment provides
119
+ an IV-surface, which is a continuous function in three dimensions: voltage,
120
+ current, and time. Based on this surface, the emulation can derive the
121
+ available IV-curve at each point in time. The harvester looks up the current
122
+ that is available (according to the energy environment) from a given
123
+ harvesting voltage. The harvesting voltage may be dynamically chosen by the
124
+ harvester based on the implemented harvesting algorithm, which models
125
+ different real-world harvesters. For example, a maximum power point tracking
126
+ harvester may choose a harvesting voltage as a ratio of the open circuit
127
+ voltage available from the energy environment (or transducer in practice).
128
+
129
+ The energy environments are encoded not as a three-dimensional function, but
130
+ as IV tuples over time (sampled at a constant frequency). This originates
131
+ from the technical implementation when recording the IV-surface, where the
132
+ recorder provides the IV-curve by measuring the current for a given voltage
133
+ and ramping the voltage from minimal to maximum.
134
+
135
+ For harvest-recordings:
136
+
137
+ An energy environment is fully described by the IV surface, which are IV
138
+ curves over time. Shepherd approximates this by sampling the current at
139
+ equidistant steps of a voltage ramp. The VirtualHarvesterConfig is also used
140
+ to parameterize the recording process, typically, it should be configured to
141
+ record a full IV surface, as this contains the full information of the energy
142
+ environment. The postponed harvesting is then performed during emulation.
143
+
144
+ However, it is also possible to record a "pre-harvested" energy environment
145
+ by performing the harvesting during recording. This results in a recording
146
+ containing IV samples over time that represent the harvesting voltage
147
+ (chosen by the virtual harvester during recording) and the current available
148
+ from the energy environment for that voltage. Together, these represent the
149
+ power available for harvesting at the time, and during emulation, this power
150
+ can be converted by the input stage (boost converter) to charge the energy
151
+ storage.
41
152
  """
42
153
 
43
154
  # General Metadata & Ownership -> ContentModel
44
155
 
45
156
  algorithm: AlgorithmDType
46
- # used to harvest energy
157
+ """The algorithm determines how the harvester chooses the harvesting voltage.
158
+ """
47
159
 
48
160
  samples_n: Annotated[int, Field(ge=8, le=2_000)] = 8
49
- # for & of ivcurve (and more?`)
161
+ """How many IV samples are measured for one IV curve.
162
+
163
+ The curve is recorded by measuring the el. current available from the
164
+ transducer at equidistant voltage intervals. These voltages are
165
+ probed by ramping between `voltage_min_mV` and `voltage_max_mV` at
166
+ `samples_n` points equally distributed over the voltage range. After
167
+ setting the voltage, the recorder waits for a short period - allowing
168
+ the analog frontend and transducer to settle - before recording the
169
+ harvesting current. This wait duration is influenced by
170
+ `wait_cycles`.
171
+
172
+ Selecting all these parameters is a tradeoff between accuracy of the IV
173
+ curve (density of IV samples) and measurement duration, hence the time
174
+ accuracy (density of points) of the IV-surface.
175
+
176
+ Only applicable to recording, not used in emulation.
177
+
178
+ Used together with `voltage_min_mV`, `voltage_max_mV`, `rising`, and
179
+ `wait_cycles`.
180
+ """
50
181
 
51
182
  voltage_mV: Annotated[float, Field(ge=0, le=5_000)] = 2_500
52
- # starting-point for some algorithms (mppt_po)
183
+ """The harvesting voltage for constant voltage harvesting.
184
+
185
+ Additionally, for Perturb-and-Observe MPPT, this defines the voltage at
186
+ startup.
187
+ """
188
+
53
189
  voltage_min_mV: Annotated[float, Field(ge=0, le=5_000)] = 0
190
+ """Minimum voltage recorded for the IV curve.
191
+
192
+ See `samples_n` for further details.
193
+
194
+ In emulation, this can be used to "block" parts of the recorded IV curve
195
+ and not utilize them in the virtual source. However, this is generally
196
+ discouraged as it can result in discontinuities in the curve and is not
197
+ well tested.
198
+ For emulation, this value ideally corresponds to the value of the
199
+ recorded energy environment.
200
+ """
201
+
54
202
  voltage_max_mV: Annotated[float, Field(ge=0, le=5_000)] = 5_000
203
+ """Maximum voltage sampled for the curve.
204
+
205
+ See `voltage_min_mV` and `samples_n`.
206
+ """
207
+
55
208
  current_limit_uA: Annotated[float, Field(ge=1, le=50_000)] = 50_000
56
- # ⤷ allows to keep trajectory in special region (or constant current tracking)
57
- # boundary for detecting open circuit in emulated version (working on IV-Curves)
209
+ """
210
+ For MPPT VOC, the open circuit voltage is identified as the el. current
211
+ crosses below this threshold.
212
+
213
+ During recording it allows to keep trajectory in special region
214
+ (constant current tracking).
215
+ """
216
+
58
217
  voltage_step_mV: Optional[Annotated[float, Field(ge=1, le=1_000_000)]] = None
218
+ """The difference between two adjacent voltage samples.
219
+
220
+ This value is implicitly derived from the other ramp parameters:
221
+ (voltage_max_mV - voltage_min_mV) / (samples_n - 1)
222
+ """
59
223
 
60
224
  setpoint_n: Annotated[float, Field(ge=0, le=1.0)] = 0.70
61
- # ⤷ ie. for mppt_voc
225
+ """
226
+ The "Open Circuit Voltage Maximum Power Point Tracker" estimates the MPP
227
+ by taking a constant fraction defined by this parameter of the open
228
+ circuit voltage. For example, if the IV curve shows an open circuit
229
+ voltage of 2V and the setpoint is 0.75, then the harvester selects
230
+ 1.5 volts as the harvesting voltage.
231
+
232
+ This value is only relevant when 'algorithm == mppt_voc'.
233
+ """
234
+
62
235
  interval_ms: Annotated[float, Field(ge=0.01, le=1_000_000)] = 100
63
- # between start of measurements (ie. V_OC)
236
+ """The MPP is repeatedly estimated at fixed intervals defined by this duration.
237
+
238
+ Note that the energy environment can still change in between MPP
239
+ estimations, but the harvesting voltage is not updated in between.
240
+
241
+ This value is relevant for all MPP algorithms.
242
+ For Perturb and Observe, this value is the wait interval between steps.
243
+
244
+ When an energy environment is recorded with `mppt_opt`, the optimal
245
+ harvester is approximated with a very fast Perturb-Observe algorithm,
246
+ where this interval should be set to a very small value.
247
+ When emulating with `mppt_opt`, this value is not relevant as the
248
+ emulation simply picks the maximum power point from the IV-curve.
249
+ """
250
+
64
251
  duration_ms: Annotated[float, Field(ge=0.01, le=1_000_000)] = 0.1
65
- # of (open voltage) measurement
252
+ """The duration of MPP sampling.
253
+
254
+ While performing an MPP sampling every 'interval_ms', the input is
255
+ disconnected to accurately measure the open circuit voltage.
256
+
257
+ This value is only relevant for `mppt_voc`.
258
+ """
259
+
66
260
  rising: bool = True
67
- # direction of sawtooth
261
+ """Ramp direction for sampling the IV curve.
262
+
263
+ When set to true, sampling starts at the minimum voltage and ramps up to
264
+ the maximum.
265
+
266
+ See `samples_n` for further details.
267
+ Not relevant for emulation.
268
+ """
269
+
68
270
  enable_linear_extrapolation: bool = True
69
- # ⤷ improves slow cv-algo that is base of most ivcurve-harvesters
70
- # (update-freq dependent on window-size)
271
+ """
272
+ Because the IV curve is not stored fully in PRU memory but streamed
273
+ sequentially to the PRU, looking up any IV value at any time is not
274
+ possible. However, because the precision of the emulation degrades
275
+ until the relevant IV sample passes by, it can extrapolate the available data
276
+ to estimate the required IV sample.
277
+
278
+ Enabling extrapolation can yield a better numeric simulation, especially
279
+ if the harvesting voltage changes rapidly or the IV surface is steep in
280
+ relevant regions. For example, when emulating a capacitor diode
281
+ setup and the current falls at high voltages.
282
+
283
+ This value is only relevant for emulation.
284
+ """
71
285
 
72
286
  # Underlying recorder
73
287
  wait_cycles: Annotated[int, Field(ge=0, le=100)] = 1
288
+ """
289
+ The wait duration to let the analog frontend settle before taking a
290
+ measurement.
291
+
292
+ When recording the energy environment, the voltage is set by the
293
+ digital-to-analog-converter. This parameter delays the current
294
+ measurement performed by the analog-to-digital converter to allow the
295
+ harvesting transducer to settle at the defined voltage.
296
+
297
+ When recording with `IscVoc`, wait cycles should be added as the analog
298
+ changes are more significant.
299
+
300
+ Not relevant for emulation.
301
+ """
302
+
74
303
  # ⤷ first cycle: ADC-Sampling & DAC-Writing, further steps: waiting
75
304
 
76
305
  @model_validator(mode="before")
@@ -21,7 +21,7 @@
21
21
  parameters:
22
22
  id: 1100
23
23
  name: ivcurve
24
- description: Postpone harvesting by sampling ivcurves (voltage stepped as sawtooth-wave)
24
+ description: Postpone harvesting by sampling ivsurface / curves (voltage stepped as sawtooth-wave)
25
25
  comment: ~110 Hz, Between 50 & 60 Hz line-frequency to avoid standing waves
26
26
  inherit_from: neutral
27
27
  algorithm: ivcurve
@@ -36,7 +36,7 @@
36
36
  - datatype: VirtualHarvesterConfig
37
37
  parameters:
38
38
  id: 1101
39
- name: ivcurves # synonym
39
+ name: ivsurface # synonym
40
40
  inherit_from: ivcurve
41
41
 
42
42
  - datatype: VirtualHarvesterConfig