Ethercat installation summary
17 Aug 2023 21:09 - 17 Aug 2023 21:13 #278302
by maghis
Replied by maghis on topic Ethercat installation summary
Ok, I'll do some reading before continuing.
As an update, it looks like I'm pretty close.
The only changes I applied so fare are to the cia402 component:
- I wait for the ECT60 to confirm homing- I lie with the current position to linuxcnc during homing
Current tested behavior is:
- I press "home all"
- joint sets cia402 home (joint.0.index-enable => cia402.0.home)
- the drive follows the homing sequence and finds the edge of the home sensor
- the drive exits the homing mode
- at that point, the next "write all" sends again the current pos_cmd and the drive moves back to the position before the homing started
I'll study homing.c - I was hoping to find a solution that didn't involve rebuilding linuxcnc (I'm running off of the 2.8.1 raspberry pi image right now).
As an update, it looks like I'm pretty close.
The only changes I applied so fare are to the cia402 component:
- I wait for the ECT60 to confirm homing
if (home) {
opmode = OPMODE_HOMING;
if (opmode_homing) {
controlword |= (home << 4);
}
}
//home states
if (opmode_homing) {
// hack
pos_fb = pos_cmd;
stat_homed = ((statusword >> 10) & 1) && ((statusword >> 12) & 1);
stat_homing = !stat_homed && !((statusword >> 10) & 1);
}
Current tested behavior is:
- I press "home all"
- joint sets cia402 home (joint.0.index-enable => cia402.0.home)
- the drive follows the homing sequence and finds the edge of the home sensor
- the drive exits the homing mode
- at that point, the next "write all" sends again the current pos_cmd and the drive moves back to the position before the homing started
I'll study homing.c - I was hoping to find a solution that didn't involve rebuilding linuxcnc (I'm running off of the 2.8.1 raspberry pi image right now).
Last edit: 17 Aug 2023 21:13 by maghis.
Please Log in or Create an account to join the conversation.
17 Aug 2023 21:18 #278303
by maghis
Replied by maghis on topic Ethercat installation summary
I just had another idea, from all the lying about the pos_fb: what if, after the drive is done homing, I stored an offset in memory and applied it to pos_cmd and pos_fb?
What is the lifecycle of a component? Do I risk anything being reinitialized or is it safe?
What is the lifecycle of a component? Do I risk anything being reinitialized or is it safe?
Please Log in or Create an account to join the conversation.
17 Aug 2023 21:56 #278305
by rodw
Replied by rodw on topic Ethercat installation summary
That makes sense. I have not look at it for a long time. Homecomp did not exist until afdter I got my ethercat machine working. I started to write a homing module and made some progress, essentially moving Dominic's code into the module then the homemod code changed totally to make it easier to use (except for me as I had started!)
Please Log in or Create an account to join the conversation.
17 Aug 2023 22:43 #278309
by maghis
Replied by maghis on topic Ethercat installation summary
I'll give it a try and report back! Do you know if Dominic is still around? I would love to get his opinion as well - it looks like he was using the drive homing in his setup.
Please Log in or Create an account to join the conversation.
18 Aug 2023 16:43 #278397
by maghis
Replied by maghis on topic Ethercat installation summary
Not sure if this will work, I'll test today: the current solution is directly in cia402.comp.
When homing ends, I save the current actual position of the drive in a "home_offset" variable and I always subtract the home offset when reporting pos_fb (I prob should add it to the drive target position).
What do you think?
When homing ends, I save the current actual position of the drive in a "home_offset" variable and I always subtract the home offset when reporting pos_fb (I prob should add it to the drive target position).
FUNCTION(read_all) {
// read Modes of Operation
opmode_no_mode = (opmode_display == OPMODE_NONE);
opmode_homing = (opmode_display == OPMODE_HOMING);
opmode_cyclic_velocity = (opmode_display == OPMODE_CYCLIC_VELOCITY);
opmode_cyclic_position = (opmode_display == OPMODE_CYCLIC_POSITION);
// read status
stat_switchon_ready = (statusword >> 0) & 1;
stat_switched_on = (statusword >> 1) & 1;
stat_op_enabled = (statusword >> 2) & 1;
stat_fault = (statusword >> 3) & 1;
stat_voltage_enabled = (statusword >> 4) & 1;
stat_quick_stop = (statusword >> 5) & 1;
stat_switchon_disabled = (statusword >> 6) & 1;
stat_warning = (statusword >> 7) & 1;
stat_remote = (statusword >> 9) & 1;
if (opmode_cyclic_position || opmode_cyclic_velocity) {
stat_target_reached = (statusword >> 10) & 1;
} else {
stat_target_reached = 0;
}
//home states
if (opmode_homing) {
stat_homed = ((statusword >> 10) & 1) && ((statusword >> 12) & 1);
stat_homing = !stat_homed && !((statusword >> 10) & 1);
} else if (opmode_homing_old) {
home_offset = drv_actual_position;
}
opmode_homing_old = opmode_homing;
// check for change in scale value
check_scales(&pos_scale, &pos_scale_old, &pos_scale_rcpt);
check_scales(&velo_scale, &velo_scale_old, &velo_scale_rcpt);
// read position feedback
pos_fb = ((double)(drv_actual_position - home_offset)) * pos_scale_rcpt;
if (opmode_homing) {
// hack
pos_fb = pos_cmd;
}
// read velocity feedback
velocity_fb = ((double)drv_actual_velocity) * velo_scale_rcpt;
// update fault output
if (auto_fault_reset_delay > 0) {
auto_fault_reset_delay -= period;
drv_fault = 0;
} else {
drv_fault = stat_fault && enable;
}
}
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
18 Aug 2023 16:57 #278399
by rodw
Replied by rodw on topic Ethercat installation summary
Worth a try.
When I started on my homing module, I wanted to clean up the code to make it easier to read without all the binary maths. I created a union so the individual bits AND the Status/Control words lived in a structure.Then you could access the data like
MIght confuse you but its worth considering if you are hacking into this.
When I started on my homing module, I wanted to clean up the code to make it easier to read without all the binary maths. I created a union so the individual bits AND the Status/Control words lived in a structure.
//local data
//CIA Control Word
typedef union
{
struct
{
unsigned char SwitchOn : 1; // 00
unsigned char EnableVoltage : 1; // 01
unsigned char QuickStop : 1; // 02
unsigned char EnableOperation : 1; // 03
unsigned char StartHome : 1; // 04 not used in CSP or homing
unsigned char bit5 : 1; // 05 not used in CSP or homing
unsigned char bit6 : 1; // 06 not used in CSP or homing
unsigned char Faultreset : 1; // 07
unsigned char Timeout : 1; // 08
unsigned char bit9 : 1; // 09 not used in any mode
unsigned char keep : 6; // 10-15 not used in any mode
}b;
hal_u32_t Word;
}Control_t;
//CIA Status Word
typedef union
{
struct
{
unsigned char ReadyToSwitchOn : 1; // 00
unsigned char SwitchOn : 1; // 01
unsigned char OperationEnabled : 1; // 02
unsigned char Fault : 1; // 03
unsigned char VoltageEnabled : 1; // 04
unsigned char QuickStop : 1; // 05
unsigned char SwitchOnDisabled : 1; // 06
unsigned char Warning : 1; // 07
unsigned char keep1 : 1; // 08
unsigned char Remote : 1; // 09
hal_bit_t TargetReached : 1; // 10
unsigned char bit11 : 1; // 11
unsigned char bit12 : 1; // 12
unsigned char keep2 : 3; // 13-15
}b;
hal_u32_t Word;
}Status_t;
Status_t Status; // IN - CIA Status Word with bitmap
Control_t Control; // OUT - CIA Control Word with bitmap
Status.Word // the full word
Status.StartHome // the bit set to start homing
MIght confuse you but its worth considering if you are hacking into this.
Please Log in or Create an account to join the conversation.
18 Aug 2023 18:18 #278407
by maghis
Replied by maghis on topic Ethercat installation summary
Not confusing at all, I'm sw eng by trade
Thanks for sharing, could be a refactoring opportunity.
Thanks for sharing, could be a refactoring opportunity.
Please Log in or Create an account to join the conversation.
12 Oct 2023 02:57 #282793
by geo01005
I removed the "[/code]
This works well, and the motor no longer jumps. I then decided to make a hacky solution for the following error. I added a couple of input pins to the CIA402 component to store the standard following error parameters from the INI file, and a couple of output pins to set the current following error. The component keeps the output pins equal to the input pins except during homing. During homing the output following error pins are set to a high value, 1e38.
Then you just connect up the following error output pins to the following error pins and result is Linuxcnc ignoring following error during homing, but not at other times without modifying the Linuxcnc code.
you can see the example config attached. I changed the CIA402 component name to CIA402JAG just to I could do side by side comparison of the two components on my system.
What do you think? To hacky?
Replied by geo01005 on topic Ethercat installation summary
So I picked up where you left off here. I decided to ignore the following error issue and just set the following error limits to a large value and focus on the jumping after homing.Ok, I'll do some reading before continuing.
As an update, it looks like I'm pretty close.
The only changes I applied so fare are to the cia402 component:
- I wait for the ECT60 to confirm homing
[/code]if (home) { opmode = OPMODE_HOMING; if (opmode_homing) { controlword |= (home << 4); } } - I lie with the current position to linuxcnc during homing [code]//home states if (opmode_homing) { // hack pos_fb = pos_cmd; stat_homed = ((statusword >> 10) & 1) && ((statusword >> 12) & 1); stat_homing = !stat_homed && !((statusword >> 10) & 1); } Current tested behavior is: - I press "home all" - joint sets cia402 home (joint.0.index-enable => cia402.0.home) - the drive follows the homing sequence and finds the edge of the home sensor - the drive exits the homing mode - at that point, the next "write all" sends again the current pos_cmd and the drive moves back to the position before the homing started I'll study homing.c - I was hoping to find a solution that didn't involve rebuilding linuxcnc (I'm running off of the 2.8.1 raspberry pi image right now).
I removed the "
[code]pos_fb = pos_cmd;" and still noticed jumping. After looking at some Halscope traces it became apparent that the drive was being put back into cyclic position mode before the position register was cleared from homing. I made a small change in order of a few lines of code forcing the homing procedure in the drive to finish before setting the drive back to position mode.
// OP Mode
// set to position mode
if (stat_voltage_enabled && !home ) {
opmode = OPMODE_CYCLIC_POSITION;
}
// set velo mode
if (stat_voltage_enabled && !pos_mode && !home) {
opmode = OPMODE_CYCLIC_VELOCITY;
}
// reset home command
if (home && (stat_homed && !stat_homed_old) && opmode_homing) {
home = 0;
}
This works well, and the motor no longer jumps. I then decided to make a hacky solution for the following error. I added a couple of input pins to the CIA402 component to store the standard following error parameters from the INI file, and a couple of output pins to set the current following error. The component keeps the output pins equal to the input pins except during homing. During homing the output following error pins are set to a high value, 1e38.
Then you just connect up the following error output pins to the following error pins and result is Linuxcnc ignoring following error during homing, but not at other times without modifying the Linuxcnc code.
you can see the example config attached. I changed the CIA402 component name to CIA402JAG just to I could do side by side comparison of the two components on my system.
What do you think? To hacky?
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
12 Oct 2023 18:03 #282824
by endian
Replied by endian on topic Ethercat installation summary
hello guys,
check my for ds402.comp from post where is all of that jumping implemented ... it will not work for cia402 setup drivers... it should be great inspiration for f_error etc.... on single place. there are difference in binary PDOs values between old ds402 and new cia402 standard
before starting homing at rise edge you have to setup single scan pos_cmd = pos_feedback and after homing when it is finishing at folling edge the same .. and switching modes betwen homing and csp are done after driver position feedback value will be less then f_error and there will be no f?error trigger or jumping during it..
regards Slav
check my for ds402.comp from post where is all of that jumping implemented ... it will not work for cia402 setup drivers... it should be great inspiration for f_error etc.... on single place. there are difference in binary PDOs values between old ds402 and new cia402 standard
before starting homing at rise edge you have to setup single scan pos_cmd = pos_feedback and after homing when it is finishing at folling edge the same .. and switching modes betwen homing and csp are done after driver position feedback value will be less then f_error and there will be no f?error trigger or jumping during it..
regards Slav
Please Log in or Create an account to join the conversation.
- jimwhiting
- Offline
- Junior Member
Less
More
- Posts: 34
- Thank you received: 6
25 Oct 2023 10:45 #283790
by jimwhiting
Replied by jimwhiting on topic Ethercat installation summary
Hi,
So working on from geo's updates, plus some of foxington's state machine code to stop the following error I changed the cia402 code to try and get it homing on my Leadshine EL8 drives. The issue I was having is that the home pin was being cleared instantly - The logic checks on the status registers where not correct for my drives and instantly deactivated the home pin. So I've had to make some pretty nasty code to get it into the homing state and then detect when it is finished and clear the home at the end. Anyhow, with all that done it will now home using the drives internal procedure.
However... I now run into "j0 end of move in home state 18" if I'm too far (too much time) from the end of the homing sequence which from examining the code is the timer running out in the homing code. Any ideas on how to prevent that without rebuilding linuxcnc?
Thanks,
Jim.
So working on from geo's updates, plus some of foxington's state machine code to stop the following error I changed the cia402 code to try and get it homing on my Leadshine EL8 drives. The issue I was having is that the home pin was being cleared instantly - The logic checks on the status registers where not correct for my drives and instantly deactivated the home pin. So I've had to make some pretty nasty code to get it into the homing state and then detect when it is finished and clear the home at the end. Anyhow, with all that done it will now home using the drives internal procedure.
However... I now run into "j0 end of move in home state 18" if I'm too far (too much time) from the end of the homing sequence which from examining the code is the timer running out in the homing code. Any ideas on how to prevent that without rebuilding linuxcnc?
Thanks,
Jim.
Please Log in or Create an account to join the conversation.
Time to create page: 0.137 seconds