Tool Enable Doesn't Work With Huanyang VFD

Hey,

you are using “tool-enable-mode” on Tool Configuration Tab which sets Pin 15 to “hi” to switch your “Router On” relay. But as we seem to have found out here, apparently Pin 15 seems to do nothing if you select a VFD as tool-type. “Tool-enable-mode” on Pin 15 ceases to work as soon as you select something other than “PWM Spindle”. That would mean your Router Switch on Pin 15 is ignored if you select a VFD as Tool-type. And it would mean that you might have had a good reason to set “tool-type” to “PWM Spindle” :slight_smile: – apparently “tool-enable” on Pin 15 doesn’t work without this…

I remember also repeatedly some people complaining that their laser didn’t fire. The solution was, they had not selected “PWM Spindle” as Tool-type (but a VFD instead). Buildbotics writes:

PWM Spindle - this tool-type is also used for lasers.

Buildbotics.com writes in How to use a VFD spindle driver:

4.1.4.tool-enable-mode & tool-direction-mode

These options are not normally needed for RS485 VFD control. Set them disabled.

Well, they do not say that “tool-enable-mode” doesn’t work when a VFD is selected as Tool-type, but in fact it doesn’t. :slight_smile:

The PWM signal is made for spindles that work without VFD. Regarding VFDs, besides them being able to receive commands from the CNC Controller via RS-485/ModBus, the spindle speed (Frequency) can also be controlled by a Pulse Train input (PWM) or by an analog input Terminal to which either a potentiometer or an active circuit output is connected:


– Source: Omron MX2 User’s Manual

And the VFD’s outputs are usually used to activate spindle cooling (or dust collection also if you want)

Hi Aiph5u,

I really appreciate all of the help that you (and everyone else) have provided. I’m not super comfortable using DRV/UPF as a digital input to the Arduino as it will require further circuitry that I’m not super familiar with. I’d hate to wreck the VFD or my external power supply over this.

I think that I will use L1/L2 as it should be fairly easy to account for in CAM. It would still be nice to see a firmware / software update to iron out the Pin 15 bug in the future however it does seem that there are an abundance of options to pick from so its not a big deal.

Thanks again for all of the help!

1 Like

Hey Branden,

Exactly. Connecting something to an Open Collector Output is not Rocket Science. An open collector means there is nothing connected to it, especially there is no power on it, it’s a Transistor with its Collector connected to nothing and led out for use. In order to use it, you provide the power through a Pull-up Resistor, so already by choosing the Voltage you can prevent damaging something.

Huanyang_VFD__Basic_Connection_Diagram__With_mark_on_Optocoupler_Outputs_DRV_and_UPF

On these collector outputs, you may directly connect a low-voltage Relay (with a Flyback Diode) and a power source of up to 24 V in order to switch on a water pump or something.

But of course you can also give a logical “high” to your Arduino input pin easily.

An Open Collector Output is an output that has a state of either open or near GND, but it is not defined at what voltage level “high” state is. You are up to define this by attaching a power source and a pullup resistor.

In fact on the Huanyang these outputs are Optical Coupler Outputs but that works the same way.

Which Arduino Model and which input pin do you want to use for reading out?

Hey Branden, hey Andy, hey all,

Of course you can switch workpiece coolant/mist on as part of your G Code program. M7 and M8 commands are made for this. This is something with a clear relation to the workpiece material and tool selection you designed your G Code program for.

But as for turning on spindle cooling and dust collection, this is something different. Especially spindle cooling must run whenever spindle runs and I would say it’s the VFDs job to ensure that. And VFDs are built to do exactly that.

The danger of controlling spindle cooling by a G Code program is that if you run a program where you forgot to insert M7/M8 commands the spindle will run without cooling and die.

Tags: load-1, load-2, 25-pin I/O port, M7, M8, M9 Workpiece coolant control

1 Like

Agree. I’m thinking through options (I chose air-cooled to avoid the complications of water-cooling). One last though, you can make Mist/Cooling active for every run using the General Tab in the controller:

4.7.1.

General Tab

The General Tab provides the ability to set the units for configuration, define code blocks to be executed at start, end, and during tool changes, define the path accuracy, and set the limit for acceleration around corners.

2 Likes

Hey Aiph5u, Hey Andy,

I’m using a Mega 2650 for the local controls. Id rather not have to add diodes/resistors to the circuit if I don’t have to. Do you think this would work if I used pinMode(SpindleRunningEnable,INPUT_PULLUP) that way when the DRV output is high it would send a ground signal to the arduino? (SpindleRunningEnable is pin 17). I definitely need this to go to the Arduino instead of directly to a relay because it needs to block other controls/actions while the spindle is on.

I agree - removing human interaction whenever possible will definitely prevent potential accidents. Would this be preventable by using the general configuration program start and program end posted by @AndyP? That seems easy enough to incorporate. If only pin15 worked :sweat_smile:

