Arduino based Laser Control

A forum for the Arduino based Mach4/Darwin Laser Control Panel
Post Reply
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,

Yes, I can confirm that ports 1 or 2 don't matter - they both behave OK.

Because Outputs above #64 are unavailable for our use may I suggest that:- serial clk, serial data and step flag are re-allocated to lower values ??

Thanks for the info re: M62/M63 - I will await a later relase of Mach4.  ;)

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

Sorry, I explained that badly. I put those signal at 126-128 so that users wouldnt change them form what I set their names to. YOu CAN use them, I do so they should work. If enabled and set to pins you should see them work. In the case of the step flag for example, you should see it pulse whenever a step is taken, no matter if its port 1 or 2. This should work for anyone , even if unlicensed.  You cannot use the toggle button on the setup to test it though, the step flag will only work when steps are actually taken by a motor. The Serial CLK output will also work but canot be tested with toggle either..and it will only work when laser mode is on, spindle is on, a spindle speed is set from 0 - 100 ( with range set 0 - 100) and steps are taken. SO it too is hard to test..
Serial data is the same, unless your actually using it properly setup , its hard to test..

  So stepflag is the easiest to test, just run any program and watch that it toggles, it should pulse on any step from any motor.. so its a great fire trigger..

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

  Cant find your post.. ( Was it deleted? ). I ll recreate it here as  I think it needs a public answer..

Original Post:

In Darwin pp driver I open a .bmp image, set the size, arduino laser mode etc. then create and save the .dim file. I then link the image which creates the Mach4 raster. So far so good. When I run the Gcode (Cycle Start) having set M3 S50 I seem to get the correct signals on StepFlag and SerialClo ck but the SerialDat a is just a 460uS square wave. What am I doing wrong please ??

  The protocol of the serial data transmission is a bit odd.. this is due to my system being a bit noisy, but also because the arduino is too slow for all the activity at high speeds. Ive found a max of 30Khz here simply due to all the interrupt traffic. So I implemented the protocol in a fairly weird way, one that likely should be modified when more of us do it.

  In Darwin ( like most plugins) a cycle time tells M4 how much data to send each waypoint. ( update loop of the plugin). M4 sends darwin no more than 16 steps at a time , thats at full speed at any frequency. Darwin then tacks on a Power level when appropriate to that packet. It tags the power word with a frame to indicate to the driver that its a power command. This looks in hex like this.. 0xfnnf , where nn is the power word from 0 - 100. This entire word is sent to the arduino and when the arduino see's 0xfnnf it will accept the nn part as a power command only if the word is framed by f's, AND it is repeated twice. This is also slowed so the serial is sent at 1/2 kernal frequency. This too was done to try to make the interrupts work better in the arduino.. ( it didnt help much so I may go back to full frequency sending after more experiments. ). 

  So the end result is a power word that will control typically every 64 steps. In my system I do 250 steps per mm, so thats a base resolution of .25mm per power word. If we go back to the full kernal frequency that will make it .125mm
per power word on my system. Ill wait on that till there are more users of this to improve the protocol..

  So if your scoping, the data stream will be 0xfnnf with nn being power. This will be zero when not in an image or when in a white part of an image, it will be 0-100 representing 0-255 of the image data.

  Since shifting any f's serially would create a false reading in the nn section , any power divisable by 16 will be bumped by 1 to ensure the protocol is as error free as it can be. Its my thinking a bump of 1 level will be unseen so I havent tried to come up with a tighter protocol. My servos inject a bit more noise than Id like so stepper users should find a higher speed works fine. This is a primary area that needs improving.. so hopefully we'll get some hardware guys with better ideas..


Art


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,

Yes, I deleted the original post - I was too hasty - after Mach4 had been running longer and got further into the image then the serial data in the waveform became evident so my post became redundant. I should have chosen an image where the detail meets all the edges.

Looks like I have to connect up an Adruino now.  :)

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

  Np, its good to have the protocol listed as someone else may want to build an interface far different than my arduino...beagle board maybe, or TI boards. Ill keep no secrets on how things operate and try very hard to get other motion devices to accept such a protocol..or adapt mine to match one the community decides on.
 

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

Re: Arduino based Laser Control

Post by DanL »

sorry if this sounds a bit daft but her goes
I am a bit confused about what output to use I am using a G540 so only have 3 outputs and one of them is pwm what is 50Hz so I am just unsure what to use for what
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4593
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Dan:

  A G540 wouldnt work I dont think. Its outputs are prescribed. 
  Id add a second printer port and use only that for the laser outputs. Thats probably the best solution..

Art

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

Re: Arduino based Laser Control

Post by DanL »

cool thanks for that art
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4593
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Hi Guys:

  Just tested some new power routines, heres that lighthouse on a granite tile, 300mm x 200mm , with a power gradient of 5% to 70% , it probably should have been a bit lower power.. but its all coming together. :)

Art
Attachments
Lighthouseingranite.jpg
BobL
Global Moderator
Global Moderator
Posts: 466
Joined: Sun Sep 05, 2010 7:18 am

Re: Arduino based Laser Control

Post by BobL »

Well done pal....  Only 1 million tests to go..lol


Cheers
Bob :)
Gearotic Motion
Bob
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Arduino based Laser Control

Post by DanL »

for a test that's pretty cool
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4593
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Arduino based Laser Control

Post by ArtF »

Not as white as Id like.. I think perhaps its the type of stone..thats just a 6.00 polished granite tile from home depot.. Im thining different stones likely give varying
grey scales..

art
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,

Very nice work indeed with the lighthouse on granite - I really must try something like that.

Now I am being extremely cheeky (and extremely lazy) here but back in post #8 you mentioned;

?you may not want a diagnostics mode at all, and if so, just a simple arduino with
no box, buttons or LCD display would work fine, the program would simply require a bit of recoding and you could hot glue the arduino into your cnc control box to permanently control your laser power
with no interaction?.

Is there any chance of a ?bare bones? arduino sketch (using just the Leonardo board and pot) so we can try out the ngrave mode of operation with Darwin ?.

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

  Well, the pot would be hard to read as to where you have it set..but then you could just label it and figure out the power as a
position thing..

  So to do that, all youd really have to do it lock it to NGrave mode.. since the unit now has to be switched to NGrave from Diags mode
when its powered up. So all youd need to do is use the sketch as it is.. and add below this line.,..

if( OpMode < 0 ) OpMode = 2;

the line

OpMode = 2;

&nbsp; This way the Leonardo would come up in NGrave mode ready to go. If you decide to do this let me know because Ill need to publish
the latest sketch I use as it makes the power run from 0 - PotPower in 100 steps of PWM instead of 0-100% determined by Darwin.
The difference is that previously if Darwin limited power to 20% it coudl only send 1-20 in 1% increments..so 20 steps.. but now Darwin always sends
0-100% in NGrave and the leonardo makes it 100 steps no matter the max power selected..&nbsp; I still dont know the minimum change the synrad will accept
but the responce does seem better.

&nbsp; I havent released the sketch information as yet because I just didnt want to confuse anyone currently building.. and the released Darwin isnt the
new 0-100% no matter the spindle speed seting, but the old one that sent power based on S word in photo mode.

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

Re: Arduino based Laser Control

Post by ArtF »

Tweakie:

&nbsp; I should point out that none of the other code needs changing because no errors will happen if the lcd isnt connected or the buttons etc... the code assumes no push buttons need pushing and the lcd is only sent data, so if it isnt there, it doesnt matter, the system will still work..

Art
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests