Hello for all:
I created an issue in Scott's
linuxcnc-ethercat repository
with this content to provide support for the EL7342 module in speed mode and to be able to use some of the internal functionalities of the module that are not currently supported in the lcec_el7342 driver. Unfortunately, my minimal changes have not worked; I have not yet been able to get velocity control mode working.
Hi Scott, first of all, thank you for your great contribution to the LinuxCNC community, of which I am a member.
Now, getting down to business:
I've been inspecting the EL7342 module for a few days now. I currently have one on my workbench. I've tried reading and studying your code for the lcec_el7342 driver, and everything is correct regarding PWM/direct mode. The problem is that I've spent several days making minor modifications to both PDOs and SDOs to see if I can force the driver to operate in speed control mode, but I can't get the module's internal PID controller to work.
From the module manual I have obtained the following information:
8022:01 (Operation mode)
0: Automatic
1: Velocity direct
2: Velocity controller
3: Position controller
...: reserved
15: Chopper resistor
Although in chapter 6.6.4 (Selection of the operating mode), I infer that if the correct PDOs are configured, the module should enter the correct mode without problems:
You can select the operating mode in the index 0x8022:01"Operation mode". It is recommended that you select the operation mode "Automatic" (Fig. Setting the operation mode) and then set the suitable operation mode for your application on the Process Data tab. More information on this can be found in the chapter "Process Data".
Then in chapter 6.5.3 Predefined PDO Assignment the following is proposed:
The "Predefined PDO Assignment" enables a simplified selection of the process data. The desired function is selected on the lower part of the "Process Data" tab. As a result, all necessary PDOs are automatically activated, and the unnecessary PDOs are deactivated.
This chapter also includes a table with the predefined PDOs for each application. While it doesn't perfectly match the one currently implemented in the driver, it largely aligns with the first row, Velocity Control Compact. Therefore, I understand that to use the module's internal PID controller, we should use the PDOs listed in the second row.
Velocity control compact
SM2, PDO assignment: 0x1600, 0x1602, 0x1604, 0x1606, 0x1607, 0x1609
SM3, PDO assignment: 0x1A00, 0x1A03, 0x1A06, 0x1A08
static ec_pdo_info_t lcec_el7342_pdos_out[] = {
{0x1600, 7, lcec_el7342_channel1_enc_out},
{0x1602, 7, lcec_el7342_channel2_enc_out},
{0x1604, 5, lcec_el7342_channel1_dcm_out},
{0x1606, 1, lcec_el7342_channel1_vel_out},
{0x1607, 5, lcec_el7342_channel2_dcm_out},
{0x1609, 1, lcec_el7342_channel2_vel_out},
};
static ec_pdo_info_t lcec_el7342_pdos_in[] = {
{0x1a00, 17, lcec_el7342_channel1_enc_in},
{0x1a03, 17, lcec_el7342_channel2_enc_in},
{0x1a06, 14, lcec_el7342_channel1_dcm_in},
{0x1a07, 2, lcec_el7342_channel1_dcm_sync_info},
{0x1a08, 14, lcec_el7342_channel2_dcm_in},
{0x1a09, 2, lcec_el7342_channel2_dcm_sync_info},
};
As you can see in the driver, two more PDOs are added to SM3: 0x1a07 and 0x1a09. However, these are informational PDOs, so I don't think they're very relevant.
Now I'll list the PDOs mentioned in the second row of the table, which are the ones we should map:
Velocity control
SM2, PDO assignment: 0x1601, 0x1603, 0x1604, 0x1606, 0x1607, 0x1609
SM3, PDO assignment: 0x1A01, 0x1A04, 0x1A06, 0x1A08
Therefore, the configuration would look something like this:
static ec_pdo_info_t lcec_el7342_pdos_out[] = {
{0x1601, 7, lcec_el7342_channel1_enc_out}, //test
{0x1603, 7, lcec_el7342_channel2_enc_out}, //test
{0x1604, 5, lcec_el7342_channel1_dcm_out},
{0x1606, 1, lcec_el7342_channel1_vel_out},
{0x1607, 5, lcec_el7342_channel2_dcm_out},
{0x1609, 1, lcec_el7342_channel2_vel_out},
};
static ec_pdo_info_t lcec_el7342_pdos_in[] = {
{0x1a01, 17, lcec_el7342_channel1_enc_in}, //test
{0x1a04, 17, lcec_el7342_channel2_enc_in}, //test
{0x1a06, 14, lcec_el7342_channel1_dcm_in},
{0x1a07, 2, lcec_el7342_channel1_dcm_sync_info},
{0x1a08, 14, lcec_el7342_channel2_dcm_in},
{0x1a09, 2, lcec_el7342_channel2_dcm_sync_info},
};
Reviewing the description of these new PDOs in the manual, there are a few points to note:
1st - PDOs 0x1601 and 0x1603:07 have a different bit length compared to PDOs 0x1600 and 0x1602, so I've made the following changes:
static ec_pdo_entry_info_t lcec_el7342_channel1_enc_out[] = {
{0x0000, 0x00, 1}, // Gap
{0x7000, 0x02, 1}, // Enable latch external on positive edge
{0x7000, 0x03, 1}, // Set counter
{0x7000, 0x04, 1}, // Enable latch external on negative edge
{0x0000, 0x00, 4}, // Gap
{0x0000, 0x00, 8}, // Gap
{0x7000, 0x11, 32}, // Set counter value //test
};
static ec_pdo_entry_info_t lcec_el7342_channel2_enc_out[] = {
{0x0000, 0x00, 1}, // Gap
{0x7010, 0x02, 1}, // Enable latch extern on positive edge
{0x7010, 0x03, 1}, // Set counter
{0x7010, 0x04, 1}, // Enable latch extern on negative edge
{0x0000, 0x00, 4}, // Gap
{0x0000, 0x00, 8}, // Gap
{0x7010, 0x11, 32}, // Set counter value //test
};
Something that isn't entirely clear in the manual is whether, in Velocity Control mode, the speed should be scaled to 16 bits or expressed in revolutions per minute (RPM) in the command PDO???
I'm also unclear on whether I should write the same command PDO as the one used in the current driver???
static ec_pdo_entry_info_t lcec_el7342_channel1_vel_out[] = {
{0x7020, 0x21, 16}, // Velocity ??????
};
static ec_pdo_entry_info_t lcec_el7342_channel2_vel_out[] = {
{0x7030, 0x21, 16}, // Velocity ??????
};
With these minimal configurations, I've performed some tests without success. For example, I tried setting all the internal PID constants to zero, hoping the motor wouldn't move, but it always moves. In other words, I'm always operating in PWM/Direct mode, which I can't change even though I select Velocity Control mode or use Automatic mode via SDO in both lcec_el7342.c and XML.
Although I'll continue investigating, I would appreciate any help.