Hey Branden,

Yes, one of the nice things of AVR’s is that they offer integrated pull-up resistors, that’s why I asked you for the input and model. So you see it’s not difficult at all.

With the Huanyang factory settings for DRV (PD050=01), DRV is triggered when spindle runs, and for UPF (PD051=05), UPF is triggered when the spindle has reached the set speed. You may of course reprogram the function of these pins.

Hey Andy,

I think M7 and M8 should be activated when the tool is in fact milling and pause during moves in the air.

Agree, but this is a workaround to create a switch. M7 and M8 turn them on and M9 turns them off. Stick m7 / m8 in the startup section and an m9 in the closedown code section of the general tab.

Bob’s your uncle and Fanny’s your aunt.

Hey Andy, hey Branden,

But a switch for what? Branden said:

Okay, Dust collection. Okay. If you want to switch Dust collection on from your G Code program. Sorry I mean from your controller G Code presets. Then it’s supposed to be like that.

But not the spindle cooling! :scream_cat: :hear_no_evil: :cold_sweat: :slight_smile:

I don’t like M7 and M8 to be used for something else. It attacks my order! :scream_cat: :grin: :wink:

Et voilà!

I just connected DRV to pin 17 & DCM to my power supply common. When the spindle is running the input seems to float between high and low, toggling the vacuum & water cooling on and off constantly. I can confirm that DRV is programmed to Run and pin 17 is programmed as a pullup. I’ll play around with it some more when I have time.

Hey Branden,

connecting Huanyang’s DRV Output Terminal directly to your Mega input pin without any further wiring is correct if INPUT_PULLUP is set, and DCM Terminal is ground then. Pin 17, do you mean Pin 17 of the Arduino MEGA2560 right? Then it is Port PC1 right? Or do you mean Pin 17 of the ATMEGA2560 µC?

I do not know why it does this. For diagnosis one would need to know the library and the code that reads the input and first of all, the hysteresis that controls the loop for switching the outputs on and off.

Also take into account that the Huanyang VFD in not regarded as a high-quality VFD, it’s cheapest electronics. Who knows how reliably it triggers that output. Do you have an oscilloscope?

Hey Aiph5u,

Correct, I mean pin 17 if the Arduino.

Unfortunately not. I may look into this more in the future, but I think I’ve settled on using L1 for now. I still have tons of learning to do before I can get this machine up and running and maybe @OnefinityCNC will have a solution for pin 15 by then :grinning:

Hey Branden,

I don’t see any obvious reason why you couldn’t read the DRV and UPF outputs with the Arduino. I would do this way it if I wanted to use an Arduino for this purpose.

To isolate the problem, I would next ask:

Have you really already connected the whole things, both the input (DRV from VFD) and the outputs (relays for water pumps and dust extraction) to the Arduino?

If so, I would only try and check the input reading in first, i.e. pin 17 that is attached to the DRV pin of VFD, and I would use this only to output a message or have an LED switched on and off depending on the DRV status read out.

So you could check whether the reading in is the problem, or if not, you could then turn to the code which is switching the outputs.

One question: Do you use a self-written program, a finished program from somewhere else, or adapted sketch modules from books and web examples?

Hi Aiph5u,

Yes I have. All outputs are functional at this point (when I tried to use DRV before it actually toggled the water pump and vac on and off a few times before I shut it down. I probably should have shut off those breakers before trying this lol)

I saw the interposing relays toggle on and off which is why I think the input is floating. When I have time I might connect it to an analog input and see what the input is reading in the serial monitor.

The code is self-written however fairly straight forward. I’m pretty confident that it is working properly because when input 17 is connected to L1 it works as intended, however when I connect it to DRV it does not.

If the cause of the issue is that the VFD does not hold the signal constantly to low you will find it this way. You can adapt your code for the input reading loop then.

I would be happy to hear from you what the cause of the issue was.

I’ll make sure to let you know!

Hey Branden,

You are using the Onefinity’s Controller’s Load-1 Output. I just read what rickyacruz wrote:

Hey Aiph5u,

Thanks for the reference! As this is being used as an input to the Arduino the current draw should be negligible. Having said that, I’ve been thinking about switching input 17 to be driven off the VFD again. I’ve been very busy with work and haven’t had much time to play around with it unfortunately. Lots of time to over think it though :sweat_smile:

1 Like

Hey Aiph5u,

I hope all has been well for you.

I ended up using the VFD terminals FB & FC to drive the arduino. This seemed to be the safest solution for controls, although it sucks loosing the potential alarm. In the future I may look into the other outputs however for now I’m going to stick with FB & FC.

Thanks for all your help (and everyone else) in this thread, its greatly appreciated.

1 Like