Comments (9)
Hi @bolp70 ,
I'm not 100% sure what you like to do. But if you want to select 0x1A00 and 0x1A01 in 0x1C13 you need to do it this way:
map_1c13_bytes = struct.pack('BxHH', 1, 0x1A00, 0x1A01)
slave.sdo_write(0x1c13, 0, map_1c13_bytes, True)
It is just one write to 0x1c13. Note it is now 'BxHH' instead of 'BxH'.
I don't know how your ESI looks but from your input you could do something like this (for the InputPdo
):
class InputPdo(ctypes.Structure):
_pack_ = 1
_fields_ = [
# PDO_0 0x1A00
('Position_actual_value_DUMMY', ctypes.c_int32),
('digital_input', ctypes.c_uint32),
('statusword_DUMMY', ctypes.c_uint16),
# PDO_0 0x1A01
('Position_actual_value', ctypes.c_int32),
('velocity_actual_consigne', ctypes.c_int32),
('couple_actual_consigne', ctypes.c_int16),
('statusword', ctypes.c_uint16),
]
Problem here is that you have names twice, but you could give each a unique name like I did above (notice the statusword_DUMMY).
Second option would be nested "Structures".
class InputPdo0x1A00(ctypes.Structure)
_pack_ = 1
_fields_ = [
# PDO_0 0x1A00
('Position_actual_value', ctypes.c_int32),
('digital_input', ctypes.c_uint32),
('statusword', ctypes.c_uint16),
]
class InputPdo0x1A01(ctypes.Structure)
_pack_ = 1
_fields_ = [
# PDO_0 0x1A01
('Position_actual_value', ctypes.c_int32),
('velocity_actual_consigne', ctypes.c_int32),
('couple_actual_consigne', ctypes.c_int16),
('statusword', ctypes.c_uint16),
]
class InputPdo(ctypes.Structure):
_pack_ = 1
_fields_ = [
('pdo_0', InputPdo0x1A00),
('pdo_1', InputPdo0x1A01),
]
And access the elements like this:
input = InputPdo.from_buffer_copy(slave.input)
print(input.pdo_0.Position_actual_value)
print(input.pdo_1.velocity_actual_consigne)
But I did not test this.
from pysoem.
Hi @bolp70,
take a look at issue #30, I guess reading through this will get you a bit further.
The TMCM-1617 and TMCM-3213 discussed there also implement the CiA 402 device profile.
from pysoem.
from pysoem.
Sorry I didn't get you attachment. You can attach files if you answer directly on GitHub (at issue #33).
The TMCM-1617 from my example has only RxPD1 and TxPD1, so the PDO selection object 0x1C12 and 0x1C13 is fixed (to 0x1600 and 0x1A00).
It seems that you can select other PDO configurations, thus you can write for example 0x1601 into subindex 1 of object 0x1C12.
In one of the examples you can see how to do this for a Beckhoff device:
pysoem/examples/minimal_example.py
Line 31 in 7dbc6c2
There I set 0x1C12 to 0. With that I don't have any RxPDO as I don't want to send any commands to the device in this example.
Note: It is really the best to update 0x1C12/0x1C13 in these setup-functions.
In your code you could try something like this:
map_1c12_bytes = struct.pack('BxH', 1, 0x1601)
slave.sdo_write(0x1c12, 0, map_1c12_bytes, True)
map_1c13_bytes = struct.pack('BxH', 1, 0x1A01)
slave.sdo_write(0x1c13, 0, map_1c13_bytes, True)
These SDO-writes update subindex 0 and subindex 1 at the same time.
from pysoem.
Hi @bolp70,
were you able to solve this?
from pysoem.
from pysoem.
hi bnjmnp I tried with your code, it works.
As you can see I am using PDO RTx 2.
It seems to me that we can use several PDOs at the same time?
map_1c13_bytes = struct.pack('BxH', 1, 0x1A00)
slave.sdo_write(0x1c13, 0, map_1c13_bytes, True)
to
map_1c13_bytes = struct.pack('BxH', 1, 0x1A01)
slave.sdo_write(0x1c13, 1, map_1c13_bytes, True)
if i do this, how does it work for class InputPdo and class OutputPdo ?
class InputPdo(ctypes.Structure):
_pack_ = 1
_fields_ = [
# PDO_0 0x1A00
#('Position_actual_value', ctypes.c_int32),
#('digital_input', ctypes.c_uint32),
#('statusword', ctypes.c_uint16),
# PDO_0 0x1A01
('Position_actual_value', ctypes.c_int32),
('velocity_actual_consigne', ctypes.c_int32),
('couple_actual_consigne', ctypes.c_int16),
('statusword', ctypes.c_uint16),
]
class OutputPdo(ctypes.Structure):
_pack_ = 1
_fields_ = [
# PDO_0 0x1600
#('Axe_target_position', ctypes.c_int32),
#('digital_output', ctypes.c_uint32),
#('controlword', ctypes.c_uint16),
# PDO_0 0x1601
('Axe_target_velocity', ctypes.c_int32),
('controlword', ctypes.c_uint16),
]
def convert_input_data(data):
return InputPdo.from_buffer_copy(data)
class BasicExample:
ZERRO_DRIVER_ID = 0x5a65726f #id du fabricant
axes = 0x00029252 #id des moteur
EL1259_PRODUCT_CODE = 0x04eb3052
def __init__(self, ifname):
self._ifname = "enp3s0"
self._pd_thread_stop_event = threading.Event()
self._ch_thread_stop_event = threading.Event()
self._actual_wkc = 0
self._master = pysoem.Master()
self._master.in_op = False
self._master.do_check_state = False
SlaveSet = namedtuple('SlaveSet', 'name product_code config_func')
self._expected_slave_layout = {0: SlaveSet('Axe1', self.axes, self.axes_setup),
1: SlaveSet('Axe2', self.axes, self.axes_setup),
2: SlaveSet('Axe3', self.axes, self.axes_setup),
3: SlaveSet('Axe4', self.axes, self.axes_setup),
4: SlaveSet('Axe5', self.axes, self.axes_setup),
5: SlaveSet('Axe6', self.axes, self.axes_setup)}
#2: SlaveSet('EL1259', self.EL1259_PRODUCT_CODE, self.axes_setup)
def axes_setup(self, slave_pos):
slave = self._master.slaves[slave_pos]
map_1c12_bytes = struct.pack('BxH', 1, 0x1601)
slave.sdo_write(0x1c12, 0, map_1c12_bytes, True)
map_1c13_bytes = struct.pack('BxH', 1, 0x1A01)
slave.sdo_write(0x1c13, 0, map_1c13_bytes, True)
thank you for your help
from pysoem.
Hi @bolp70,
did you had any success with the project you were working on here? I would be happy to hear.
from pysoem.
Closed due to inactivity of the OP.
from pysoem.
Related Issues (20)
- IO-Link Ethercat module (EL6224) HOT 2
- Returning PDO frame late (Windows) HOT 2
- Handle Safety HOT 2
- ConnectionError: could not open interface on Ubuntu HOT 3
- Motion control HOT 1
- read and write PDOS question HOT 2
- Add meaning of 'network adapter ID' to documentation HOT 3
- Script crashes when Python debugger inspects `CdefSlave` HOT 3
- OD version bug HOT 1
- maybe a BUGm needs deeg in HOT 1
- How to pack / unpack single `BIT`s in PDO `input` / `output` HOT 3
- Open function returns always None HOT 2
- slave.write_eeprom() bug? HOT 2
- Transfer `pysoem` into the `OpenEtherCATsociety` Github group HOT 2
- Code completion / Intellisense not working HOT 3
- Setuptool version clash HOT 1
- no SDO info for slave device
- no SDO info for slave device
- ReadTheDocs documentation is not updating
- Servo State Change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysoem.