HAL CiA402 Drive Interface for Can Bus,Ethercat etc...

More
4 years 7 months ago #238047 by sqmathlete
Hi Rod,

My apologies for not responding earlier, work interrupted. That being said,  I have managed to create my own fork but I was having difficulty getting an rip version to build in Bookworm and I think that ethercat master doesn't play well the 5.16 Kernel.  Doing a  fresh install of Bullseye
as we speak.
 

  I don't think its possible to home without modifying homing.c as the LCNC velocities seem to override the internal ones.

I would agree with this. The code that controls homing is spread around 10 or so files. Not much editing/addition is required but it is quite a tangled web.

My thought was to add a new flag to homing configuration called HOME_EXTERNAL that bypassed all of the stuff linuxcnc does in homing.c until homing is completed except all the homing  offsets etc. To do this I modified the bitmap in homing.h 

Then in homing.c, I jump down the homing sequence_state if this flag is set.

I might add, I had to dig deep to remember how bitmaps worked!
 

That's basically what is required. You create the variable HOME_EXTERNAL or in my  HOME_AUTO =1 for the .ini  file then you can use that to set a bit (that you have created), then in the homing file LinuxCNC knows to ignore the error during homing. It may not be that elegant but it works.

  What Dominc has provided though is a way to eliminate using M codes to change modes by  tying the mode changes with a home to index signal.

I will have to have a look at this. A  comp file that handles the mode switching and brake at the appropriate time would be nice. Might even be able to delete a few rungs on the ladder. 

Will let you know when I get the changes uploaded to my fork. I'm going to clean them up a bit, there is a lot of stuff left over from previous attempts that may be confusing.

Kind regards,
Dan 

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

More
4 years 7 months ago #238060 by rodw
Dan, The sittner repo and use of obsolete mercurial repos is a problem from Bullseye and on. The solution is to use an unofficial repo created by the IgH Etherlabmaster team. It includes nightly build for many platforms

I documented how to do this in this thread which is now a  sticky in the ethercat section.
forum.linuxcnc.org/ethercat/45336-etherc...-how-to-step-by-step

I was able to install bullseye, change the sources.list to point to unstable, upgrade Bullseye to testing, Install lcnc and Ethercat without compiling any code (except the hal driver)

Try this:
Code:
Install Debian Bullseye from an ISO open a terminal sudo apt install geany curl sudo geany /etc/apt/sources.list make sure any lines containing cd are commented out with a # replace any reference to bullseye or stable with unstable eg. deb http://deb.debian.org/debian/ unstable main non-free contrib deb-src http://deb.debian.org/debian/ unstable main non-free contrib Note that unstable should be replaced with testing when Linuxcnc gets there (soon) If you are an ETHERCAT user insert this line at the end of the file deb [allow-insecure=yes] https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_10/ ./ Save and close geany If you are an ETHERCAT user enter these two commands to create a security key KEYRING=/usr/share/keyrings/ethercat.gpg curl -fsSL https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_10/Release.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null Upgrading your Debian to unstable branch becasue Linuxcnc is packaged there sudo apt update sudo apt full-upgrade sudo apt install linuxcnc-uspace linuxcnc-uspace-dev reboot type uname -a (to check PREEMPT-RT kernel is running) Linuxcnc should be in the menus or open a terminal and type: linuxcnc

Then 
Code:
udo apt install -y linux-headers-rt-amd64 grub-customizer sudo apt-get install ethercat-dkms libethercat libethercat-dev ethercat-master ip a (and save MAC address of the NIC used for ethercat) sudo geany /etc/ethernet.conf set your Master0 device to your MAC address and device modules to generic MASTER0_DEVICE="xx:aa:yy:zz:bb:cc" DEVICE_MODULES="generic" save and close geany sudo systemctl enable ethercat.service sudo systemctl start ethercat.service sudo systemctl status ethercat.service sudo chmod 666 /dev/EtherCAT0 Ethercat should be running. If the above command is not found, you have a problem You can list the slaves if you type ethercat slaves mkdir dev cd dev git clone https://github.com/sittner/linuxcnc-ethercat.git cd linuxcnc-ethercat make clean sudo make install cd .. git clone https://github.com/dbraun1981/hal-cia402 cd hal-cia402 sudo halcompile --install cia402.comp

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

More
4 years 7 months ago #238061 by rodw
oops, the second block of code should start with sudo not udo

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

More
4 years 7 months ago #238063 by rodw

oops, the second block of code should start with sudo not udo


Actually, sometimes, ethercat gets confused with the kernel versions so with preempt_rt running replace the first line with 
Code:
sudo apt install -y linux-headers-rt-$(uname -r) grub-customizer

This will install the correct headers.

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

More
4 years 7 months ago #238200 by rodw
Well, this is interesting. Homing is now able to be a user defined module thanks to Dewey Garrett
github.com/LinuxCNC/linuxcnc/commit/08ac...b0cd47dc0eedfbc36785

Docs:   linuxcnc.org/docs/devel/html/man/man9/homecomp.9.html

This sounds like what is required.
 

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

More
4 years 7 months ago - 4 years 7 months ago #238562 by sqmathlete
Hi Rod,

Thanks for you're very detailed instructions on how to install ethercat and linuxcnc . Worked perfectly!

Also, I totally agree, this github.com/LinuxCNC/linuxcnc/commit/08ac...b0cd47dc0eedfbc36785  
is very interesting. I think this would be way more elegant than forcing the code to ignore the homing error and would keep everything in one place rather than spread out over several files. Being able to eliminate having to create an ini variable and allow one to focus on dropping through the homing states is also nice.  Thanks Garret Dewey! 

I've posted my homing.c file, it's a bit of a mess but you can see how I dropped through the homing states.

Dan 


 

File Attachment:

File Name: homing.h
File Size:3.08 KB

File Attachment:

File Name: homing_2022-03-28.c
File Size:47.19 KB
Last edit: 4 years 7 months ago by sqmathlete. Reason: Linked whole paragraph

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

Time to create page: 0.306 seconds
Powered by Kunena Forum