Hello Guest it is August 13, 2022, 05:44:13 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 - zafarsalam

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 »
1
Recently retrofit this turret punch machine from Trumpf in Kazan, Russia. Had been a great experience. Replaced 6 servos on the machine with Chinese AC servos. Used a customized screen for user interface and tons of coding in VB script, brains and Arduino to make the different functions work. Mechanical structure of machine was excellent and after the new electronics installed the useful service life of the machine was extended for many years.

Customer was not happy at all with the old Bosch controller which broke every other day. After tinkering with it for over a year they invited us over for the retrofit. The look on the customer's face was priceless when the machine started punching and produced their first part effortlessly. Reclamping, autoindex, auto-retracting clamps and a load of other functions were programmed in the controller. Took us almost a month including the mechanical fittings of motors, display screen, keyboards, and other stuff.

Here is the video of the machine in operation.

https://youtu.be/epibX_NZ1Is

Zafar

2
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 27, 2022, 10:46:16 AM »
In the Arduino sketch you can do an if statement in the main loop. You can read the value of a register from Mach3 modbus or the state of a pin which can be connected to an output pin from Mach.

In the tool change macro you can either turn an output on and off to signal the arduino to start the tool change sequence. Or change the value of a user DRO which can be read in brains and then to modbus. Then you can do a while statement in the tool change macro which waits for the input from Arduino to finish the tool change macro.

3
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 27, 2022, 03:27:40 AM »
During a delay the modbus communication will stop. Since you don’t need to send any signals to mach3 during the stepper movement so it is safe to use it.

4
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 26, 2022, 12:21:22 PM »
You can try the stepper library to drive the stepper motor. With it you can put acceleration, deceleration, Max speed etc on your pulse train.

So i received this feedback from a user on the arduino forums:

A while loop is blocking by its very nature and a delay() in a while loop magnifies the length of the blocking

The solution is to use an if instead of a while and millis() for timing. No doubt you have seen the BlinkWithoutDelay example which uses this method

So, your code would in essence look like this

if the switch is activated
  if the step period has elapsed as measured using millis
    take a step
    save the time of the step
  end if
end if

A Timer is non-blocking and will also allow other code to run while this one is running which could be catastrophic as the ATC uses a solenoid pin, therefore is there any way to replace the Delay() and make it non-blocking code but not run the rest of the loop? any other method or function?

5
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 26, 2022, 08:14:24 AM »
I normally use the MAX3232 module to connect the arduino to serial port of the computer. Using pins 0 and 1 on arduino for RX and TX.

https://www.amazon.com/MAX3232-Converter-breadboard-Electronic-Connector/dp/B082B97DYQ

Why are you not using mach3 to drive the stepper motor for the tool changer. You can share the code if you wish.

Zafar

6
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 26, 2022, 01:04:22 AM »
It is not needed there.

I added MB_REG10, ? is that correct?



7
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 26, 2022, 12:52:24 AM »
The terminator in the new brain should be like this.



So to clarify just check my images if this is correct?

and then in the sketch:

enum {       
        MB_REG0,
        MB_REG1,
        MB_REG10,
        // line below is for holding registers.    'vinny'
        MB_REGS   = 40    /* total number of registers on slave */
};

I added MB_REG10, ? is that correct?

I'm struggling with the brain where you say modbus output register as the terminal:
enter the modbus adres to use. what number should i enter here?
the CFG# would be number 2 then?
and macro modbus emulation?



8
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 26, 2022, 12:33:05 AM »
Good to see that you have progressed so far. You can view the brain using the menu Operator/Brain Control ... and then click on the Brain View button.

In the Arduino sketch you should handle the inputs and outputs through the DIO pins. What I prefer to do is use two of the pins of Arduino to communicate with Mach3. One pin receives signal from Mach3 to initiate the toolchange sequence and the other signals back to Mach3 when the tool change sequence has completed. You can connect all your tool change actuators and sensors to the input and output pins of the Arduino. Be careful when using the delay command in Arduino. During the delay loop the communication with Mach3 through modbus will stop. Better use the timer function in Arduino for the delay. Also be careful of the infinite loops in case of any actuator or sensor malfunction. Add checks in your code to break out of infinite loops based on a time limit.

Also you can program some error codes which you can feed back to Mach3 through the modbus registers.

Zafar

I had to uncheck the box "ignore tool change" in the general config and check the box "Auto toolchanger"
Now the macro is working fine along with userDRO of 2001. How will I test the brain I made to see if it is working the way it should?
Now it seems it is just the arduino sketch left to modify? So how do I do this and how do I add my toolchanger code to it? without either one interfering with the other?

9
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 25, 2022, 10:42:58 AM »
In the M6Start macro you can use the vbcript function GetSelectedTool() and save it in a userdro.
setuserdro(2001)=getselectedtool()

In the arduino sketch 40 regs are already assigned while we are using just two of them regs[0] and regs[1] for reading analog inputs on pins A0 and A1. These regs are passed on to Mach3 brain as input-holding.

Now you'll have to define new config as output-holding and assign an address of 10 and number of registers 1. In the brain you add the new rung with userdro as the input and the modbus output register as the terminal.

The value of userdro(2001) will reflect in the arduino as regs[10].

I hope you got some hold of this confusing technique.

Zafar

Hi Zafar,

Thank you for the quick reply.

The new fields that I add assume needs to be Output holding?

I have never made a userDRO before, I will watch a couple of youtube videos that might enlighten me.

I know how to make a brain based on your tutorial but have no idea what functions to use for this?

the m6start macro I could do. How do I change the arduino sketch to receive the inputs and can this still be done using the USB or do i need a RS232 to USB converter and use serial 1,2 or 3 on the arduino? I am completely lost.

10
General Mach Discussion / Re: Arduino - Mach 3 - Gcode M6 T0101
« on: March 25, 2022, 10:10:10 AM »
Hi,
You'll have to add new fields to the modbus configuration in setup serial modbus control menu. Perhaps use a userdro to hold the new tool number and then use this dro in the brains. This all can be handled in the M6Start macro and a brain. Also the arduino sketch needs some additions to handle the new registers.

Zafar

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 »