Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tristan Renon
motorPhaserVisualisationTool
Commits
8d951cd4
Commit
8d951cd4
authored
May 31, 2021
by
Tristan Renon
Browse files
Radiobuttons added
parent
6fc19f88
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
54 deletions
+125
-54
Management/motorPhaser.pptx
Management/motorPhaser.pptx
+0
-0
Prog/Exe/rotatingFieldVisualisationTool_V0_1.zip
Prog/Exe/rotatingFieldVisualisationTool_V0_1.zip
+0
-0
Prog/Exe/rotatingFieldVisualisationTool_V0_2.zip
Prog/Exe/rotatingFieldVisualisationTool_V0_2.zip
+0
-0
Prog/Exe/rotatingFieldVisualisationTool_V1_0.zip
Prog/Exe/rotatingFieldVisualisationTool_V1_0.zip
+0
-0
Prog/Python/motorPhaser/fixedArrowPatches.py
Prog/Python/motorPhaser/fixedArrowPatches.py
+1
-1
Prog/Python/motorPhaser/generateSinLib.py
Prog/Python/motorPhaser/generateSinLib.py
+6
-3
Prog/Python/motorPhaser/setup.py
Prog/Python/motorPhaser/setup.py
+4
-2
Prog/Python/motorPhaser/tkinterTestRealWithStatorOptimized.py
.../Python/motorPhaser/tkinterTestRealWithStatorOptimized.py
+114
-48
No files found.
Management/motorPhaser.pptx
View file @
8d951cd4
No preview for this file type
Prog/Exe/rotatingFieldVisualisationTool
Exe
.zip
→
Prog/Exe/rotatingFieldVisualisationTool
_V0_1
.zip
View file @
8d951cd4
File moved
Prog/Exe/rotatingFieldVisualisationTool
ExeWithStator
.zip
→
Prog/Exe/rotatingFieldVisualisationTool
_V0_2
.zip
View file @
8d951cd4
File moved
Prog/Exe/rotatingFieldVisualisationTool_V1_0.zip
0 → 100644
View file @
8d951cd4
File added
Prog/Python/motorPhaser/fixedArrowPatches.py
View file @
8d951cd4
...
...
@@ -6,7 +6,7 @@ import matplotlib.patches as mpatches
import
generateSinLib
as
gsl
nSamples
=
50
nPhases
=
13
nPhases
=
5
# phaseAmplitude = (0, 1.382, 1.382, 1.382, 1.382)
# phaseShiftMec = (0, 72, 72*2, 72*3, 72*4)
...
...
Prog/Python/motorPhaser/generateSinLib.py
View file @
8d951cd4
import
numpy
as
np
from
scipy
import
signal
import
matplotlib.pyplot
as
plt
from
scipy
import
signal
def
generateSin
(
n
=
3
,
phaseShiftReg
=
None
,
phaseAmplitude
=
None
,
phaseShiftMec
=
None
,
nSamples
=
100
):
# Generate things if user did not tell about them
...
...
@@ -50,10 +50,13 @@ def generateSin3(n=3, phaseShiftReg=None, phaseAmplitude=None, phaseShiftReg3=No
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
ret
=
list
()
sig
=
np
.
sin
(
xSin
)
+
0.15
*
np
.
sin
(
3
*
xSin
)
# Generate power supply for coils
for
i
in
range
(
n
):
ret
.
append
(
phaseAmplitude
[
i
]
*
np
.
sin
(
xSin
+
phaseShiftReg
[
i
]
/
180
*
np
.
pi
)
+
phaseAmplitude3
[
i
]
*
np
.
sin
(
3
*
(
xSin
+
phaseShiftReg3
[
i
]
/
180
*
np
.
pi
)))
# ret.append(phaseAmplitude[i]*np.sin(xSin+phaseShiftReg[i]/180*np.pi)
# + phaseAmplitude3[i]*np.sin(3*(xSin+phaseShiftReg3[i]/180*np.pi)))
ret
.
append
(
phaseShifter
(
phaseAmplitude
[
i
]
*
sig
,
phaseShiftReg
[
i
]
/
180
*
np
.
pi
))
return
tuple
(
ret
),
n
,
phaseShiftReg
,
phaseAmplitude
,
phaseShiftMec
,
xSin
...
...
Prog/Python/motorPhaser/setup.py
View file @
8d951cd4
import
cx_Freeze
import
sys
import
os
import
matplotlib
import
scipy
base
=
None
if
sys
.
platform
==
"win32"
:
...
...
@@ -10,8 +12,8 @@ executables = [
cx_Freeze
.
Executable
(
"tkinterTestRealWithStatorOptimized.py"
),
]
build_exe_options
=
{
"includes"
:[
"matplotlib.backends.backend_tkagg"
],
"include_files"
:[(
matplotlib
.
get_data_path
(),
"mpl-data"
)],
build_exe_options
=
{
"includes"
:[
"matplotlib.backends.backend_tkagg"
,
"scipy.signal"
],
"include_files"
:[(
matplotlib
.
get_data_path
(),
"mpl-data"
)
,
os
.
path
.
dirname
(
scipy
.
__file__
)
],
"excludes"
:[],
}
...
...
Prog/Python/motorPhaser/tkinterTestRealWithStatorOptimized.py
View file @
8d951cd4
...
...
@@ -11,6 +11,7 @@ import generateSinLib as gsl
class
Window
(
Frame
):
def
__init__
(
self
,
master
=
None
):
Frame
.
__init__
(
self
,
master
)
...
...
@@ -64,17 +65,56 @@ class Window(Frame):
self
.
inputChange
=
True
def
refreshAfterNewData
(
self
):
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateSin
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
self
.
limit1
=
self
.
inputNPhases
/
2
*
1.1
*
max
(
self
.
phaseAmplitude
)
if
self
.
radioValue
.
get
()
==
0
:
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateSin
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
elif
self
.
radioValue
.
get
()
==
1
:
self
.
limit1
=
self
.
nPhases
*
1.1
*
max
(
self
.
phaseAmplitude
)
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateSquare
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
elif
self
.
radioValue
.
get
()
==
2
:
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateTriangle
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
elif
self
.
radioValue
.
get
()
==
3
:
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateTrapeze
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
elif
self
.
radioValue
.
get
()
==
4
:
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateSin3
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
elif
self
.
radioValue
.
get
()
==
5
:
self
.
limit1
=
self
.
nPhases
*
1.1
*
max
(
self
.
phaseAmplitude
)
self
.
generatedSin
,
self
.
nPhases
,
self
.
phaseShiftReg
,
self
.
phaseAmplitude
,
self
.
phaseShiftMec
,
self
.
xSin
=
gsl
.
generateSinPWM
(
n
=
self
.
inputNPhases
,
phaseShiftReg
=
self
.
inputPhaseShiftReg
,
phaseAmplitude
=
self
.
inputPhaseAmplitude
,
phaseShiftMec
=
self
.
inputPhaseShiftMec
,
nSamples
=
self
.
inputnSamples
)
self
.
ax3
.
cla
()
self
.
ax1
.
cla
()
self
.
ax2
.
cla
()
self
.
limit1
=
self
.
nPhases
/
2
*
1.1
*
max
(
self
.
phaseAmplitude
)
self
.
limit2
=
max
(
self
.
phaseAmplitude
)
*
1.1
self
.
ax3
.
set
(
xlim
=
(
0
,
2
*
np
.
pi
),
ylim
=
(
-
self
.
limit2
,
self
.
limit2
))
self
.
ax2
.
set
(
xlim
=
(
-
self
.
limit2
,
self
.
limit2
),
ylim
=
(
-
self
.
limit2
,
self
.
limit2
))
...
...
@@ -117,17 +157,22 @@ class Window(Frame):
self
.
ax2
.
add_patch
(
self
.
circleWiresUp
[
j
])
self
.
ax2
.
add_patch
(
self
.
circleWiresDown
[
j
])
actualExcitation
=
self
.
generatedSin
[
j
][
0
]
if
actualExcitation
>=
0
:
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
else
:
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
# actualExcitation = self.generatedSin[j][0]
# if actualExcitation >= 0:
# self.dots[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=10, c=color,
# marker='.')
# self.crosses[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=20, c=color,
# marker='x')
# else:
# self.dots[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=10, c=color,
# marker='.')
# self.crosses[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=20, c=color,
# marker='x')
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
self
.
vertical
=
self
.
ax3
.
axvline
(
x
=
self
.
xSin
[
0
],
color
=
'black'
)
self
.
ax2
.
add_patch
(
self
.
outterCircle
)
...
...
@@ -195,22 +240,22 @@ class Window(Frame):
self
.
arrows
[
j
]
=
arrow
self
.
ax2
.
add_patch
(
self
.
arrows
[
j
])
if
actualExcitation
>=
0
:
last
=
self
.
sign
[
j
]
self
.
sign
[
j
]
=
True
if
self
.
sign
[
j
]
!=
last
:
self
.
dots
[
j
].
remove
()
self
.
crosses
[
j
].
remove
()
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
10
,
c
=
colors
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
20
,
c
=
colors
,
marker
=
'x'
)
else
:
last
=
self
.
sign
[
j
]
self
.
sign
[
j
]
=
False
if
self
.
sign
[
j
]
!=
last
:
self
.
dots
[
j
].
remove
()
self
.
crosses
[
j
].
remove
()
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
10
,
c
=
colors
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
20
,
c
=
colors
,
marker
=
'x'
)
#
if actualExcitation >= 0:
#
last = self.sign[j]
#
self.sign[j] = True
#
if self.sign[j] != last:
#
self.dots[j].remove()
#
self.crosses[j].remove()
#
self.dots[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=10, c=colors, marker='.')
#
self.crosses[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=20, c=colors, marker='x')
#
else:
#
last = self.sign[j]
#
self.sign[j] = False
#
if self.sign[j] != last:
#
self.dots[j].remove()
#
self.crosses[j].remove()
#
self.dots[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=10, c=colors, marker='.')
#
self.crosses[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=20, c=colors, marker='x')
# -----------------------------------------------------------------------------------------------------
# Subplot 3 -------------------------------------------------------------------------------------------
...
...
@@ -224,7 +269,8 @@ class Window(Frame):
def
init_window
(
self
):
self
.
master
.
title
(
"Electric Motor Rotating Field - Visualisation Tool"
)
self
.
pack
(
fill
=
'both'
,
expand
=
1
)
self
.
grid
()
# self.pack(fill='both', expand=1)
#Create the controls, note use of grid
...
...
@@ -262,11 +308,26 @@ class Window(Frame):
self
.
buttonClear
.
bind
(
lambda
e
:
self
.
Clear
)
tk
.
Label
(
self
,
text
=
"Phasers Animation"
).
grid
(
row
=
17
,
column
=
0
)
tk
.
Label
(
self
,
text
=
"HES-SO // Valais-Wallis"
).
place
(
x
=
0
,
y
=
0
)
tk
.
Label
(
self
,
text
=
"Power & Drive"
).
place
(
x
=
0
,
y
=
15
)
tk
.
Label
(
self
,
text
=
"Visualisation Tool V1.0"
).
place
(
x
=
0
,
y
=
30
)
tk
.
Label
(
self
,
text
=
"Chevailler Samuel"
).
place
(
x
=
0
,
y
=
60
)
tk
.
Label
(
self
,
text
=
"Renon Tristan"
).
place
(
x
=
0
,
y
=
75
)
self
.
fig
,
(
self
.
ax1
,
self
.
ax2
,
self
.
ax3
)
=
plt
.
subplots
(
1
,
3
,
figsize
=
(
13
,
4
))
# Dictionary to create multiple buttons
self
.
radioVals
=
[
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
]
self
.
radioString
=
[
'Sinus'
,
'Rectangle'
,
'Triangle'
,
'Trapezoidal'
,
'Sinus h3'
,
'Sinus PWM'
]
self
.
radioValue
=
tk
.
IntVar
()
for
i
in
range
(
len
(
self
.
radioVals
)):
tk
.
Radiobutton
(
root
,
text
=
self
.
radioString
[
i
],
variable
=
self
.
radioValue
,
value
=
self
.
radioVals
[
i
]).
place
(
x
=
900
,
y
=
30
+
i
*
20
)
# -----------------------------------------------------------------------------------
self
.
inputChange
=
False
self
.
inputnSamples
=
5
0
self
.
inputnSamples
=
10
0
self
.
inputNPhases
=
5
self
.
inputPhaseAmplitude
=
(
0
,
1.382
,
1.382
,
1.382
,
1.382
)
self
.
inputPhaseShiftMec
=
(
0
,
72
,
144
,
216
,
288
)
...
...
@@ -316,17 +377,22 @@ class Window(Frame):
self
.
ax2
.
add_patch
(
self
.
circleWiresUp
[
j
])
self
.
ax2
.
add_patch
(
self
.
circleWiresDown
[
j
])
actualExcitation
=
self
.
generatedSin
[
j
][
0
]
if
actualExcitation
>=
0
:
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
else
:
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
# actualExcitation = self.generatedSin[j][0]
# if actualExcitation >= 0:
# self.dots[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=10, c=color,
# marker='.')
# self.crosses[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=20, c=color,
# marker='x')
# else:
# self.dots[j] = self.ax2.scatter(self.angleCosNegative[j], self.angleSinNegative[j], s=10, c=color,
# marker='.')
# self.crosses[j] = self.ax2.scatter(self.angleCosPositive[j], self.angleSinPositive[j], s=20, c=color,
# marker='x')
self
.
dots
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosPositive
[
j
],
self
.
angleSinPositive
[
j
],
s
=
10
,
c
=
color
,
marker
=
'.'
)
self
.
crosses
[
j
]
=
self
.
ax2
.
scatter
(
self
.
angleCosNegative
[
j
],
self
.
angleSinNegative
[
j
],
s
=
20
,
c
=
color
,
marker
=
'x'
)
self
.
vertical
=
self
.
ax3
.
axvline
(
x
=
self
.
xSin
[
0
],
color
=
'black'
)
self
.
ax2
.
add_patch
(
self
.
outterCircle
)
...
...
@@ -338,7 +404,7 @@ class Window(Frame):
self
.
canvas
=
FigureCanvasTkAgg
(
self
.
fig
,
master
=
self
)
self
.
canvas
.
get_tk_widget
().
grid
(
row
=
18
,
column
=
0
)
self
.
ani
=
animation
.
FuncAnimation
(
self
.
fig
,
self
.
animate
,
interval
=
2
,
frames
=
self
.
inputnSamples
,
blit
=
False
,
save_count
=
self
.
inputnSamples
)
self
.
ani
=
animation
.
FuncAnimation
(
self
.
fig
,
self
.
animate
,
interval
=
0.5
,
frames
=
self
.
inputnSamples
,
blit
=
False
,
save_count
=
self
.
inputnSamples
)
root
=
tk
.
Tk
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment