Ethercat HAL driver

More
27 May 2020 06:23 - 27 May 2020 12:33 #169035 by theshade
Hello @ chimeno,

I made some progress yesterday. When I start linuxcnc my device goes into OP and now if I write this in a terminal.
The motor gets current and I can't turn it by hand anymore:
ethercat -p0 -t uint16 download 0x6040 0 0x0006 # EnableVoltage+QuickStop
ethercat -p0 -t uint16 download 0x6040 0 0x0007 #                        +SwitchOn
ethercat -p0 -t uint16 download 0x6040 0 0x000f #                                 +EnableOperation

But how and where should I have this in linuxcnc?
[update] I think there are plenty of examples in here: github.com/aschiffler/linuxcnc/tree/master/configs/roschi_cnc
I will try to adapt sth from this in the hal file...
setp lcec.0.3.drivecontrol-8 1
setp lcec.0.3.drivecontrol-13 1
setp lcec.0.3.drivecontrol-14 1
setp lcec.0.3.signalcontrol-0 0

setp lcec.0.4.drivecontrol-8 1
setp lcec.0.4.drivecontrol-13 1
setp lcec.0.4.drivecontrol-14 1
setp lcec.0.4.signalcontrol-0 0

setp lcec.0.5.drivecontrol-8 1
setp lcec.0.5.drivecontrol-13 1
setp lcec.0.5.drivecontrol-14 1
setp lcec.0.5.signalcontrol-0 0
Also I think my "scaling" is currently wrong, I think the encoders are 1000 steps per rev while the stepper is actually 200 steps per rev.. and I will attach some SFU1605 screws to them.

Thank you again for your support
Last edit: 27 May 2020 12:33 by theshade.

Please Log in or Create an account to join the conversation.

More
27 May 2020 19:45 - 27 May 2020 19:49 #169148 by chimeno
Hi @theshade
I do not use this type of generic file, it costs me a bit, and without having the device it is also a little more difficult
I attach a new .xml file with some changes

a your .hal file
setp lcec.0.X-cmd-SwitchOn 1
setp lcec.0.X-cmd-EnableVoltage 1
setp lcec.0.X-cmd-/QuickStop 1
setp lcec.0.X-cmd-EnableOperation 1

Now the driver is ready to work ...

the scale is surely wrong if not calculated, but to start leave at 1 and then check the measurement
Could this be the scale?
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="poscmd" halType="float" scale="40.0"/>
<pdoEntry idx="6064" subIdx="00" bitLen="32" halPin="actpos" halType="float" scale="200.0"/>

Now we connect the signals ...
lcec.0.poscmd -> joint.0.motor-pos-cmd
lcec.0.actpos <- joint.0.motor-pos-fb

I hope it is a good start ...

Reguard
Chimeno
Attachments:
Last edit: 27 May 2020 19:49 by chimeno. Reason: Edit
The following user(s) said Thank You: thefabricator03

Please Log in or Create an account to join the conversation.

More
01 Jun 2020 20:58 #169715 by theshade
Dear Chimeno,

I am making good progress but the motor still does not move.
when I start linuxcnc the motor does get power and is locked into position.. it is very hard to move it by hand...

I read position from encoder it is 0.
the motor is in CSP mode 0x8
When I download a new position to 0x607A manually the motor does not move.
Same when I try to move the motor using the linuxcnc interface.
I can see the cursor moving on the 3d screen but the motor is always at 0

When I start linuxcnc and get in OP dmesg
reads this:
[14186.406727] EtherCAT 0: Slave states on main device: PREOP.
[14186.476831] EtherCAT WARNING: Datagram 0e6a62ff (master-fsm) was SKIPPED 1 time.
[14212.690402] EtherCAT: Requesting master 0...
[14212.690416] EtherCAT: Successfully requested master 0.
[14212.691529] EtherCAT 0: Domain0: Logical address 0x00000000, 18 byte, expected working counter 3.
[14212.691537] EtherCAT 0:   Datagram domain0-0-main: Logical offset 0x00000000, 18 byte, type LRW.
[14212.691571] EtherCAT 0: Master thread exited.
[14212.691582] EtherCAT 0: Starting EtherCAT-OP thread.
[14212.691709] EtherCAT WARNING 0: 1 datagram UNMATCHED!
[14217.917614] EtherCAT WARNING 0-0: Slave did not sync after 5000 ms.
[14217.921603] EtherCAT 0: Domain 0: Working counter changed to 3/3
[14217.921612] .
[14217.937322] EtherCAT 0: Slave states on main device: OP.

So as you can see my sync is not working although I reached OP

I also read this sentence in the manual:
In this mode, the primary controller generates a position trace and sends the target
location (0x607A) to the drive during each PDO update cycle. The drive feeds back the
actual motor position and optional actual motor speed and torque.
Enable CSP

So what does happen if the PDO is not update at every cycle because the master is not synced correctly would CSP still work?

Also I was able to read the position from the actual location (0x6064) and the encoder has 4000 steps per revolution.
finally linuxcnc (2.9) wasn't happy with the hal command you gave me:
the hal wanted a command so I made a net..

from last message:

"Now we connect the signals ...
lcec.0.poscmd -> joint.0.motor-pos-cmd
lcec.0.actpos <- joint.0.motor-pos-fb"


so I modified to this:
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb
net Xpos joint.0.motor-pos-cmd => lcec.0.0.poscmd
net Xact lcec.0.0.actpos => joint.0.motor-pos-fb

is it correct (what you meant?) or am I reversed with my arrows?

now it seems that when I start linuxcnc the motor turns on but when I try to move it
I get this
joint 0 following error
emc/task/taskintf.cc 947: Error on joint 0, command number 474

Also when I try to apply some force to the motor left or right from the stuck position, I see the encoder does work though..
So somehow it is not closing the loop on the position... do I need to set a speed for the CSP mode?
I thought updating position is enough.
The motor does work in windows with twincat so I know the cables are all correct.
Thank you again for your time and help

Cheers,
Attachments:

Please Log in or Create an account to join the conversation.

More
02 Jun 2020 20:11 - 02 Jun 2020 20:16 #169863 by chimeno
Hi @theshade

So as you can see my sync is not working although I reached OP

I also read this sentence in the manual:
In this mode, the primary controller generates a position trace and sends the target
location (0x607A) to the drive during each PDO update cycle. The drive feeds back the
actual motor position and optional actual motor speed and torque.
Enable CSP
So what does happen if the PDO is not update at every cycle because the master is not synced correctly would CSP still work?


In all the devices that have been tried so far, if the DC mode does not synchronize, the device appears an error and stays in the "PREOP E" state, if yours is in OP it must be synchronized in principle, you can try to lower the time.

<dcConf assignActivate="300" sync0Cycle="20000000" sync0Shift="0"/>

is it correct (what you meant?) or am I reversed with my arrows?

The arrows do not affect the programming, it is only as a comment to understand it better

now it seems that when I start linuxcnc the motor turns on but when I try to move it
I get this
joint 0 following error
emc/task/taskintf.cc 947: Error on joint 0, command number 474

This error is normal because the motor is not moving.


In TWINCAT 3, does it work for you? you can compare these values ​​with linuxcnc
0x0640 Control Word
​​
0x6041 Status Word
In which direction do you place the position? = 0x607A?

You have activated in linuxcnc is Quick stop status ?? it's okay?

If you want you can also pass me the project in TWINCAT3 configured and that it operates and I look at it in case I see something different.

Regards
Chimeno
Last edit: 02 Jun 2020 20:16 by chimeno. Reason: Edit

Please Log in or Create an account to join the conversation.

More
02 Jun 2020 22:32 - 03 Jun 2020 17:44 #169875 by theshade
Yes the motor works fine in twincat3 when I use the "NC" controller in online mode it rotates, I can choose speed and everything is working great.
The values in 0x6040 and 0x6041 in TWINCAT are 0x1F and 0x1237 (see screenshot) when the NC controller is started

I do not understand why though it is not just 0x0F because in CSP the 0x10 bit is is not required according to manual
Anyway I did try to add it into linuxcnc using the hal command to get the same as:
setp lcec.0.0.X-cmd-OPmodeRel1 1

pi@raspberrypi:~ $ ethercat -p0 -t uint16 upload 0x6040 0
0x001f 31
pi@raspberrypi:~ $ ethercat -p0 -t uint16 upload 0x6041 0
0x1237 4663
pi@raspberrypi:~ $

Also it seems to me that all status including /Quickstop are good according to my current understanding of things:


I have tried setting 0x6040 from 0x06 to 0x0f and also from 0x06 to 0x1f multiple times. Because I think that in PP mode it is required to be switched for each new position.. but in CSP I believe it should stay at 1... (at least that is what I observe when it works in twincat)

I also tried turning on
setp joint.0.jog-enable 1
don't know if that is relevant... but it seems a good thing to enable the jog if I want to move the X axis..

What I am not sure is that in the doc both 0x607A(poscmd) and 0x6064(actpos) are specified as "pulse units" integer32 so I suppose this should be some kind of integer..
but in the xml, following may examples, I have them defined as float (because otherwise it complains about the scaling) .. I saw there was a thread on that subject here but it is somewhat old and used haltype=special32 ???
I also tried different scaling betwen 0.001 to 1 and 1000 for actpos and poscmd... ( it does indeed change the encoder resolution when I force the motor) generating more or less error.

Again thank you for your help.. I feel there is just one little thing to find ... it is a bit frustrating to be so close and not see the motor move...
Attachments:
Last edit: 03 Jun 2020 17:44 by theshade.

Please Log in or Create an account to join the conversation.

More
03 Jun 2020 19:24 - 03 Jun 2020 19:52 #169980 by chimeno
Hi @theshade
If it is surely a small detail that does not leave you, meanwhile you can try another configuration mode, for example speed,

You can test the SYNC unit cycle at 1000us in TWINCAT and define the SYNC0 x 1 = 1000 us ?? if it works you can try this configuration.
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>


In the screenshot that you show me these records are zero? why?


