forked from SDI-SoftwareDefinedInverter/TAPAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTAPASstartV1_0.py
More file actions
618 lines (545 loc) · 28.3 KB
/
TAPASstartV1_0.py
File metadata and controls
618 lines (545 loc) · 28.3 KB
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
612
613
614
615
616
617
618
#!/usr/bin/python3
###################################################################################################
## SDI TAPAS python demo application - main module
##
## Revisions:
## 1.0 - Initial version
##
## Copyright (c) 2017 Siemens AG
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###################################################################################################
# import for platform check
import platform
# modules for spi communication
import spidev
import TAPASComm
# other modules for data handling
import struct
import json
# modules for implementing user interface
import curses
import time
# global constants
RATED_CURRENT_RUN = 2.5
SERVO_MOTOR = "1"
MODEL_MOTOR = "2"
###
# this function is necessary for running the script on IOT2000 platform
# exporting gpio file
def export_gpio ():
export = "/sys/class/gpio/export"
file = open(export, 'w')
file.write("10")
if (platform.machine() == "i586"):
export_gpio()
###
# defining the names for the states of Controller-state-machine, estimator and custom user errors
_CTRL_states_ = ["CTRL_State_Error","CTRL_State_Idle","CTRL_State_OffLine","CTRL_State_OnLine","CTRL_numStates","CTRL_State_unknown"]
_EST_states_ = ["EST_State_Error","EST_State_Idle","EST_State_RoverL","EST_State_Rs","EST_State_RampUp","EST_State_IdRated",
"EST_State_RatedFlux_OL","EST_State_RatedFlux","EST_StateRampDown","EST_StateLockRotor","EST_State_Ls","EST_State_Rr",
"EST_State_MotorIdentified","EST_State_OnLine","EST_numStates","EST_State_unknown"]
_PROTECT_states_ = ["Normal_OP", "PROTECT_OVERTEMP", "PROTECT_OVERCURRENT", "PROTECT_UNKNOWN"]
# start application
# set title of terminal window
title = "SDI TAPAS BOARD QUICK START"
print("\x1b]2;%s\x07" % title)
# initialize SPI-HW
spi = spidev.SpiDev()
if (platform.machine() == "i586"):
# open spi connection on IOT2040
spi.open(1,0)
else :
# e.g. for raspberry pi zero (w)
spi.open(0,0)
spi.bits_per_word = 8
spi.mode = 3
#initialize "curses"-module for console management
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
###
# this one is not executable on the iot2040
if not (platform.machine() == "i586"):
# e.g. raspberry pi lib supports this
curses.curs_set(False)
###
stdscr.keypad(1)
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_WHITE)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_WHITE)
curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_WHITE)
stdscr.bkgd(curses.color_pair(1))
stdscr.refresh()
win = curses.newwin(40, 85, 1, 2)
win.bkgd(curses.color_pair(2))
win.box()
# init variables
callNo = 0
RoverLestFrequencyHz = 0.0
fluxEstFrequency = 0.0
motorParametersSet = 0
motorIsIdentified = 0
# init table for CRC
TAPASComm.GenerateCrcTable()
# synchronize the communication with the slave
syncStatus = 0
SPIstatusTest = 0
countTransactionsSuccess = 0
win.addstr(1,2, "Connecting to slave...")
win.refresh()
try :
while syncStatus != 1:
ret = TAPASComm.transferMasterSlave(spi,0,
1,0.0,
10.0,10.0,
0.0,0.0)
if(ret["spi connection status"] == 1):
countTransactionsSuccess += 1
if((ret["spi status slave"] == 0xABCD) and (countTransactionsSuccess > 15)):
syncStatus = 1
else:
syncStatus = 0
else:
syncStatus = 0
except KeyboardInterrupt :
win.addstr(10,5, "User abort of connection procedure...", curses.A_BOLD)
win.refresh()
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
spi.close()
time.sleep(1.5)
quit()
# when sync is done
# -> start the interactive part
try:
while True:
# clear screen and print buffer
win.erase()
win.box()
win.addstr(1, 2, "SDI TAPAS BOARD QUICK START - MAIN MENU", curses.A_BOLD)
win.addstr(2, 2, "##########################################################################")
win.addstr(3, 2, "please choose one of the following options:")
win.addstr(4, 2, "1 : set basic motor parameters")
win.addstr(5, 2, "2 : identify motor")
win.addstr(6, 2, "3 : run motor")
win.addstr(7, 2, "4 : disable inverter")
win.addstr(8, 2, "5 : disable inverter and quit")
win.addstr(9, 2, "##########################################################################")
# print to the terminal-screen
win.refresh()
# evaluate user input for mode selection
selectedMode = chr(stdscr.getch(11,4))
if selectedMode == "1" :
curses.echo()
# get rough motor parameters
win.erase()
win.refresh()
win.box()
win.addstr(1, 2, "SDI TAPAS BOARD QUICK START - SET BASIC MOTOR PARAMETERS",curses.A_BOLD)
win.addstr(2, 2, "###################################################")
#win.addstr(3, 2,"Please enter a few motor parameters neccessary to start the identification", curses.A_BOLD)
# get the number of pole pairs for the connected motor
win.addstr(5,2,"a)Number of motor pole pairs", curses.A_DIM)
win.addstr(6,4,"2", curses.color_pair(4))
win.refresh()
polePairsInputSucc = 0
while(polePairsInputSucc == 0):
try :
# read in number of pole pairs and convert to int format
polePairs = stdscr.getstr(7,6)
polePairs = int(polePairs)
polePairsInputSucc = 1
except ValueError:
win.addstr(6,2, " ")
win.addstr(7,5 , "! ERROR: Invalid input, please retry !", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
polePairsInputSucc = 0
win.addstr(7,2,"--> Motor has " + str(polePairs) + " pole pairs ")
win.refresh()
# get rated current for the connected motor
win.addstr(9,2,"b) Enter maximum rated motor current [A] ", curses.A_DIM)
win.addstr(10,4, "4", curses.color_pair(4))
win.refresh()
currentInputSucc = 0
while(currentInputSucc == 0):
try :
ratedCurrent = stdscr.getstr(11, 6)
ratedCurrent = float(ratedCurrent)
currentInputSucc = 1
except ValueError:
win.addstr(10,2, " ")
win.addstr(11,5 , "! ERROR: Your input was invalid, please retry !", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
currentInputSucc = 0
win.addstr(11,2,"--> Rated motor current " + str(ratedCurrent) + " [A]")
win.refresh()
win.addstr(13,2,"c) Motor type:", curses.A_DIM)
win.addstr(14,4, " 1 - servo motor (does it look gray and serious)", curses.A_DIM)
win.addstr(15,4, " 2 - hobbyist motor (for models and rc toys)", curses.A_DIM)
win.addstr(16,4, "1", curses.color_pair(4))
win.refresh()
# get motor type
motorTypeInputSucc = 0
while(motorTypeInputSucc == 0):
try :
motorType = chr(stdscr.getch(17, 6))
if motorType == SERVO_MOTOR:
win.addstr(17, 2, "--> Selected a servo motor ")
win.refresh()
RoverLestFrequencyHz = 150.0
fluxEstFrequency = 50.0
motorParametersSet = 1
motorTypeInputSucc = 1
elif motorType == MODEL_MOTOR:
win.addstr(17, 2, "--> Selected a hobbyist motor ")
win.refresh()
RoverLestFrequencyHz = 300.0
fluxEstFrequency = 30.0
motorParametersSet = 1
motorTypeInputSucc = 1
else:
win.addstr(16,2, " ")
win.addstr(17, 6, "! --> invalid selection, choose either 1 or 2 !", curses.A_BOLD)
win.refresh()
motorParametersSet = 0
motorTypeInputSucc = 0
except ValueError:
win.addstr(16,2, " ")
win.addstr(17,5 , "! ERROR: Invalid input, please retry !", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
motorTypeInputSucc = 0
curses.noecho()
time.sleep(1.5)
elif selectedMode == "2" :
# start id
if(not motorParametersSet == 1) :
win.erase()
win.refresh()
win.box()
win.addstr(10, 10, "ERROR: ", curses.color_pair(3))
win.addstr(11,5,"! you have to set the motor parameters first !", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
else :
Senden_flags = 1
for i in range(0,4):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
1.0,1.0)
Senden_flags = 3 # set run and identify bits
runConfiguration = 0
try :
while ((ret["flags"] & (1 << 5)) == 0):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
1.0,1.0)
# monitor the CTRL_state index
if(ret["controller state [CTRL_state]"] > 4):
ret["controller state [CTRL_state]"] = 5
# monitor the EST_state index
if(ret["estimator state [EST_state]"] > 14):
ret["estimator state [EST_state]"] = 15
# check the TAPAS-slave for a protection error
if(ret["Protection mode"] != 0):
Senden_flags = 0
motorIsIdentified = 0
if(ret["Protection mode"] > 2) :
ret["Protection mode"] = 3
win.erase()
win.refresh()
win.box()
win.addstr(10,10, "ERROR!", curses.color_pair(3))
win.addstr(11, 5, "SDI TAPAS-Board reported an " + str(_PROTECT_states_[int(ret["Protection mode"])]) + "!", curses.color_pair(3))
win.addstr(12, 5, "Restart identification to continue")
win.refresh()
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0 , 0.0)
time.sleep(1.5)
break
win.erase()
win.box()
win.addstr(1, 2, " SDI TAPAS BOARD QUICK START - MOTOR IDENTIFICATION ", curses.A_BOLD)
win.addstr(2, 2, "###################################################")
win.addstr(3, 2, "--------------current SDI TAPAS-board data-------------")
win.addstr(4, 2, "* Protection mode..............: " + _PROTECT_states_[ret["Protection mode"]])
win.addstr(5, 2, "* dc-bus voltage...............: " + str(round((ret["dc-bus voltage"]*1000.0),2)))
win.addstr(5, 43, " [V] ")
win.addstr(6, 2, "* dc-bus current...............: " + str(round((ret["dc-bus current"]),2)))
win.addstr(6, 43, " [A] ")
win.addstr(7, 2, "* dc-bus power.................: " + str(round(((ret["dc-bus voltage"]*1000.0)*ret["dc-bus current"]),2)))
win.addstr(7, 43, " [W] ")
win.addstr(8, 2, "* board-temperature............: " + str(round((ret["board-temperature"]),2)))
win.addstr(8, 43, " [C] ")
win.addstr(9, 2, "* motor speed..................: " + str(round((ret["motor speed"]*1000.0),2)))
win.addstr(9, 43, " [rpm] ")
win.addstr(10,2, "* controller state [CTRL_state]: " + _CTRL_states_[int(ret["controller state [CTRL_state]"])])
win.addstr(11,2, "* estimator state [EST_state]..: " + _EST_states_[int(ret["estimator state [EST_state]"])])
win.addstr(12,2, "------------identified motor parameters------------")
win.addstr(13,2, "* motorRs......................: " + str(round(ret["motorRs"],7)))
win.addstr(13,43, " [Ohm] ")
win.addstr(14,2, "* motorRr......................: " + str(round(ret["motorRr"],7)))
win.addstr(14,43, " [Ohm] ")
win.addstr(15,2, "* motorLsd.....................: " + str(round(ret["motorLsd"],7)))
win.addstr(15,43, " [Henry] ")
win.addstr(16,2, "* motorLsq.....................: " + str(round(ret["motorLsq"],7)))
win.addstr(16,43, " [Henry] ")
win.addstr(17,2, "* ratedFlux....................: " + str(round(ret["ratedFlux"],7)))
win.addstr(17,43, " [V/Hz] ")
win.addstr(18,2, "---------------------------------------------------")
if(ret["spi connection status"] == 1) :
win.addstr(19,6, " checksum correct - data valid ")
else :
win.addstr(19,6, "!!checksum incorrect - data invalid!!", curses.color_pair(3))
win.addstr(20,2, "###################################################")
win.addstr(22,2, "Identifying connected motor - please wait ...", curses.A_BOLD)
win.addstr(24,4, "ABORT WITH CTRL-C", curses.color_pair(3))
win.refresh()
time.sleep(0.2)
ratedCurrent = RATED_CURRENT_RUN
Senden_flags = 1 # system remains enabled
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0 , 0.0)
win.addstr(22, 2, " ")
win.addstr(22, 2, "Motor identification successful", curses.color_pair(1))
win.addstr(23, 4, "Please press <s> to save the identified motor ")
win.addstr(24, 4, "parameters to file or any other key to quit without saving ")
win.refresh()
# save or not save ?
sel = chr(stdscr.getch(28,4))
motorIsIdentified = 1
if(sel == 's'):
json.dump(ret, open("yourMotorParams.json","w") )
except KeyboardInterrupt:
Senden_flags = 0
motorParametersSet = 0
motorIsIdentified = 0
ratedCurrent = 0.0
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0 , 0.0)
win.erase()
win.box()
win.refresh()
win.addstr(10,10, "HINT:", curses.A_BOLD)
win.addstr(11, 5, "User canceled motor identification, disabling inverter", curses.color_pair(3))
win.addstr(12, 5, "Enter motor parameters again - see (1)", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
elif selectedMode == "3" :
if(motorIsIdentified != 1):
win.erase()
win.refresh()
win.box()
win.addstr(10,10, "ERROR: ", curses.color_pair(3))
win.addstr(11,5, "Identify motor first - see (2)! ", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
else:
Senden_flags = 3
curses.echo()
# get setpoint for the maximum acceleration
win.erase()
win.box()
win.addstr(1,2,"SDI TAPAS BOARD QUICK START - RUN MOTOR", curses.A_BOLD)
win.addstr(2, 2, "###################################################")
win.addstr(3,2,"a) Set maximum acceleration in [rpm/s]")
win.addstr(4,4,"100.0", curses.color_pair(4))
win.refresh()
getMaxAccSucc = 0
while(getMaxAccSucc == 0):
try:
win.addstr(16,5," ")
win.refresh()
setMaxAcc = stdscr.getstr(5, 6)
setMaxAcc = float(setMaxAcc)
if(setMaxAcc > 1500.0):
setMaxAcc = 1500
win.addstr(5,6, "HINT: Acceleration limited to 1500 rpm/s for security reasons", curses.A_BOLD)
win.refresh()
setMaxAcc /= 1000.0
getMaxAccSucc = 1
except ValueError:
win.addstr(4, 1, " ")
win.addstr(16,5 , "ERROR: invalid input, please retry", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
getMaxAccSucc = 0
# get setpoint for the motor speed
win.addstr(7,2,"b) Set speed [rpm] ")
win.addstr(8,4,"200", curses.color_pair(4))
win.refresh()
getSpeedSucc = 0
while(getSpeedSucc == 0):
try:
win.addstr(16,5," ")
win.refresh()
setSpeed = stdscr.getstr(9, 6)
setSpeed = float(setSpeed)
setSpeed /= 1000.0
getSpeedSucc = 1
except ValueError:
win.addstr(8, 1, " ")
win.addstr(16, 5, "ERROR: Invalid input, please retry", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
getSpeedSucc = 0
win.addstr(10 ,6," -> Your acceleration : " + str(setMaxAcc*1000.0) + " [rpm/s]")
win.addstr(11 ,6," -> Your motor speed : " + str(setSpeed*1000.0) + " [rpm]")
win.addstr(12 ,6," -> To stop observing values, hit Ctrl-C")
win.refresh()
time.sleep(1.0)
curses.noecho()
readData = 1
ratedCurrent = RATED_CURRENT_RUN
try :
while readData:
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
float(setSpeed),float(setMaxAcc))
# monitor the CTRL_state index
if(ret["controller state [CTRL_state]"] > 4):
ret["controller state [CTRL_state]"] = 5
# monitor the EST_state index
if(ret["estimator state [EST_state]"] > 14):
ret["estimator state [EST_state]"] = 15
# check the TAPAS-slave for a protection error
if(ret["Protection mode"] != 0):
if(ret["Protection mode"] > 2) :
ret["Protection mode"] = 3
Senden_flags = 0
motorIsIdentified = 0
win.erase()
win.refresh()
win.box()
win.addstr(10, 10, "ERROR!", curses.color_pair(3))
win.addstr(11, 5, "Your SDI TAPAS-Board reported an " + str(_PROTECT_states_[int(ret["Protection mode"])]) + "!", curses.color_pair(3))
win.refresh()
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,int(Senden_flags),
int(polePairs),float(ratedCurrent),
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0 , 0.0)
readData = 0
time.sleep(1.5)
break
win.erase()
win.box()
win.addstr(1, 2, "SDI TAPAS BOARD QICK START - OBSERVER VIEW", curses.A_BOLD)
win.addstr(2, 2, "###################################################")
win.addstr(3, 2, "--------------current SDI TAPAS-board data-------------")
win.addstr(4, 2, "* Protection mode..............: " + _PROTECT_states_[ret["Protection mode"]])
win.addstr(5, 2, "* dc-bus voltage...............: " + str(round((ret["dc-bus voltage"]*1000.0),2)))
win.addstr(5, 43, " [V] ")
win.addstr(6, 2, "* dc-bus current...............: " + str(round((ret["dc-bus current"]),2)))
win.addstr(6, 43, " [A] ")
win.addstr(7, 2, "* dc-bus power.................: " + str(round(((ret["dc-bus voltage"]*1000.0)*ret["dc-bus current"]),2)))
win.addstr(7, 43, " [W] ")
win.addstr(8, 2, "* board-temperature............: " + str(round((ret["board-temperature"]),2)))
win.addstr(8, 43, " [C] ")
win.addstr(9, 2, "* motor speed..................: " + str(round((ret["motor speed"]*1000.0),2)))
win.addstr(9, 43, " [rpm] ")
win.addstr(10,2, "* controller state [CTRL_state]: " + _CTRL_states_[int(ret["controller state [CTRL_state]"])])
win.addstr(11,2, "* estimator state [EST_state]..: " + _EST_states_[int(ret["estimator state [EST_state]"])])
win.addstr(12,2, "---------------------------------------------------")
if(ret["spi connection status"] == 1) :
win.addstr(13,6, " checksum correct - data valid ")
else :
win.addstr(13,6, "!!checksum incorrect - data invalid!!", curses.color_pair(3))
win.addstr(14,2, "###################################################")
win.addstr(16,2, "Running motor in closed loop mode now ...", curses.A_BOLD)
win.addstr(18,4, "press CTRL-C to quit this view", curses.color_pair(1))
win.refresh()
time.sleep(0.2)
except KeyboardInterrupt:
readData = 0
elif selectedMode == "4" :
win.erase()
win.box()
win.refresh()
win.addstr(5,5, "Inverter now gets shut down", curses.A_BOLD)
win.refresh()
motorParametersSet = 0
motorIsIdentified = 0
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,0,
1,0.0,
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0,0.0)
time.sleep(1.5)
elif selectedMode == "5" :
win.erase()
win.box()
win.refresh()
win.addstr(5,5, "Disabling inverter ...", curses.A_BOLD)
win.addstr(6,5, "Shutting down ...", curses.A_BOLD)
win.refresh()
motorParametersSet = 0
motorIsIdentified = 0
for i in range(0,3):
ret = TAPASComm.transferMasterSlave(spi,0,
1,0.0,
float(RoverLestFrequencyHz),float(fluxEstFrequency),
0.0,0.0)
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
spi.close()
quit()
time.sleep(1.5)
else :
win.erase()
win.refresh()
win.box()
win.addstr(11, 5,"Invalid selection", curses.color_pair(3))
win.refresh()
time.sleep(1.5)
except KeyboardInterrupt:# Ctrl+C pressed, so...
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
spi.close()
#end try