Hello Guest it is October 21, 2019, 05:10:35 PM

Author Topic: Controlling Mach with Powerpoint? Is this possible?  (Read 14551 times)

0 Members and 1 Guest are viewing this topic.

andrewm

*
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #30 on: May 26, 2011, 10:27:37 AM »
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
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #31 on: May 26, 2011, 10:40:34 AM »
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)

andrewm

*
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #32 on: May 26, 2011, 12:29:46 PM »
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 ^_^

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #33 on: May 26, 2011, 01:14:39 PM »
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

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #34 on: May 26, 2011, 01:34:24 PM »
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

andrewm

*
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #35 on: May 26, 2011, 01:48:36 PM »
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?
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #36 on: May 26, 2011, 03:21:29 PM »
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
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #37 on: May 26, 2011, 11:20:17 PM »
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.  :)

andrewm

*
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #38 on: May 27, 2011, 02:40:18 PM »
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?)
Re: Controlling Mach with Powerpoint? Is this possible?
« Reply #39 on: May 27, 2011, 02:50:21 PM »
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. :)