Hello Guest it is May 19, 2024, 08:16:59 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - jevs

Pages: « 1 2 3 4 5 6 7 8 »
31
Mach4 General Discussion / How to stop the spindle motor in M6 script?
« on: August 04, 2019, 04:54:59 PM »
I believe I need to use mcSpindleSetCommandRPM, however, the cryptic way the API help is written it never just tells you exactly what code to use. So how do I turn this information into something that actually works?
This does not work:
Code: [Select]
rc = mc.mcSpindleSetCommandRPM (inst, 0)and neither does this:
Code: [Select]
int rc = mcSpindleSetCommandRPM(inst, 0)


 mcSpindleSetCommandRPM
C/C++ Syntax:
int mcSpindleSetCommandRPM(
      MINSTANCE mInst,
      double RPM);

LUA Syntax:
rc = mc.mcSpindleSetCommandRPM(
      number mInst,
      number RPM)

Description:
Set the commanded RPM for the spindle.

Parameters: Parameter Description
mInst The controller instance.
RPM A double specifying the RPM.


Returns: Return Code Description
MERROR_NOERROR No Error.
MERROR_INVALID_INSTANCE The mInst parameter was out of range.

Notes:
None.

Usage:

// Set the spindle RPM to 5000.
MINSTANCE mInst = 0;
int rc = mcSpindleSetCommandRPM(mInst, 5000);


32
Do I need to turn it off in the M6 script?
If so, how do I make sure it is stopped before it tries to release the tool and make the change?
I do not have a spindle encoder. It runs off a VFD connected to 0-10V output and CW CCW relays from the BOB.

I do not see anything in my Mach3 M6 script that did this, and I don't recall what happens or how it knew not to start the change without the spindle stopping first. I can only guess I somehow it knew to turn off the spindle and then wait a certain amount of time that would allow it to stop from it's highest RPM....it has been too long.
 

33
I am watching a video on youtube and he is hovering over things and getting values in the editor. This does not seem to work in the current editor?
Is there a way to see this?
I can right click stuff and select "Evaluate in console", but all i ever get is nil.
I am not really sure how your supposed to test your code to see if it is working without getting it all done and seeing if it runs in Mach4 or not. It would be nice if you could run it and get some idea of what you have written so far is working.
Keep in mind I am not a computer programmer.

34
Here is my code for the Mach3 script that works for my tool changer. My tool changer is purely mechanical. It moves above the Z home position and back down to ratchet the turret to the next tool. Pretty simple, but it still takes some coding.
I do have some concerns over Mach4 knowing what tool was loaded when you shut down and restart the software and having means to correct the tool number if something gets out of whack. This would happen with Mach3 at times so I added in some checks for a tool number out of the range  of realism. Maybe Mach4 is better with this and it won't happen?
I also thought about adding a startup question of asking what tool is loaded when you first turn on the machine.
Anyway, I am starting to try to convert thus to Lua. If anyone wants to help or has suggestions it is much appreciated.
I will post questions here as I get stuck figuring it out. I am pretty new to trying to use this code and even the VB took me awhile to figure out.
Code: [Select]
'Tool change macro for 7 tool turret
Sub Main()
'Sets variable OldTool to what is currently loaded
OldTool=GetCurrentTool()

'Sets Variable MaxToolNum to the max number of tools possible
MaxToolNum=7

'Sets variable Newtool to the one being selected with M6 T#
NewTool=GetSelectedTool()

'Get positions before moving to do tool change
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
c = GetToolChangeStart( 5 )

'If the current tool loaded is 0 or greater than 7 then tool has been lost
'so need to ask what tool is currently loaded
While OldTool=0 Or OldTool>7
OldTool=Question ("Current tool unknown, enter tool in spindle 1 to " & MaxToolNum)
Wend

'Sets CurrentTool to Oldtool in case it was lost and entered above
SetCurrentTool(OldTool)

'When the tool asked for is invalid then this makes you select a valid tool
While NewTool > MaxToolNum Or NewTool <1
NewTool = Question ("Invalid tool chosen, enter tool number 1 to " & MaxToolNum)
Wend

        'If the tool asked for is the same one that is already loaded then exit macro
If NewTool=OldTool Then
Message "Tool already loaded or tool not specified with T# (ex:M6 T4)"
Exit Sub
End If

'Turn off soft limits if they are on
If GetOEMLED(23) Then
DoOEMButton(119)
End If

'Moves To Z home from where ever it is
code "G53G0Z0"
While IsMoving()
Wend

'Sets ChangeNums to 0 for safety in case it is not at 0
ChangeNums=0

'Makes the magic happen and moves the proper number of times if new tool is higher than old
If NewTool>OldTool Then
For ChangeNums=1 To NewTool-OldTool

'Moves Z axis to the top of tool change
code "G53 G1 F70 Z5.800"
While IsMoving()
Wend

'Moves back to bottom of tool change area
code "G53 G1 F70 Z3.8"
While IsMoving()
Wend

Next

'Makes the magic happen and moves the proper number of times if new tool is lower than old
Else
For ChangeNums=(OldTool-NewTool) To 6

'Moves Z axis to the top of tool change
code "G53 G1 F70 Z5.800"
While IsMoving()
Wend

'Moves back to bottom of tool change area
code "G53 G1 F70 Z3.8"
While IsMoving()
Wend

