M3 blocks changing PoKeys PWM

Discussions and file drops for Auggie
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

M3 blocks changing PoKeys PWM

Post by Joakim »

When M3 (laser Auto On) is activated, it is no longer possible to change setting for PWM channel #4.
First when M5 is executed, it is again possible to change PWM setting.

As I have the laser current setting wired to PWM channel #4 this prevents changing current setting during cutting/engraving.
I could of cause leave and re-enter Auto On (M5 + M3) to change current setting, but that seems unpractical just to change PWM on the fly.

The output GCode from image Augmentation "forgets" to run M5 and turn Auto On off as it runs M30 before it reaches M5:

Code: Select all

...
G1X0
Y 10.0000  

 M30 


 (  Augmented Machine Controller Program End) 

M5
M30 
Tested on: Auggie 1.48a, PoKeys57CNC rev. 1.2/version 4.1.64

Joakim
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

J:

Thx, Ill check that out. I thought I had fixed that race between the m30 and the m5..

  As to changing it while running, the slider should change it while its runs, I do it frequently here. But
then it is only the slider that can change it, nothing else.. I am going away next week for a summer vacation,
but when I return Ill see about finalizing the way the S word works so that power can be controlled by that on the fly..

Thx
Art

Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

For all reading this thread, the K40 laser is controlled in two ways (in my configuration):

1) The current send to the laser tube. The value is set with PoKeys PWM #4 (0 - 100%).
I refer to this value as laser current.

2) On/off of the the laser beam. This value is set with PoKeys PWM #2 (0 - 100%).
I refer to this value as the laser power.
This value is controlled by Auggie and takes into account movement, acceleration and augmentation (engraving). This value is set real-time and coordinated with motion.

Max power can be set with the slider on the control panel.

What I see, is that M3 MCode is blocking the current setting on PWM #4, not the real-time power setting.

Auggie script makes it easy to implementing the S parameter to set the max power slider. It can be done in the SpindleSpeed() function:

Code: Select all

/*
  Called whenever S parameter is used in GCode.
  Sets laser power DRO to new value 0 - 100%.
*/
global SpindleSpeed = function( speed )
{
  s = speed;
&nbsp; if (s < 0) { s = 0.0; };&nbsp; &nbsp;  // Low limit 0%
&nbsp; if (s > 100) { s = 100.0; }; // High limit 100%
&nbsp; GlobalSet("LaserMaxPower", s);
};
Likewise it is easy to implement a new GCode to set the laser current, ex. G110:

Code: Select all

/*
&nbsp; This function implements G110 GCode - When
&nbsp; called it sets the laser current from 0 to 100%
&nbsp; using the P parameter.
*/
global GCode110 = function()
{
&nbsp; p = ParmsPRI[0];
&nbsp; if (p == -999999) { // Parameter P not defined
&nbsp; &nbsp; return;
&nbsp; }
 
&nbsp; if (p < 0) { p = 0; };&nbsp; &nbsp;  // Min value is 0%
&nbsp; if (p > 100) { p = 100; }; // Max value is 100%

&nbsp; SpindleControl.SetPWM(4, p); // Change laser current on PWM #4
};

This post got long... sorry :-)

Joakim
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

Hi J:

Hmm, your controlling it backwars to how I do it.. Actually, I suggest only one PWM is necessary..

>>1) The current send to the laser tube. The value is set with PoKeys PWM #4 (0 - 100%).
I refer to this value as laser current.

&nbsp; I use this as the Beam power in real time. On mine , this is the value set by the slider, AND the one controlled by Auggie during photos or vector cutting. Essentially, its the only power control I use.

2) On/off of the the laser beam. This value is set with PoKeys PWM #2 (0 - 100%).

&nbsp; I just use a relay for this. If on, there is still no laser until the PWM goes high enough, but its safe to leave this on all the time.
You shoulnt need 2 PWM's at once,. one may fight the other. TTL can be left on all the time, where the PWM can then control both power and on/off with one signal, if PWM is too low it wont fire even though TTL is on. This allows Auggie to control the
power more smoothly rather than just on/off..

&nbsp; The way you have it can work too, just goes to show there is more than one way, but Id think more than 1 PWM
is overkill for what your doing and complicates it. My way, you set only 1 relay for laser power, and then Auggie , the Aug systems, and the slider all control a single PWM..in various ways.. much less complicated I think to set up that way..

Art




Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Art:
ArtF wrote: Hmm, your controlling it backwars to how I do it.. Actually, I suggest only one PWM is necessary..
Our configurations are much the same, except that I uses PWM #2 where you uses PWM #4 and I have additional current setting on PWM #4.

I have a relay to turn the power supply on/off as you do on the same relay - it is parallel to the the old switch on the control panel to allow both to work. Handy to have a manual switch when calibrating mirrors.

