Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:27 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Hall effect transducer interface.

Author Message
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 05:52pm 08 Oct 2016
Copy link to clipboard 
Print this post

Has anyone played around with interfacing a Hall effect water flow transducer to a uM+ chip using MMBasic?

The sensor I'm thinking of using is the Sea YF-DN40 which is sized for 1.5 inch pipe and produces 50% duty cycle pulses at the rate of 1.32 Hz / gpm for flows from 2 gpm to 39 gpm. In other words Q (gpm) = f (Hz) * .757575.

Thanks,
PaulEdited by Paul_L 2016-10-10
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 09:23pm 08 Oct 2016
Copy link to clipboard 
Print this post

I use 4 to monitor my water systems.
Mine work with 5V and have open collector outputs. I use a pullup resistor on the output and connect them to the counting inputs of the uMite.

The ones you are looking at appear similar.

Jim

VK7JH
MMedit
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 09:47pm 08 Oct 2016
Copy link to clipboard 
Print this post

I've no experience with them Paul but since that's quite a low frequency (1Hz or less, up to around 50Hz), you're probably best to just use the appropriate version of the SETPIN command (pp 69&70 of the Manual) along with the PIN function (p70). The PULSEIN function is a bad choice because it holds up the program for too long at low frequency.

Greg

Edit - you beat me to it Jim.Edited by paceman 2016-10-10
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 07:45pm 09 Oct 2016
Copy link to clipboard 
Print this post

Thanks Jim and Greg.

So I should first say
SETPIN ##,PIN [,1]

