Switch relay in a defined x position

More
4 years 9 months ago #231793 by mgm
Good evening,

Since my X axis is 2800 mm long I have built a pneumatic support. This is mounted in the middle. 

What I want now is the following:
When the X axis arrives at 1000 mm, a relay should be switched to high and at 1800 mm switch back to low so that the axis can pass through.

Is there a pin or a signal that I can use for this?

Moderator: if wrong here please move

Cheers
Micha

 

Please Log in to join the conversation.

More
4 years 9 months ago #231796 by rodw
Its best to do this in a component that monitors the axis.x.pos-cmd
Here is an example that triggers a relay if the position is > a specific location set by a pin. If you added a second pin, to turn the output off, you would jjust need to change the if statement
Code:
  param rw  float cutoff    "Absolute axis coordinate above which disables zone change";  .... if((position > cutover) && (position < cutoff))

YOu may need to change when position is set to 0 or 1 to suit your needs
 

Attachment not found

Please Log in to join the conversation.

More
4 years 9 months ago #231801 by mgm
Hello Rod,
thanks for your answer, this is exactly what I was looking for.
Please explain me now how and where I can include this.

Please Log in to join the conversation.

More
4 years 9 months ago #231803 by rodw
sudo apt-get install downdraft.comp
and add the suggested hal connections.
Check the main docs for details on using the "hal component generator" (halcompile)

Please Log in to join the conversation.

More
4 years 9 months ago #231806 by mgm
Thanks for this information, will do.
Best
Micha

Please Log in to join the conversation.

More
4 years 9 months ago #232014 by mgm
Hello Rod,

I have now tried to test your suggestion.
Unfortunately, I get along with it at all.
It fails already with the fact that I cannot find the correct directory:
"Place the .comp file in the source directory linuxcnc/src/hal/ components and re-run make. Comp files are automatically detected by the build system."

I am using Linum MX and 2.9 for testing, in a VirtualBox.

I installed it according to this manual:
LinuxCNC Install using MX Linux 19.4 - Geared Toward New/Windows Users

What am I doing wrong?

Please Log in to join the conversation.

More
4 years 9 months ago #232043 by rodw
Oops I was totally wrong above. There is no need to copy the file to any special location

For a rip build type this in the folder the comp file is in
halcompile --install downdraft.comp

For a deb install add sudo to the command above.
sudo halcompile --install downdraft.comp

See  linuxcnc.org/docs/devel/html/hal/comp.html


You can change the file name but you also need to edit the first line in the file to use the new file name

Please Log in to join the conversation.

More
4 years 9 months ago #232074 by andypugh
Isn't this something that the built-on "comp" or "wcomp" components can do?

linuxcnc.org/docs/2.8/html/man/man9/comp.9.html
linuxcnc.org/docs/2.8/html/man/man9/wcomp.9.html

Please Log in to join the conversation.

More
4 years 9 months ago #232091 by rodw

Isn't this something that the built-on "comp" or "wcomp" components can do?

linuxcnc.org/docs/2.8/html/man/man9/comp.9.html
linuxcnc.org/docs/2.8/html/man/man9/wcomp.9.html
No wonder I wrote a component. The documentation there is truly awful. UNnless you have an electronics major you have no  clue what a comparator is.

Please Log in to join the conversation.

More
4 years 9 months ago #232148 by mgm
I have now managed to do this with the Halcompile. As an answer I got:

compiling realtime downdraft.c
Linking downdraft.so
cp downdraft.so /usr/lib/linuxcnc/modules/

I have also added the lines in the Hal file.

Now when I start Linuxcnc I get this error message:
HAL-ERROR: function downdraft not found!

What or where is the wrong?

Please Log in to join the conversation.

Time to create page: 0.153 seconds
Powered by Kunena Forum