Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: watsonstudios on May 16, 2011, 12:58:44 AM
-
I'm in the process of making my own 3d printer. With that said, is there any was to link Powerpoint & Mach 3 so that when you display a slide in PP, it will send a gcode instruction to Mach? In other words....If I run a slide show in PP of 3d object slices, I would need Mach to run a couple lines of Gcode to lower or raise the Z axis by a few thousanths, thus building an object layer by layer.
The crude way to do this is to set up gcode in Mach to match the timing of the slide show....So that if the slides are on the screen for 10 seconds and there is a 3 second pause between the slides, I would want to move the Z axis between each slide so I would write the Gcode to match the proper timing ( is this even possible? Can you time your moves in gcode?). Then I would start both at the same time and hope they would stay in sync.
So....Is there any way to link the two programs? Or can Mach be set up to be triggered by an optical sensor so I can put up a trigger slide in between the regular slides to trigger the Z axis in Mach?
Any ideas would be appreciated. Thanks
-
How do you plan on getting the information from the power point slide into GCode to control the X - Y movement for the extruder ?
Tweakie.
-
I'm not making an extruder-type printer. It will be a stereo lithography-type printer so I only need to move the Z axis. There will be no XY movement.
Yes, that's what I am asking here. How to trigger Mach to run gcode for each slide.
Another solution (possibly easier) would be to use an optical sensor attached to the monitor so in between each slide, there will be a blank slide with a small graphic shape that pops up under the sensor that will trigger Mach to advance the Z axis - this is another technique that will work if possible for Mach to do.
-
Sounds like the totally wrong application for powerpoint. Why bother generating your slices to powerpoint when you could just generate them straight to a G-Code file and just run it. What powerpoint hads to do whith this process???
-
The images need to be shown on-screen so they can be projected onto the UV curable resin. The computer needs to output the images to a DLP projector and Powerpoint will do that. You can't generate them right to gcode, they need to be diplayed on the monitor as raster images, this is what cures the resin layer by layer.
-
Maybe there can be a plugin or wizard written to call up the images one by one and display them while Mach runs a couple lines of code each time an image is displayed, that would be ideal but I'm not a software engineer so I'm clueless when it comes to programming.
Remember, Mach only has to run a few lines of code, basically to move the Z axis up or down a few thousandths for each image displayed. Mach is doing very minimal work here. It just has to be in sync with the images as they are displayed.
-
Maybe there can be a plugin or wizard written to call up the images one by one and display them while Mach runs a couple lines of code each time an image is displayed, that would be ideal but I'm not a software engineer so I'm clueless when it comes to programming.
Remember, Mach only has to run a few lines of code, basically to move the Z axis up or down a few thousandths for each image displayed. Mach is doing very minimal work here. It just has to be in sync with the images as they are displayed.
Thinking aloud.....
For each image slice have PP output a audio tone. (Speaker O/P)
Using a simple electronic circuit, the tone can be rectified and turned into a square wave pulse.
Feed this pulse into Mach to index the next Z position ?????
Would that work?
ATB
Derek.
-
Good idea and I was also contemplating an optical sensor to do the same thing. An image can come up in between the slice images with a small graphic in the upper right corner of the screen where a mounted optical sensor can pick it up and send a similar signal to Mach to advance to the next position. This would alleviate any external noise that might false trigger the audio sensor/microphone.
-
Good idea and I was also contemplating an optical sensor to do the same thing. An image can come up in between the slice images with a small graphic in the upper right corner of the screen where a mounted optical sensor can pick it up and send a similar signal to Mach to advance to the next position. This would alleviate any external noise that might false trigger the audio sensor/microphone.
You could connect directly to the speaker output socket on your PC - there would be no problem with external noise.
ATB
derek
-
True, either way would work as long as you can trigger Mach externally like that. I have an email into them to find out. I'm sure you could use one of the inputs from the breakout box to feed the signal to Mach. It would really only have to repeat the same line of code each time. Instead of raising the Z by .005 each time, I would like to raise past that and then back down into position, this will make it more accurate and allow the resin to flow over the build table evenly before the next layer is exposed.
-
Most interesting idea.
Powerpoint can be event driven so the whole thing could be under Mach control including exposure timing Z movement etc. This could also be achieved, equally as well, using a simple PIC Microprocessor.
No doubt you have carried out preliminary experiments but I think you will be hard pressed to get enough UV from a viewing screen to actually expose UV curable resins but what do I know, I have never actually tried it. ;)
Please keep us posted on you progress with this great project.
Tweakie.
-
Well if you have any insight on controlling PP with Mach, please let me know. I would be interested in trying anything. Also, I'm not exposing the resin with the computer monitor, I will be using a DLP video projector which is sufficient to expose photo-polymer.
-
I presume you will be using two computers here - one for Mach and one for Powerpoint ?
Assuming this is the case then there are many possible solutions, some easy and some complex.
Probably the easiest, that comes to mind, would be to use a Powerpoint Remote Controller which can be modified to have an LPT parallel port output pin operate the slide advance function. (the electronic equivalent of pushing the button).
The Mach GCode could toggle this output pin using something like the M3 / M5 combination.
Tweakie.
-
Maybe even easier......
Connect a relay to mach and use the contacts to "press" the space bar of the PP computer.
i.e wire the relay contacts across the keyboard space bar switch (its normally the space bar that indexes to the next slide in PP).
Agreed, it's a bit of a hack, but "simple shimple" :D
ATB
Derek.
-
I think I figured it out. I will use an input on my breakout box to add a switch (optical or audio). Brian from Artsoft told me I can monitor the input with the Macro pump, which when it sees the input trigger, will run the G-code. Now I need to make an optical trigger that will attach to the monitor and between every slice slide will be a blank slide with a graphic shape, say in the top right corner, that will trigger the optical sensor. This should do the trick.
-
This any use to you as a basis? Save as a macro (say M800.m1s) and run from the MDI or wherever. Change the number of slides and the Z increment and of course the path to your slideshow to suit.
Option Explicit
Dim objPPT
Dim objPresentation
Dim s As Integer
Const numSlides As Integer = 10
Const ZIncrement As Double = 1
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Open("C:\some folder\some powerpoint.pps")
Code "G90" 'absolute distance mode
While IsMoving()
sleep 10
Wend
Code "G0 Z0" 'start Z at wherever
While IsMoving()
sleep 10
Wend
Code "G91" 'incremental distance mode
While IsMoving()
sleep 10
Wend
For s=1 To numSlides
Code "G1 Z" & ZIncrement 'lift Z a tad
While IsMoving()
sleep 10
Wend
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep 1000
Next
Code "G90"
objPresentation.Close
objPPT.Quit
Ian
-
Now that you explain it better - you don't need mach - What you need is a program that will display pictures in sequence along with some code to index the table up and down. Got anyone involved that can program in Visual C or Visual Basic? Wouldn't have to be a very complex app, but would probably be less work that trying to create a custom interface between Powerpoint and Mach.
-
Thank you Stirling! Ok, this looks good but have no idea what I'm looking at. lol If you can give me a quick tutorial on how to load this and run it, that would be great! I use Mach but only from the interface, I've never used any custom scripts or macros. So will this locate PPT, open the slide show and run it, while executing the g-code? If so, that's exactly what I need!
I'm assuming that the "G91" is where I insert the Gcode for the movement? I.e. raising the Z .05 then back down .045? I want the Z to move past the mark then back down into the actual position, this will ensure a fresh, even layer of resin to flow over the build. Also, the code will be the same for each slide because I don't need the Z to return to zero each time, it needs to keep moving, one little bit at a time. So the movement would be (in non code form) raise Z .05, lower Z .045 = +.005 increments for each slide.
Is the sleep in pulses, seconds, steps?? what is this value?
Also, will this section of code load & execute for each slide? Or does this need to be copied and pasted for each slide (this could be thousands of slides depending on the job)
For s=1 To numSlides
Code "G1 Z" & ZIncrement 'lift Z a tad
While IsMoving()
sleep 10
Wend
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep 1000
Next
Any additional help would be appreciated. Thanks again! ;D
-
...So will this locate PPT, open the slide show and run it, while executing the g-code?
Yes.
OK attached is a modified version. Save it to M800.m1s in c:\mach3\macros\YOUR PROFILE where YOUR PROFILE is shown at the bottom right of the Mach screen. Then either type M800 on the MDI screen or call M800 from a gcode program (you might want to set feedrate first either way). You'll need to edit the file and set the 5 constants at the top as required. Also you may want to make the first slide black.
Ian
-
Thanks Ian. One question I have is ZStartPoint can't be a constant unless it is only implemented at the start of the job. Z will always start .005 higher for each slide and Z cannot always return to zero between each slide, that would crush the object being made. I'm no expert when it comes to code so I could be way off here. For each slide, Z would have to start from where Z ended up from the previous slide and Z can never go back to zero at the end. It has to stay where it is or raise up a bit then stop, end of job. Just trying to understand. Thanks. :)
-
One question I have is ZStartPoint can't be a constant unless it is only implemented at the start of the job.
Yes - that's why I called it ZStartPoint - it's run once at the start.
Have you run the macro yet? - I think you're thinking it needs to be run once for each slide - it doesn't. You just run the macro once and it does the whole shabang you asked for. It starts at ZStartPoint shows the first slide for the set exposure time, moves up by 0.01 and then down by 0.005 and then shows the next slide and so on till all the slides have been shown etc. and and it's down the pub for lots of beer - job done.
-
Thanks again Stirling. I will run this script this weekend to test it out (I still need to install PP on my "garage" machine which currently runs Mach & my CNC router. I will set up a simple 10 - 20 slide presentation to test it out. I will let you know the results. I wasn't thinking the macro would run for each slide, I just thought the Z would go back to start for each slide which is good that it doesn't. I'm not real good with code or scripts yet so I am just applying common sense to what I see in the script. I know, I'm still a bit "script ignorant" right now but I'm learning.
So basically, I just change the values in this section? Do I insert any values below this section or is everything below good to go?
'*****************************************************************
Const ppFileName As String = "my documents\your PP folder\your PP.pps"
Const numSlides As Integer = 10 'number of slides in the show
Const exposureTime As Integer = 2000 'exposure time in milliseconds
Const ZStartPoint As Double = 0.0 'where Z starts from
Const ZIncrement As Double = 0.005 'the Z increment
'*****************************************************************
Thanks again,
Jon
-
So basically, I just change the values in this section?
Yup.
Do I insert any values below this section or is everything below good to go?
Nope - tis "good to go"
Ian
-
Sterling. I forgot one thing. Can you adjust the macro to do the Z move every other slide? I forgot that there needs to be a blank(all black) slide between each image slide. So instead of moving on each slide, we need to move on every other slide.
So...Would you do this where it says "For s=1 To numSlides", would you make it "For s=2 To numSlides"? Would that make it move every other slide? Sorry I forgot this detail earlier, hope it's an easy fix. Thank you! :)
-
Or....I can use a "cut from black" transition in the slide show but right now the transition is too fast even on the slowest setting. I'm trying to get some help with PowerPoint to see if this is possible. If I can make a 5 second transition between each slide, that should make the screen black long enough to make the Z axis move before the next slide appears. Any PowerPoint experts out there?
-
Stirling, I've not had success yet with the transitions for the slides which would allow your macro work as is, still working on that.
If I can figure out the transition timing and make it longer, I won't need any modification to your Mach macro. I'm also trying to get help with custom animation feature in PP because that also allows for fade to black and fade up from black on the slides so I won't have to add any blank ones in there.
Thanks for your help. :)
-
Hey Stirling, the macro works great! I was also able to go in and edit a few things just to see how it would effect the macro. I was able to figure out that if I add additional Z increments, (.005 each) I can raise Z higher before coming back down.
For s=1 To numSlides
Code "G1 Z" & ZIncrement + ZIncrement + ZIncrement + ZIncrement + ZIncrement + ZIncrement 'lift Z a couple of tads
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement + ZIncrement + ZIncrement + ZIncrement + ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
So basically, with this edit, I can move Z up .03 then back down .025 which might be better to let the resin flow better between layers.
Now I also tried to adjust the sleep time between the two moves but didn't seem to work. I added sleep time after the G1 Z move so there was more of a pause before going back down but it didn't seem to effect it. I put in 1000 instead of 10 (where bold). What am I missing here?
One more question: Does this macro control the timing of the slide show? Does it override the timing built into the PPT show? It seems it did because when I played with the exposureTime integer, it still seemed to stay in sync with the slide show.
Thanks again for your help. Now I just need to figure my black screen issue. The Z move has to happen on a black screen so I've been trying to figure out the transitions and fade animations in PPT to accomplish this, still working on it.
-
UPDATE: I figured out my fade-in fade-out issue with Powerpoint so I will not need to add blank slides in between each image slide. I had someone write me a macro for PP to apply the same fade animations to all the slides at once.
I would still like to know if I can put a slight pause between the +Z move and the -Z move so when the Z goes up...pause(sleep)...then back down.
Thanks.
-
G4 will allow you to make a dwell(pause) between the moves.
G4 P.5 would dwell after a Z+ for half a second.
Is this what you were after?
-
Yes Andrew, if the time parameter can be adjusted, I'm thinking 1 -2 seconds would be sufficient. Where would this be inserted into the macro?
-
Yes, the P can be whatever you would like for a dwell length.
In a macro you would put it right after the Z+ move, not sure how you have it written but something like this for example;
Code "G0 Z.50"
While IsMoving()
Wend
G4 P2
-
Here is the finished macro:
Option Explicit
'Change the five constant values below to suit
'*****************************************************************
Const ppFileName As String = "my documents\your PP folder\your PP.pps"
Const numSlides As Integer = 20 'number of slides in the show
Const exposureTime As Integer = 2000 'exposure time in milliseconds
Const ZStartPoint As Double = 0.0 'where Z starts from
Const ZIncrement As Double = 0.005 'the Z increment
'*****************************************************************
Dim objPPT
Dim objPresentation
Dim s As Integer
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Open(ppFileName)
Code "G90" 'absolute distance mode
While IsMoving()
sleep 10
Wend
Code "G0 Z" & ZStartPoint 'start Z at wherever
While IsMoving()
sleep 10
Wend
Code "G91" 'incremental distance mode
While IsMoving()
sleep 10
Wend
For s=1 To numSlides
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep exposureTime
Next
Code "G90" 'back to absolute distance mode
objPresentation.Close
objPPT.Quit
Here is the finished macro. There is a "sleep" parameter after the +ZIncrement "IsMoving" but that had no effect when changing this value. So would I add the G4 P2 after the Wend, before the Z- move? (red highlighted area)
-
I think your issue is that the sleep commands need to be after the Wend command, this is the reason you are not seeing them do anything(I Think) you should replace all the sleep commands with the G4 commands though(In my opinion)
Let me know how that works out for you ^_^
-
Are you sure the G4P# will work in a macro. As I understand it only works inside of a Gcode program "running" otherwise it does nothing.
At least testing it here that is what happens.
For s=1 To numSlides
Code "G1 Z" & (ZIncrement + ZIncrement) 'lift Z a couple of tads NOTE: you may want to try brakets around the Math operation
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
Just a thought(;-) TP
-
IF you want to control a Gcode side move with a G4P# then you need to use an approach like this. Other wise the VB will blow right through and start the next VB line while the G4 dwell is still running(;-) The While Ismoving() STOPS the VB thread until the Gcode side has completed the dwell and then the Wend allows the VB to continue.
Message " Start Test"
Code"G4p5"
While Ismoving()
Wend
Message "G4 delay" & (5+5)
Code "G1 X10 F30"
While Ismoving()
Sleep 5000
Wend
Message "End Sleep Delay Test"
End
Just a thought, (;-) TP
-
You are indeed correct Sir.
So for his needs he would put the G4 before the While IsMoving() making it look like this:
For s=1 To numSlides
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
Code "G4 P2"
While IsMoving()
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
Code "G4 P2"
While IsMoving()
Wend
Is that correct?
-
Thanks guys! I will try this:
For s=1 To numSlides
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
Code "G4 P2"
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
I only need the delay after the first move. I will try this out in the next couple hours and let you know if it worked.
Thanks again!
Jon
-
Andrew, The "G4 P2" worked perfectly right before the "While IsMoving()". Thank You!
Now my next question: Can I put in a delay before calling the next slide from PPT? Right now, the next slide gets called up right when the Z hits it's final position. I would like to delay the next slide just a tad, maybe a second, before it appears. That way the Z is in place before the next slide is displayed.
Would it have to be added this into this section? (just guessing)
" objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep exposureTime
Next
I'm not sure at what line of code that it calls the next slide but I need a time delay right before it does. Thanks again, I'm getting very close to what I need here. :)
-
I would think adding another set of G4 would do the trick, try this:
G4 P1
While IsMoving()
Wend
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep exposureTime
Next
Try that and let me know how it goes for you(are the sleep commands even working for you?)
-
Thanks, I will try this but I think I solved my problem on the PowerPoint side. I was able to put a fade in and fade out into the slides so the screen goes black before the Z axis moves again. So far, this has worked well.
I understand your adding another G4 delay but what I asked may have been misleading. I don't need a delay in machine movement, I need a delay in calling the next slide from PowerPoint.
I want the machine to do it's thing....then instead of loading the next slide when it does now, I would need to wait a second or two before asking PPT to open the next slide. Hope that clarifies things.
Thanks again for the help on this. :)
-
Im not sure how you would do that in VB, Sorry.
-
No problem, Thank goodness I don't need that now since I finally got PPT to add the fades in where I need them.
Thanks again.
-
NP, Glad you got it working ^_^
-
Thanks again for all your help! Here's a video I made of the macro in action.
http://www.youtube.com/watch?v=Kc0pd-WNfqI (http://www.youtube.com/watch?v=Kc0pd-WNfqI)
-
Andrew, I have a question: Right now, when I run the macro, the machine moves at the start of (before) the first slide. Is there a way to start the Zmovement "after" the first slide? The first slide needs to be shown when Z is still at zero(Const ZStartPoint) then I need it to do the first move before the second slide, then continue as is. How can we edit the macro to do this? Thanks.
Jon
-
Not Andrew but you may want to try it this way.
For s=1 To numSlides
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep exposureTime
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
NEXT
Just a thought (;-) TP
-
Thanks TP, That did the trick!
-
BR549
Why the Code "G4 P2" was omited in your last reply (#45)? That is no longer necessary? ???
What is the final version of the macro?
Thanks for sharing, this is really amazing.
Regards,
For s=1 To numSlides
objPresentation.SlideShowWindow.View.GotoSlide (s) 'show the next slide
sleep exposureTime
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
Code "G4 P2"
While IsMoving()
sleep 10
Wend
NEXT
-
The final configuration is this:
For s=1 To numSlides
Code "G1 Z" & ZIncrement + ZIncrement 'lift Z a couple of tads
Code "G4 P2"
While IsMoving()
sleep 10
Wend
Code "G1 Z-" & ZIncrement 'lower Z a tad
While IsMoving()
sleep 10
Wend
The G4 is not really necessary, it just gives a slight delay between the moves. I will know if it needs to be there or not once I start experimenting.
-
Hello,
Would be possible edit the macro in order to activate & sync a second axis (..X or Y..) during the time when the screen is black (...machine moves up, pauses, then moves back down)...?
This is for a tilti-action system that I try to implement.
How can I edit the macro to do this?
Any help will be greatfully appreciated.