then the period in milliseconds will be returned by
ppp = PIN(##)

And the only pins I can use for this will be
28 pin = 15, 16, 17 & 18
44 pin = 1, 42, 43 & 44
E64 = 23, 49, 51 & 52
E100 = 34, 76, 78 & 81

Have I got that straight????

Paul
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 08:39pm 09 Oct 2016
Copy link to clipboard 
Print this post

If you use period, you will have problems with program hanging if there are no pulses.
I prefer counting over 10 seconds for water flow readings but one second or one minute etc would do also.

On a 28 pin uMite:
  Quote  
setup_ports:
FOR n = 15 TO 18
SETPIN n,CIN
NEXT n
RETURN

every_10_seconds:
' count over suitable period and scale to give litres/minute
flow1 = (PIN(15) - flow1)/scalingfactor
flow2 = (
PIN(16) - flow2)/scalingfactor
flow3 = (
PIN(17) - flow3)/scalingfactor
flow4 = (
PIN(18) - flow4)/scalingfactor
RETURN


I started counting water this way in 2011 and only stopped when the Maximite was destroyed by lightning earlier this year.
I have to get the replacement running before summer.

Jim

VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 02:02pm 10 Oct 2016
Copy link to clipboard 
Print this post

Jim, you are correct when you say that if you use period the program will hang if there are no pulses. Your 2011 solution looks elegant, but it confuses me. I'm not sure what you do to flowN between your repetitive calls to every_10_seconds.

This starts the counting of pulse edges from zero on pin N.
setup_ports:
SETPIN N,CIN
Then you repetitively call this.
every_10_seconds:
flowN = (PIN(N) - flowN) / scalingfactor
Did you dimension flowN as an integer?

PIN(n) returns cumulative total of pulses received from the sensor since the counter was started from zero by the SETPIN command above. Does PIN(n) return an integer?

When will PIN(n) overflow if it counts at the maximum rate of 50 Hz?

Assuming that a flow of 50 gpm produces a 66 Hz output then in 10 seconds the sensor will count 660 pulses, in 20 seconds 1320 pulses, in 30 seconds 1980 pulses. When you calculate flow1 you will get
pass 1: flow1 = ( 660 - 0)/13.2 = 50 gpm
pass 2: flow1 = (1320 - 50)/13.2 = 96 gpm
pass 3: flow1 = (1980 - 96)/13.2 = 143 gpm
I'm not sure but I think you would have to reset the cumulative count for each pin to zero after you read it each time.
every_10_seconds: ' get flow rate and reset the pin counter to zero
flow1 = PIN(15)/13.2 : SETPIN 15,CIN
flow2 = PIN(16)/13.2 : SETPIN 16,CIN
flow3 = PIN(17)/13.2 : SETPIN 17,CIN
flow4 = PIN(18)/13.2 : SETPIN 18,CIN
RETURN
I wonder if using PIN(n) as a command like this instead of SETPIN will reset the pin counter to zero?
PIN(15) = 0
Paul_LEdited by Paul_L 2016-10-12
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 06:11pm 10 Oct 2016
Copy link to clipboard 
Print this post

Sorry about the last bit of code Paul.
I tried to modify bits of my program without too much thought.

This alternative program reads 4 flow meters and two distance modules. The distance modules are mounted above my water tanks and give the water level.

The program prints out the flow and storage ever 30 seconds.
All variables are floating point as this program was also started before integers were available.
  Quote  
' PumpHouse
' Feb 2015
SETPIN 15, CIN
SETPIN 16, CIN
SETPIN 17, CIN
SETPIN 18, CIN

SETTICK 29995, doread ' read every 30 seconds (adjusted for clock error)

doread
DO
k$=
INKEY$
IF k$<>"" THEN doKey
LOOP

END

SUB doKey
DO
k$=
INKEY$
LOOP UNTIL k$=""
PAUSE 100
DoHeader
Doread
END SUB

SUB Doread
oldL1=L1
oldL2=L2
oldL3=L3
oldL4=l4
flow1=
PIN(15)
flow2=
PIN(16)
flow3=
PIN(17)
flow4=
PIN(18)
L1=scale(flow1)
' garden accumulated volume pumped since a reset.
L2=scale(flow2)' padock
L3=scale(flow3)' bore pump
L4=scale(flow4)' house water
Rate1=(L1-oldL1)* 2 ' flow rate in litres per min
Rate2=(L2-oldL2)* 2
Rate3=(L3-oldL3)*
2
Rate4=(L4-oldL4)*
2
range1 =
DISTANCE(26,25)' house tank, full = ~25.0
vol1 = (227 - range1)*94
PAUSE 100
range2 =
DISTANCE(26,24)' garden tank, full = 29.0
vol2 = (260 - range2)*80
PRINT TIME$+","+STR$(range1,4,1," ")+","+STR$(range2,4,1," ")+","+STR$(vol1,6,0," ")+","+STR$(vol2,6,0," ")+",";
PRINT STR$(L1,8,0," ")+","+STR$(L2,8,0," ")+","+STR$(L3,8,0," ")+","+STR$(L4,8,0," ");
PRINT ","+STR$(Rate1,3,1," ")+","+STR$(Rate2,3,1," ")+","+STR$(Rate3,3,1," ")+","+STR$(Rate4,3,1," ")
'PRINT
END SUB
' end

SUB DoHeader
PRINT "Time House Gdn House Gdn Gdn Stock Bore House"
END SUB

FUNCTION scale(raw)
scale = raw/
330
DO WHILE scale > 1000000 ' keep the value within the floating point range
scale = scale - 1000000
loop
end function


I hope this one makes more sense.

Jim

VK7JH
MMedit
 
jeffj
Regular Member

Joined: 04/02/2012
Location: Australia
Posts: 84
Posted: 06:56pm 10 Oct 2016
Copy link to clipboard 
Print this post

Cheap as chips Proximity switch

I have been using a hall effect transducer for a year or two in my hydroponic NFT system. Recently it failed.
There is a handy hall effect transducer in computer fans . These are latching types, so need 2 magnets to operate.
The one In my fan used a AH276
I was removing one of these but gave it a test prior to removing it.
To my surprise it worked just like a proximity switch < 35 mm On > 35 mm Off.
So instead of extracting it I used the pcb and stator complete for my flow detector.
From memory the pcb is about 35mm in dia
It works ok at 5 volts . The output was 4v on 0v off.

For those interested I have what I call a nodder It is a tube open at the top balanced so it tips when a set volume fills it . A rare earth magnet detects the tip and sends a signal to the Mmite 40 ml /dip 260ml /min. They are a bit tricky to get to work properly .I can make a sketch if anyone is interested
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 08:08pm 12 Oct 2016
Copy link to clipboard 
Print this post

@jeffj - Your nodder sounds like a really cute idea! Do you by any chance have a cat? It sounds like something a cat would find very intriguing.

@Jim - That code makes a good bit more sense than the first bit! As Robert McCluskey said, "I know that you believe you understand what you think I said, but I'm not sure you realize that what you heard is not what I meant".

I need to measure the flow volume in a 2 inch HDPE pipe in order to determine the amount of heat being moved by my freon heat pump.

I wonder if the SETPIN ##,CIN command establishes a hidden interrupt routine which allows other code to run until the pin goes high? It would seem to require an interrupt routine otherwise everything would just stop as soon as the command was issued because the program would be looking for something to count.

PaulEdited by Paul_L 2016-10-14
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 08:23pm 12 Oct 2016
Copy link to clipboard 
Print this post

SETPIN x, CIN starts a background counting routine.
You then decide how often you want to read the value.
If you want to reset the counter, issue SETPIN x, CIN again (after reading the counter).

The advantage of the counting function is, no count doesn't cause any problems and you don't have to write special code to cater for a zero reading.

My flow meters are 3/4 inch (20mm) and put out about 330 pulses per litre.

I take a reading every 30 seconds, divide by 330 to get litres and then multiply by 2 to get litres/minute.

The first flow meters I used only lasted a couple of years but the new replacements (cheap ebay) look like doing better.

By monitoring the flow from thew bore, I can tell how low the water table is.
I can also tell how much water the BOSS uses in the shower but I am not game to tell her that!

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025