The PWM power control has the same function as in your configuration, just another PWM channel - you made the channel option along with the frequency settings in configuration a while back.
This input also has a manual switch to test fire, as it is handy when calibrating mirrors.

The laser current setting on PWM #4 replaces the manual potentiometer on the physical control panel and gives the opportunity to set the current via GCode instead of manual adjustment. I like this option as it makes it possible to save this information in the GCode file and to change setting if a job is mixed engraving and cutting.
If I remember correct GlennD uses a similar current control with a booster on PWM #2 on his K40. It was from his postings I got the idea to use G110 Pxx to control the current... thanks :-)

I think it is a bit confusing that we all have different configurations, mine is pt.:
  • Power supply on/off: Relay 1
  • Realtime PWM: PoKeys PWM #2
  • Current PWM (potentiometer replacement): PoKeys PWM #4
The problem is that I can't change the PWM setting of PWM #4 after M3 is executed - this makes it impossible to adjust the current from the dialog or via G110 Pxx commands in the GCode (It looks like everything is OK, but the PWM stays the same on the oscilloscope).
I would like to make test GCode files, cutting lines with different current settings to easy find the right current setting for different materials to just cut through.

Joakim
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

J:

&nbsp; Whatever works is fine :), my point was that if a laser has 2 inputs, TTL and PWM, it doesnt do any good to have
2 PWM inputs, one should be 100% on all the time (TTL), while the second should be the PWM power.&nbsp;

&nbsp; Having&nbsp; PWM on both can cause power fluctuations. Thats why I usually would recommend only 1 PWM..
Having two I would think gets confusing, one would have to be on at 100% (TTL) while using the other PWMIN
to control power , I was only worried about one fighting the other.&nbsp;

&nbsp; &nbsp; Power supply on/off: Relay 1 --&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( I use this as well)
&nbsp; &nbsp; Realtime PWM: PoKeys PWM #2&nbsp; &nbsp; &nbsp; &nbsp; ( Id suggest 5 volts at all times..why control this at all?)

&nbsp;
&nbsp; &nbsp; Current PWM (potentiometer replacement): PoKeys PWM #4&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (this can be used for all control, I use it for Imaging, vector and real time control , changing slider on screen will control the PWM#4 , as will Imaging Aug's, as will slider for Vector moves. ) I dont see any real use for PWM#2, not really
required, but as long as it works that fine, but it does mean PWM4 has to be at 100% when using PWM 2 to do anything
doesnt it? As I say, doesnt matter, but seemed a bit of overkill and may explain why it seems locked out during run..
when mine isnt.. The onscreen test button also fires PWM4, so really I was just wondering why having 2 PWM channels
was necessary at all, seems a complex arrangement to decode compared to using one channel.

Art







Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Art:

On the power supply there are three inputs: TTL (fire), On/off (Enable/Protection) and Current control (DAC/potentiometer).

I have attached a handmade sketch of my current wiring.

There should not be any conflicts between TTL controlling the laser and setting the current for the tube - Current setting was earlier done with a manuel potentiometer and is properly a slow way of changing the max output effect.

I just made the manual adjustment of current into a program controlled version with PWM channel #4.
The analog to this setting in CNC would be to change the spindle speed - It is not fast but some times needed when running a job.
Because it is possible, I would like to have the same option on the K40&nbsp; :) Others on the net has done the same.
It is working fine as long as M3 is not activated. After M3 is run, the value is frozen and can not be changed until M5 is run.

(The power supply on my K40 is a little different, but the sketch shows the same signals)

Joakim
Attachments
2016.05.27 K40 PoKeys Connection Sketch 0001.jpg
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

J:

&nbsp; I understand. My point was that input A is not required, it could be jumpered to ground. Since PWM#4 is controlling power,
a setting of 0.0 duty cycle power is always off even if TTL is on.&nbsp; Max power would be a 100% duty on PWM 4.

&nbsp; Under that scenario, the pwm control is never locked out, it is provided by #4 whether&nbsp; using S words, or slider, or Image augments.

On a K40, from our testing, the PWM input is fast enough to control everything in realtime. But.. whatever works , works. :)

Art


Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Art:

I my setup, the laser power slider and S word is controlling PWM #2. That is the way I configured it.
Replacing PWM #4 back with the potentiometer will engrave using the output on PWM #2.

I don't know that much about laser power supplies, but I was of the impression that the potentiometer just gave a DC input between 0 and 5V to set a current limit for the tube. That input react very slowly and I read that it is recommended to use a 20kHz for that DAC.
If I measure the input voltage, it must be below 3.5 to limit current to max 17mA and give the tube long life.

Need to read some more on laser power supplies and how they work...

