![]() |
Forum Index : Microcontroller and PC projects : Hall effect transducer interface.
Author | Message | ||||
Paul_L Guru ![]() Joined: 03/03/2016 Location: United StatesPosts: 769 |
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, Paul |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
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: AustraliaPosts: 1329 |
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. |
||||
Paul_L Guru ![]() Joined: 03/03/2016 Location: United StatesPosts: 769 |
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: AustraliaPosts: 6269 |
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: 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 StatesPosts: 769 |
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: Then you repetitively call this.SETPIN N,CIN every_10_seconds: Did you dimension flowN as an integer?flowN = (PIN(N) - flowN) / scalingfactor 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 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.pass 2: flow1 = (1320 - 50)/13.2 = 96 gpm pass 3: flow1 = (1980 - 96)/13.2 = 143 gpm every_10_seconds: ' get flow rate and reset the pin counter to zero I wonder if using PIN(n) as a command like this instead of SETPIN will 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 PIN(15) = 0 Paul_L |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
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. I hope this one makes more sense. Jim VK7JH MMedit |
||||
jeffj Regular Member ![]() Joined: 04/02/2012 Location: AustraliaPosts: 84 |
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 StatesPosts: 769 |
@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. Paul |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |