Hi all,
I have recently started using Orocos with the SOEM master.
I would have a question about the correct method to send PDO.
So the question is:
after setting a PDO mapping with SDO, I want, for example, send a PDO that
contain the target_position (short of 16 bit).
First of all, I have to write it in slave[i].outputs, supposing it is the
first variable in the pdo mapping. Then I have to send it using
ec_send_processdata().
So I think I have to do that in the updateHook() of the master in this way:
void SoemMasterComponent::updateHook()
{
...
...
if ((inPort.connected()) && (inPort.read(target_position)==RTT::NewData))
{
memcpy(ec_slave[1].outputs,&target_position ,2);
ec_send_processdata();
}
...
...
}
where target_position can be used connected to an input port of the
SoemMasterComponent (to be sett from another component) in this way:
in SoemMasterComponent.hpp
RTT::InputPort <short>inPort;
in SoemMasterComponent.cpp
this->ports()->addPort("inPort",inPort).doc("signal from the Orocos
component that commands the master");
Is it the correct way? There is a problem because I'm
doing memcpy(ec_slave[1].outputs,&target_position ,2); and
ec_send_processdata(); in the same thread [the only one thread that is
executing the updateHook() of the master component??
Are you doing in a different way?
Any suggestion would be helpful
Sending a PDO command using SOEM/Orocos etherCAT master
2012/4/26 Luca Magnabosco <magnabosco [dot] luca [..] ...>:
> Hi all,
> I have recently started using Orocos with the SOEM master.
>
> I would have a question about the correct method to send PDO.
>
> So the question is:
>
> after setting a PDO mapping with SDO, I want, for example, send a PDO that
> contain the target_position (short of 16 bit).
> First of all, I have to write it in slave[i].outputs, supposing it is the
> first variable in the pdo mapping. Then I have to send it using
> ec_send_processdata().
> So I think I have to do that in the updateHook() of the master in this way:
>
> void SoemMasterComponent::updateHook()
> {
> ...
> ...
> if ((inPort.connected()) && (inPort.read(target_position)==RTT::NewData))
> {
> memcpy(ec_slave[1].outputs,&target_position ,2);
> ec_send_processdata();
> }
> ...
> ...
> }
>
> where target_position can be used connected to an input port of the
> SoemMasterComponent (to be sett from another component) in this way:
>
> in SoemMasterComponent.hpp
>
> RTT::InputPort <short>inPort;
>
> in SoemMasterComponent.cpp
>
> this->ports()->addPort("inPort",inPort).doc("signal from the Orocos
> component that commands the master");
>
> Is it the correct way? There is a problem because I'm
> doing memcpy(ec_slave[1].outputs,&target_position ,2); and
> ec_send_processdata(); in the same thread [the only one thread that is
> executing the updateHook() of the master component??
>
> Are you doing in a different way?
Yes, a couple of components and services are available that take care
of all the low level stuff for you:
http://git.mech.kuleuven.be/?p=robotics/soem.git;a=summary
The soem_master component will, upon startup, create all available
services for you (there is a test.ops script available to get you
started), for all drivers that are found and known to the system -
these are all defined in soem_beckhoff_drivers. Then all you would
have to do to send commands is call the appropriate service, e.g.
<moduleName>.write(<channel>,<value>) for an analog input module.
Steven
>
> Any suggestion would be helpful
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>