Rando hal component collections
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10902
- Thank you received: 3613
21 Jan 2025 20:05 #319585
by rodw
This thread maybe should be helping people to get this formatted and into the code.
Replied by rodw on topic Rando hal component collections
This is how it should be done. Chances are it would be approved because a broken component will not break Linuxcnc. Compilation is automatically tested with the commit. I have submitted one this way. It does add some overhead to what you have to do as you need to format the comments etc so the man page is generated.Well anyone can just submit a component via pull request to the linuxcnc repo. Not sure if the maintainers test them at all other than making sure they compile. If it's a good an useful component, there's really no reason not to just submit it via pull request.
This thread maybe should be helping people to get this formatted and into the code.
Please Log in or Create an account to join the conversation.
- Aciera
- Offline
- Administrator
Less
More
- Posts: 4077
- Thank you received: 1763
21 Jan 2025 20:21 - 21 Jan 2025 21:03 #319588
by Aciera
Replied by Aciera on topic Rando hal component collections
Anything in a pull request should be mature and thoroughly tested. Changing the code of a hal component after it has been released brings the unpleasant possibility of breaking configurations.
A recent example is the 'toggle2nist.comp' that showed buggy behavior.
Given the lack of personnel we must not expect others to check the code we submit for inclusion.
A recent example is the 'toggle2nist.comp' that showed buggy behavior.
Given the lack of personnel we must not expect others to check the code we submit for inclusion.
Last edit: 21 Jan 2025 21:03 by Aciera.
Please Log in or Create an account to join the conversation.
- blazini36
- Away
- Platinum Member
Less
More
- Posts: 952
- Thank you received: 161
21 Jan 2025 21:28 #319592
by blazini36
Replied by blazini36 on topic Rando hal component collections
Sure, which is why this thread exists. We've all found useful crap in the wild on this forum but it's all still just floating around. Post it here, if it's of any particular interest to anyone that sees it here they can test it and discuss it......at least until there's a better place to dump the randos.Anything in a pull request should be mature and thoroughly tested. Changing the code of a hal component after it has been released brings the unpleasant possibility of breaking configurations.
A recent example is the 'toggle2nist.comp' that showed buggy behavior.
Given the lack of personnel we must not expect others to check the code we submit for inclusion.
Please Log in or Create an account to join the conversation.
- blazini36
- Away
- Platinum Member
Less
More
- Posts: 952
- Thank you received: 161
21 Jan 2025 21:38 #319595
by blazini36
In the spirit of community scrutinized randos, I'll post up the flash component I just whipped up. I've already tested the daylights out of it. It works where the blink component didn't because of the extra logic inputs. I won't submit it until I'm done setting up my project in case I have to add something but as far as it actually working, that's not an issue.
Replied by blazini36 on topic Rando hal component collections
Yeah that's kinda the point. People write their own little component and are kind enough to share it but don't want to deal with submitting and the description stuff as they don't really need it. Someone who just stumbles upon it here can take up that burden.
In the spirit of community scrutinized randos, I'll post up the flash component I just whipped up. I've already tested the daylights out of it. It works where the blink component didn't because of the extra logic inputs. I won't submit it until I'm done setting up my project in case I have to add something but as far as it actually working, that's not an issue.
component flash "Flash component to toggle output based on timing and control pins.";
function _ fp;
license "GPL";
author "Shade Technik";
description
"""
The flash component is a timed flasher with extra logic to make it suitable for many situations. The enable pin will begin flashing the output if the logic of the other pins does not hold it. The hold input pin can be used to hold the output true, which is useful to connect a separate output to in order to change the out pin from the flashing state to the held true state. The hold-prec (hold precidence) pin can be set or connected to a control pin
to switch whether the hold or flash effect takes precidence when both enable and hold are set true. The hold-prec-inv pin is used to invert the state of hold-prec internal logic so the pin controlling hold-prec can have opposing logic.
""";
pin in bit enable "Enable the output.";
pin in bit hold "Hold the output true when active.";
pin in bit hold_prec "Hold precidence. If true, hold input has precidence over the flash effect.";
pin in bit hold_prec_inv "If true, inverts the internal value of hold_prec.";
pin out bit out "The output pin.";
param rw s32 flash_rate_ms = 500 "Flash rate in milliseconds.";
variable float elapsed_time; // Tracks elapsed time in seconds
variable hal_bit_t state; // Internal state for blinking logic
;;
#include "rtapi.h"
#include "rtapi_app.h"
#include "hal.h"
static volatile hal_bit_t *enable_var;
static volatile hal_bit_t *hold_var;
static volatile hal_bit_t *hold_prec_var;
static volatile hal_bit_t *hold_prec_inv_var;
static volatile hal_bit_t *out_var;
static volatile hal_s32_t *flash_rate_ms_var;
FUNCTION(_)
{
if (!enable) {
state = 0; // Reset internal state when not enabled
out = 0; // Disable output
elapsed_time = 0.0; // Reset elapsed time
return;
}
// Calculate effective hold_prec based on hold_prec_inv
hal_bit_t effective_hold_prec = hold_prec;
if (hold_prec_inv) {
effective_hold_prec = !hold_prec; // Invert hold_prec if hold_prec_inv is true
}
if (hold) {
if (effective_hold_prec) {
// Enable flashing logic when effective_hold_prec is true and hold is active
elapsed_time += fperiod;
if (elapsed_time >= (flash_rate_ms / 1000.0)) {
elapsed_time = 0.0;
state = !state; // Toggle internal state
}
} else {
// Force output on when hold is active and effective_hold_prec is false
state = 1;
}
} else {
// Default to blinking logic when hold is not active
elapsed_time += fperiod;
if (elapsed_time >= (flash_rate_ms / 1000.0)) {
elapsed_time = 0.0;
state = !state; // Toggle internal state
}
}
out = state; // Update output based on internal state
}
The following user(s) said Thank You: rodw, spumco
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10902
- Thank you received: 3613
22 Jan 2025 03:19 #319612
by rodw
Replied by rodw on topic Rando hal component collections
STEPBOOST.COMP
For Lam Technologies Stepper drivers with Boost function
Enabling the stepper driver boost pin when at constant velocity reduces the stepper amperage allowing the motor to cool when not working hard.
This allows masssive improvement on performance from the stepper motor which only works when accellerationg at start and end of motion segment. Set the boost reduction to be say 30% of the default amps.
Certified tested safe for production
For Lam Technologies Stepper drivers with Boost function
Enabling the stepper driver boost pin when at constant velocity reduces the stepper amperage allowing the motor to cool when not working hard.
This allows masssive improvement on performance from the stepper motor which only works when accellerationg at start and end of motion segment. Set the boost reduction to be say 30% of the default amps.
Certified tested safe for production
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10902
- Thank you received: 3613
22 Jan 2025 03:23 #319613
by rodw
Replied by rodw on topic Rando hal component collections
SCALEBELTS.COMP
Calculate spindle speed based on belt positoin for a machine with 2 belts and 4 positions
Use with a matching QTdragon custom screen which was included in the qdragon release
linuxcnc.org/docs/stable/html/gui/qtdrag...ed_custom_vcp_panels
Calculate spindle speed based on belt positoin for a machine with 2 belts and 4 positions
Use with a matching QTdragon custom screen which was included in the qdragon release
linuxcnc.org/docs/stable/html/gui/qtdrag...ed_custom_vcp_panels
The following user(s) said Thank You: spumco
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10902
- Thank you received: 3613
22 Jan 2025 03:26 #319614
by rodw
Replied by rodw on topic Rando hal component collections
GEARBOX.COMP
Another gearbox component I wrote for a forum member. If you search for Techno, you might find more about this
Another gearbox component I wrote for a forum member. If you search for Techno, you might find more about this
The following user(s) said Thank You: tommylight, spumco
Please Log in or Create an account to join the conversation.
- blazini36
- Away
- Platinum Member
Less
More
- Posts: 952
- Thank you received: 161
22 Jan 2025 23:05 - 22 Jan 2025 23:07 #319683
by blazini36
Replied by blazini36 on topic Rando hal component collections
Here's a good one.....
The control panel I'm working on uses 1 button for (cycle) start/pause and another button for (cycle) stop. I made it that way before I bothered figuring out how to do the hal programming. Now that I look at halui, it doesn't really like that setup. I searched and this came up before...
forum.linuxcnc.org/47-hal-examples/13201...-hold-resume-buttons
Writing HAL lines like that I find confusing when there's alot of logic involved. I started to break it down like I write them, to "look" like a terminal block. I'm sure it works but that's alot of HAL to do something like this. I reworked the toggle2nist component to add 2 more outputs to set resume and pause directly and another input to take the opposing state of what was "is-on". I just named the component and the pins as a specialized component since it's probably not as generally useful. It works perfectly without extra hal components. My flash component is also used here to switch an LED on/flashing when program is running, and on/solid when it is paused. It's off when stopped.
This is all the HAL lines for this setup:
And this is the component:
I'll submit this when I'm done testing it but so far so good.
The control panel I'm working on uses 1 button for (cycle) start/pause and another button for (cycle) stop. I made it that way before I bothered figuring out how to do the hal programming. Now that I look at halui, it doesn't really like that setup. I searched and this came up before...
forum.linuxcnc.org/47-hal-examples/13201...-hold-resume-buttons
Writing HAL lines like that I find confusing when there's alot of logic involved. I started to break it down like I write them, to "look" like a terminal block. I'm sure it works but that's alot of HAL to do something like this. I reworked the toggle2nist component to add 2 more outputs to set resume and pause directly and another input to take the opposing state of what was "is-on". I just named the component and the pins as a specialized component since it's probably not as generally useful. It works perfectly without extra hal components. My flash component is also used here to switch an LED on/flashing when program is running, and on/solid when it is paused. It's off when stopped.
This is all the HAL lines for this setup:
#program-run,pause,stop
net program-btn => run_pause.program.in
net program-toggle-run <= run_pause.program.run
net program-toggle-run => halui.program.run
net program-toggle-pause <= run_pause.program.pause
net program-toggle-pause => halui.program.pause
net program-is-running <= halui.program.is-running
net program-is-running => run_pause.program.running
net program-is-running => or2.program.in0
net program-resume <= run_pause.program.resume
net program-resume => halui.program.resume
net program-is-paused <= halui.program.is-paused
net program-is-paused => run_pause.program.paused
net program-is-paused => or2.program.in1
net program-run-or-pause <= or2.program.out
net program-run-or-pause => flash.program.enable
net program-is-paused => flash.program.hold
net program-led <= flash.program.out
net program-stop-btn => halui.program.stop
setp flash.program.hold-prec false
setp flash.program.hold-prec-inv false
setp flash.program.flash-rate-ms 250
And this is the component:
component run_pause "Run-Pause, component for controlling halui program pins with 2 momentary pushbuttons";
description
"""
Run_Pause is based on the component toggle2nist. It has been specialized to work with halui program pins controlled with only 2 pushbuttons, start/resume and stop without adding a bunch of external logic.
""";
pin in bit in "momentary button for run/pause input";
pin in bit running "running state input";
pin in bit paused "paused state input";
pin in unsigned debounce = 2 "debounce delay for 'in'-pin in cycles";
pin out bit run "run output, activates on in=true when paused=false and running=false";
pin out bit pause "pause output, activates on in=true when paused=false and running=true";
pin out bit resume "resume output, activates on in=true when paused=true and running=false";
variable int debounce_cntr;
variable unsigned debounce_set;
variable int state;
function _ nofp;
license "GPL";
author "Shade Technik";
author "Anders Wallin, David Mueller"; //Authors or toggle2nist
;;
FUNCTION(_) {
if (( debounce < 1 ) || ( debounce > 10000 )) {
debounce_set = 2; /* set a sane value */
} else {
debounce_set = debounce;
}
if (in && state == 0 ) { /* input has changed from debounced 0 -> 1 */
debounce_cntr++;
if ( debounce_cntr >= debounce_set ) {
if (!running && paused) { /* turn ON if it's paused */
resume = 1;
pause = 0;
} else if (running && !paused) { /* turn OFF if it's running */
resume = 0;
pause = 1;
}
state = 1;
debounce_cntr = 0;
}
} else if (!in && state == 1) { /* input has changed from debounced 1 -> 0 */
debounce_cntr++;
if ( debounce_cntr >= debounce_set ) {
state = 0;
debounce_cntr = 0;
}
} else if ((!running && pause) || (running && run)) { /* reset outputs once device has switched */
run = 0;
pause = 0;
debounce_cntr = 0;
} else {
debounce_cntr = 0;
}
/* Set resume output while in is true and neither running nor paused is active */
if (in && !running && !paused) {
run = 1;
} else {
run = 0;
}
}
I'll submit this when I'm done testing it but so far so good.
Last edit: 22 Jan 2025 23:07 by blazini36.
The following user(s) said Thank You: rodw, spumco
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10902
- Thank you received: 3613
23 Jan 2025 10:17 #319701
by rodw
Replied by rodw on topic Rando hal component collections
DDRAFT4x2.comp
This one is designed to drive the air side of a zoned downdraft plasma table with 8 zones (2 in x direction and 4 in y direction)
the extraction duct has shutters triggered by an air solenoid so this is output pin heavy!
And a hal file you can add to your ini file. We found adding an off delay which leave 2 zones open when crossing a zone boundary worked well.
Forum thread for pictures of machine is here
forum.linuxcnc.org/plasma-laser/40517-do...ions?start=10#188738
This one is designed to drive the air side of a zoned downdraft plasma table with 8 zones (2 in x direction and 4 in y direction)
the extraction duct has shutters triggered by an air solenoid so this is output pin heavy!
And a hal file you can add to your ini file. We found adding an off delay which leave 2 zones open when crossing a zone boundary worked well.
Forum thread for pictures of machine is here
forum.linuxcnc.org/plasma-laser/40517-do...ions?start=10#188738
Attachments:
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
Time to create page: 0.081 seconds