How are the other K40 Auggie users power supplies wired up. I did a quick forum scan, but it only gets partial setups. When I get my laser working, I will draw a schematic and put it up for others.
That testing you did on another K40, was that with TTL to ground and only sending signal to the input from the potentiometer?

There is still the question, why are changing PWM value locked after M3 - I understand that the Real-time PWM used for laser pulsing is locked, but how about the others. They could be used for other tasks at the same time, not relating to laser output?

Joakim
Attachments
K40 PWM Setup.jpg
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

J:

>>That testing you did on another K40, was that with TTL to ground and only sending signal to the input from the potentiom eter?
>>There is still the question, why are changing PWM value locked after M3 - I understan d that the Real-time PWM used for laser pulsing is locked, but how about the others. They could be used for other tasks at the same time, not relating to laser output?

&nbsp; The other K40 was the one run by YaNvrNo. There he has the TTL gounded, and uses the PWM only into the place the analogue pot went.
Yes, he sets it to 20Khz, the TTL simply gets grounded. It is fast enough for the engravings he shows on the forum so it seems plenty fast.

&nbsp; The other channels will work, but cannot be changed during realtime PWM mode.&nbsp; This is because setting the PWM duty causes a reset which can cause a false fire signal. As a result, all PWM commands are locked out during realtime PWM active mode. In the case of a laser,
only 1 PWM should be needed.


&nbsp; Again, there is no wrong way, whatever works is right, but I think it may explain why its locking out. In order for Realttime PWM to work,
it has to disable calls to the PWM settings for other channels, otherwise it can trigger spurious fires.. so thats may be why you find it locks
out.. youd need to disable rtPWM mode before you could use the two channels together..


GlennD
Old Timer
Posts: 80
Joined: Tue Oct 18, 2011 4:19 pm

Re: M3 blocks changing PoKeys PWM

Post by GlennD »

I am also running as YaNvrNo on my K40.
Not at a point i can spend much time playing with the laser unfortunately.

Working on an automation project for a 5 axis, multi head router almost makes up for it though. :)

Glenn
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Art:
Thank you for the explanation - that clear up a lot of things!&nbsp; :D

I have been reading a little more from power supply descriptions and it seem like I have mixed up the two ways the laser can be driven: Continuous and pulse driven mode.
From the Chinese descriptions it is hard to get head and tail on how things are working and how they are expected to be used...

In continuous mode it is right to talk about a current setting and using TTL to turn laser on and off.
In pulsed mode the PWM is nearly everything, current can be set, but must be a dc value to not interfere with the PWM control.

I will properly revert my PWM current control back to manual to have it for mirror calibration with three markings: Low, medium and high (5, 10 and 15mA). Some cuttings in thin material like paper can benefit the very low power setting.
That would also give me full optical isolation as there is an optical input for the PWM on the power supply.

One have to make mistakes to learn new stuff... and don't forget to ask stupid questions too...&nbsp; ;)

I understand the need for locking PWM updates during real-time usage of the laser PWM, but didn't know&nbsp; that all PWM channels had to be locked to ensure correct operation. Now I know.

Playing around with PWM functions I found that the value in SetPWM() is a percent, but the value from the GetPWM() is in seconds. It would be nice if both values was i percent.

Code: Select all

SetPWM(channel, value);
value = GetPWM(channel);
GlennD:
Thank you for joining with your experience. I read in the forum, that you and YaNvrNo was experimenting with the potentiometer input and thought it was for current control and not the main PWM, my mistake.

Joakim
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: M3 blocks changing PoKeys PWM

Post by ArtF »

J:

>>In pulsed mode the PWM is nearly everythin g, current can be set, but must be a dc value to not interfere with the PWM control.

&nbsp; PWM at 20Khz is basically a DC value to the circuits. I would recommend just using PWM into the analogue input, and tie
the TTL to ground. PWM is enough to do all the control, really nothing else is needed.

Art
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Art:
I plan to use the optical isolated input that the original Mosidraw board used and the analog potentiometer. The optical isolated input can be used without any modifications - using the analog input for PWM can result in over current if voltage gets to high and I have no electrical protection (It is a cheap Chinese power supply).
The optical input is designed to be used for engravings, the Mosidraw board used this input.

If I let the potentiometer be at the highest level the end result should be the same.
And it is still handy to have manual fire and low power when calibrating...

I can always switch to using the analog input at a later time if this configuration gives trouble.

Joakim
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: M3 blocks changing PoKeys PWM

Post by Joakim »

Another benefit of this configuration is that I am not bound by the 20kHz requirement for current control. I could use a lower PWM frequency as the current is managed by a DC voltage from the potentiometer.

When browsing the net for cut/engraving settings I often see a recommended frequency - often wondered what that ment... Anyone have an explanation for this?

Joakim
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests