Author Topic: Flow Meter Integration  (Read 79842 times)

Fitzsimmons Hydraulics

  • Guest
Flow Meter Integration
« on: October 09, 2014, 08:50:44 PM »
I am trying to interpret a flow meter signal with a micro controller. The pulse rate/gallon is known.

I have written some code for this application, but its not picking up the signal. I have wired one side of the flowmeter to the micro input. The other wire is grounded.

Can anyone share their experiences with incorporating flow meters into the Plus+1 environment?

I have included a snapshot of what I am doing with the frequency signals. pinconfig0=0, pinconfig1=0 for both inputs. The service tool can't seem to pick up the frequency. Any suggestions?

Offline BRIan

  • PLUS+1 Expert
  • ****
  • Posts: 60
  • Karma: +3/-0
Re: Flow Meter Integration
« Reply #1 on: October 09, 2014, 11:15:37 PM »
I assume you are not getting a Freq when you check with the service tool. This may be due to NPN output rather than PNP. Just change the PinConfig on the input and recheck.

Offline Jakob

  • PLUS+1 Expert
  • ****
  • Posts: 98
  • Karma: +2/-0
Re: Flow Meter Integration
« Reply #2 on: October 10, 2014, 08:16:16 AM »
Good point BRIan.

If you do see the frequency on the input pin, but nothing comes out to you CAN-data.
I suspect the value is lost due to being multiplied with 0,00112485, and then multiplied with 60 rather than just dividing the input with around 14.

Fitzsimmons Hydraulics

  • Guest
Re: Flow Meter Integration
« Reply #3 on: October 10, 2014, 04:19:21 PM »
BRIan, I will have to try it out today. Just wanted to make sure my wiring logic was correct. There doesn't seem to be a specific polarity to either pin.

Jakob, I have run into this before with a SDT sensor and temperature output. Assuming I can get the input fixed and the signal reaches the mathematical logic, and my code creates trouble, would it be better to just use a scale function?

Offline oiltronic

  • PLUS+1 Guru
  • *****
  • Posts: 170
  • Karma: +15/-0
Re: Flow Meter Integration
« Reply #4 on: October 10, 2014, 04:54:13 PM »
Left side of the oil flowmeter code shows 1 divided by 216.  Plus+1 is all integer math, so the result is zero, which will result in zero gallons coming out of the next multiplication.

Left side of the glycol flowmeter code shows 889005 divided by 1000, which is just 889, no decimal point due to integer math.  If you want high accuracy you'll need to make it u32 and work with milli-gallons (i.e. gallonsx1000, fixed-point integer math), then save that division for later, like before it's shown on a screen (when you create two separate numbers for the values for before & after the decimal).

For math like a gpm flow rate you might want to switch all the math to u32, multiply by 60 and by your conversion rate first, and divide by 1000 or whatever scaling factor last, before changing back to desired data size.  Otherwise your gpm will always be some multiple of 60 (0, 60, 120, etc).

What is your expected frequency?  I see you're using the IO bus, meaning the signal is coming from a remote I/O unit, correct?  Which one?  Check the hardware spec for the frequency and period limitations for that particular pin.  I had a particularly slow pulse where I ended up using the period input instead, and really slow ones used my own direct period measurement.

To test just the signal I have forced some speed sensors and paddle wheels to the on-state and looked for the signal with the service tool.  At least one has required a goofy external pull-up resistor (internal microcontroller one was too weak).

Fitzsimmons Hydraulics

  • Guest
Re: Flow Meter Integration
« Reply #5 on: October 10, 2014, 09:51:56 PM »
Oiltronic, I am using an IX024-010. Thanks for the suggestion - I try not to mess with scale blocks if I don't have to. I have enclosed a new image of the logic. The oil flowmeter pulse is 216 per gallon, which corresponds to the meter currently installed. The note tells the pulse count of our new meter (which will be installed as soon as I can get a signal from the old one), so just disregard the pulse count of 329.

Problem is that I still can't get the service tool to read a frequency. I have tried changing pinconfig0 to all options - nothing for any of them. I tested AC voltage across the 2 wires and it read about .075. This proportionally increased/decreased with the flow, and even the microcontroller picks up a small voltage value of 5 on C2p04. In light of that, I have changed pinconfig1 from 0 to 1 for low voltage. I will have to test the rest of the combinations Monday - still kind of stumped. At least now I think the signal will be interpreted and transmitted when it does register.

Looks like the controller can handle up to 32000hz so I don't think that's the issue. I'm beginning to think its my wiring. I've been using alligator clips to flip which meter pin goes to the input, doing so for each new configuration just to be sure. One signal to micro input and the other to 5v sensor ground (on a terminal coming from the MC024-010 that the IX is used with). I think this could be an issue (despite CAN) - I will try again with the 5v coming from the IX. Thank you all for the tips.

