[SOLVED] Adjustable timed output flasher

More
05 Jan 2022 19:47 #230888 by spumco

You can do this with the time delay component:
loadrt timedelay
loadrt not
addf timedelay.0 servo-thread
addf not.0 servo-thread


net timeloop1 timedelay.0.out not.0.in
net timeloop2 timedelay.0.in not.0.out

And then net timedelay.0.on-delay and timedelay.0.off-delay to
pins from encoders etc that set the appropriate times



Thank you PCW.  I'll try it when I get home... but what starts/stops the timer/relay process?

It looks like a closed circle between the timedelay and not components.  timedelay.0.out => not.0.in => timedelay.0.in => not.0.out =>

What am I missing?  Or is this a continuous loop that runs as long as LCNC is open, and I turn it "on" by changing the on-delay & off-delay values up from zero?

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

More
05 Jan 2022 20:05 #230890 by rodw
The servo-thread is a continuous loop that runs whenever linuxcnc is running (assuming your hal file creates it)
It is basically a timer interrupt that fires every 1 millisecond and services all the components loaded in turn.
So you never need to use loops in a component, you just wait 1 ms for the next call.
That goes for the core components like timedelay and also for custom components like Chris wrote.
Sometimes you can build what you want by combining custom components, but as Chris showed, its often easier and more efficient to write a custom component.

If you are familiar with PLC's and ladder logic like the Feral Engineer, Classic Ladder is worth using. If you have a smattering of C, writing your own component is simple and efficient. see linuxcnc.org/docs/devel/html/hal/comp.html
The following user(s) said Thank You: spumco

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

More
05 Jan 2022 20:06 #230891 by PCW
Yeah there's no off on this...
You could either gate the output (with an "and2" comp)
or put a and2 gate in the loop so it starts synchronously
The following user(s) said Thank You: spumco

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

More
06 Jan 2022 02:41 #230922 by spumco
Perfect, thank you PCW!

Had to fiddle a bit, but this works exceptionally well.  Press the momentary button and the cycle starts with the output off, then 'catches up' and starts flashing nicely. ON and OFF times respond nicely when the pots are twiddled.

Next step is to set up a multiclick so I can press/hold the button for a manual blast, or a double-click to start the on/off cycle.

For posterity:
net BLAST_OFF_ANA          <=  hm2_7i76e.0.7i84.0.1.analogin0
net BLAST_OFF_ANA          =>  scale.1.in
net BLAST_OFF_SCALED    <=  scale.1.out
setp scale.1.gain       0.125   #0-24V pot in = 0-3 seconds ON time
net BLAST_ON_ANA            <=  hm2_7i76e.0.7i84.0.1.analogin1
net BLAST_ON_ANA            =>  scale.2.in
net BLAST_ON_SCALED     <=  scale.2.out
setp scale.2.gain       1.25    #0-24V pot in = 0-30 seconds OFF time

net BLAST_BTN                   <=  hm2_7i76e.0.7i84.0.1.input-30
net BLAST_BTN                   =>  toggle.4.in
net BLAST_TOG                  <=  toggle.4.out

net BLAST_ON_SCALED      =>  timedelay.4.off-delay
net BLAST_OFF_SCALED    =>  timedelay.4.on-delay
net BLAST_TIMER               <=  timedelay.4.out
net BLAST_TIMER               =>  not.3.in
net BLAST_TIME_ON          <=  not.3.out
net BLAST_TIME_ON          =>  and2.3.in0
net BLAST_TOG                 =>  and2.3.in1
net BLAST_ON                   <=  and2.3.out
net BLAST_ON                   =>  timedelay.4.in

net BLAST_TIMER              =>  hm2_7i76e.0.7i84.0.1.output-10        #button LED
net BLAST_TIMER              =>  [HMOT](CARD0).7i76.0.0.output-04  #solenoid valve
The following user(s) said Thank You: tommylight

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

More
06 Jan 2022 12:05 #230947 by tommylight
Nicely done, but who is ANA? :)
I absolutely and unequivocaly love HAL since the first time i edited a config, it can do pretty much everything.

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

More
06 Jan 2022 12:38 #230951 by spumco

Nicely done, but who is ANA? :)
I absolutely and unequivocaly love HAL since the first time i edited a config, it can do pretty much everything.
 


The temptation to further identify the pots as "L" and "R" was almost overwhelming as it would have led to sniggering ever time I read over that section.

But I don't need to get banned here just yet...
The following user(s) said Thank You: tommylight

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

More
06 Jan 2022 12:48 #230955 by tommylight
The topic is set for all replies to solved.
Thank you.

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

Time to create page: 0.090 seconds
Powered by Kunena Forum