Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Stefano Prato on October 11, 2020, 06:44:54 AM

Title: Square wave input in Mach3
Post by: Stefano Prato on October 11, 2020, 06:44:54 AM
Hello,

I would like to add a flow measurement tool to my system to measure the flow of water in the spindle watercooling circuit. Probably this is not very useful but I still would like to do it just to get confidence with the input management of Mach3. These flowmeters output a square wave signal, the frequency is a function of the measured flow(liters/min). So to get the flow I should get the pulse frequency and then write a code that convert it by using a constant that depends on the various models of flowmeter.
It is not clear to me (I'm a new user) how to manage this kind of input. All the inputs in "ports and pins" seem to be intended as some sort of switch more than a measuring input and also I don't think this kind of instrument should be treated as an encoder (also noticed that encoder inputs are very limited in Mach3).
I searched for programming macros that can read a pulse frequency but I haven't found any and I don't know if running a while cycle to count pulses can be ok.

I'm using smoothstepper with an MB3 BoB.

Thanks.

Title: Re: Square wave input in Mach3
Post by: Tweakie.CNC on October 11, 2020, 07:25:09 AM
Sounds like a fun project.
It may be a lot easier to make your Flow Meter a ‘Stand-Alone’ unit using a PLC or Arduino or similar to measure the pulse rate then drive a separate digital readout display. You could then have an alarm signal output which would Estop Mach3 and turn off the spindle if the flow rate went below a certain value.

I use a water flow sensor and temperature sensor with my laser, I am not really interested in the actual flow rate as if the flow stops it operates the Mach3 Estop and if the water temp. exceeds a pre-set limit again it operates Estop.
I don’t have to visually monitor anything as the system will operate automatically and over the last 11 Years it has behaved perfectly.

Tweakie.
Title: Re: Square wave input in Mach3
Post by: Stefano Prato on October 11, 2020, 07:57:39 AM
Maybe I can use and Arduino to read the pulse frequency and then transmit a byte,that rappresent the flow, every x second to smoothstepper and use the getByte macro to read it. This way I should be able to have everything inside mach3 (not because I need it or I think is better this way, is just a sort of experiment).
Title: Re: Square wave input in Mach3
Post by: Tweakie.CNC on October 11, 2020, 08:31:33 AM
A bit further down the line… the Smooth Stepper 2 has some analogue inputs which would allow your square wave signal to use a simple digital to analogue conversion to easily get the flow rate data into a Mach3 DRO.
It may be possible to do something similar with the current ESS using, as you suggest, a single byte every x seconds but I have no idea how to go about it. However, there are others much more knowledgeable then me and hopefully they may be able to suggest a way.

Tweakie.