Secondary PWM Output for LASER

More
30 Apr 2017 21:26 - 30 Apr 2017 21:28 #92376 by Askjerry
I have a CNC machine set up to operate a spindle with PWM... so I can do a M3 S6000 and the spindle will come up to speed nicely.

That is fine and wonderful... but now I want to connect a LASER to my CNC for some engraving work. I was going to connect the trigger of the laser to a pin... let's say PARAPORT-17 since it's available. And I can make a post-processor using Aspire that will switch a DIGITAL 0 on and off to operate the laser.

Basically... M62 through M65 as needed. Re: linuxcnc.org/docs/html/gcode/m-code.html#mcode:m62-m65

But here is the thing... what if I want to connect the LASER trigger to a PWM instead of just ON/OFF? There are a couple of things I could do... I could take the same PWM from the spindle and run it through a AND gate with the DIGITAL OUT 0 so that it only fires the laser when BOTH the PWM and the DIGITAL 0 are high.

It would allow something like M62 P0 S5000 to turn it on at a specified PWM. (If possible)

Or I could assign another pin (say PARAPORT-16) as a dedicated PWM for the laser... and change it from 0 to xxxx as needed.

Any idea how this could be accomplished?

It would mean variable LASER output under machine control... light marks through heavy etching depending on the PWM used.

Can it be done or do I need a manually controlled PWM source?

How can I configure a pin to be PWM and trigger it as needed?

Any ideas?

Thanks!
Jerry
Last edit: 30 Apr 2017 21:28 by Askjerry.

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

More
30 Apr 2017 22:04 #92381 by tommylight
Have a look at this, has everything included, did it a while back and use it quite offten. Should do as is, just change the pin numbers if needed.

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

More
30 Apr 2017 22:07 #92382 by Askjerry
Not seeing an attachment nor a link... am I missing something?
Thanks ~ Jerry

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

More
30 Apr 2017 22:12 #92383 by tommylight
There are several further down in the post, but here is the one i am using currenlty. It has quadrature outputs, so you would be better off just taking the spindle pwm part and using the dmap2gcode for output.
Attachments:
The following user(s) said Thank You: Askjerry

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

More
30 Apr 2017 23:11 #92393 by Askjerry
It may take me awhile to decipher this... it looks like the core section is here...
addf pwmgen.make-pulses base-thread
addf pwmgen.update servo-thread

setp pwmgen.0.enable TRUE

#setp pwmgen.0.pwm-freq 1000
#setp pwmgen.0.scale 100
#setp pwmgen.0.offset 0
#setp pwmgen.0.min-dc 1
#setp pwmgen.0.max-dc 99
#setp pwmgen.0.dither-pwm true
#net spindle-cw <= motion.spindle-forward

net analogout motion.analog-out-00 => pwmgen.0.value
net laserpwm pwmgen.0.pwm => parport.0.pin-02-out
net laserpwm pwmgen.0.pwm => parport.0.pin-04-out
setp parport.0.pin-04-out-invert TRUE

Fairly certain my HAL already started a PWM function... may or may not need to start another one.
Looks like you are connecting the PWM function to pins 2 and 4... with 4 being inverted... not really sure why.

On the laser I purchased, there is 12vcd, Ground, and 5v PWM which will come from the PC.

Presuming I get this configured and connected to say PIN 16 or 17 on my paraport... I still need to figure out how to send it the command to set the PWM. I know that for the spindle it is Sxxxx used in conjunction with M3.


I'm seeing lines similar to this: G00 Z[0.000000*#11+#8] M67 E0 Q0 in the G-Code... so I presume the following... linuxcnc.org/docs/html/gcode/m-code.html#mcode:m67

Switching a synchronized motion... with E0 being OUTPUT 0 and the Qx.xx value being the desired voltage.

I should be able to get something running with this information... thanks.
May take me a bit to figure it all out however.

I appreciate getting me started!
Jerry

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

