bnjmnp / pysoem

Cython wrapper for the Simple Open EtherCAT Master Library
MIT License
101 stars 37 forks source link

Can pysoem run on a virtual machine? #42

Closed nikki330 closed 8 months ago

nikki330 commented 3 years ago

As the document said, the pysoem seems can run on linux and windows. But I only have a Mac, I tried to install ubuntu with parallel, but when I tried to use find _adapters, it can find the 'eth0', However When I tried the following code, it returns a empty list. I'm sure the servo device is correctly connected on my computer.

import pysoem
import sys

master = pysoem.Master()
master.open(sys.argv[1])
master.config_init()

print(master.slaves)

Is there any other configurations I need to do, or this library can't work on a virtual machine. Anyway, I'm new to develop etherCAT servo. I really want to let the servo run as the code. I also tried to use a raspberry 4b, it can find the servo as the above code. Then I tried to use sdo_write to write params, I follows a case on the manual of the servo, I write all the params with correct indexes and types and values. I also tried to use sdo_read to check if the device got the values. The params' indexs, types and values are all good, but the servo device was still not work. I tried to read other values, like temperature, it works and reasonable.

So confused, why my device not work. Is my understanding correct? I use sdo_write gives all params that the devices need, it should work correctly?

my code like this:

import pysoem
import sys

master = pysoem.Master()
master.open(sys.argv[1])
master.config_init()

device = master.slaves[0] # I only connected one device

# 1. set device running mode, such as velocity mode
# 2. set target  and acceleration and deceleration velocity
# 3. set control words to enable the device run
# use the device.sdo_write to config the above steps

device.sdo_write(index, subindex, value) 

# optional, monitor the device state
device.sdo_read(index, subindex)
..
..
master.close()

I am grateful if anyone can point out the mistakes I made or help me solve these problems. Thanks so much friends

bnjmnp commented 3 years ago

Hi @nikki330,

your first code snippet looks fine, the list should not be empty. I can't tell if pysoem on a virtual Ubuntu machine will work on a Mac. Maybe there are problems with access rights, and you are not allowed to open 'eth0'. For the rest, take a look at #30 there I provided a minimal example on how to operate a Trinamic servo drive. I hope this helps a little bit.

bnjmnp commented 8 months ago

Closed due to inactivity of the OP.