Hello Guest it is March 30, 2023, 09:00:10 PM

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 - pjcevallos@gmail.com

Pages: 1 2 »
1
Mach4 General Discussion / Re: Doing math to DRO values
« on: December 02, 2022, 04:54:44 AM »
Hi

Craig is right, but I am not sure it depends on the Mach4 version. In my case, the Screen Load script already came with a reading and writing registers according to the Lua script manual as below. please check the manual. This means reading and writing registers is straight forward, but please remember they are write and read as strings, not numbers.

Code: [Select]
function GetRegister(regname)
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
return mc.mcRegGetValueString(hreg)
end

Code: [Select]
function WriteRegister(regname, regvalue)
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
mc.mcRegSetValueString(hreg, tostring(regvalue))
end

That meant that the registers are strings, even though they are numbers. You have to convert them into a number
Code: [Select]
val = tonumber(val)
Then you can use the variables to do math.

Something that I did not have time to check is that I could not perform an if the operation (Equal) because the decimals were not the same.
I guess I need to use the following, but I have not had time to do it.

Code: [Select]
tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
Silly things happened to me and crashed mach4, but now I learned (literally this week)

Check your register's name: an empty space at the end of the register. I copy/pasted from notepad and didn't check the empty space, which crashed the PLC script because a "new" variable with nil value was being used.

Pablo

2
Mach4 General Discussion / Re: Read Register from a text file
« on: August 09, 2022, 04:32:16 PM »
Sorry for the long explanation, but I cannot find better words. Also English is not my native language, so please accept my apologies for any mistake, though I lived quite a few years in the UK.