Reguard
Chimeno
Attachments:
Last edit: 03 Jun 2020 19:52 by chimeno. Reason: Edit

Please Log in or Create an account to join the conversation.

More
03 Jun 2020 21:29 #170015 by theshade
Dear Chimeno,

I tried the new dcConf you suggested but it doesn't seem to work
also when I try to edit the sync unit cycle to 2000us, but the field in the window would not let me change the value.
I suppose I would need to change it in the SDO somehow and save the value in the firmware of the driver?

ALso I still have some warnings in the ethercat and still fail to sync.
but I do get to OP:
[  444.038961] EtherCAT 0: Slave states on main device: PREOP.
[  444.948987] EtherCAT WARNING: Datagram e745f9ef (master-fsm) was SKIPPED 1 time.
[  479.273797] EtherCAT: Requesting master 0...
[  479.273813] EtherCAT: Successfully requested master 0.
[  479.274580] EtherCAT 0: Domain0: Logical address 0x00000000, 18 byte, expected working counter 3.
[  479.274590] EtherCAT 0:   Datagram domain0-0-main: Logical offset 0x00000000, 18 byte, type LRW.
[  479.274791] EtherCAT 0: Master thread exited.
[  479.274806] EtherCAT 0: Starting EtherCAT-OP thread.
[  479.274977] EtherCAT WARNING 0: 1 datagram UNMATCHED!
[  484.539948] EtherCAT WARNING 0-0: Slave did not sync after 5000 ms.
[  484.543979] EtherCAT 0: Domain 0: Working counter changed to 3/3
[  484.543988] .
[  484.859325] EtherCAT 0: Slave states on main device: OP.


When I set 2.4mm to the target position in twincat the position of both actpos and poscm is 24000 so I suppose it is always an integer So do I need to have "FLOAT" haltype is correct for actpos and poscmd registers despite the integer32 type in the manual?


Do I maybe need to start an other thread or function in linuxcnc to enable actual displacement? or set windows or limits of operation or remove some safety somewhere?
Attachments:

Please Log in or Create an account to join the conversation.

More
04 Jun 2020 02:58 #170066 by CORBETT
Replied by CORBETT on topic Ethercat HAL driver
@ Chimeno

I finally got everything wired up in the machine and running fully on Ethercat only. No more software encoder or parallel port slow down, and now working on the PID tuning. I couldn't properly tune it in the past as it couldn't ever get up past about 30ipm as it would loose counts and then error the axis. At some point the original 200ppr encoders were replaced with 1000ppr BEI encoders, so software encoding is practically impossible at moderate to high speed. Low speed not a problem, but once past 25ipm it was really iffy about loosing counts. But now, even with just some rough tuning, I can get 50ipm with it being smooth, it came from the factory with 250ipm, so after I finish PID tuning I am going to adjust my INI and crank up the jog speed some. Huge difference in the EL5151 hardware counting comparred to the previous parallel port software encoding. Absolutely love the Ethercat setup.

Robert
The following user(s) said Thank You: chimeno

Please Log in or Create an account to join the conversation.

More
04 Jun 2020 18:03 #170112 by chimeno
Hi @theshade,

I tried the new dcConf you suggested but it doesn't seem to work
also when I try to edit the sync unit cycle to 2000us, but the field in the window would not let me change the value.
I suppose I would need to change it in the SDO somehow and save the value in the firmware of the driver?

Here I explain how to change it through images that is much more intuitive

First I show you the DC tab where you have 2000us


now you have to go to the MOTION tab where we have the first TASK to 2000us


now we change it to 1000us


Now we go back to the DC tab of your device and automatically we have the value 1000us, now you just have to change the value of the SYNC0 in this case we multiply it x1 and reconfigure


You can also change the value and the different SYNC modes directly on the device, in the COE tab I cannot tell you where because I do not have the device and it does not allow me to see all the records although it is surely in 1C32 and 1C33, you also have to think that whenever the device is configured in linux, you usually have to do it before the device goes into OP mode and only send and receive data through PDOs.

I feel that I cannot be of more help,

Reguard
Chimeno
Attachments:

Please Log in or Create an account to join the conversation.

More
04 Jun 2020 20:05 - 04 Jun 2020 20:17 #170123 by theshade
Dear Chimeno,

Thank you so much...
I was able to change to 1ms and it works nice in twincat...
Also in twincat I have to enable controller+ feed FW + feed BW to make the motor move.
there is no such thing in linuxcnc?


I don't think there is more you can do indeed whithout a driver and hardware
And I don't really know how to thank you for all that... If you would ever come to Switzerland, I would be happy to offer you a good restaurant. Alternatively, if you need or would like something from here that I could ship, please let me know.

And of course, if I ever manage to make it work, I'll make sure to document the thing fully so newcomer (like me) with similar hardware can benefit of all this somehow.
Attachments:
Last edit: 04 Jun 2020 20:17 by theshade.
The following user(s) said Thank You: chimeno

Please Log in or Create an account to join the conversation.

Time to create page: 0.454 seconds
Powered by Kunena Forum