Switch relay in a defined x position

More
4 years 3 months ago #247145 by caretech
I figured I'd probably take the component Rodw provided in this thread and modify it as needed for my table, but was wondering if there would be reasons why using built-in components would be better. For instance will the "halcompile" step be needed again after upgrading LinuxCNC? I built on MX Linux 21.

Then again, now it just occurred to me that as far as custom components go I'm using Rod's ohmic3.comp for ohmic probing with a THCAD-5. So... if custom components need to be reinstalled after upgrading I am not clear of that anyhow. I'll go study the downdraft component provided in the other thread some more.
The following user(s) said Thank You: tommylight

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

More
4 years 3 months ago - 4 years 3 months ago #247147 by mgm
I have a spindle support which is retracted and extended with a pneumatic cylinder. The cylinder is controlled via a relay which is controlled with a digital output of the Mesacard.

Attached is the comp file.
This is the hal entry
# --- Spindle support---
net position axis.x.pos-cmd => spport.position
net spport-trigger spport.trigger => hm2_7i76e.0.7i76.0.0.output-05
setp spport.on 700
setp spport.off 1900
 
Last edit: 4 years 3 months ago by mgm.
The following user(s) said Thank You: caretech

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

More
4 years 3 months ago - 4 years 3 months ago #247154 by itsme
Code:
loadrt wcomp names=wcomp_segment0,wcomp_segment1,wcomp_segment2,wcomp_segment3,wcomp_segment4,wcomp_segment5 loadrt not names=not_segment0,not_segment1,not_segment2,not_segment3,not_segment4,not_segment5 addf wcomp_segment0    servo-thread addf wcomp_segment1    servo-thread addf wcomp_segment2    servo-thread addf wcomp_segment3    servo-thread addf wcomp_segment4    servo-thread addf wcomp_segment5    servo-thread setp wcomp_segment0.min    -456 setp wcomp_segment0.max    -44 setp wcomp_segment1.min    -144 setp wcomp_segment1.max    268 setp wcomp_segment2.min    168 setp wcomp_segment2.max    580 setp wcomp_segment3.min    480 setp wcomp_segment3.max    892 setp wcomp_segment4.min    792 setp wcomp_segment4.max    1204 setp wcomp_segment5.min    1104 setp wcomp_segment5.max    1516 #SEGMENTS switching net y_curr_pos axis.y.pos-cmd wcomp_segment0.in wcomp_segment1.in wcomp_segment2.in wcomp_segment3.in wcomp_segment4.in wcomp_segment5.in net within_segment0 wcomp_segment0.out => not_segment0.in net within_segment1 wcomp_segment1.out => not_segment1.in net within_segment2 wcomp_segment2.out => not_segment2.in net within_segment3 wcomp_segment3.out => not_segment3.in net within_segment4 wcomp_segment4.out => not_segment4.in net within_segment5 wcomp_segment5.out => not_segment5.in # i use GPIO 11, 09, 10, 25, 08, 07 segment0-5, thats rpin 23, 21, 19, 22, 24, 26 net not_within_segment0 not_segment0.out => hal_pi_gpio.pin-23-out net not_within_segment1 not_segment1.out => hal_pi_gpio.pin-21-out net not_within_segment2 not_segment2.out => hal_pi_gpio.pin-19-out net not_within_segment3 not_segment3.out => hal_pi_gpio.pin-22-out net not_within_segment4 not_segment4.out => hal_pi_gpio.pin-24-out net not_within_segment5 not_segment5.out => hal_pi_gpio.pin-26-out
I use a RPI4 and have to use inverted outputs, thus the not usage...
There are 6 (overlapping) segments configured on y axis.
Last edit: 4 years 3 months ago by itsme.
The following user(s) said Thank You: caretech

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

More
1 year 2 months ago #332752 by mgm
Hello everyone,

I would like to revisit this topic.
The component has been working very well and reliably for three years now.
Unfortunately, I have already broken the spindle support twice, but this was not due to the component itself, but rather to the compressed air in our workshop.
I would therefore like to install a position switch to check the position of the cylinder and ensure that it is actually retracted.
To do this, the component would need to be expanded with an additional pin and a query.
Now my question to you, or rather to Rod, is whether you could help me with this again?
This is the current Comp file:
Code:
component spinport "LinuxCNC HAL component that switches the spindle support"; description """ Component to trigger the spindle support \\fBEXAMPLE:\\fR .br .br loadrt spinport names=spport .br addf spport servo-thread .br net position axis.y.pos-cmd => spport.position .br setp spport.on 900 .br setp spport.off 1600 .br net spport-trigger spport.trigger """; author "Rod Webster"; pin in float position "Motion signal for Axis position"; pin out bit trigger "True if spinport segment should be triggered"; param rw float on "Absolute axis coordinate from which the support is retracted"; param rw float off "Absolute axis coordinate from which the support is extended"; function _; license "GPL"; ;; #include <rtapi_math.h> FUNCTION(_) { if((position > on)&&(position < off)) trigger = 0; else trigger = 1; }

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

More
1 year 2 months ago #332763 by Benb
The following hal file is based on linuxcnc wcomp component.
linuxcnc.org/docs/2.8/html/man/man9/wcomp.9.html
The file was automatically generated by the eagle2hal script. 
 
​​​​​​​
#
# Load realtime Components and their counts
loadrt not          count= 1
loadrt or2          count= 1
loadrt wcomp    count= 1
#
# Add functions to threads
addf wcomp.0              servo-thread
addf not.0                    servo-thread 
addf or2.0                    servo-thread 
#
# Set parameters
setp wcomp.0.max  1600.0      
setp wcomp.0.min  900.0     
#
# Connect Pins using signals/wires
net axis.x.pos-cmd wcomp.0.in
net cyln.pos<max&&>min wcomp.0.out  not.0.in
net cyln.pos>max&&<min not.0.out  or2.0.in0 
net cyln.extended or2.0.in1  wcomp.0.under  
net trigger or2.0.out  hm2_7i76e.0.7i76.0.0.output-05 
 

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

More
1 year 2 months ago #332804 by mgm
Hi Benny,
Thanks for your message!
If I understand correctly, the HAL lines are the implementation of my current comp file, right?

I would now have to add the position switch and the query for the switch position and then connect it to the emergency stop if the position is incorrect.

Do I add the HAL lines to my existing HAL?

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

Time to create page: 0.466 seconds
Powered by Kunena Forum