Right now I am studying material extrusion for 3D printing which uses a coordinated axis A, and an out-of-band axis. The coordinated axes push a specific quantity of material, and the OB axis acts as a shutter valve opening and closing an aperture. Apart we have the normal X-Y-Z axes.
A gcode program is loaded from a slicer (which is post-processed to add the OB axis commands using pound variables #600,#601), and we wait until it finishes with the parameters given.

We are studying an option to do in-situ modification or closed-loop feedback while running the gcode program to achieve a good quality part. Furthermore, we also are studying a defect correction by using a spindle that removes material and then we can re-start the extrusion from a previous line in the gcode.

While it is printing, we can see if the extrusion is good or not, and then we use the feed rate override to improve it, but this is dependent on an operator's decision, and this is one of the parameters we want to automate if possible. In the second case, if there is a defect that can be removed, we stop, we manually removed the material, and then restart the gcode from the line we want. Again, we would like to automate this.

Our options for external sensors are Camera vision, laser scanner, and possible a flow rate or pressure sensor with an analogue output.

In all cases, we will need an external interface (hardware and/or software) to do the data post-processing and decision-making and the person in charge of that wants to use python. Furthermore, we do not have analog inputs in our controller.

What we are not sure about is how this "decision-making" from python can be communicated to Mach4.

I believe using registers is our best shot because of their flexibility: they can be either signal states, numbers, or strings. Using only digital inputs doesn't look logical.

For example, If a text file contains a table with registers, this file can be updated by python when needed (txt or csv file), then the PLC script in mach4 can open, read the file, and set the new values of the registers such as the FRO, the gcode line to start, Depth of cut, or others, or do nothing if there are no modifications in the register values, and then close the file. Because it is the PLC script it will check this file every 50 ms. It is like feeding variables (numbers/string) to mach4 to do online modifications. Of course, there will be a lag, but we want to study the efficiency of the method.

In the case of stoping, machining, and restarting, I believe a lua program can use a depth_of_cut register to perform a machining operation. Once it finished machining, then restart the gcode program in a previous line.

The third idea from one of our colleagues is to modify the gcode on the go and sent it and execute it in mach4 line by line. Again the same, the problem is how to communicate between another software and mach4.

As a reference from a previous project.
In the past, I achieved a "closed-loop force system" for a totally different application and with a different controller and software (GRBL) in which Labview was the CNC graphical interface sending Gcode commands through serial communication to the GRBL microcontroller (see link below). I was able to modify the position of the Z axis based on the force sensor values only because the microcontroller responded to serial commands in the shape of Gcode. Here I did not care about axis accuracy but having a "constant" force
https://www.youtube.com/watch?v=k0nlSpAebmA


I hope I described the goals as clear as possible. I cannot stop thinking how to do it so I hope someone can give me some direction.

Pablo


3
Mach4 General Discussion / Read Register from a text file
« on: August 08, 2022, 06:51:35 PM »
Hi

Is it possible to read registers or variables from a text file using Lua scripts?

The idea is to overwrite the text file when needed while a gcode is running, and therefore change the registers/variables in the process but from the text file.

Hope you can help me

Pablo

4
Mach4 General Discussion / Re: Programs won't continue after m6
« on: August 08, 2022, 05:14:20 PM »
does your m6 macro has a "return"

for example

Code: [Select]
if selectedTool == currentTool then
mc.mcCntlSetLastError(inst,'Tool Change activated not required')
return
elseif currentTool == 1 then  --DROP TOOL 1 BLANK AND COLLECT TOOL 2

mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z-70 F3500")

return

end


5
Modbus / Re: Where to start
« on: August 08, 2022, 08:40:14 AM »
Hi Craig

Just wondering if you have ever sent data (numbers, string, no digital/analogue inputs) from another software/interface (python/arduino) to Mach4?

My idea is to have an input signal that stops the gcode running, and then the "software/interface" decides the new gcode line where to start (another piece of data sent to Mach4), and then an input signal (string, or number) to start the cycle from that line.

I hope my idea is clear

kind regards

Pablo

6
Hi

Is there any way to enable an output when a specific axis is running?

For example for the X axis

G21 G90 X10 Y10 (output is enable)
G21 G90 Y15 (output is disable)

kind regards

Pablo


7
Hi

We need a piece of advice to see if an automated defect detection and correction program can run in Mach4. For example, our current gcode program has different sections such as:
Section 1 – Gcode blocks (lines 1-10)
Section 2 – Gcode blocks (lines 11-20)
Section 3 - Gcode blocks (lines 21-30)
Etc.

Defect Scanning
To implement the defect detection, we can easily insert a block that activates and output (M64 p#) and waits a specific time to do a scanning (G4 P#). It is just moving the piece below the camera and scanning. Easy. The new program should be written as:
Section 1 – Gcode blocks (lines 1-11)
Subsection 1 – gcode block for defect detection
Section 2 – Gcode blocks (lines 12-21)
Subsection 1 – gcode block for defect detection
Section 3 - Gcode blocks (lines 22-32)
   Subsection 1 – gcode block for defect detection
Etc.

Defect detection and correction
Then, the post-processing of the image will be done in another software (python, Matlab, etc). It will detect if there is an error, and here is our problem, How do we inform Mach4 there is an error and how to correct it.
Problem 1. How do we inform mach4 there is an error? 
I think it will be easy to write on the signal script to actively search for a digital input to STOP the program. This is something similar than having a limit switch. We are using soft limits because we have absolute encoders, and the systems works perfectly with that. Can we use a limit axis input if the soft limits are active? I think this would be the fastest solution. However, if a limit switch is activated, it disables mach4 rather than stopping the program, and restart the program from a different gcode line, which is the stated in the problem 2.

Problem 2. How to correct the defect.

Our strategy to correct the defect is “simple” as we only need to Re-Start the gcode program in a previous section decided by the external software. We can do it manually once we see the software indicates an error, but the idea is to automate it and eliminate human interaction. In the following program, the first phase corresponds to “defect detection and stopping the program”, and the second phase correspond to start the program in a previous fcode line commanded by the software as shown below:
(First phase: defect detection)
Section 1 – Gcode blocks (lines 1-11)
Subsection 1 – gcode block for defect detection
Section 2 – Gcode blocks (lines 12-21)
Subsection 1 – gcode block for defect detection
Section 3 - Gcode blocks (lines 22-32)
   Subsection 1 – gcode block for defect detection
(-comment: defect detected, digital input is activaded, program is stopped)
Section 4 - Gcode blocks (lines 33-42)
   Subsection 1 – gcode block for defect detection
Etc

(second phase: defect detection)
Section 1 – Gcode blocks (lines 1-11)
Subsection 1 – gcode block for defect detection
Section 2 – Gcode blocks (lines 12-21) – New start of the program
Subsection 1 – gcode block for defect detection
Section 3 - Gcode blocks (lines 22-32)
   Subsection 1 – gcode block for defect detection
Section 4 - Gcode blocks (lines 33-42)
   Subsection 1 – gcode block for defect detection
Etc

The question here is how we can tell mach4 to start the program at a specific line? Which communication to use? We are using an EtherCAT controller with several several GPIO, also we can have analog inputs and outputs. Maybe, there is another type of communication to inform mach4 which line to start in the program. I believe it shouldn’t be something that complicated, but not sure if mach4 can do it.

The second option is if the loading and running of a gcode program can be automated. Python, Matlab, etc then will chop the original program and upload the new one. is it possible?

What thoughts do you have? is it possible?

Kind regards


Pablo

8
Hi Rab

I am looking for high speed engravers for micro machining.

Do you have some brands that I could start asking?

thanks a lot

Pablo

9
Bargain Basement / Re: High speed spindle with controller unit
« on: April 11, 2022, 08:50:20 AM »
Hi

Just wondering if there are any other brands for high speed spindles you recommend?
currently Nakanishi has long lead times

Best regards

Pablo

10
Hi Pedro

Can I ask what micromachining spindle are you using?
I was going to buy a Nakanishi, but the lead time is 4 months and I need something faster.

Best Regards

Pablo

Pages: 1 2 »