Offline BRIan

  • PLUS+1 Expert
  • ****
  • Posts: 60
  • Karma: +3/-0
Re: Flow Meter Integration
« Reply #6 on: October 12, 2014, 11:00:58 PM »
I don't recall any controller being able to handle anything like 32kHz. The datasheet says 10kHz max.

Offline Jakob

  • PLUS+1 Expert
  • ****
  • Posts: 98
  • Karma: +2/-0
Re: Flow Meter Integration
« Reply #7 on: October 13, 2014, 10:17:51 AM »
For the IX module it does actually does say, range 0 – 35300 Hz.
Is this really correct ?
I'm finding it hard to believe, because the Controllers only range 0-10000 Hz.

Thomas

  • Guest
Re: Flow Meter Integration
« Reply #8 on: October 13, 2014, 10:58:28 AM »
Hi Jakob!

I was also surprised so I had to check myself. Attached is the data sheet from our website.
http://www.plus1forum.danfoss.com/index.php?action=profile;u=342

I am not sure if you did find it in an older version of the data sheet.

Hope this helps // Thomas

Offline Jakob

  • PLUS+1 Expert
  • ****
  • Posts: 98
  • Karma: +2/-0
Re: Flow Meter Integration
« Reply #9 on: October 13, 2014, 11:49:26 AM »
Hi Thomas

I was looking in the PLUS+1 Compliant IX024-010 Function Block User Manual from 2009, so in the datasheet (http://files.danfoss.com/documents/520l0711.pdf) it does say 0-10 kHz.

Fitzsimmons Hydraulics

  • Guest
Re: Flow Meter Integration
« Reply #10 on: October 13, 2014, 08:40:23 PM »
I'm seeing on my data sheet 10kHz as well. I've since been able to get the flowmeter working. It was a grounding issue. Now I've grounded the flowmeter to the IX and it's seeing a frequency and outputting a flow value to the display.

We hooked up a 90 series pump and the display was showing max flow. (35gpm, I believe 55cc) The service took freq signal value reads about 120-130 and flutters around 31-36 gpm as a result. I assume this means 120-130Hz. Problem now is, when we destroke the pump the flow value reads 0. Service tool reads 0 for freq as well, so I don't think there's an error in calculations. The pump is not in neutral when this happens - it is still flowing, the signal is simply zeroed out once the frequency signal crosses some lower threshold. I have tried some different pin configurations and the only one that accepts the signal is pinconfig0=2 pinconfig1=1 for pull down and low range voltage.

If I had to guess, this must be what oiltronic was talking about. Frequencies which would be lower than 60hz don't appear to be registering. I will try to use the period input instead. Thanks all for the input, back to the test bench for now!

Offline BRIan

  • PLUS+1 Expert
  • ****
  • Posts: 60
  • Karma: +3/-0
Re: Flow Meter Integration
« Reply #11 on: October 14, 2014, 01:41:46 AM »
It will measure lower frequencies than 60 Hz (provided the sensor output doesn't also drop too low).
The problem is the FREQ signal is an Integer and therefore is limited in it's resolution.
As a norm when the pulses per rev or the rpm are low, I use the PER signal and as long as you are careful with maths you can get perfectly adequate accuracy.

Offline Neil

  • PLUS+1 Expert
  • ****
  • Posts: 96
  • Karma: +2/-0
Re: Flow Meter Integration
« Reply #12 on: October 20, 2014, 10:13:20 PM »
Hi Guys,

I'm coming in late on this one, have you checked the voltage at the pin and change .PinConfig1: to suit the voltage range?

regards Neil

Fitzsimmons Hydraulics

  • Guest
Re: Flow Meter Integration
« Reply #13 on: October 20, 2014, 10:21:28 PM »
Yes, its a low voltage signal. It's picking up the signal now. I changed my program from using the freq to using per, and it works just like freq did. High flow pumps are ok, and are pretty accurate, but for some reason low flow just doesn't register. I'm going to do more testing and come back to this at a later date. I think it's possible now that the internal calculations are going out of range, even with a U32. What happens when a value goes out of range, anyways? Does it drop out to zero, or does it stick at the max bit value?

Offline oiltronic

  • PLUS+1 Guru
  • *****
  • Posts: 170
  • Karma: +15/-0
Re: Flow Meter Integration
« Reply #14 on: October 21, 2014, 12:20:40 AM »
"Out of range" integer calculations typically overflow and wrap around again, or in other words the result of the calculation is clipped to the number of bits at the output.  It helps to understand binary, or how microprocessors do arithmetic.

If there's ever a risk of overflow, despite what the "normal" operating conditions should be,  always use the "capped" version of the arithmetic operator which limits the output to the highest value of the data type.