-
Notifications
You must be signed in to change notification settings - Fork 0
/
KalmanBlock.mdl
executable file
·611 lines (611 loc) · 17.1 KB
/
KalmanBlock.mdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
Model {
Name "KalmanBlock"
Version 5.0
SaveDefaultBlockParams on
SampleTimeColors off
LibraryLinkDisplay "none"
WideLines off
ShowLineDimensions off
ShowPortDataTypes off
ShowLoopsOnError on
IgnoreBidirectionalLines off
ShowStorageClass off
ExecutionOrder off
RecordCoverage off
CovPath "/"
CovSaveName "covdata"
CovMetricSettings "dw"
CovNameIncrementing off
CovHtmlReporting on
covSaveCumulativeToWorkspaceVar on
CovSaveSingleToWorkspaceVar on
CovCumulativeVarName "covCumulativeData"
CovCumulativeReport off
DataTypeOverride "UseLocalSettings"
MinMaxOverflowLogging "UseLocalSettings"
MinMaxOverflowArchiveMode "Overwrite"
BlockNameDataTip off
BlockParametersDataTip off
BlockDescriptionStringDataTip off
ToolBar on
StatusBar on
BrowserShowLibraryLinks off
BrowserLookUnderMasks off
Created "Wed Apr 23 13:52:17 2003"
UpdateHistory "UpdateHistoryNever"
ModifiedByFormat "%<Auto>"
LastModifiedBy "Praveen"
ModifiedDateFormat "%<Auto>"
LastModifiedDate "Fri Apr 25 15:37:00 2003"
ModelVersionFormat "1.%<AutoIncrement:27>"
ConfigurationManager "None"
SimParamPage "Solver"
LinearizationMsg "none"
Profile off
ParamWorkspaceSource "MATLABWorkspace"
AccelSystemTargetFile "accel.tlc"
AccelTemplateMakefile "accel_default_tmf"
AccelMakeCommand "make_rtw"
TryForcingSFcnDF off
ExtModeMexFile "ext_comm"
ExtModeBatchMode off
ExtModeTrigType "manual"
ExtModeTrigMode "normal"
ExtModeTrigPort "1"
ExtModeTrigElement "any"
ExtModeTrigDuration 1000
ExtModeTrigHoldOff 0
ExtModeTrigDelay 0
ExtModeTrigDirection "rising"
ExtModeTrigLevel 0
ExtModeArchiveMode "off"
ExtModeAutoIncOneShot off
ExtModeIncDirWhenArm off
ExtModeAddSuffixToVar off
ExtModeWriteAllDataToWs off
ExtModeArmWhenConnect on
ExtModeSkipDownloadWhenConnect off
ExtModeLogAll on
ExtModeAutoUpdateStatusClock on
BufferReuse on
RTWExpressionDepthLimit 5
SimulationMode "normal"
Solver "ode45"
SolverMode "Auto"
StartTime "0.0"
StopTime "0.1"
MaxOrder 5
MaxStep "auto"
MinStep "auto"
MaxNumMinSteps "-1"
InitialStep "auto"
FixedStep "auto"
RelTol "1e-3"
AbsTol "auto"
OutputOption "RefineOutputTimes"
OutputTimes "[]"
Refine "1"
LoadExternalInput off
ExternalInput "[t, u]"
LoadInitialState off
InitialState "xInitial"
SaveTime on
TimeSaveName "tout"
SaveState off
StateSaveName "xout"
SaveOutput on
OutputSaveName "yout"
SaveFinalState off
FinalStateName "xFinal"
SaveFormat "Array"
Decimation "1"
LimitDataPoints on
MaxDataPoints "1000"
SignalLoggingName "sigsOut"
ConsistencyChecking "none"
ArrayBoundsChecking "none"
AlgebraicLoopMsg "warning"
BlockPriorityViolationMsg "warning"
MinStepSizeMsg "warning"
InheritedTsInSrcMsg "warning"
DiscreteInheritContinuousMsg "warning"
MultiTaskRateTransMsg "error"
SingleTaskRateTransMsg "none"
CheckForMatrixSingularity "none"
IntegerOverflowMsg "warning"
Int32ToFloatConvMsg "warning"
ParameterDowncastMsg "error"
ParameterOverflowMsg "error"
ParameterPrecisionLossMsg "warning"
UnderSpecifiedDataTypeMsg "none"
UnnecessaryDatatypeConvMsg "none"
VectorMatrixConversionMsg "none"
InvalidFcnCallConnMsg "error"
SignalLabelMismatchMsg "none"
UnconnectedInputMsg "warning"
UnconnectedOutputMsg "warning"
UnconnectedLineMsg "warning"
SfunCompatibilityCheckMsg "none"
RTWInlineParameters off
BlockReductionOpt on
BooleanDataType on
ConditionallyExecuteInputs on
ParameterPooling on
OptimizeBlockIOStorage on
ZeroCross on
AssertionControl "UseLocalSettings"
ProdHWDeviceType "Microprocessor"
ProdHWWordLengths "8,16,32,32"
RTWSystemTargetFile "grt.tlc"
RTWTemplateMakefile "grt_default_tmf"
RTWMakeCommand "make_rtw"
RTWGenerateCodeOnly off
RTWRetainRTWFile off
TLCProfiler off
TLCDebug off
TLCCoverage off
TLCAssertion off
BlockDefaults {
Orientation "right"
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
NamePlacement "normal"
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
ShowName on
}
BlockParameterDefaults {
Block {
BlockType ComplexToMagnitudeAngle
Output "Magnitude and angle"
}
Block {
BlockType Constant
Value "1"
VectorParams1D on
ShowAdditionalParam off
OutDataTypeMode "Inherit from 'Constant value'"
OutDataType "sfix(16)"
ConRadixGroup "Use specified scaling"
OutScaling "2^0"
}
Block {
BlockType Demux
Outputs "4"
DisplayOption "none"
BusSelectionMode off
}
Block {
BlockType Inport
Port "1"
PortDimensions "-1"
SampleTime "-1"
ShowAdditionalParam off
LatchInput off
DataType "auto"
OutDataType "sfix(16)"
OutScaling "2^0"
SignalType "auto"
SamplingMode "auto"
Interpolate on
}
Block {
BlockType Outport
Port "1"
OutputWhenDisabled "held"
InitialOutput "[]"
}
Block {
BlockType Product
Inputs "2"
Multiplication "Element-wise(.*)"
ShowAdditionalParam off
InputSameDT on
OutDataTypeMode "Same as first input"
OutDataType "sfix(16)"
OutScaling "2^0"
LockScale off
RndMeth "Floor"
SaturateOnIntegerOverflow on
}
Block {
BlockType RealImagToComplex
Input "Real and imag"
ConstantPart "0"
}
Block {
BlockType "S-Function"
FunctionName "system"
PortCounts "[]"
SFunctionModules "''"
}
Block {
BlockType SubSystem
ShowPortLabels on
Permissions "ReadWrite"
RTWSystemCode "Auto"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
SimViewingDevice off
DataTypeOverride "UseLocalSettings"
MinMaxOverflowLogging "UseLocalSettings"
}
}
AnnotationDefaults {
HorizontalAlignment "center"
VerticalAlignment "middle"
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
}
LineDefaults {
FontName "Helvetica"
FontSize 9
FontWeight "normal"
FontAngle "normal"
}
System {
Name "KalmanBlock"
Location [6, 102, 1018, 716]
Open on
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
ReportName "simulink-default.rpt"
Block {
BlockType SubSystem
Name "Recursive Kalman Filter Block"
Ports [1, 3]
Position [400, 267, 510, 343]
BackgroundColor "lightBlue"
TreatAsAtomicUnit off
MaskType "Kalman Block"
MaskDescription "Measures the Phasor voltage values using the Ka"
"lman filter. \nThe input to the block is 'Zs(n)', the signal at time nT. 'f' "
"is the fundamental frequency of the signal, and the harmonics are assumed to "
"be integral multiple of this.\n'C' is the ralationship between voltage and ph"
"asor values. The default value is [1,0,1] assuming zero imaginary component a"
"nd non-zero DC component.\nMeasurement noise variance 'sigman' models the noi"
"se during the voltage measurement.\nProcess variance 'sigmav' denotes the var"
"iation in the measurement of voltage values. \n'M' denotes the single step va"
"riation\nDecaying DC component models the decreasing nature of the DC."
MaskPromptString "Fundamental Frequency of Input Signal (f) in Hz"
"|Sampling Frequency (Fs) in samples per second|Initial State (x0)|Voltage-Pha"
"sor relation matrix (C)|Measurement Noise Variance (Sigma n)|Process noise va"
"riance (Sigma v)|Single step transition error covariance (M)|Decaying DC Para"
"meter (lambda)"
MaskStyleString "edit,edit,edit,edit,edit,edit,edit,edit"
MaskTunableValueString "on,on,on,on,on,on,on,on"
MaskCallbackString "|||||||"
MaskEnableString "on,on,on,on,on,on,on,on"
MaskVisibilityString "on,on,on,on,on,on,on,on"
MaskToolTipString "on,on,on,on,on,on,on,on"
MaskVarAliasString ",,,,,,,"
MaskVariables "f=@1;Fs=@2;X0=@3;C=@4;sigman=@5;sigmav=@6;M=@7;"
"lambda=@8;"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
MaskValueString "60|32|[0;0;0]|[1 0 1]|0.01|0.005|[(0.24^2) 0 0;"
"0 (0.24^2) 0;0 0 (0.24^2)]|1000"
System {
Name "Recursive Kalman Filter Block"
Location [6, 94, 1018, 716]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
Block {
BlockType Inport
Name "Zs"
Position [215, 203, 245, 217]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
}
Block {
BlockType SubSystem
Name "Filter Module"
Ports [1, 3]
Position [520, 160, 630, 260]
BackgroundColor "lightBlue"
Priority "2"
TreatAsAtomicUnit off
System {
Name "Filter Module"
Location [2, 74, 1014, 724]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
Block {
BlockType Inport
Name "Zs"
Position [215, 213, 245, 227]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
}
Block {
BlockType ComplexToMagnitudeAngle
Name "Complex to\nMagnitude-Angle"
Ports [1, 2]
Position [540, 138, 570, 167]
Output "Magnitude and angle"
}
Block {
BlockType Demux
Name "Demux"
Ports [1, 3]
Position [385, 201, 390, 239]
BackgroundColor "black"
ShowName off
Outputs "3"
}
Block {
BlockType "S-Function"
Name "Kalman Filter"
Ports [1, 1]
Position [270, 180, 355, 260]
BackgroundColor "[0.686275, 0.823529, 0.960784]"
Priority "2"
FontName "Arial"
FontSize 11
FontWeight "bold"
FunctionName "kfamp"
Parameters "X0 C M"
MaskType "Kalman Filter Block"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
}
Block {
BlockType Product
Name "Product1"
Ports [2, 1]
Position [655, 205, 700, 240]
ShowAdditionalParam on
InputSameDT off
}
Block {
BlockType Constant
Name "Rad2Degrees"
Position [545, 215, 575, 245]
Value "180/pi"
}
Block {
BlockType RealImagToComplex
Name "Real-Imag to\nComplex"
Ports [2, 1]
Position [465, 138, 495, 167]
Input "Real and imag"
}
Block {
BlockType Outport
Name "Signal Amplitude"
Position [750, 138, 780, 152]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
}
Block {
BlockType Outport
Name "Phase Value"
Position [755, 218, 785, 232]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
Port "2"
}
Block {
BlockType Outport
Name "DC Amplitude"
Position [755, 263, 785, 277]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
Port "3"
}
Line {
SrcBlock "Zs"
SrcPort 1
DstBlock "Kalman Filter"
DstPort 1
}
Line {
SrcBlock "Kalman Filter"
SrcPort 1
DstBlock "Demux"
DstPort 1
}
Line {
SrcBlock "Demux"
SrcPort 1
Points [20, 0; 0, -65]
DstBlock "Real-Imag to\nComplex"
DstPort 1
}
Line {
SrcBlock "Demux"
SrcPort 2
Points [40, 0; 0, -60]
DstBlock "Real-Imag to\nComplex"
DstPort 2
}
Line {
SrcBlock "Demux"
SrcPort 3
Points [15, 0; 0, 40]
DstBlock "DC Amplitude"
DstPort 1
}
Line {
SrcBlock "Product1"
SrcPort 1
DstBlock "Phase Value"
DstPort 1
}
Line {
SrcBlock "Real-Imag to\nComplex"
SrcPort 1
DstBlock "Complex to\nMagnitude-Angle"
DstPort 1
}
Line {
SrcBlock "Complex to\nMagnitude-Angle"
SrcPort 1
DstBlock "Signal Amplitude"
DstPort 1
}
Line {
SrcBlock "Rad2Degrees"
SrcPort 1
DstBlock "Product1"
DstPort 2
}
Line {
SrcBlock "Complex to\nMagnitude-Angle"
SrcPort 2
Points [35, 0; 0, 55]
DstBlock "Product1"
DstPort 1
}
}
}
Block {
BlockType SubSystem
Name "Parameter Calculation Module"
Ports [1, 1]
Position [285, 161, 475, 259]
BackgroundColor "lightBlue"
Priority "1"
FontName "Arial"
FontSize 11
TreatAsAtomicUnit off
MaskDisplay "disp('PARAMETER MODULE');\nport_label('inpu"
"t',1,'Zs in');\nport_label('output',1,'Zs out');"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
System {
Name "Parameter Calculation Module"
Location [2, 98, 1014, 720]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
Block {
BlockType Inport
Name "Zs In"
Position [355, 228, 385, 242]
BackgroundColor "[1.000000, 0.176471, 0.176471]"
}
Block {
BlockType "S-Function"
Name "Kalman Parameter Block"
Ports []
Position [415, 165, 536, 193]
BackgroundColor "[0.686275, 0.823529, 0.960784]"
Priority "1"
FontName "Arial"
FontSize 11
FontWeight "bold"
FunctionName "KalmanParameters"
Parameters "Fs f sigman sigmav M lambda"
}
Block {
BlockType Outport
Name "Zs Out"
Position [565, 228, 595, 242]
BackgroundColor "[1.000000, 0.176471, 0.176471]"
}
Line {
SrcBlock "Zs In"
SrcPort 1
DstBlock "Zs Out"
DstPort 1
}
}
}
Block {
BlockType Outport
Name "Amplitude"
Position [675, 168, 705, 182]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
}
Block {
BlockType Outport
Name "Phase"
Position [675, 203, 705, 217]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
Port "2"
}
Block {
BlockType Outport
Name "DC Amplitude"
Position [680, 238, 710, 252]
BackgroundColor "[0.980392, 0.647059, 0.447059]"
Port "3"
}
Line {
SrcBlock "Zs"
SrcPort 1
DstBlock "Parameter Calculation Module"
DstPort 1
}
Line {
SrcBlock "Parameter Calculation Module"
SrcPort 1
DstBlock "Filter Module"
DstPort 1
}
Line {
SrcBlock "Filter Module"
SrcPort 1
DstBlock "Amplitude"
DstPort 1
}
Line {
SrcBlock "Filter Module"
SrcPort 3
DstBlock "DC Amplitude"
DstPort 1
}
Line {
SrcBlock "Filter Module"
SrcPort 2
DstBlock "Phase"
DstPort 1
}
}
}
Annotation {
Name "Recursive Kalman Filter Library Element"
Position [448, 102]
BackgroundColor "orange"
DropShadow on
FontName "Arial Black"
FontSize 16
}
}
}