lube - time component
- greg23_78
- Offline
- Premium Member
Less
More
- Posts: 134
- Thank you received: 5
04 Sep 2024 16:43 - 04 Sep 2024 16:49 #309369
by greg23_78
lube - time component was created by greg23_78
currently have a CentralizedLubricator but it works differently from lube.py
I have the same components as lube.py except that my engine runs more slowly 0.13333 RPM with a reduction behind. so it sends oil about every 10 minutes.
not knowing the python language i wanted to know if with the hal Component if it is possible to implement a timer that works when the machine and the spindle are enabled. reset the timer when an oil pressure is received, activate the output of the timer if the timer=preset, which indicates that the motor is in fault or big leak.
TON can be considered but I would like the time to remain in memory if the spindle is stopped and resume the timer when it is on
#!/usr/bin/python
import linuxcnc, hal, time
lube = hal.component("lube")
lube.newpin("fault", hal.HAL_BIT, hal.HAL_OUT)
lube.newpin("run", hal.HAL_BIT, hal.HAL_OUT)
lube.newpin("delay", hal.HAL_BIT, hal.HAL_OUT)
lube.newpin("machine_status", hal.HAL_BIT, hal.HAL_IN)
lube.newpin("spindle_status", hal.HAL_BIT, hal.HAL_IN)
lube.newpin("pressuresw_floatsw", hal.HAL_BIT, hal.HAL_IN)
lube.newpin("reset", hal.HAL_BIT, hal.HAL_IN)
lube.ready()
#initialize variables
lube['run'], lube['fault'] = 0, 0
try:
while 1:
time.sleep(0.5)
lube['delay'] = 0
#1. machine needs to be on
#2. spindle needs to be running like in a g-code program
#3. there should be no pump faults
if(lube['machine_status'] and lube['spindle_status'] and not lube['fault']):
lube['run'] = 1;
time.sleep(10) #run pump for 10s
if(lube['pressuresw_floatsw']):
time.sleep(50) #continue running pump for an additional 50s
lube['run'] = 0;
lube['delay'] = 1; #show that pump is resting
time.sleep(720) #let the pump rest for 720s (12 min)
else:
lube['run'] = 0; #shut off pump immediately
lube['fault'] = 1; #there is a fault if input 14 becomes active (fluid low or a big leak somewhere)
#gives user to ability to reset the fault after fluid was filled or leak was fixed
if(lube['reset']):
lube['fault'] = 0;
lube['reset'] = 0; #reset the reset!
except KeyboardInterrupt:
raise SystemExit
I have the same components as lube.py except that my engine runs more slowly 0.13333 RPM with a reduction behind. so it sends oil about every 10 minutes.
not knowing the python language i wanted to know if with the hal Component if it is possible to implement a timer that works when the machine and the spindle are enabled. reset the timer when an oil pressure is received, activate the output of the timer if the timer=preset, which indicates that the motor is in fault or big leak.
TON can be considered but I would like the time to remain in memory if the spindle is stopped and resume the timer when it is on
Attachments:
Last edit: 04 Sep 2024 16:49 by greg23_78.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23558
- Thank you received: 4858
07 Sep 2024 09:04 #309546
by andypugh
Replied by andypugh on topic lube - time component
You say that you don't know Python, so do you know C? (Or classic ladder)
If you know C then you could look at making a custom realtime component (it's easy with halcompile)
linuxcnc.org/docs/devel/html/hal/comp.html
You could maybe start with the timedelay component and add your extra features.
github.com/LinuxCNC/linuxcnc/blob/master...nents/timedelay.comp
Otherwise, you can almost certainly assemble the behaviour you want from existing, standard HAL components. For example maybe a flipflop
linuxcnc.org/docs/stable/html/man/man9/flipflop.9.html
with a timerdelay to reset it, with some HAL logic elements to control the inputs.
If you know C then you could look at making a custom realtime component (it's easy with halcompile)
linuxcnc.org/docs/devel/html/hal/comp.html
You could maybe start with the timedelay component and add your extra features.
github.com/LinuxCNC/linuxcnc/blob/master...nents/timedelay.comp
Otherwise, you can almost certainly assemble the behaviour you want from existing, standard HAL components. For example maybe a flipflop
linuxcnc.org/docs/stable/html/man/man9/flipflop.9.html
with a timerdelay to reset it, with some HAL logic elements to control the inputs.
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
07 Sep 2024 16:01 #309588
by chris@cnc
Replied by chris@cnc on topic lube - time component
I tried to build a custom component like this. It looks pretty good at the moment.
It works like this:
if input0 and 1 are active, the lube on timer starts and the output.
If the lubrication time has elapsed, the output switches off.
A pressure switch connection is also possible with input2.
After the lubrication time has been reached, the pressure switch is expected for 5 seconds (pressure time).
If it is not high, the alarm output is set, which you can then connect to messages. It works very well in my simulator.
Maybe it will help you.to install the component, save the lube.comp file and then
"sudo halcompile --install lube.comp"or follow Andy's link.
And for the connection in hal, is an example in custom_postgui.hal.
lube on and off time is adjustable with these pins
setp lube.0.lubeon 10 -> 10 seconds lube time
setp lube.0.lubeoff 600 -> 10 min off time
expected pressure time is adjustable with this pin
setp lube.0.pressuretime 5 -> 5 seconds expected the pressure switch high on input2 I guess o good monitoring. If to much you could decrease
It works like this:
if input0 and 1 are active, the lube on timer starts and the output.
If the lubrication time has elapsed, the output switches off.
A pressure switch connection is also possible with input2.
After the lubrication time has been reached, the pressure switch is expected for 5 seconds (pressure time).
If it is not high, the alarm output is set, which you can then connect to messages. It works very well in my simulator.
Maybe it will help you.to install the component, save the lube.comp file and then
"sudo halcompile --install lube.comp"or follow Andy's link.
And for the connection in hal, is an example in custom_postgui.hal.
lube on and off time is adjustable with these pins
setp lube.0.lubeon 10 -> 10 seconds lube time
setp lube.0.lubeoff 600 -> 10 min off time
expected pressure time is adjustable with this pin
setp lube.0.pressuretime 5 -> 5 seconds expected the pressure switch high on input2 I guess o good monitoring. If to much you could decrease
The following user(s) said Thank You: andypugh, pommen, besriworld
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
08 Sep 2024 18:24 #309691
by chris@cnc
Replied by chris@cnc on topic lube - time component
I noticed that the pressure drops immediately after the lubrication pump is switched off. I think it is better to check the pressure switch before lubrication time end. With 30 second lubrication time, the pressure switch has to go up after 25 seconds. And after lubrication time end, no pressure is expected.
Please Log in or Create an account to join the conversation.
- greg23_78
- Offline
- Premium Member
Less
More
- Posts: 134
- Thank you received: 5
11 Sep 2024 19:16 #309935
by greg23_78
Replied by greg23_78 on topic lube - time component
thank you for sharing your code, but my configuration is a little bit different.
Indeed, you have a lubrication every 30 seconds so you can control not to keep in memory the timer when the condition spindle and motion are not met.
on the other hand, in my configuration I have lubrication every 10-15 min. so if I have a programme that lasts 8 min I will never see the oil pressure information. I will have to wait for a programme that lasts more than 10-15 min to find out if I have an motor fault or a big leak.
Unfortunately I don't know the python language or c (I can read it if there are a lot of comments) only the ladder but it's the last thing to set on my lathe and I haven't used classic ladder so I wouldn't want to use it just for that.
how can i implement your code with a timer in memory?
Indeed, you have a lubrication every 30 seconds so you can control not to keep in memory the timer when the condition spindle and motion are not met.
on the other hand, in my configuration I have lubrication every 10-15 min. so if I have a programme that lasts 8 min I will never see the oil pressure information. I will have to wait for a programme that lasts more than 10-15 min to find out if I have an motor fault or a big leak.
Unfortunately I don't know the python language or c (I can read it if there are a lot of comments) only the ladder but it's the last thing to set on my lathe and I haven't used classic ladder so I wouldn't want to use it just for that.
how can i implement your code with a timer in memory?
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
11 Sep 2024 20:10 #309940
by chris@cnc
Replied by chris@cnc on topic lube - time component
It is not possible to mix them but the code is more flexible than it looks.
The lubon and lubeoff timers are freely adjustable.I have this time only for testing. You can change it freely
If you change this line in hal to
If the lubrication cycle is aborted by the end of the program, the timer remains in memory and continues at the same point the next time it is started. Try it out as shown in the screenshot. It works..
The lubon and lubeoff timers are freely adjustable.
setp lube.0.lubeon 10 // 10 secons lubeon
setp lube.0.lubeoff 30 // 30 secons lubeoff
setp lube.0.pressuretime 5 // 5 secons pressureswitch on
If you change this line in hal to
setp lube.0.lubeon 30 // 30 secons lubeon
setp lube.0.lubeoff 600 // 10min lubeoff
setp lube.0.pressuretime 2 // 2 secons pressureswitch on
If the lubrication cycle is aborted by the end of the program, the timer remains in memory and continues at the same point the next time it is started. Try it out as shown in the screenshot. It works..
Please Log in or Create an account to join the conversation.
- Benb
- Offline
- Premium Member
Less
More
- Posts: 136
- Thank you received: 50
12 Sep 2024 00:53 - 12 Sep 2024 00:55 #309957
by Benb
Replied by Benb on topic lube - time component
Following is a LinuxCNC hal configuration as per your description.
Netlisting of the above schematic:
# Load realtime Components and their counts
loadrt and2 count= 2
loadrt message count= 1 messages="No oil pressure"
loadrt not count= 1
loadrt timedelay count= 1
# Add functions to threads
addf and2.0 servo-thread
addf and2.1 servo-thread
addf message.0 servo-thread
addf not.0 servo-thread
addf timedelay.0 servo-thread
# Set parameters
setp timedelay.0.on-delay 10.0
# Connect pins to signals
net hm2_7i97.0.7i84.0.0.input-01 timedelay.0.in
net hm2_7i97.0.ssr.out-05 and2.1.out
net mot-spndl-on and2.1.in0 and2.0.out
net motion.enabled and2.0.in0
net no-fault not.0.out and2.1.in1
net spindle.enabled and2.0.in1
net trig.msg timedelay.0.out not.0.in message.0.trigger
Netlisting of the above schematic:
# Load realtime Components and their counts
loadrt and2 count= 2
loadrt message count= 1 messages="No oil pressure"
loadrt not count= 1
loadrt timedelay count= 1
# Add functions to threads
addf and2.0 servo-thread
addf and2.1 servo-thread
addf message.0 servo-thread
addf not.0 servo-thread
addf timedelay.0 servo-thread
# Set parameters
setp timedelay.0.on-delay 10.0
# Connect pins to signals
net hm2_7i97.0.7i84.0.0.input-01 timedelay.0.in
net hm2_7i97.0.ssr.out-05 and2.1.out
net mot-spndl-on and2.1.in0 and2.0.out
net motion.enabled and2.0.in0
net no-fault not.0.out and2.1.in1
net spindle.enabled and2.0.in1
net trig.msg timedelay.0.out not.0.in message.0.trigger
Attachments:
Last edit: 12 Sep 2024 00:55 by Benb.
The following user(s) said Thank You: besriworld, the_erk
Please Log in or Create an account to join the conversation.
- Mecanix
- Offline
- Platinum Member
Less
More
- Posts: 446
- Thank you received: 216
19 Nov 2024 16:11 #314857
by Mecanix
Replied by Mecanix on topic lube - time component
Here's the one I use. It's a Travel Distance & Lube component. Rather than time based.
That way you can leave the machine idle for a day and the oil jar won't empty itself in your coolant reservoir.
e.g. at every 3000mm travel in the Z, lube for 2 seconds.
Must have (imho)
That way you can leave the machine idle for a day and the oil jar won't empty itself in your coolant reservoir.
e.g. at every 3000mm travel in the Z, lube for 2 seconds.
Must have (imho)
Please Log in or Create an account to join the conversation.
Time to create page: 0.116 seconds