Hello Guest it is October 20, 2020, 10:11:15 PM

### Author Topic: Mach4 Spindle At Speed, Spindle Zero Problem  (Read 11083 times)

0 Members and 1 Guest are viewing this topic.

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #40 on: October 18, 2017, 01:41:14 PM »
Hi,
Daz has a useful solution.

I wonder why its happening. Could it be that the spindle gets told to turn on and THEN gets its new commanded frequency. So just for a wee while it believes
its already up to frequency....its just that frequency is zero?

Craig
My wife left with my best friend...
and I miss him!

#### DazTheGas

• 752
• DazTheGas
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #41 on: October 18, 2017, 02:47:19 PM »
This should get you going, just tried on my machine and works fine.

Code: [Select]
`function m4() local inst = mc.mcGetInstance();    mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_SPINDLEON),0) mc.mcSpindleSetDirection(inst, mc.MC_SPINDLE_REV)    wx.wxSleep(10) -- Change to how many seconds you requireendif (mc.mcInEditor() == 1) then m4()end`
DazTheGas
Theres always time for a choccy biccy

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #42 on: October 18, 2017, 04:14:31 PM »
Hi Daz,
that code introduces a straight delay. Hakans intent was to use a signal from the VFD to indicate that the spindle
is at commanded speed.

If you are using a small diameter endmill the spindle could accelerate quickly whereas a large face mill would take longer.
The advantage of waiting only until a signal comes good is clear.

Hakan hasn't said how he commands frequency/speed of the spindle. If he is using modbus whats the bet that the
start signal is arriving before the frequency command.

Craig
My wife left with my best friend...
and I miss him!

#### hyildiz

• 60
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #43 on: October 18, 2017, 04:43:27 PM »
Hi Daz,

Our purpose was to get the "spindle at speed" input HIGH before moving the gantry, so that while using MDI or Gcode machine will not move before vfd does not send the signal.

Which reminds me Craig, in this code if vfd does not send the signal m3 code gives "spindle does not respond" and continues the gcode when spindle is not moving. Can u add a code there if input62 is not HIGH machine should not move.

I am trying to make this logic work because there will be a AC line lost procedure which will be controlled by arduino, machine has internal ups, basically while machine working for hours if AC line lost occur arduino will take control and feed hold the machine first then record the coordinates and gcode line then it will park all axises to a location and shut down the power. Then it will start to listen the AC line, when line comes back it will turn on the machine, goes to the coordinates recorded, input the gcode to Mach4 and goes to the last line and start from there. During this procedure it will check the spindle input but to be sure i need that function also in Mach4 so it wont dive in to part with spindle off which is very dangerous.

Regards,

Hakan

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #44 on: October 18, 2017, 05:00:34 PM »
Hi Hakan,
what code are you referring to... I personally don't think Daz's code is suitable as is, it could be made so but it is only
a barest sketch of what it would need to be in practice.

May I suggest that you use Mach to detect phase loss and if you wish it phase rotation. Mach can therefore shut down
or refuse to engage if it detects power fault.

Craig
My wife left with my best friend...
and I miss him!

#### hyildiz

• 60
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #45 on: October 18, 2017, 06:13:21 PM »
Hi Craig,

Das's code is not suitable for my purpose.

I was referring to the m3 code u sent last, when it can not see the input62 it says "spindle does not respond" and then instead of stopping it goes on to gcode/MDI code and all axis moves with spindle turned off. Is there a way to stop it when there is no input62 HIGH signal?

Regards,

Hakan

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #46 on: October 18, 2017, 07:55:22 PM »
Hi Hakan,
I understand what you mean. We have code that waits for the spindle to accelerate or detects thats the spindle
is un-responsive. In the event of an un-responsive spindle what do you want the machine to do?
You could cause an Estop or a Feedhold easily enuf.

I think you could incorperate into your power detection/protection strategy. I would suggest that you get a power
monitor relay, for under \$100 you can get a relay which monitors under/over voltage, phase failure and phase rotation.
The contact of the relay could be monitored by Mach easily. Why bother with another device like an Arduino?

Craig
My wife left with my best friend...
and I miss him!

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #47 on: October 19, 2017, 01:47:31 AM »
Hi Hakan

