Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ebpfCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Teichmann
ebpfCAT
Commits
13119dbb
Commit
13119dbb
authored
4 years ago
by
Martin Teichmann
Committed by
Martin Teichmann
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
now I can move motors on the CHEM
parent
e43b4d6f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ebpfcat/chem.py
+19
-20
19 additions, 20 deletions
ebpfcat/chem.py
ebpfcat/devices.py
+6
-1
6 additions, 1 deletion
ebpfcat/devices.py
ebpfcat/ethercat.py
+11
-24
11 additions, 24 deletions
ebpfcat/ethercat.py
ebpfcat/terminals.py
+0
-3
0 additions, 3 deletions
ebpfcat/terminals.py
with
36 additions
and
48 deletions
ebpfcat/chem.py
+
19
−
20
View file @
13119dbb
from
asyncio
import
gather
,
sleep
,
ensure_future
from
struct
import
unpack
from
struct
import
unpack
,
pack
from
.terminals
import
EL7041
,
EL5042
,
Skip
from
.devices
import
Motor
,
Counter
,
AnalogInput
from
.ebpfcat
import
FastEtherCat
,
FastSyncGroup
,
SyncGroup
...
...
@@ -31,6 +31,10 @@ async def main():
#await te12.sdo_write(b"\x1a", 0x8018, 0x16) # singleturn
await
te12
.
sdo_write
(
b
"
"
,
0x8018
,
0x16
)
# singleturn
await
tm2
.
set_state
(
2
)
await
tm2
.
sdo_write
(
pack
(
"
<H
"
,
2500
),
0x8010
,
0x1
)
# current
await
tm2
.
sdo_write
(
pack
(
"
<H
"
,
24000
),
0x8010
,
0x3
)
# voltage
for
i
in
[
1
,
2
,
3
]:
print
(
f
"
S
{
i
:
x
}
"
,
await
te12
.
sdo_read
(
0xB018
,
i
))
print
(
f
"
Pos
"
,
await
te12
.
sdo_read
(
0x6010
,
0x11
))
...
...
@@ -53,31 +57,26 @@ async def main():
fsg
=
SyncGroup
(
ec
,
[
m1
,
aie
,
aim
])
m1
.
max_velocity
=
10000
m1
.
proportional
=
23
m1
.
target
=
185525000
print
(
"
do start
"
)
fsg
.
start
()
print
(
"
did start
"
)
for
i
in
range
(
10
):
print
(
"
P
"
,
m1
.
current_position
,
hex
(
aie
.
value
),
hex
(
aim
.
value
))
await
sleep
(
0.02
)
for
i
in
[
1
,
2
,
3
,
4
,
5
,
6
,
7
]:
print
(
f
"
I
{
i
:
x
}
"
,
unpack
(
"
B
"
,
await
tm2
.
sdo_read
(
0x6010
,
i
))[
0
])
for
i
in
[
1
,
2
,
3
]:
print
(
f
"
O
{
i
:
x
}
"
,
unpack
(
"
B
"
,
await
tm2
.
sdo_read
(
0x7010
,
i
))[
0
])
print
(
f
"
V
"
,
unpack
(
"
H
"
,
await
tm2
.
sdo_read
(
0x7010
,
0x21
))[
0
])
m1
.
velocity
=
1000
m1
.
enable
=
True
print
(
f
"
P0
"
,
unpack
(
"
I
"
,
await
tm2
.
sdo_read
(
0x6010
,
0x14
))[
0
])
await
sleep
(
0.1
)
for
i
in
[
1
,
2
,
3
]:
print
(
f
"
O
{
i
:
x
}
"
,
unpack
(
"
B
"
,
await
tm2
.
sdo_read
(
0x7010
,
i
))[
0
])
print
(
f
"
V
"
,
unpack
(
"
H
"
,
await
tm2
.
sdo_read
(
0x7010
,
0x21
))[
0
])
m1
.
velocity
=
0
#m1.enable = True
for
i
in
range
(
10
):
print
(
"
P
"
,
m1
.
current_position
,
hex
(
aie
.
value
),
hex
(
aim
.
value
))
m1
.
set_enable
=
True
for
i
in
range
(
20
):
print
(
f
"
M
{
m1
.
current_position
:
12
}
{
m1
.
velocity
:
5
}
{
aie
.
value
:
4
x
}
{
aim
.
value
:
4
x
}
"
)
await
sleep
(
0.2
)
m1
.
set_enable
=
False
m1
.
max_velocity
=
0
for
i
in
range
(
20
):
print
(
f
"
S
{
m1
.
current_position
:
12
}
{
aie
.
value
:
4
x
}
{
aim
.
value
:
4
x
}
"
)
await
sleep
(
0.02
)
#m1.enable = False
m1
.
velocity
=
0
print
(
f
"
P1
"
,
unpack
(
"
I
"
,
await
tm2
.
sdo_read
(
0x6010
,
0x14
))[
0
])
if
__name__
==
"
__main__
"
:
from
asyncio
import
get_event_loop
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/devices.py
+
6
−
1
View file @
13119dbb
...
...
@@ -175,8 +175,13 @@ class Motor(Device):
self
.
enable
=
self
.
set_enable
def
update
(
self
):
velocity
=
self
.
proportional
*
(
self
.
target
-
self
.
encoder
)
if
velocity
>
self
.
max_velocity
:
velocity
=
self
.
max_velocity
elif
velocity
<
-
self
.
max_velocity
:
velocity
=
-
self
.
max_velocity
self
.
current_position
=
self
.
encoder
self
.
velocity
=
self
.
set_
velocity
self
.
velocity
=
velocity
self
.
enable
=
self
.
set_enable
def
program
(
self
):
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/ethercat.py
+
11
−
24
View file @
13119dbb
...
...
@@ -692,48 +692,35 @@ class Terminal:
async
def
main
():
ec
=
EtherCat
(
"
enp0s31f6
"
)
print
(
1
)
await
ec
.
connect
()
print
(
2
)
tin
=
Terminal
()
tout
=
Terminal
()
tdigi
=
Terminal
()
tin
.
ec
=
tout
.
ec
=
tdigi
.
ec
=
ec
print
(
3
)
await
gather
(
tin
.
initialize
(
-
1
,
5
),
tout
.
initialize
(
-
2
,
6
),
tdigi
.
initialize
(
-
3
,
22
),
)
print
(
"
tin
"
)
#await tin.to_operational()
await
tin
.
set_state
(
2
)
await
tin
.
to_operational
()
print
(
"
tout
"
)
await
tout
.
to_operational
()
print
(
"
reading odlist
"
)
odlist2
,
odlist
=
await
gather
(
tin
.
read_ODlist
(),
tout
.
read_ODlist
())
#oe = odlist[0x7001][1]
#await oe.write(1)
await
tdigi
.
to_operational
()
print
(
"
read odlist
"
)
odlist
=
await
tdigi
.
read_ODlist
()
for
o
in
odlist
.
values
():
print
(
hex
(
o
.
index
),
o
.
name
,
o
.
maxSub
)
for
i
,
p
in
o
.
entries
.
items
():
print
(
"
"
,
i
,
p
.
name
,
"
|
"
,
p
.
dataType
,
p
.
bitLength
,
p
.
objectAccess
)
#sdo = await tin.sdo_read(o.index, i)
try
:
sdo
=
await
p
.
read
()
if
isinstance
(
sdo
,
int
):
t
=
hex
(
sdo
)
else
:
t
=
""
print
(
"
"
,
sdo
,
t
)
except
RuntimeError
as
e
:
print
(
"
E
"
,
e
)
print
(
"
set sdo
"
)
oe
=
odlist
[
0x8010
][
7
]
print
(
"
=
"
,
await
oe
.
read
())
await
oe
.
write
(
1
)
print
(
"
=
"
,
await
oe
.
read
())
print
(
tdigi
.
eeprom
[
10
])
sdo
=
await
p
.
read
()
if
isinstance
(
sdo
,
int
):
print
(
f
"
{
sdo
:
12
}
{
sdo
:
8
x
}
"
)
else
:
print
(
"
"
,
sdo
)
print
(
"
tdigi
"
)
if
__name__
==
"
__main__
"
:
loop
=
get_event_loop
()
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/terminals.py
+
0
−
3
View file @
13119dbb
...
...
@@ -27,7 +27,6 @@ class Skip(EBPFTerminal):
pass
<<<<<<<
HEAD
class
EL1808
(
EBPFTerminal
):
compatibility
=
{(
2
,
118501458
)}
...
...
@@ -54,8 +53,6 @@ class EL2808(EBPFTerminal):
ch8
=
PacketDesc
((
1
,
0
),
7
)
=======
>>>>>>>
a6f8814
(
encoder
working
for
chem
)
class
EL4104
(
EBPFTerminal
):
ch1_value
=
PacketDesc
((
1
,
0
),
'
H
'
)
ch2_value
=
PacketDesc
((
1
,
2
),
'
H
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment