Hello Guest it is April 24, 2024, 02:05:47 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.


Messages - cncman172

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 »
1
Mach4 Plugins / Re: Pokeys Mach4 plugin LUA reference for LCD
« on: January 07, 2019, 08:20:39 AM »

This line just gets you the handle, where is the code that populates the string?

local hreg = mc.mcRegGetHandle (inst, string.format("Pokeys_Lathe / LCD Line 1"))


This line populates the Xcoords with a string.
Xcoords = string.format("X: %4.4f", Xcoords)


I am running to catch a plan this morning but will respond again with the complete program, you have something wrong...

Russ

2
Mach4 Plugins / Re: Pokeys Mach4 plugin LUA reference for LCD
« on: January 02, 2018, 03:15:47 PM »
The first thing you do is go the the OPERATOR tab at the top of the Mach4 screen, then select "LUA SCRIPT"  it is about the forth or fifth item on the list under Operator.

This will show you the current LUA code you are running.

I have attached my code, the entire script was designed to put the DROs on my LCD inside my Yaskawa pendant.  You will not need lots of this code, but if you print this out and highlight the sections that update the LCD display you will understand what you need to add to your LUA script.  Back up your initial script before you make any changes, that way you can always go back.

The other item I should have mentioned on my DRO update code you need to change the serial number to the serial number of your POKEYS device.  You can find that under diagnostics screen you will find the POKEYS device listed.


Hope this helps.


Russ

3
Mach4 Plugins / Re: Pokeys Mach4 plugin LUA reference for LCD
« on: January 01, 2018, 06:52:03 PM »
Sorry for the delay been buried in College Football today.  LOL


LUA Code for X DRO

local inst = mc.mcGetInstance()
local Xcoords = scr.GetProperty("droCurrentX", "value")
local hreg = mc.mcRegGetHandle (inst, string.format("Pokeys_32062 / LCD Line 1"))
Xcoords = string.format("X: %4.4f", Xcoords)
mc.mcRegSetValue(hreg, tostring (Xcoords).. "     ")


LUA Code for Y DRO

local inst = mc.mcGetInstance()
local Ycoords = scr.GetProperty("droCurrentY", "value")
local hreg = mc.mcRegGetHandle (inst, string.format("Pokeys_32062 / LCD Line 2"))
Ycoords = string.format("Y: %4.4f", Ycoords)
mc.mcRegSetValue(hreg, tostring (Ycoords).. "     ")



LUA Code for Z DRO

local inst = mc.mcGetInstance()
local Zcoords = scr.GetProperty("droCurrentZ", "value")
local hreg = mc.mcRegGetHandle (inst, string.format("Pokeys_32062 / LCD Line 3"))
Zcoords = string.format("Z: %4.4f", Zcoords)
mc.mcRegSetValue(hreg, tostring (Zcoords).. "     ")





Here is the code that goes in the main LUA loop

--------------------------------------------------------------
-- Yaskawa Pendant Clear LCD Display
--------------------------------------------------------------
function YPenLCD()
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
        mc.mcRegSetValueString(hreg, "X:  0.0000          ")  -- X zero display
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 2"))
        mc.mcRegSetValueString(hreg, "Y:  0.0000          ")  -- Y zero display
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 3"))
        mc.mcRegSetValueString(hreg, "Z:  0.0000          ")  -- Z zero display
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 4"))
        mc.mcRegSetValueString(hreg, "A:  0.0000          ")  -- A zero display
end

--function YPenLCD(Axis, Line)
--    local CurPos = scr.GetProperty("droCurrent" .. tostring(Axis), "Value")
--    CurPos = string.format("%4.4f", CurPos)
--    local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line " .. tostring(Line)))
--    mc.mcRegSetValueString(hreg, string.format(tostring(Axis) .. ":  " .. tostring(CurPos) .. "          "))
--end


Russ

4
Mach4 Plugins / Re: Pokeys Mach4 plugin LUA reference for LCD
« on: January 01, 2018, 08:49:30 AM »
YES, I got it all working correctly.  I will post the code shortly, have to run out to the shop and look at the code.  Forgot exactly been a few days.  LOL

Russ

5
FocusPaul,

Mach3 or Mach4 never start up with a "random" position.  When you exit these programs it asks you if you want to save the last G54 position.  This means if you zero'd the machine at some given spot on your table say x=5,  y=5, z=-3, then when you start the program again it will report the offset from the last G54 saved position.  The first thing you do when you start these programs is to home them so they know where home is located.  As soon as you do this you will see the last saved G54 offset on the DROs.  So say you had a 10" x 10" table and you moved to 5,5 the very center of the table.  You zero the DRO so not it says 0,0 this is your G54 location.  You can press machine coordinate button and it will show you 5,5.  Now close out the program and it ask if you want to save the last location, say YES.  Now start the program and home your machine.  The DRO will now way X= -5, Y= -5 and whatever Z was set at when you saved the position.  Now go to the MDI screen and issue the following command.  G1 X0 Y0 F50 and the machine will move to the last saved G54 location which is at machine 5,5 or the very center of this table.

Do you follow how this works?

Russ

6
FocusPaul,

The only way that can happen is if you use absolute encoders on your servos.  Absolute encoders have batteries as backup power so when you turn off the machine it holds the exact encoder count the machine had when you turned it off.  That way when you turn it back on it has the exact position and the machine knows exactly where it is located.  This is very common on expensive commercial machines.

Russ

7
Yes but I am out of town on business will post info when I get back
Russ

8
FocusPaul,

You are getting much closer to understanding how things work.  Good Job.    I am not rich either and do not have absolute encoders on my machines.  Ha Ha

G54 is one set Work Offset Coordinates, you can have others like G55, G56, G57, G58, G59,  see the link below for an entire explanation

http://www.cnccookbook.com/CCCNCGCodeG54G92WorkOffsets.htm

You can actually save work offset coordinates inside of most CNC software programs like Mach3, Mach4, KmotionCNC, LinuxCNC, etc.

In Mach4, if you go to the "Offsets" tab at the top of the screen, and then to the "Fixture Table" button at the top middle of the screen.  You will find a fixture offsets table.  You can record various fixture offsets that you use repeatedly.  Perhaps you have a fixture you position on your table in the same place each time you run a certain job.  It is located at X=14.5, Y=15.6, if you record this in the table then after you home your machine and zero the DROs you can just put a G54 in your gcode and it will move to this offset location.  Think of a garage at your house maybe it is a two car garage and you always park your Mercedes in the right garage and your Porsche in the left garage.  In the case of your machine maybe you build guitars and you also machine the Neck at a certain position on your table, maybe G54, and then you might have another fixture that does the top of the guitar and the hole cut out, and you have that located at G55.

Now many users especially hobby users run one off jobs so they just do the G54 on the fly, they bolt down the material on their table and job over and find the corner of the material and zero the DROs and that is their G54.


"When I close M4 on machine position (X;Y)=(40;40), am I wrong in suspecting that M4 comes up with that latest machine coordinates it recorded?"
YES, Mach4 will come up with the last saved G54 position.  So if you home your machine, zero the DRO and jog to 40,40 and then zero the DRO for X,Y, at that point Mach4 has G54 defined as 40,40
If you exit M4 now it will ask if you want to save the job position, if you say YES it will record 40,40 so when it starts up again it will show -40,-40, if you say NO it will keep that last recorded G54 position used.

If you want M4 to come up and show 0,0 when it starts, you need to home the machine before you turn off the machine and then zero the DROs and then exit.  This way the M4 will know that no G54 position needs to be remembered.


"Of course, M4 cannot know if I have moved the mechanics while the software has been offline. So is M4 resetting machine coordinates to 0;0 on every start-up because it cannot know the "exact" position (missing encoders)?"
Absolutely TRUE, if you move the axis without Mach4 it has no idea of where things are when it starts.  This is why we always must home the machine after startup so that is when it finally knows where it is on your given table.  Very important to home the machine at the beginning.  Let me give you an example of why this is important.