Next
End If

'Move Back to Z Home
code "G53 G1 F70 Z0"
While IsMoving()
Wend

'Should be a succesful tool change at this point so this sets the NewTool as the current tool
SetCurrentTool(NewTool)

'Turn back on soft limits
DoOEMButton(119)
End Sub           

35
Do I need to modify the start screen code and the sig library and create M code scripts to just make a button that already exists and has predefined M Code action work?

For example I just want to make the Mist button work and give it an output to turn on. Where do I do this? Is there a tutorial for this exact thing where you just want to make an existing button and Mcode work?

 I can make a new button that does this and I could make a new M code script that does this, but I would think they intend for you to use the built in action for this? mc.OSIG_MISTON? I will keep reading and reading and reading to figure it out, but hopefully someone can just give a quick link with a good simple to understand way of how it should be done for best performance.

Thanks. I looked for a couple hours so far and have not figured it out yet. Too tired from a long day I guess. I am reading through a bunch of information, but there is just so much to look at and no straight to the point of the best way and the exact code and where to put it etc. The only variable from what pretty much everyone is doing for this simple task is which output they are using. In my mnd this simple thing should not require a programmer to get working...

36
I setup a button to turn an output on and off that only works when the machine is enabled.
However, if you leave it on and Disable the machine, the output stays on (button itself is disabled).

I also setup custom M codes to turn it off and on. If you turn it on with the M-Code and disable the machine, it will also still leave the output on.

So, I have no idea where and what to put somewhere to ensure this output gets shut down no matter what when the machine is disabled?

Thanks

37
I am just trying to do some of what should be some simple stuff but the roadblocks and learning curves are huge so far....

I found out you can use the PMC editor to automate creating a macro for you. However, I am stuck on the first step because there is no Core Function to pick for what I want to do...

I am trying to create two custom M codes.They will be M200 to turn on the oiler and M201 to turn it off.

I created a button and an LED that I want to use so I can do this manually. I copied the flood on off stuff and renamed them etc.

I also want to be able to have this output on whenever X or Y is moving.

I created the output setup and named it Enable Oiler in the ESS pins setup and turned it on the outputs.




38
I need to make a script or macro for turning on my oiler output anytime an axis is moving.

The oiler has it's own motor that pumps out a certain volume over time. So all I need to do is turn it on when the X or Y is moving to keep the ways oiled.

I figured this out in mach 3 with the brain editor thing, but now I am starting from scratch here. I also lost this brain for mach3 somehow. I cannot find it anywhere....I have not used the machine in years. 

Other than turning it on anytime there is a move, do you think I should add a minimum time limit or minimum distance so it is not clicking off and on with every little jog? The issue here is that if you make a bunch of little jogs it may not lube enough? However if it is clicking on and off a million times maybe that will wear out the relay or oil pump?

Anyway, I am sure someone has to have done this by now so any help is appreciated. I was watching videos on youtube of making a tool change script and started to fall asleep, so I figured I better get out here on the machine and do something simpler and wake up :)

In the mean time I will do more research and reading while I see if there is any response here.

Thanks!


39
I have to upgrade my pokeys 55 that is used for physical buttons, switches, & Pendant to go to Mach4.

I am wondering about going with the Ethernet version(57e) instead of the USB version (57u)?

Anyone done this? Any details?

Since there is only one ethernet port on the computer I am wondering the best way to go on adding a second one. I am also wanting to make sure there would be no issues with the ESS.

From my understanding the ethernet pokeys may be a bit more reliable than USB?

40
I think I have everything figured out for the spindle motor except I can't get the BoB relays to come on for forward and reverse signals to send out to the VFD. I am using the OB for step and direction to go to the BoB.

First of all, what ports and pins of the ESS actually send out these controls? I cannot find this anywhere. It seems like you need to know ports and pins to set it up or something.

I assume I need to set something up with the Spindle Fwd and Spindle Rev in the Output signals, but I am not sure what settings to make here.

The documentation for the ESS says this, but gives you no specifics on how to set it up:
"You may also assign the relays for Spindle On, Spindle Fwd and Spindle Rev as desired at this point."

You can also find this info, but it tells you nothing about setting them up other than when they come on:
Spindle related outputs.

Spindle Step or PWM: This will take the commanded spindle speed in RPM and convert it to an output signal with a duty cycle between 0% and 100%, which your spindle speed control module will convert into an analog voltage (typically 0v to 10 V DC).  This analog voltages is used by your VFD to run your spindle at the commanded RPM.
Spindle Motor Dir:  This output retains the current spindle direction even when the spindle stops.  It only switches state when a direction change is ordered (which prevents spindle direction glitching).
Spindle On: This output is active when the spindle is active
Spindle Fwd: This output is active when the spindle is running forwards (CW)
Spindle Rev: This output is active when the spindle is running in reverse (CCW)

See attached pic for the settings I am talking about.
Do I need to set anything for Spindle - Unused? Why is this even there if it is unused?
Do I need to set anything for Spindle Motor Dir?
Do I need to use the Spindle On?
I assume my issue is that I do need to set something for Spindle Fwd and Spindle Rev, but I am not sure what. I assume to enable them and I guess pick ESS for Mach Mapping?? What do I pick for pin mappings? 

Pages: « 1 2 3 4 5 6 7 8 »