More
30 Apr 2017 23:56 #92396 by tommylight
Yes on all cases.
I used an inverted pwm pin for testing as the included dmap2gcode will produce negative values for m67, they have to be removed for normal use. The included dmap will output gcode ready for use with Linuxcnc, removing "-" is all the editing it needs, can be done with "replace" function in any text editor in about 10 seconds. Included are 2 ngc files for testing, should work, been a long time since i did that so i can not recal at what state i left the.
Another tip, to prevent jerking and slow downs, make sure the machine can handle high acceleretion, i have mine set at 3000 and 5000 on 2 types of machines, metric values.

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

More
01 May 2017 00:04 #92397 by Askjerry
Thanks again.

Getting it to work on the Frankenlab will be for testing only. I intend to build a much larger machine with a completely different configuration. Possibly a secondary X-Axis (belt driven) to allow high-speed raster drawing. Not sure yet. The Frankenlab was built for my YouTube series as a training machine.

www.youtube.com/playlist?list=PLa_L8q5ve...zP_yOKBXPB8zKn-iWCsX

Hopefully by the time the 15W blue laser arrives... I have enough figured out to make some videos on the subject. Your help will be noted of course. Getting ready for a divorce... so it may be awhile until the new machine is built... something on the order of 5x9 feet. (give or take.)

Thanks,
Jerry

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

More
04 May 2017 11:57 #92628 by andypugh
Do you anticipate ever milling and lasering at the same time?

If not then you might prefer to create two separate INI files in the same config folder. That will give you two configs that can share HAL files and tool tables etc. Then one can load laser.hal and the other can load spindle.hal.

If you want both at the same time, then you could load the laser as a tool, with an XY offset for the laser to align it with the spindle.
Some HAL magic or a remapped G-code could be used to make spindle speed 0-100 map to a variable PWM output.

It is probably simplest to load a second pwmgen and send it to a different output pin to the spindle pwm, just from the point of view of wiring complexity.

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

More
04 May 2017 12:46 #92638 by Askjerry
At the same time... no. :huh:

The thought was to combine the G-Code for the LASER and the SPINDLE into one code... I would have a G10 L2 P1 X_ Y_Z_ built into the LASER's Vectric Aspire Post-processor to handle the offsets. (Already coded that one.) The thought being that it would laser mark the wood, then readjust position then engrave / cut the piece out. Pretty much just for show on my YouTube channel and/or events (like Boy Scouts) to catch people's attention so I can teach them CNC and LinuxCNC technology.

The endgame will be when I make a roughly 5'x9' (1.5m x 2.75m) CNC machine with a dual X-Axis... a ball-screw for the spindle, and an independent belt drive for the laser. In theory... then I could do raster printing with the machine as well. But that's likely a year off... for now just playing with the technology to get it working.

Once operational, I'll post my findings here... as always.
Thanks,
Jerry

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

More
06 May 2017 18:39 - 06 May 2017 18:41 #92752 by Askjerry
I connected a bright blue LED to the selected output pin... and configured a second PWM generator.

I have PWMGEN.0 for the spindle, and PWMGEN.1 for the LASER... both functional, both independent.

I tried M68 E0 Q 0.5 and the LED came up about 1/2 as bright as full... then M68 E0 Q 0.99 and it appeared as bright as expected... then M68 E0 Q 0.1 which was very dim, and lastly M68 E0 Q 0.0 which turned it off.

I loaded the "elizabeth-hurle.ngc" file from the samples sent by Andypugh and it appears to be fully functional... the carriage moving properly, and I saw variable light levels.

There was only one issue that I need to resolve... if I hit the ESTOP... the LED was still illuminated... so if it were running a job... it would fail in the ON position... that could be problematic. :huh:

When I tried setp parport.0.pin-08-out-invert TRUE the LASER came on immediately, and the Q0 was brightest, Q.99 dimmest. I changed ti to FALSE... then it all seemed fine. Now I just need a way to tell it that if the ESTOP is pressed... to default to the OFF condition.

I could probably do some AND function... but I'm sure there is another way.

Here are my VERSION (5) configuration files...

File Attachment:

File Name: FRANKENLAB.hal
File Size:7 KB

File Attachment:

File Name: custom_postgui.hal
File Size:4 KB

File Attachment:

File Name: FRANKENLAB.ini
File Size:5 KB
Attachments:
Last edit: 06 May 2017 18:41 by Askjerry. Reason: Neater...

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

Time to create page: 0.130 seconds
Powered by Kunena Forum