You start cutting a job and it is half way done, and suddenly your spindle hits a clamp you used to secure the material to the table.  It breaks your cutting tool and you react and hit the ESTOP.  After you stop shaking and calm back down you change the broken bit and now MACH4 is flashing because of the estop.  You now need to home the machine, because you might have lost steps due to the accident and the location could be off slightly.  Now after you home M4 again knows it is a absolutely 0,0.    Now how will M4 get back to your G54 location.  One way is to exit and have M4 save the location then start again, home, and G0 X0 Y0 will take you back to your job start location.  I make it a habit to record my G54 location before a big job in Absolute Coordinates and write it on paper.  This is a safeguard, so I know I can get back to the right spot.  Once I zero my X and Y at the corner of my job, I then turn on absolute coordinates and record them, then I turn them off and I am back to zero zero for G54.  Now you can restart the job and you will be exactly lined up again.  You can also use the tool RUN FROM HERE to avoid doing the first part of the job again.

"It all comes down to: Why does it zero the machine coords on every start-up?"
Mach4 zeros machine coordinates when it starts because that is the only way it has of know exactly where it is on the table.  

Think of it this way.  When you turn on a Garmin GPS so you can find that wonderful Bar and Restaurant you have heard so much about, what is the first thing the GPS does?  It has to find out where are you now.  Then after it gets the satellite signals it shows where you are on a map.  Now it can route you to your destination.  If it never found your "HOME" position it has no idea how to send you on your way.

Understand now?


Russ








9
FocusPaul,

You must be doing something wrong.  Let me explain a few basics and then I will give you another experiment.

When Mach4 starts it has no idea of where the machine axis are located.  Why?  All machines suffer this issue unless they have absolute encoders on their motors.  What is an absolute encoder?  An absolute encoder is different than an incremental encoder.  The absolute encoder has a battery and it is also designed in such a way that the entire range of that given axis is known.  This has to do with the optical encoding on the disc, but that is beyond what is required in this discussion.  The incremental encoder has 1000, 2000, 2500 pulses per revolution or higher and the electronics monitor these counts to determine if they motor has turned far enough.  The absolute encoder also does this but the difference is when you turn off your machine the incremental encoder does not remember the number of rotations in a given direction that have been moved from the home location.

What does all this mean?  It means unless your are rich and have absolute encoders on  your machine,  you will need to let MACH4 initialize its machine coordinates, by running the homing routine.   As soon as the homing routine is complete Mach4 now knows where it is on your table, with is absolute zero or the machine coordinate zero position.

Now lets look at your experiment.

1) home your machine, when the DRO indicators show a green ring it lets you know the machine has come to the home position.  By default Mach4 will zero the DROs for X and Y after the homing sequence, EXCEPT if a G54 location was saved on a prior exit.  This is normally pretty evident because the X and Y dros will usually have a Negative number populated in them after the initial homing sequence.

2) Why is there a negative number in the X,Y dros?  This is actually the saved G54 position.  All you need to do after the homing and you see the Negative DRO reading is to issue a G0 X0 Y0,  after that move finishes you will be at the saved G54 position.  

Keep in mind that G54 is an offset position from the machine coordinate 0,0 position.

I can tell by your experiment this is all working because you point out when you opened MACH4, you found the X axis with a -40.94.


Now if you start Mach4 and you see the negative DRO positions reported after the homing sequence and you need to set a new G54 position, you zero the DRO when it is at the home position.  Now that the DRO reads zero at machine home you can now jog to the new location you need to setup for G54.  Once you have jogged to where you want you zero the X,Y dros again.  That is what establishes the G54 position.  To prove this to yourself run the following experiment.

home the machine, and zero the DRO for X,Y
move the machine to the center of your table, write down X and Y on paper, now zero the X and Y DRO
now home the machine again, once it is there you will see negative X and Negative Y from the G54 numbers you recorded on paper.
now issue the following command.   G0 X0 Y0, the machine will move to the G54 coordinates you wrote down on your paper.

Do you understand now?

Russ

10
DazTheGas,

Thanks for the laugh.  I needed it today.  You answer so many of these type questions figured I would give you a break.  LOL.  How are you doing, you making any more Mach4 videos.  I love watching your videos.  :)

Russ

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 »