Hall effect sensor, water flow indicator alarm

Hello guys! Im currently building a CNC router that uses a water cooled spindle, and I've got a 3D printer and are making a flow indicator with a magnet attached to one of the fins of the indicator and outside the housing is a Hall effect sensor attached,

So my plan is to use that flow indicator with an Hall effect sensor to get a pulsed (pwm signal) as an input to the arduino,

And I want the arduino to react to when/if the flow stops to sound a alarm,

So the arduino needs to detect the pwm signal from the hall sensor and when the flow stops and it gets constant low/high to sound a alarm,

The arduino will output a pwm signal to a piezo so that I can hear it instead of being forced to look for continuous flow.

And as you guys may understand that I'm not to good at arduino programming yet.
I'm kinda new to all electronics and programming
And that my English isn't the best and are hoping that you understand what I mean :wink:

I would really appreciate some help :slight_smile:

The sensor is a eBay bought sensor with an LM393 IC and got 4 connections DO VCC GND AO

Digital output / 5v / GNG / Analog output

And the arduino is an Arduino uno (atmega 328P)
Which doesn't make to big difference,

I'm planning to later on, etch a board and make a standalone arduino board.

With hopes of not get to much noise interference from the 400hz spindle? It may or may not be possible to use an arduino so close to the machine?

Otherwise? Is there anyone that have any other idea? Using 555 timers or any other IC's to get the Same function?

The sensor is a eBay bought sensor with an LM393 IC and got 4 connections DO VCC GND AO

Post a link to the sensor (NOT the stupid EBAY link).

Reading a hall effect sensor is relatively easy. Having the sensor trigger an interrupt is another possibility.

Deciding what "when the flow stops" means is a different story. You'll need to keep track of when you get a signal, and decide how long between signals means that the flow has stopped (or dropped to too low a rate).

I also got individual Hall effect sensors, 44E's and 3144's

There is no good link for the China crap sensor that I've bought, which i did for a long time ago,

But the idea is to read the pwm input, and monitor it to a certain pulse width?

Let's say that we have a normal pulse of about 10hz? When it's at its top of flow.

And if it then drops below ~5hz then it will trigger a pulsed output to a piezo? And maybe trigger a ssr relay with some lights? or a mosfet?

I have no idea how fast it will spin,

found a schematic for the Hall sensor module.

But the idea is to read the pwm input

Why do you assume that you will get a PWM output from the sensor? Hall effect sensors typically output a pulse when there is a magnet nearby, and nothing if there is no magnet near. That sounds like a digital output to me.

Let's say that we have a normal pulse of about 10hz?

Is that a question? Or is it a statement?

Suppose you do get 10 pulses per second. That means that the pulses are 100 milliseconds apart. Any interval between pulses that exceeds 200 milliseconds would then indicate that the flow rate had dropped to half.

If the hall effect sensor triggers an interrupt on the RISING edge, then the ISR could record when the interrupt happened (using millis()). loop() could then compare now (obtained using millis()) vs. then (the time that the last interrupt happened). if the difference is greater than 200, then the flow rate has dropped by half.

The first step, obviously, is to determine exactly what you get from the sensor/circuit you have. Then, you can determine how to use the data.

It's just a statment, i don't actually know the real rpms/pulses but i'm on my way to figure that out :slight_smile:

I don't think the rotation is going to be continuous, there is some friction going on, and there isn't a totally perfect fit, the paddle wheel will have some clearance between the walls,

It's pretty hard to really get a linear value, especially from a 3D printed part with no bearings,

I think I'll need to get a code that looks into a wider spectrum?

Let's say that in running condition it's rotating from 10-50 RPMs and then when it decides to stop pumping? Or if any air pockets stops the pump from moving the liquid? The rotation will stop?

Then the sensor will detect that there isn't anything going on and It will sound the alarm?

The only problem is that in some rare cases the magnet maybe stops in the right spot to trigger the hall sensor?

Let's say that the sensor detection zone is 45°

Out of 360° then there is 1 to 8 chance that it will stop in the right spot to trigger the sensor?

So the code also needs a line that's trigger the piezo pwm output if it's a solid high or low,

It depends on what the sensor gives out?

It should be possible to write a code that is universal?

So that the only thing needed is to change the threshold/spectrum value? Let's say active pulse span? Or when the off state is called?

I don't think it's needed to do it by math? Or in any kind of precision?

There will not be any value to actually read?
for an LCD or the serial monitor?

Do you understand what I mean?

The only problem is that in some rare cases the magnet maybe stops in the right spot to trigger the hall sensor?

Why is that a problem? The sensor will change state when the magnet comes near, and will change state when the magnet moves away. if the magnet never comes, or it the magnet never goes away, there will be no change in state, and the time that the state last changed will get older and older. At some point, it will be old enough that you can scream for help.

Out of 360° then there is 1 to 8 chance that it will stop in the right spot to trigger the sensor?

Maybe it's one in 14. You are the one with the hardware. Don't ask us questions about hardware we can't see.

So the code also needs a line that's trigger the piezo pwm output if it's a solid high or low,

If what is a solid high or low? See the comments under the first quote. It is the age of the last change that is important, NOT anything about the current state.

It depends on what the sensor gives out?

Of course it does.

It should be possible to write a code that is universal?

No. If you change sensors, to something that is more intelligent (does some of the work for you), you would want to take advantage of that intelligence.

I don't think it's needed to do it by math?

The age of a change is now minus then. Oops, that involves math... Good thing that the Arduino is REALLY good at math.

Or in any kind of precision?

Well, in that case, don't bother reading the sensor. Just call random() to determine whether to sound the alarm.

There will not be any value to actually read?

Of course there will be.

for an LCD or the serial monitor?

You won't be reading values from either of them to determine if the pump is still running.

