Is it possible to combine M67 and pyVCP?

More
05 Jan 2020 12:12 #154093 by aleksamc
I want to make for my analog signal (M67 E0 Q<power>) some regulation, similar to spinde regulation.

What we have for spindle:
We set rotation with M3 S### and after that we can decrease spindle rotation with buttons on panel.

I want to make the same for may analog output. Analog output should regulate power using PWM of laser.
Does it's possible to make such mathematical calculations in pyVCP?
I see my aim as:
1) I create scale in pyVCP with some value "k1"
2) I need to make math calculations P=k1*Q0; (it's floating point calculatiosns, Q0 - is output 0 of M67)
3) Connect P => pwmgen.0.value

And after that this calculations should be fast to work on flow of running G-code with G64 (maximum possible speed).
Does it's possible to realize it? What ways of doing it?

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

More
07 Jan 2020 15:11 #154216 by andypugh
One way would be to pass the M67 output through a HAL scale component and set the value of the gain pin of that module from Python code.

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

More
07 Jan 2020 21:02 #154257 by rodw
This post may be of interest to you.
forum.linuxcnc.org/plasma-laser/32691-settings-from-g-code-file

Here we had a real time component catching the M67/M68 analog value and sending it to the python screen handler for the Gmoccappy Plasma sim. This allowed setting of a GUI variable from gcode. And yes any maths becomes trivial in Python. (or in the component if real time is required).

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

More
09 Jan 2020 08:35 - 09 Jan 2020 08:36 #154417 by aleksamc
Thanks, I used "scale"
loadrt scale count=1
addf scale.0 servo-thread

net sc_in scale.0.in <= motion.analog-out-00
net sc_gn scale.0.gain
setp scale.0.offset 0
net laser_power scale.0.out => pwmgen.0.value
#where sc_gn comes from pyvcp.variable

As for rodw answer, it's very interesting, I must study it.
Last edit: 09 Jan 2020 08:36 by aleksamc.
The following user(s) said Thank You: rodw

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

More
26 Jan 2020 12:51 #155801 by bbsr_5a
woudent it be better to get LASER_Power over the Spindle RPM so you can TWEAK it in the GUI direct as Sliders Like AXIS
Spindle override USED

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

More
27 Jan 2020 18:43 #155938 by aleksamc
No, it's not. I used such way at first.
It's only useful if you want to use laser as cutter. If you want change power "on-line" than in such way your program will stops each time when in G-code be writtent <S###>.

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

More
27 Jan 2020 20:48 #155954 by tommylight

No, it's not. I used such way at first.

Me too.

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

More
28 Jan 2020 06:56 - 28 Jan 2020 06:58 #155979 by andypugh

Here we had a real time component catching the M67/M68 analog value and sending it to the python screen handler for the Gmoccappy Plasma sim. This allowed setting of a GUI variable from gcode. And yes any maths becomes trivial in Python. (or in the component if real time is required).


I just want to clarify something here.

If you want realtime control of the laser power then any scaling has to be done in HAL by a realtime component.
It's OK to pass a value out of the GUI in the HAL as a factor, because anything you operate by hand is inherently not realtime or synchronised to motion. But the scaling should be in HAL realtime, not in Python.

M67 is the best way to change laser power in G-code as it does not break path blending, whereas using S or Z can.

But bear in mind that the final laser power setting needs to be an M68, as M67 takes effect the moment that the next axis move starts. And at the end of the program there might not be one.
Last edit: 28 Jan 2020 06:58 by andypugh.
The following user(s) said Thank You: tommylight, rodw

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

More
28 Jan 2020 16:49 - 28 Jan 2020 16:50 #156018 by tommylight

But bear in mind that the final laser power setting needs to be an M68, as M67 takes effect the moment that the next axis move starts. And at the end of the program there might not be one.

I have solved that issue with adding M3 and M5 to gcode and wiring spindle on to pwm enable, and adding G1 X0 y0 z0 M67 E0 Q0 at the end of gcode files, this way even when i hit ESC it disables PWM so the pressure or laser will be off.
Last edit: 28 Jan 2020 16:50 by tommylight.

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

More
28 Jan 2020 18:19 #156033 by aleksamc
I made something similar logic:
My logic looks like:
TurnSpindle_ON = NOT use_laser AND TurnSpindle_ON
TurnLaser_ON = use_laser AND TurnSpindle_On 
And PWM regulates using M68 E0 Q255 separetly.
It gives me posibility to worke with laser and spindle simultanously. But I'm sure I will never work like this because
spindle makes a lot of dust that can demage laser lense.

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

Time to create page: 0.166 seconds
Powered by Kunena Forum