Hi Qing :)<div>I finally solved the problem that I didn't implement the DC sync.</div><div>When I made a DC sync signal from master, my RxPDOs are properly working.</div><div>Anyway thank you for your reply.</div><div>
<br></div><div>sincerely</div><div><br><div class="gmail_quote">2012/12/6 <span dir="ltr"><<a href="mailto:etherlab-dev-request@etherlab.org" target="_blank">etherlab-dev-request@etherlab.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Send etherlab-dev mailing list submissions to<br>
<a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:etherlab-dev-owner@etherlab.org">etherlab-dev-owner@etherlab.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of etherlab-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: A problem related to the pdo communication (Royal Qing)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 6 Dec 2012 20:39:37 +0800 (CST)<br>
From: "Royal Qing" <<a href="mailto:royalqing@163.com">royalqing@163.com</a>><br>
Subject: Re: [etherlab-dev] A problem related to the pdo communication<br>
To: <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
Message-ID: <<a href="mailto:2dba321.2233c.13b703a74ad.Coremail.royalqing@163.com">2dba321.2233c.13b703a74ad.Coremail.royalqing@163.com</a>><br>
Content-Type: text/plain; charset="gbk"<br>
<br>
Hi Jinyoung,<br>
<br>
Sorry, I have not used epos3 motor drive up to now.<br>
But I wonder what operation mode you used? Csp or Csv?<br>
And Whether the same operation mode can work very well under TwinCAT control?<br>
<br>
BR!<br>
<br>
<br>
<br>
<br>
At 2012-12-06 18:23:38,<a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a> wrote:<br>
>Send etherlab-dev mailing list submissions to<br>
> <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
><br>
>To subscribe or unsubscribe via the World Wide Web, visit<br>
> <a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
>or, via email, send a message with subject or body 'help' to<br>
> <a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a><br>
><br>
>You can reach the person managing the list at<br>
> <a href="mailto:etherlab-dev-owner@etherlab.org">etherlab-dev-owner@etherlab.org</a><br>
><br>
>When replying, please edit your Subject line so it is more specific<br>
>than "Re: Contents of etherlab-dev digest..."<br>
><br>
><br>
>Today's Topics:<br>
><br>
> 1. Re: etherlab-dev Digest, Vol 50, Issue 1 (Jinyoung Choi)<br>
><br>
><br>
>----------------------------------------------------------------------<br>
><br>
>Message: 1<br>
>Date: Thu, 6 Dec 2012 19:23:33 +0900<br>
>From: Jinyoung Choi <<a href="mailto:kbkbc88@gmail.com">kbkbc88@gmail.com</a>><br>
>Subject: Re: [etherlab-dev] etherlab-dev Digest, Vol 50, Issue 1<br>
>To: <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>Message-ID:<br>
> <CADsBPRSWYwV7G46GmYAMSZKRonW=gDac6RUbFAE=<a href="mailto:XZeqP9opWA@mail.gmail.com">XZeqP9opWA@mail.gmail.com</a>><br>
>Content-Type: text/plain; charset="iso-8859-1"<br>
><br>
>Thank you for your answer Qing.<br>
><br>
>still, i can't solve the problem : (<br>
><br>
>I captured some packets by using the wireshark program and i checked the<br>
>pdos are sent properly.<br>
><br>
>but the real values of object dictionary are no changed!<br>
><br>
>so I think it is not a master module's problem....<br>
><br>
>I use epos3 motor drive for the test...<br>
><br>
>is there any solution?<br>
><br>
>2012/12/5 <<a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a>><br>
><br>
>> Send etherlab-dev mailing list submissions to<br>
>> <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>><br>
>> To subscribe or unsubscribe via the World Wide Web, visit<br>
>> <a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
>> or, via email, send a message with subject or body 'help' to<br>
>> <a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a><br>
>><br>
>> You can reach the person managing the list at<br>
>> <a href="mailto:etherlab-dev-owner@etherlab.org">etherlab-dev-owner@etherlab.org</a><br>
>><br>
>> When replying, please edit your Subject line so it is more specific<br>
>> than "Re: Contents of etherlab-dev digest..."<br>
>><br>
>><br>
>> Today's Topics:<br>
>><br>
>> 1. Re: A problem related to the pdo communication (Jinyoung<br>
>> Choi) (Royal Qing)<br>
>><br>
>><br>
>> ----------------------------------------------------------------------<br>
>><br>
>> Message: 1<br>
>> Date: Wed, 5 Dec 2012 11:38:09 +0800 (CST)<br>
>> From: "Royal Qing" <<a href="mailto:royalqing@163.com">royalqing@163.com</a>><br>
>> Subject: Re: [etherlab-dev] A problem related to the pdo communication<br>
>> (Jinyoung Choi)<br>
>> To: <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>> Message-ID: <<a href="mailto:20c0bac1.500e.13b6924602d.Coremail.royalqing@163.com">20c0bac1.500e.13b6924602d.Coremail.royalqing@163.com</a>><br>
>> Content-Type: text/plain; charset="gbk"<br>
>><br>
>> Hi Jinyoung,<br>
>><br>
>> It looks like nothing wrong with your codes.<br>
>> First of all, please check the device description file(XML) and make sure<br>
>> it just contains only 1 RxPDO with 7 entries and 1 TxPDO with 6 entries.<br>
>> Then please try to use external memory to manage the internal process data<br>
>> for your domain. I doubt that your pointer domain0_output is clear after<br>
>> ecrt_master_send(master).<br>
>><br>
>> if ((size = ecrt_domain_size(domain0))) {<br>
>> if (!(domain0_output = (uint8_t *) kmalloc(size, GFP_KERNEL))) {<br>
>> printk(KERN_ERR PFX "Failed to allocate %u bytes of process<br>
>> data"<br>
>> " memory!\n", size);<br>
>> return -1;<br>
>> }<br>
>> ecrt_domain_external_memory(domain0, domain0_output);<br>
>> }<br>
>><br>
>> BR!<br>
>><br>
>> Royal Qing<br>
>><br>
>><br>
>><br>
>> At 2012-11-30 18:20:10,<a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a> wrote:<br>
>> >Send etherlab-dev mailing list submissions to<br>
>> > <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>> ><br>
>> >To subscribe or unsubscribe via the World Wide Web, visit<br>
>> > <a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
>> >or, via email, send a message with subject or body 'help' to<br>
>> > <a href="mailto:etherlab-dev-request@etherlab.org">etherlab-dev-request@etherlab.org</a><br>
>> ><br>
>> >You can reach the person managing the list at<br>
>> > <a href="mailto:etherlab-dev-owner@etherlab.org">etherlab-dev-owner@etherlab.org</a><br>
>> ><br>
>> >When replying, please edit your Subject line so it is more specific<br>
>> >than "Re: Contents of etherlab-dev digest..."<br>
>> ><br>
>> ><br>
>> >Today's Topics:<br>
>> ><br>
>> > 1. A problem related to the pdo communication (Jinyoung Choi)<br>
>> ><br>
>> ><br>
>> >----------------------------------------------------------------------<br>
>> ><br>
>> >Message: 1<br>
>> >Date: Fri, 30 Nov 2012 19:20:07 +0900<br>
>> >From: Jinyoung Choi <<a href="mailto:kbkbc88@gmail.com">kbkbc88@gmail.com</a>><br>
>> >Subject: [etherlab-dev] A problem related to the pdo communication<br>
>> >To: <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>> >Message-ID:<br>
>> > <<br>
>> <a href="mailto:CADsBPRSrAhDoJad1n2fyKhc8ADCW412o8b1eX-mwzYp%2Bb68rtA@mail.gmail.com">CADsBPRSrAhDoJad1n2fyKhc8ADCW412o8b1eX-mwzYp+b68rtA@mail.gmail.com</a>><br>
>> >Content-Type: text/plain; charset="iso-8859-1"<br>
>> ><br>
>> >Hi all, my name CJ from south korea.<br>
>> ><br>
>> >I modified an example in /example/user/main.c<br>
>> ><br>
>> >My goal is to communicate with slave motor drive(epos3) by using ethercat<br>
>> >through SDO and PDO messages.<br>
>> ><br>
>> >My slave drive can get into OP state like these messages<br>
>> ><br>
>> >Activating master...<br>
>> ><br>
>> >Starting timer...<br>
>> ><br>
>> >Started.<br>
>> ><br>
>> >1 slave(s).<br>
>> ><br>
>> >AL states: 0x02.<br>
>> ><br>
>> >Link is up.<br>
>> ><br>
>> >EPOS3 slave 0 State 0x02.<br>
>> ><br>
>> >EPOS3 slave 0: online.<br>
>> ><br>
>> >Domain: WC 3.<br>
>> ><br>
>> >Domain: State 2.<br>
>> ><br>
>> >AL states: 0x08.<br>
>> ><br>
>> >EPOS3 slave 0 State 0x08.<br>
>> ><br>
>> >EPOS3 slave 0: operational.<br>
>> ><br>
>> ><br>
>> >and kernel messages are like this,<br>
>> ><br>
>> >...<br>
>> ><br>
>> >[29145.133927] EtherCAT DEBUG 0: Stopping master thread.<br>
>> ><br>
>> >[29145.133930] EtherCAT DEBUG 0: Master IDLE thread exiting...<br>
>> ><br>
>> >[29145.133952] EtherCAT 0: Master thread exited.<br>
>> ><br>
>> >[29145.133954] EtherCAT DEBUG 0: FSM datagram is ffff8800527bd648.<br>
>> ><br>
>> >[29145.133955] EtherCAT 0: Starting EtherCAT-OP thread.<br>
>> ><br>
>> >[29145.133973] EtherCAT DEBUG 0: mmap()<br>
>> ><br>
>> >[29145.133975] EtherCAT DEBUG 0: Vma fault, virtual_address =<br>
>> >00007fb7e9b61000, offset = 0, page = ffffea00011ffe30<br>
>> ><br>
>> >[29145.134008] EtherCAT DEBUG 0: Operation thread running with fsm<br>
>> interval<br>
>> >= 10000 us, max data size=112500<br>
>> ><br>
>> >[29145.134010] EtherCAT WARNING 0: 1 datagram UNMATCHED!<br>
>> ><br>
>> >[29145.143508] EtherCAT DEBUG 0: Configuration changed (aborting state<br>
>> >check).<br>
>> ><br>
>> >[29145.143511] EtherCAT DEBUG 0: Writing system time offsets...<br>
>> ><br>
>> >[29145.143512] EtherCAT WARNING 0: No app_time received up to now, but<br>
>> >master already active.<br>
>> ><br>
>> >[29145.143513] EtherCAT DEBUG 0: Requesting OP...<br>
>> ><br>
>> >[29145.181179] EtherCAT DEBUG 0-0: Changing state from PREOP to OP.<br>
>> ><br>
>> >[29145.181182] EtherCAT DEBUG 0-0: Configuring...<br>
>> ><br>
>> >[29145.215005] EtherCAT DEBUG 0-0: Now in INIT.<br>
>> ><br>
>> >[29145.215007] EtherCAT DEBUG 0-0: Clearing FMMU configurations...<br>
>> ><br>
>> >[29145.235006] EtherCAT DEBUG 0-0: Clearing sync manager configurations...<br>
>> ><br>
>> >[29145.255046] EtherCAT DEBUG 0-0: Clearing DC assignment...<br>
>> ><br>
>> >[29145.274967] EtherCAT DEBUG 0-0: Configuring mailbox sync managers...<br>
>> ><br>
>> >[29145.274995] EtherCAT DEBUG 0-0: SM0: Addr 0x1000, Size 1024, Ctrl 0x26,<br>
>> >En 1<br>
>> ><br>
>> >[29145.274997] EtherCAT DEBUG 0-0: SM1: Addr 0x1400, Size 1024, Ctrl 0x22,<br>
>> >En 1<br>
>> ><br>
>> >[29145.334911] EtherCAT DEBUG 0-0: Now in PREOP.<br>
>> ><br>
>> >[29145.334918] EtherCAT DEBUG 0-0: Setting PDO assignment of SM2:<br>
>> ><br>
>> >[29145.334919] EtherCAT DEBUG 0-0: Currently assigned PDOs: 0x1600. PDOs<br>
>> to<br>
>> >assign: 0x1600<br>
>> ><br>
>> >[29145.334922] EtherCAT DEBUG 0-0: Setting number of assigned PDOs to<br>
>> zero.<br>
>> ><br>
>> >[29145.334923] EtherCAT DEBUG 0-0: Downloading SDO 0x1C12:00.<br>
>> ><br>
>> >[29145.334924] EtherCAT DEBUG: 00<br>
>> ><br>
>> >[29145.334926] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.334927] EtherCAT DEBUG: 00 20 2F 12 1C 00 00 00 00 00<br>
>> ><br>
>> >[29145.394874] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.394876] EtherCAT DEBUG: 00 30 60 12 1C 00 00 00 00 00<br>
>> ><br>
>> >[29145.394881] EtherCAT DEBUG 0-0: Assigning PDO 0x1600 at position 1.<br>
>> ><br>
>> >[29145.394882] EtherCAT DEBUG 0-0: Downloading SDO 0x1C12:01.<br>
>> ><br>
>> >[29145.394883] EtherCAT DEBUG: 00 16<br>
>> ><br>
>> >[29145.394885] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.394885] EtherCAT DEBUG: 00 20 2B 12 1C 01 00 16 00 00<br>
>> ><br>
>> >[29145.454815] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.454816] EtherCAT DEBUG: 00 30 60 12 1C 01 00 16 00 00<br>
>> ><br>
>> >[29145.454820] EtherCAT DEBUG 0-0: Setting number of assigned PDOs to 1.<br>
>> ><br>
>> >[29145.454822] EtherCAT DEBUG 0-0: Downloading SDO 0x1C12:00.<br>
>> ><br>
>> >[29145.454822] EtherCAT DEBUG: 01<br>
>> ><br>
>> >[29145.454824] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.454824] EtherCAT DEBUG: 00 20 2F 12 1C 00 01 00 00 00<br>
>> ><br>
>> >[29145.514775] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.514777] EtherCAT DEBUG: 00 30 60 12 1C 00 01 00 00 00<br>
>> ><br>
>> >[29145.514783] EtherCAT DEBUG 0-0: Successfully configured PDO assignment<br>
>> >of SM2.<br>
>> ><br>
>> >[29145.514787] EtherCAT DEBUG 0-0: Setting PDO assignment of SM3:<br>
>> ><br>
>> >[29145.514787] EtherCAT DEBUG 0-0: Currently assigned PDOs: 0x1A00. PDOs<br>
>> to<br>
>> >assign: 0x1A00<br>
>> ><br>
>> >[29145.514790] EtherCAT DEBUG 0-0: Setting number of assigned PDOs to<br>
>> zero.<br>
>> ><br>
>> >[29145.514792] EtherCAT DEBUG 0-0: Downloading SDO 0x1C13:00.<br>
>> ><br>
>> >[29145.514792] EtherCAT DEBUG: 00<br>
>> ><br>
>> >[29145.514794] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.514794] EtherCAT DEBUG: 00 20 2F 13 1C 00 00 00 00 00<br>
>> ><br>
>> >[29145.574693] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.574695] EtherCAT DEBUG: 00 30 60 13 1C 00 00 00 00 00<br>
>> ><br>
>> >[29145.574700] EtherCAT DEBUG 0-0: Assigning PDO 0x1A00 at position 1.<br>
>> ><br>
>> >[29145.574702] EtherCAT DEBUG 0-0: Downloading SDO 0x1C13:01.<br>
>> ><br>
>> >[29145.574703] EtherCAT DEBUG: 00 1A<br>
>> ><br>
>> >[29145.574704] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.574705] EtherCAT DEBUG: 00 20 2B 13 1C 01 00 1A 00 00<br>
>> ><br>
>> >[29145.634651] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.634653] EtherCAT DEBUG: 00 30 60 13 1C 01 00 1A 00 00<br>
>> ><br>
>> >[29145.634656] EtherCAT DEBUG 0-0: Setting number of assigned PDOs to 1.<br>
>> ><br>
>> >[29145.634658] EtherCAT DEBUG 0-0: Downloading SDO 0x1C13:00.<br>
>> ><br>
>> >[29145.634659] EtherCAT DEBUG: 01<br>
>> ><br>
>> >[29145.634660] EtherCAT DEBUG 0-0: Expedited download request:<br>
>> ><br>
>> >[29145.634661] EtherCAT DEBUG: 00 20 2F 13 1C 00 01 00 00 00<br>
>> ><br>
>> >[29145.694597] EtherCAT DEBUG 0-0: Download response:<br>
>> ><br>
>> >[29145.694599] EtherCAT DEBUG: 00 30 60 13 1C 00 01 00 00 00<br>
>> ><br>
>> >[29145.694603] EtherCAT DEBUG 0-0: Successfully configured PDO assignment<br>
>> >of SM3.<br>
>> ><br>
>> >[29145.694607] EtherCAT DEBUG 0-0: SM2: Addr 0x1800, Size 19, Ctrl 0x64,<br>
>> En<br>
>> >1<br>
>> ><br>
>> >[29145.694609] EtherCAT DEBUG 0-0: SM3: Addr 0x1C00, Size 15, Ctrl 0x20,<br>
>> En<br>
>> >1<br>
>> ><br>
>> >[29145.714583] EtherCAT DEBUG 0 0:0: FMMU: LogAddr 0x00000000, Size 19,<br>
>> >PhysAddr 0x1800, SM2, Dir out<br>
>> ><br>
>> >[29145.714585] EtherCAT DEBUG 0 0:0: FMMU: LogAddr 0x00000013, Size 15,<br>
>> >PhysAddr 0x1C00, SM3, Dir in<br>
>> ><br>
>> >[29145.764458] EtherCAT 0: Domain 0: Working counter changed to 3/3.<br>
>> ><br>
>> >[29145.774506] EtherCAT DEBUG 0-0: Now in SAFEOP.<br>
>> ><br>
>> >[29145.814535] EtherCAT DEBUG 0-0: Now in OP. Finished configuration.<br>
>> ><br>
>> >[29145.840543] EtherCAT 0: Slave states: OP.<br>
>> ><br>
>> ><br>
>><br>
>> >------------------------------------------------------------------------------------------------<br>
>> ><br>
>> ><br>
>> >I guess that the pdos may be sent by master module.<br>
>> ><br>
>> >but the actual value of objects in slave's object dictionary are not<br>
>> >changed.<br>
>> ><br>
>> >what is the problem?<br>
>> ><br>
>> >please do me a favor.<br>
>> ><br>
>> >and this is my example code.<br>
>> ><br>
>> ><br>
>><br>
>> >/*****************************************************************************<br>
>> > *<br>
>> > * $Id: main.c,v 60a116ed3897 2009/07/27 10:44:16 fp $<br>
>> > *<br>
>> > * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH<br>
>> > *<br>
>> > * This file is part of the IgH EtherCAT Master.<br>
>> > *<br>
>> > * The IgH EtherCAT Master is free software; you can redistribute it<br>
>> and/or<br>
>> > * modify it under the terms of the GNU General Public License version 2,<br>
>> >as<br>
>> > * published by the Free Software Foundation.<br>
>> > *<br>
>> > * The IgH EtherCAT Master is distributed in the hope that it will be<br>
>> >useful,<br>
>> > * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
>> > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
>> >General<br>
>> > * Public License for more details.<br>
>> > *<br>
>> > * You should have received a copy of the GNU General Public License<br>
>> along<br>
>> > * with the IgH EtherCAT Master; if not, write to the Free Software<br>
>> > * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301<br>
>> >USA<br>
>> > *<br>
>> > * ---<br>
>> > *<br>
>> > * The license mentioned above concerns the source code only. Using the<br>
>> > * EtherCAT technology and brand is only permitted in compliance with the<br>
>> > * industrial property and similar rights of Beckhoff Automation GmbH.<br>
>> > *<br>
>> ><br>
>> ****************************************************************************/<br>
>> ><br>
>> >#include <errno.h><br>
>> >#include <signal.h><br>
>> >#include <stdio.h><br>
>> >#include <string.h><br>
>> >#include <sys/resource.h><br>
>> >#include <sys/time.h><br>
>> >#include <sys/types.h><br>
>> >#include <unistd.h><br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >#include "ecrt.h"<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >// Application parameters<br>
>> >#define FREQUENCY 100<br>
>> >#define PRIORITY 1<br>
>> ><br>
>> >// Optional features<br>
>> >#define CONFIGURE_PDOS 1<br>
>> >#define SDO_ACCESS 0<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >// EtherCAT<br>
>> >static ec_master_t *master = NULL;<br>
>> >static ec_master_state_t master_state = {};<br>
>> ><br>
>> >static ec_domain_t *domain0 = NULL;<br>
>> >static ec_domain_state_t domain_state = {};<br>
>> ><br>
>> >static ec_slave_config_t *sc_epos3 = NULL;<br>
>> >static ec_slave_config_state_t sc_epos3_state = {};<br>
>> ><br>
>> >// Timer<br>
>> >static unsigned int sig_alarms = 0;<br>
>> >static unsigned int user_alarms = 0;<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >// process data<br>
>> >static uint8_t *domain0_output = NULL;<br>
>> ><br>
>> >#define SLAVE_DRIVE_0 0, 0<br>
>> >#define MAXON_EPOS3 0x000000fb, 0x64400000<br>
>> ><br>
>> >// offsets for PDO entries<br>
>> ><br>
>> >static unsigned int off_epos3_cntlwd;<br>
>> >//static unsigned int off_epos3_tvel;<br>
>> >static unsigned int off_epos3_tpos;<br>
>> >static unsigned int off_epos3_off_pos;<br>
>> >static unsigned int off_epos3_off_vel;<br>
>> >static unsigned int off_epos3_off_toq;<br>
>> >static unsigned int off_epos3_moo;<br>
>> >static unsigned int off_epos3_dof;<br>
>> >static unsigned int off_epos3_status;<br>
>> >static unsigned int off_epos3_pos_val;<br>
>> >static unsigned int off_epos3_vel_val;<br>
>> >static unsigned int off_epos3_toq_val;<br>
>> >static unsigned int off_epos3_mood;<br>
>> >static unsigned int off_epos3_dif;<br>
>> ><br>
>> >const static ec_pdo_entry_reg_t domain0_regs[] = {<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6040, 0, &off_epos3_cntlwd},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x607a, 0, &off_epos3_tpos},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b0, 0, &off_epos3_off_pos},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b1, 0, &off_epos3_off_vel},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x60b2, 0, &off_epos3_off_toq},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6060, 0, &off_epos3_moo},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2078, 1, &off_epos3_dof},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6041, 0, &off_epos3_status},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6064, 0, &off_epos3_pos_val},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x606c, 0, &off_epos3_vel_val},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6077, 0, &off_epos3_toq_val},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x6061, 0, &off_epos3_mood},<br>
>> > {SLAVE_DRIVE_0, MAXON_EPOS3, 0x2071, 1, &off_epos3_dif},<br>
>> > {}<br>
>> >};<br>
>> ><br>
>> >static unsigned int counter = 0;<br>
>> >static unsigned int blink = 0;<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >#if CONFIGURE_PDOS<br>
>> ><br>
>> >static ec_pdo_entry_info_t epos3_pdo_rx_entries[] = {<br>
>> > {0x6040, 0, 16}, // controlword<br>
>> > {0x607a, 0, 32}, // target position<br>
>> > {0x60b0, 0, 32}, // position offset<br>
>> > {0x60b1, 0, 32}, // velocity offset<br>
>> > {0x60b2, 0, 16}, // torque offset<br>
>> > {0x6060, 0, 8}, // modes of opeartion<br>
>> > {0x2078, 1, 16} // digital output functionality<br>
>> ><br>
>> >};<br>
>> ><br>
>> >static ec_pdo_entry_info_t epos3_pdo_tx_entries[] = {<br>
>> > {0x6041, 0, 16}, // status word<br>
>> > {0x6064, 0, 32}, // position actual value<br>
>> > {0x606c, 0, 32}, // velocity actual value<br>
>> > {0x6077, 0, 16}, // torque actual value<br>
>> > {0x6061, 0, 8}, // modes of operation display<br>
>> > {0x2071, 1, 16} // digital input functionality<br>
>> >};<br>
>> ><br>
>> >static ec_pdo_info_t epos3_pdos[] = {<br>
>> > {0x1600, 7, epos3_pdo_rx_entries},<br>
>> > {0x1a00, 6, epos3_pdo_tx_entries}<br>
>> >};<br>
>> ><br>
>> >static ec_sync_info_t epos3_syncs[] = {<br>
>> > {2, EC_DIR_OUTPUT, 1, epos3_pdos},<br>
>> > {3, EC_DIR_INPUT, 1, epos3_pdos+1},<br>
>> > {0xff}<br>
>> >};<br>
>> ><br>
>> >#endif<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >#if SDO_ACCESS<br>
>> >static ec_sdo_request_t *sdo;<br>
>> >#endif<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >void check_domain_state(ec_domain_t *domain)<br>
>> >{<br>
>> > ec_domain_state_t ds;<br>
>> ><br>
>> > ecrt_domain_state(domain, &ds);<br>
>> ><br>
>> > if (ds.working_counter != domain_state.working_counter)<br>
>> > printf("Domain: WC %u.\n", ds.working_counter);<br>
>> > if (ds.wc_state != domain_state.wc_state)<br>
>> > printf("Domain: State %u.\n", ds.wc_state);<br>
>> ><br>
>> > domain_state = ds;<br>
>> >}<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >void check_master_state(void)<br>
>> >{<br>
>> > ec_master_state_t ms;<br>
>> ><br>
>> > ecrt_master_state(master, &ms);<br>
>> ><br>
>> > if (ms.slaves_responding != master_state.slaves_responding)<br>
>> > printf("%u slave(s).\n", ms.slaves_responding);<br>
>> > if (ms.al_states != master_state.al_states)<br>
>> > printf("AL states: 0x%02X.\n", ms.al_states);<br>
>> > if (ms.link_up != master_state.link_up)<br>
>> > printf("Link is %s.\n", ms.link_up ? "up" : "down");<br>
>> ><br>
>> > master_state = ms;<br>
>> >}<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >void check_slave_config_states(void)<br>
>> >{<br>
>> > ec_slave_config_state_t s;<br>
>> ><br>
>> > ecrt_slave_config_state(sc_epos3, &s);<br>
>> ><br>
>> > if (s.al_state != sc_epos3_state.al_state)<br>
>> > printf("EPOS3 slave 0 State 0x%02X.\n", s.al_state);<br>
>> > if (s.online != sc_epos3_state.online)<br>
>> > printf("EPOS3 slave 0: %s.\n", s.online ? "online" : "offline");<br>
>> > if (s.operational != sc_epos3_state.operational)<br>
>> > printf("EPOS3 slave 0: %soperational.\n",<br>
>> > s.operational ? "" : "Not ");<br>
>> > sc_epos3_state = s;<br>
>> >}<br>
>> ><br>
>><br>
>> >/*****************************************************************************/<br>
>> ><br>
>> >#if SDO_ACCESS<br>
>> >void read_sdo(void)<br>
>> >{<br>
>> > switch (ecrt_sdo_request_state(sdo)) {<br>
>> > case EC_REQUEST_UNUSED: // request was not used yet<br>
>> > ecrt_sdo_request_read(sdo); // trigger first read<br>
>> > break;<br>
>> > case EC_REQUEST_BUSY:<br>
>> > fprintf(stderr, "Still busy...\n");<br>
>> > break;<br>
>> > case EC_REQUEST_SUCCESS:<br>
>> > fprintf(stderr, "SDO value: 0x%04X\n",<br>
>> > EC_READ_U16(ecrt_sdo_request_data(sdo)));<br>
>> > ecrt_sdo_request_read(sdo); // trigger next read<br>
>> > break;<br>
>> > case EC_REQUEST_ERROR:<br>
>> > fprintf(stderr, "Failed to read SDO!\n");<br>
>> > ecrt_sdo_request_read(sdo); // retry reading<br>
>> > break;<br>
>> > }<br>
>> >}<br>
>> ><br>
>> >#endif<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >void cyclic_task(){<br>
>> > int i;<br>
>> ><br>
>> > // receive process data<br>
>> > ecrt_master_receive(master);<br>
>> > ecrt_domain_process(domain0);<br>
>> ><br>
>> > // check process data state (optional)<br>
>> > check_domain_state(domain0);<br>
>> ><br>
>> > if (counter) {<br>
>> > counter--;<br>
>> > }else { // do this at 1 Hz<br>
>> > counter = FREQUENCY;<br>
>> ><br>
>> > // calculate new process data<br>
>> > blink = !blink;<br>
>> ><br>
>> > // check for master state (optional)<br>
>> > check_master_state();<br>
>> ><br>
>> > // check for islave configuration state(s) (optional)<br>
>> > check_slave_config_states();<br>
>> ><br>
>> >#if SDO_ACCESS<br>
>> > // read process data SDO<br>
>> > read_sdo();<br>
>> > printf("read_sdo\n");<br>
>> >#endif<br>
>> > }<br>
>> > // read process data<br>
>> > //printf(" stataus word : %u\n",EC_READ_U8(domain1_pd +<br>
>> >off_epos3_moo));<br>
>> ><br>
>> > // write process data<br>
>> > EC_WRITE_U32(domain0_output + off_epos3_tpos, 0xff);<br>
>> ><br>
>> > // send process data<br>
>> > ecrt_domain_queue(domain0);<br>
>> > ecrt_master_send(master);<br>
>> ><br>
>> ><br>
>> >}<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >void signal_handler(int signum) {<br>
>> > switch (signum) {<br>
>> > case SIGALRM:<br>
>> > sig_alarms++;<br>
>> > break;<br>
>> > }<br>
>> >}<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> ><br>
>> >int main(int argc, char **argv)<br>
>> >{<br>
>> > ec_slave_config_t *sc;<br>
>> > struct sigaction sa;<br>
>> > struct itimerval tv;<br>
>> ><br>
>> > master = ecrt_request_master(0);<br>
>> > printf("ecrt_request_master is called \n");<br>
>> > if (!master)<br>
>> > return -1;<br>
>> ><br>
>> > domain0 = ecrt_master_create_domain(master);<br>
>> > if(!domain0)<br>
>> > return -1;<br>
>> ><br>
>> > if(!(sc_epos3 = ecrt_master_slave_config(<br>
>> > master, SLAVE_DRIVE_0, MAXON_EPOS3))){<br>
>> > fprintf(stderr, "Failed to get slave configuration. \n");<br>
>> > return -1;<br>
>> > }<br>
>> ><br>
>> > //added by kbkbc<br>
>> > //if (ecrt_slave_config_sdo16(sc_epos3, 0x6040, 0x00,9 ) == 0)<br>
>> > //printf("change SDO : 0x6040 \n");<br>
>> ><br>
>> >#if SDO_ACCESS<br>
>> > fprintf(stderr, "Creating SDO requests...\n");<br>
>> > if (!(sdo = ecrt_slave_config_create_sdo_request(sc_epos3, 0x6060,<br>
>> >0x00, 16))) {<br>
>> > fprintf(stderr, "Failed to create SDO request.\n");<br>
>> > return -1;<br>
>> > }<br>
>> > ecrt_sdo_request_timeout(sdo, 500); // ms<br>
>> ><br>
>> >#endif<br>
>> ><br>
>> >#if CONFIGURE_PDOS<br>
>> > printf("Configuring PDOs...\n");<br>
>> > if (ecrt_slave_config_pdos(sc_epos3, EC_END, epos3_syncs)) {<br>
>> > fprintf(stderr, "Failed to configure PDOs.\n");<br>
>> > return -1;<br>
>> > }<br>
>> > printf("configureing PDO is completed!\n");<br>
>> >#endif<br>
>> > if( ecrt_domain_reg_pdo_entry_list(domain0, domain0_regs)){<br>
>> > fprintf(stderr, "PDO entty registration filed! \n");<br>
>> > return -1;<br>
>> > }<br>
>> ><br>
>> > printf("Activating master...\n");<br>
>> > if (ecrt_master_activate(master))<br>
>> > return -1;<br>
>> ><br>
>> > if( !(domain0_output = ecrt_domain_data(domain0))) {<br>
>> > return -1;<br>
>> > }<br>
>> ><br>
>> >#if PRIORITY<br>
>> > pid_t pid = getpid();<br>
>> > if (setpriority(PRIO_PROCESS, pid, -19))<br>
>> > fprintf(stderr, "Warning: Failed to set priority: %s\n",<br>
>> > strerror(errno));<br>
>> >#endif<br>
>> ><br>
>> > sa.sa_handler = signal_handler;<br>
>> > sigemptyset(&sa.sa_mask);<br>
>> > sa.sa_flags = 0;<br>
>> > if (sigaction(SIGALRM, &sa, 0)) {<br>
>> > fprintf(stderr, "Failed to install signal handler!\n");<br>
>> > return -1;<br>
>> > }<br>
>> ><br>
>> > printf("Starting timer...\n");<br>
>> > tv.it_interval.tv_sec = 0;<br>
>> > tv.it_interval.tv_usec = 1000000 / FREQUENCY;<br>
>> > tv.it_value.tv_sec = 0;<br>
>> > tv.it_value.tv_usec = 1000;<br>
>> > if (setitimer(ITIMER_REAL, &tv, NULL)) {<br>
>> > fprintf(stderr, "Failed to start timer: %s\n", strerror(errno));<br>
>> > return 1;<br>
>> > }<br>
>> ><br>
>> > printf("Started.\n");<br>
>> ><br>
>> > while (1) {<br>
>> > pause();<br>
>> ><br>
>> > #if 0<br>
>> > struct timeval t;<br>
>> > gettimeofday(&t, NULL);<br>
>> > printf("%u.%06u\n", t.tv_sec, t.tv_usec);<br>
>> > #endif<br>
>> > while (sig_alarms != user_alarms) {<br>
>> > cyclic_task();<br>
>> > user_alarms++;<br>
>> > }<br>
>> > }<br>
>> ><br>
>> > return 0;<br>
>> >}<br>
>> ><br>
>><br>
>> >/****************************************************************************/<br>
>> >-------------- next part --------------<br>
>> >An HTML attachment was scrubbed...<br>
>> >URL: <<br>
>> <a href="http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121130/d7e815a7/attachment.html" target="_blank">http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121130/d7e815a7/attachment.html</a><br>
>> ><br>
>> ><br>
>> >------------------------------<br>
>> ><br>
>> >_______________________________________________<br>
>> >etherlab-dev mailing list<br>
>> ><a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>> ><a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
>> ><br>
>> ><br>
>> >End of etherlab-dev Digest, Vol 49, Issue 1<br>
>> >*******************************************<br>
>> -------------- next part --------------<br>
>> An HTML attachment was scrubbed...<br>
>> URL: <<br>
>> <a href="http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121205/d407ed9d/attachment.htm" target="_blank">http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121205/d407ed9d/attachment.htm</a><br>
>> ><br>
>><br>
>> ------------------------------<br>
>><br>
>> _______________________________________________<br>
>> etherlab-dev mailing list<br>
>> <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
>> <a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
>><br>
>><br>
>> End of etherlab-dev Digest, Vol 50, Issue 1<br>
>> *******************************************<br>
>><br>
>-------------- next part --------------<br>
>An HTML attachment was scrubbed...<br>
>URL: <<a href="http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121206/356863c7/attachment.htm" target="_blank">http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121206/356863c7/attachment.htm</a>><br>
><br>
>------------------------------<br>
><br>
>_______________________________________________<br>
>etherlab-dev mailing list<br>
><a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
><a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
><br>
><br>
>End of etherlab-dev Digest, Vol 50, Issue 3<br>
>*******************************************<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121206/c84ec2c1/attachment.htm" target="_blank">http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20121206/c84ec2c1/attachment.htm</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
etherlab-dev mailing list<br>
<a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a><br>
<a href="http://lists.etherlab.org/mailman/listinfo/etherlab-dev" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-dev</a><br>
<br>
<br>
End of etherlab-dev Digest, Vol 50, Issue 4<br>
*******************************************<br>
</blockquote></div><br></div>