Do you understand what I mean?

I thought I did. Now, I'm not sure.

Have you written ANY code to try to get anything from the sensor?

a bit of missunderstanding, or maybe not, it could be the way im explaining! you are the one that knows! I'm the one who's trying to learn :slight_smile:

And my English might be a little bit of a problem!

I've got a 3D printed paddle wheel, cased in a body that lets the water pass trough, and when the water goes trough, it spins the paddle wheel right?

On the paddle wheel is a magnet attached to one paddle/fin.

On the backside off the whole assembly is the sensor

I've measured the pulses, and it's roughly around ~16Hz

And by that ~16Hz it is without any restrictions in the system,

only pump / hose/ sensor / hose

Later on when it will be a massive restriction in the system, due to hose ID change, radiators and so on,

so the value that i have isn't worth that much,

And I'm sorry for not thinking straight, you have absolutely no idea what hardware I've got.

But I'm really starting to think about using a code that's already out there, somewhere.. that use temperature reading instead of flow.

Or I could to try learn by my own and figure something out!

And my English might be a little bit of a problem!

OK. I'll stop picking on your question vs. statement issues.

I've got a 3D printed paddle wheel, cased in a body that lets the water pass trough, and when the water goes trough, it spins the paddle wheel right?

OK.

I've measured the pulses, and it's roughly around ~16Hz

Using the Arduino? How is the sensor connected to the Arduino? What does the code look like?

If you ARE reading data using the Arduino, then you can know that the state of the sensor changes, and when that happened. So, put the code to read the sensor, and record when the state change (to magnet no longer here or to magnet just arrived, but not both) happens (using millis()).

Then, call that function from loop(). Independently, check the current time (using millis()), and compare the current time to the last state change time (that the function recorded). If the last state change detection time is too old, sound the alarm.

Ohh damn! I should not lie to you! But my knowledge about arduino programming is really not much,

I haven't learnt the basics good enough yet, all the statements, symbols and so on,

I've really tried learning, and barely started to understand, but it was like 2 years ago, everything I've learnt is pretty much gone..

the sensor should give out a pwm signal? Between AO/DO and Gnd?

There is a schematic erlier in the thread on the sensor board, and also some pictures on the sensor unit itself, imgur link,

The sensor board gives out a high signal (+5V) when the magnet triggers the hall sensor,

So the arduino will get a pulsed 5v signal?

I want the thingy to work pretty much as a switch, that reacts to the water flow

But with opposite function?

Read the pwm signal, and sound the alarm when the input pwm signal get below a certain set point?

But then the problem comes?

If the magnet stops at the location that the hall sensor is? Then it will trigger and be a constant a high/low signal?

High which the sensor puts out

Hall sensor module using M44 switch
With comparator regulating Hall signal
AO, real-time Hall signal output
DO, steadier Hall signal output
Comparator Output Current: 16mA

So the arduino will get a pulsed 5v signal?

Yes. You can then read that using digitalRead(), or you can connect the 5V signal to an external interrupt pin, and attach an interrupt handler to that pin.

But then the problem comes?

If the magnet stops at the location that the hall sensor is? Then it will trigger and be a constant a high/low signal?

High which the sensor puts out

You are concerned with something which is not a problem.

Your sketch will be counting pulses, looking for a pin changing from low to high. You can do this with an interrupt or digitalRead(). If the sensor gives a constant high output is the same effect as a constant low output. There are no changes taking place, and the flow will be determined to be zero.

I finally start to understand a little bit!
But write the code will be impossible for a guy with a brain like me, or knowledge.

I'm seriously considering to start learning for real, it's much to read/learn and take some time,

I understand what you mean with counting pulses! But not how to start write code, or how to continue writing?

It's like writing a text in Chinese or Russian, I don't understand... :frowning:

But not how to start write code

You start with JUST reading, and printing, the state of the sensor, as fast as possible. If you see that the state does indeed change as the magnet approaches and leaves, then you look at the state change detecting example to print a message only when the state changes.

Then, you expand on that to note when the state changed. Then, you expand on that to print a message when the state has not changed in a while.

You do all this testing turning the device slowly, by hand.

When it is working the way that you think it should, then you test with the real setup. When you get the "no change has occurred for xxx milliseconds" message appearing properly, with the real setup, then you can replace printing the message with sounding the alarm.

One does not build a house by having all the materials, the furniture, the plumbers, the electricians, the framers, the foundation guys, the roofers, the insulation guys, etc. all arrive at the same time, and expect anything but mass confusion and wasted time and effort.

One build a house by creating a foundation, and adding one wall at a time. One builds the wall one stud (or brick) at a time.

Programming is no different. You seem afraid to get started because the materials, the furniture, the plumbers, the electricians, the framers, the foundation guys, the roofers, the insulation guys, etc. all arrived at the same time. Ignore most of them. Get the foundation in first.

In a project I worked on, I needed to set an alarm if the rotation of a component stopped. I think this is what you would like to do. The method I used was to mark the time (millis) whenever the reed switch I used closed. If the switch did not close again within a set time, the alarm was set. The snippet below is what I believe is what I used to accomplish that. Perhaps you can use the same method.

if(digitalRead(switch_pin) == LOW){
    alarm_millis = millis();
    digitalWrite(switch_led, HIGH);
    }
  else{
    digitalWrite(switch_led, LOW);
  }
  
  if ((millis() - alarm_millis) >=10000){
  digitalWrite(alarm_pin, HIGH);
  }

As far as making your own standalone Arduino board, I did that a couple of times until I realized it's so much more convenient, easier and perhaps even cheaper to embed a cheap Nano into a printed circuit board and go from there.

P.S. I'm working on my Z axis. I'd like to see your project. Please PM me.

  • Scotty