Page 10 of 27

Re: Arduino based Laser Control

Posted: Mon Nov 24, 2014 8:27 pm
by DanL
Hi art just a couple of questions what Darwin signal do you set the pwm to is it all or just one

I have set

step flag to 25 Hz

serial data to 25Hz

serial clock to 25Hz

I am running it in PWM mode with 25 Hz as base freq

just making sure I am doing it correctly as I think I may have a problem with the switches or pot not to sure yet will be testing tomorrow.

I have a junk laser I am going to put on it to see what is happening as for some reason when in test mode I cant get the laser output to fire it will just be a setting the switches or pot playing up. when I was scoping it, it only went up to 3.8v. it also may be that I have a 10k pot on it not a 5k pot.will play with pot settings and see what is happens.

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 2:34 am
by ArtF
Hi Dan:

  You can set all to zero for frequency, it shouldnt be used. The Stepflag signal pulses whenever a motor ( any motor ) steps. So just jogging
will show that signal toggle as a test. Serial data will be gogin out all the time when using Darwin in Laser mode. Serial clock will pulse at 40khz or whatever the maximum kernal rate is set to.

  Step Flag is used all the time, you can use it in PWM mode as well as laser mode, it just means the laser will fire only
when moving. In the most recent Darwins it will fire only whiel moving in G1 mode, no other mode will fire. I like this as it makes
it all much safer and easier to deal with.

  If you execute a G1X100 , does the laser PWM go higher than the 1us tickle.. and when it does, does the laser fire.. Thats the
thing that needs to be done... or figured out. :)

Art

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 12:36 pm
by DanL
its not doing anything no laser fire nothing
tried G1 x100 nothing tried with laser on an off

did a pick linked to Mach4 with M3 S1000 F600 nothing, M3 F600 S1000 nothing
put G1 X100 M3 S1000 F600 nothing, G1 X100 F600 M3 F600 nothing,

tried it in diag nothing.

tried setting the signals active low nothing.
I have set the 3 signals to output 0,1,2 in Mach4 the leds don`t light up on dig screen

any suggestions as what to do

I am wondering if its haveing a 10k pot not a 5k pot doing it will get a 5k and see what happens

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 2:39 pm
by ArtF
Dan:

Whoa.. slow down. Lets find whats working and what isnt and go from there..

OK, first, does the diags mode work. The Diags mode will not laser no matter
what Mach4 is doing. It will laser only when you dial up a count, and press the fire button.
Counter should run to zero, laser fires until zero. Pressing reload will relaod last count and fire will
flash again ready for the next shot. Does that all work?

So, use the buttons to get a count of 1000 , then press fire ( which should be flashing.. ). Does the laser fire?
Lets make sure that works , then we'll go to stage 2 and get PWM laser from the device in CNC Mode... then finally we'll
get NGrave mode running that does photo's..

Art

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 4:12 pm
by DanL
diags mode works I could see a pwm signal on my arduino scope.

I think it is the switches I am using sometime I can`t get a reading from them.

I am using a mb06 v2 from Homann Designs as the bob to run the laser that's working ok

the Leonardo and screen are fine I have tested them.

I have some switches I can change to so I will do that and try again

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 4:44 pm
by ArtF
Dan:

If Diag mode works, then its time for the CNC mode test.. in that you setup Mach4 for a pwm spindle.. 50hz and dont turn on laser. The laser should fire when a g1 move is done whlie the spindle is turned on and a SWord is set. By the way, for all uses of the laser in MAch4, you need to set the spindle range from 0 - 100, and the SWord to use then must be 0-100 for the desired power. Its made this way on all modes to make it easier to pick power.  I think the next logical test to make is to see if we can get CNC mode working.. and debug it till we know why it isnt if it wont..

Art

Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 6:24 pm
by DanL
that's what I was doing wrong I was turning the laser on so it would of been turning it off what a dork lol
I will test now


Re: Arduino based Laser Control

Posted: Tue Nov 25, 2014 7:36 pm
by DanL
tried but cant get it working in cnc mode.
tried doing a engrave did not seem to work ever

and diag mode does work I will play some more tommorow

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 1:51 am
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

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 1:58 am
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

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 4:14 am
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.


Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 5:12 am
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

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 5:37 am
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

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 6:06 am
by tweakie
Thanks Art, that explains it.

Tweakie.

Re: Arduino based Laser Control

Posted: Wed Nov 26, 2014 7:16 am
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