Quote
I am trying to make this logic work because there will be a AC line lost procedure which will be controlled by arduino, machine has internal ups, basically while machine working for hours if AC line lost occur arduino will take control and feed hold the machine first then record the coordinates and gcode line then it will park all axises to a location and shut down the power.

This can be done quite easily and I don't think an Arduino is required or desirable.

Quote
Then it will start to listen the AC line, when line comes back it will turn on the machine, goes to the coordinates recorded, input the gcode to Mach4 and goes to the last line and start from there. During this procedure it will check the spindle input but to be sure i need that function also in Mach4 so it wont dive in to part with spindle off which is very dangerous.

This is a nightmare idea. I suspect that in New Zealand it would be illegal to have a machine start itself unless that machine were completely isolated from all
human contact. A restart of this nature should be under operator control.

In Mach3 there was the possibility to 'Run From Here', although many a CNCer came to rue the code, if it wasn't buggy it certainly seemed unpredictable and many
a job was wrecked as a result. There is no such code in Mach4, you would have to construct it. It really comes down to fictitiously running the Gcode up to the point
of the restart to determine the modals which were in operation prior to shutdown and incidentally the X,Y,Z cords  at the point of shutdown. The restart requires the
machine drive to the required co-ords whether derived from the fictitious run or from memory as stored at the moment of shutdown, restart the spindle and <cycle start>.

All in all quite a programming undertaking for someone who confesses to be a Lua newbie. If you want a hand to code some sort of safe shutdown procedure as a result
of power failure or spindle speed failure I will help. I am VERY dubious about helping anyone code 'Run From Here' functionality particularly and especially if it is to be
automatic.

Craig

My wife left with my best friend...
and I miss him!

#### hyildiz

• 60
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #48 on: October 19, 2017, 04:37:56 AM »
Hi Craig,

Its not that complicated actually, arduino is C based programming and i can do it (as long as its not too complicated) and as u know it has a wide resources for projects of all kind including communication with Mach4 via Ethernet. I will use arduino mega, ethernet and usb host board connected and its peripherals because i already start the machine with a fingerprint reader and arduino is controlling the power up procedure with relays. So it is already installed and later, through usb host i will add 3dconnexion 3d mouse to control the machine by wireless 3d mouse in all axis.

Arduino will watch the ac line with a voltage sensor so it will know the value of the voltage because in here sometimes it fall below 220V which is bad for electronics. Installed UPS will balance the voltage but if it takes too long to return to normal state arduino will interfere in that case too.

As u know some gcodes takes 9-10 hours to finish, with this setup i will be able to leave the machine on its own at nights so if lights out it will park and wait, when AC line comes back it will go on from the point which it stopped. In case of flickering in AC line or phase lost installed UPS take care of that. Its some kind of helpful automation ;-) installed UPS and batteries have enough power for running the machine about 10minutes with full functionality so it will give more than enough time to arduino for parking and recording the states of DROs, machine coordinates, gcode file, gcode line, etc. Arduino has external separate ups which holds it on for 1-2 days, so it will park the machine and shut down the power and wait for AC line to come back by itself.

Related with the signal glitch problem,

In this Delta VFD there is 2 outputs, 1 is a relay and 1 is an output signal(not relay), i connected the spindle at speed to relay output which is making that glitch so today i will change it with signal output and connect the relay to spindle at zero i think it will solve the problem because signal output does not make that glitch.

Regards,

Hakan

#### joeaverage

• 6,228
##### Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #49 on: October 19, 2017, 05:47:26 AM »
Hi Hakan,
trying to have your machine restart and resume a Gcode job automatically is likely to prove an expensive mistake.

As far as stopping the Gcode file from running if the spindle is un-responsive you could try
Code: [Select]
`mc.mcCntlCycleStop( number mInst)`or
Code: [Select]
`mc.mcCntlEStop(number mInst)`or
Code: [Select]
`mc.mcCntlFeedHold(number mInst)`
That's the easy part.
How are you controlling the VFD?. I think the start signal is arriving before the frequency/speed command and therefore you are getting a glitch.
Do you want to solve the glitch or just have some workaround to the problem?

Craig

My wife left with my best friend...
and I miss him!