Arduino based Laser Control

A forum for the Arduino based Mach4/Darwin Laser Control Panel
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Dan:

For cnc mode to work, the box must sense a PWM signal coming in... for NGrave mode to work, it must sense the serial clk and data
properly. So probably best to troubleshoot one or the other based on the way it works. Take NGRave... when its on, there is a "REM:"
in the top right hand corner that shows the power the box is recieving from Darwin. It will normally show REM:0 , but when actually cutting a photo
the REM :xx will show a number from 0-100 as a power beign recieved. (It toggles quickly as the axis scans across the photo..)

  What kernal speed are you set to in Darwin? Id advise you slow it down to 25 - 35K for testing to make sure the serial process works..

Also, here is the latest code I use for mine , Im using the latest published Darwin and the attached LAser box code..

Art
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

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

Re: Arduino based Laser Control

Post by ArtF »

Dan:

  If you wish to debug the CNC mode first, since its the easiest..

look to the code at the end of the above code..

//and finally a pwm spindle interrupt, basically Reads incoming PWM signal
at 50hz..
ISR(INT6_vect)
{
if( PINE & ( 1<<6))
{
&nbsp; SpinOnCnt = cnt;
&nbsp; SpindleOn = true;
}
else
&nbsp; SpinOffCnt = cnt;
return;

}

&nbsp; This small fragment reads the pin7 PWM incoming signal, and determins the
laser's output power, if it see's any signal
it turns on the laser power ( which would then fireon the next step flag).
SO perhaps in the display section adding a lcd output
of the state of the "SpindleOn" variable will show you if the PWM
conversation with Darwin is working. SpindleOn, once set
will remain on until it senses no further PWMs for at least 200us..&nbsp; So its
a great signal to track to troubleshoot the boxes
communication with Darwin..

&nbsp; TO make it easier on your head, Id add such a display message and make
sure you can get it to show the pwm is
being seen as on or off when you turn the spindle on or off in mach4....
once we get that far you wont be far off from
making it work..

Art



Thanks,
Art
www.gearotic.com
User avatar
tweakie
Old Timer
Posts: 170
Joined: Wed Dec 01, 2010 12:58 am

Re: Arduino based Laser Control

Post by tweakie »

Hi Art,

I am a bit confused here - in the previous post you said;

"This small fragment reads the pin7 PWM incoming signal, and determins the
laser's output power, if it see's any signal"
.

Pin 7 ??

Is that the 'Serial Data' on Arduino Pin 11 or are you using another input on Arduino Pin7 for the spindle PWM ??

Tweakie.

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie..

Now Im confused.. I wrote that from reading the code at the top where I commented pin7 is the PWM pin..

Ill check this and reply..

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

&nbsp; Its as I remembered. I use 4 pins to my breakout board. I use serial clk, serial data, and step flag. These are all used for
engraving or realtime control of fire and power. Thats NGrave mode.

Then I have Diags that uses no signals, purely manual.

Finally there is CNC mode, where&nbsp; I use a Spindle PWM and StepFlag. Stepflag still controls firing, but the PWM spindle
sets the power. It also determines if the laser is on or off whan a step flag occurs. Further, it looks to speed and corrects
power for the speed its running at. This is to correct for acceleration times. Spindle PWM comes in pin7 which is the interrupt vector 6.
There is a spot in the code when you switch out of NGrave code that the PWM interrupt gets turned on and the serial data interrupt switched off..

attachInterrupt( 4, DUMMY, CHANGE ); //reattach the spindle interrupt
detachInterrupt(1);

There is a reverse of that when you switch to NGrave mode. ( The number is interrupt 4 but really translates to 6 as a vector..).

Also noteworthy, if your in Diags mode, and the PWM input see's that PWM spindle has turned on, youll automaticallt switch out of diags
and into CNC mode. That happens because of this line...


if( SpindleOn && OpMode == DIAGS)
&nbsp; OpMode = CNCMODE; //auto switch from Diags


&nbsp; So one can test the PWM input just by turning on M4's spindle and giving it an SWord.. An M3S50 should
make the laser control swap to CNC mode..




Art
User avatar
tweakie
Old Timer
Posts: 170
Joined: Wed Dec 01, 2010 12:58 am

Re: Arduino based Laser Control

Post by tweakie »

Thanks Art, that explains it.

Tweakie.
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

So one can test the PWM input just by turning on M4's spindle and giving it an SWord.. An M3S50 should
make the laser control swap to CNC mode..


that will make it easer to test to see if I can get cnc mode working.

its the signals where the problem will be not the arduino code I will try old code first then try new code
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

I found what was wrong with the bob I am using there are two ways to enable it enable hi and enable low, enable hi is for when you have a nc estop and enable low is for a no estop had it set to enable hi with a no switch.
I am not at the machine at the moment will change later and report back and give a exploitation of how to use a mb06-v2 bob from homann to run the laser
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

cant get cnc mode to work tried m3s100
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;g1x100f400
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;g1x0f400
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m3
nothing happens.

engrave mode works well

I was correct about the switch being the wrong type changed to a nc/no switch and it works fine
I wont do a write up to I can get it all working.

I don't need to add in a lcd.print for pwm state as the bob is on the back of the box for the laser controller and I can see if pwm`s working

thanks for the help I will try the new code later and change it to Leonardo only code
Last edited by DanL on Wed Nov 26, 2014 5:58 pm, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Hi Dan:

&nbsp; If your in Diags, the state should change to cnc mode as soon as it see's a PWM pulse on the PWM input line.. Its an interrupt,
so it will trigger a switch to cnc mode immediately.. so the pin number coudl be wrong, or perhaps Darwin isnt putting it out on the
rigth pin due to config.

&nbsp; Set it up for PWM, than issue a M3S50 when you have a Spindle raneg of&nbsp; 0 ,100 set in m4. That shoudl turn on the pwm.. which should then switch the panel from diags to cnc mode..

art
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

What the problem is, with it changing from diags to cnc mode is that the scale is way of with the g540 when I had the spindle connected I had to set it to 12000 rpm more than was need so if I called for 5000 rpm I had to call 17000rpm for it to do 5000rpm.

I will change it over to the mb-06 that hopefully will fix it the signals are going out in engrave, cncmode and diag.

everything is working as it should it just the scale problem with cncmode.

I will load the new version first the change all the spindle pins over
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Dan:

&nbsp; Ive found mine is acting up, Ill have to open it up tomorrow, its running fine in NGrave mode, but CNCMode isnt
working and Diags is intermittant.. Im pretty sure its a wire loose in the buttons.. All else is running, but CNC mode
wont burn. NGrave mode burns fine though, so check the laser mode, then use NGrave mode and your fine for all usage, photos as well as normal m3/m5 cutting..

&nbsp; Ill get mine fixed up so we can compare when your firing..

Art
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

yer it may be a M4 problem causing it Ill see what happens when I change it over to the mb-06.
but first I might change the spindle to 0 - 1000, and 0 - 10000. see what happens.

if it works its a M4 fault as I was getting a voltage change of only 0.001 at 1% and 0.003 at 75% in cncmode
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Voltage change on what signal?

Art
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

pin 9 laser output
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests