Sensor Lead Length - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Sensor Lead Length


Best Answer Ernie, 22 March 2013 - 10:46 PM

Using 3 feet of 3 wires of Belden 1700 Cat 5e

Changed pullup setting in code back to original: Port.ResistorMode.Disabled

 

It is working!  Somehow I had by thread start commented out.  Sorry!!!  Don't know how that happened. :blink:

 

 

Here is the flow sensor. 

http://www.seeedstud...nsor-p-635.html

https://www.adafruit.com/products/828

 

Can't seem to find the exact datasheet for the model YF-S201 flow sensor.

Go to the full post


  • Please log in to reply
7 replies to this topic

#1 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 20 March 2013 - 10:42 PM

I have a water flow (pulse) sensor I have been working with directly connected to my N+2, which was working fine.  When I put my project box together and put a 3 foot sensor extension wire in place the sensor no longer works.  What do I need to do when I extend the wire distance between the Netduino and the sensor to get it to work again at a distance?



#2 cutlass

cutlass

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationNew England. :)

Posted 21 March 2013 - 05:49 AM

I saw this post yesterday, but the tab somehow got deleted before I got to it.  Yes, it's Firefox's fault. ;)

 

As the token hardware geek, I think that we can come up with semi-reasonable solution.  Well, that's based on knowing the ability of the n+2 and the framework. :)

 

 

I have a number of questions:

1) Any chance you have a scope or data logger with at least a 1MHZ bandwidth?  How about 10x probes that connect with a BNC connector?

 

2) What are the min/max voltages of the sensor?

 

3) Is it a "steady" analog voltage output?

 

4) Does the output pulse at some rate?  If so, how are you reading it?

 

5) If the output pluses, what is the max rate?

 

6) If the output pluses, do you know the max voltage slew rate?

 

7) Do you know the max drive current from the sensor?

 

8) Do you have a link to the sensor data sheet - with the full electrical specifications?

 

 

 

9) Simple test that "may work" and/or it "may work, but not 100% reliably".

Note: The info I asked above is needed to to a decent "rough pass" termination scheme.  A decent scope and 10x probes are needed to capture and verify the signal integrity for a "not very fast" slew rate signal like I'm guessing the sensor has.

 

9A) Get some 75ohm coax. Like RG-11 or RG-6.
Use the coax to connect the sensor to the N+2.  It's best to use a keep the coax and the shield intact until the signal pin.  For the ground shield, you can connect a short wire from a ground pin to the ground shield.

Of course, use electrical tape around the ground shield and wire to prevent them from shorting with other pins. :)

 

9B ) At the receiving end (the N+2), use an ~75ohm Thevenin termination network.

Example:

Posted Image

 

R1 - connected to 3.3v:

110 ohms

 

R2 - connected to Ground

220 ohms

 

Equivalent termination value:

~73ohms

 

Termination voltage:

~2.2v (biased on purpose more towards the high voltage).

 

Some reference links and info:

Basic thevenin termination equations:

http://www.interface...mination.html#c

 

Equiv Resistance Calculation:

http://www.sengpiela...paralresist.htm

 

Voltage Calculation:

http://hyperphysics....ric/voldiv.html

 

Old, but still valid, basic overview of termination techniques.  Hey, it even uses a 3foot coax as an example. :)

http://www.fairchild...n/AN/AN-610.pdf

 

Coax cables and their characteristic impedances.

http://en.wikipedia....i/Coaxial_cable

 

 

Let me know the answers to the first 8 questions, and if the above suggestion worked.

 

Good Luck!



#3 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 22 March 2013 - 01:27 AM

Electrical:

  • Working Voltage: 5 to 18VDC
  • Max current draw: 15mA @ 5V
  • Working Flow Rate: 1 to 30 Liters/Minute
  • Working Temperature range: -25 to 80°C
  • Working Humidity Range: 35%-80% RH
  • Maximum water pressure: 2.0 MPa
  • Output duty cycle: 50% +-10%
  • Output rise time: 0.04us
  • Output fall time: 0.18us
  • Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
  • Pulses per Liter: 450

Here is my code:

 

// count how many pulses!

public static UInt16 pulses;

 

private static void input_OnInterrupt(uint data1, uint data2, DateTime time)

{
//pulse counter//pulse counter

pulses++;

}

 

private static void MonitorFlow()

{

InterruptPort flowInput = new InterruptPort(Pins.GPIO_PIN_D5, true, Port.ResistorMode.PullUp,

Port.InterruptMode.InterruptEdgeHigh);

 

flowInput.OnInterrupt += new NativeEventHandler(input_OnInterrupt);

 

while (true)

{

pulses = 0;

flowInput.EnableInterrupt();

Thread.Sleep(1000);

flowInput.DisableInterrupt();

flowrate = pulses;

flowrate /= 7.5;

flowrate /= 60;

 

if (flowrate > 0)

{

LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow(":Flow Rate:" + flowrate.ToString("f2") + "LPM"));

Debug.Print("Pulses: " + pulses + ", Flow Rate: " + flowrate.ToString("f2") + "LPM");

}

}

}

 

So what do you think is happening?  Too much resistence on my sensor extension?  Measures .07 ohms on one cable and .03 ohms on a large wire cable.



#4 cutlass

cutlass

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationNew England. :)

Posted 22 March 2013 - 03:18 AM

Electrical:

  • Working Flow Rate: 1 to 30 Liters/Minute
  • Max current draw: 15mA @ 5V
  • Output rise time: 0.04us
  • Output fall time: 0.18us
  • Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
  • Pulses per Liter: 450

So what do you think is happening?  Too much resistence on my sensor extension?  Measures .07 ohms on one cable and .03 ohms on a large wire cable.

 

1) It looks like you're using the N+2 pin a 5v tolerant input digital signal.

 

2) The rise and fall times are "slow".  :) That should make it not too hard to fix.

 

3) I'm not sure I understand the max pulse rate per second.  Is it 7.5*30 == 225?  If so, what does the "pulses per Liter" mean.

 

 

The "DC" resistance of the cable isn't a problem at 3feet and with a 5V 15ma driver.

 

It's the "AC" impedance (the "resistance to a 'change in voltage')) that could be the issue.  The rise and fall times are slow - which is good.  Still, I'm wondering if there's too much over and undershoot on the signal input of the N+2 with the cable.

 

Any time a signal changes value, the AC impedances effect the waveform.

At 3 feet, you have approximately 6-10ns of delay in the signal from the start to the end of the cable.  If the signal rise and fall times were faster than ~10-20ns, then you'd get very noticeable reflections, overshoot, undershoot, ringing - all of the bad stuff.

 

Your signal has a rise time of 40ns and a fall time of 180ns. So, definitely anything past an ~10 foot cable would have to be treated as a transmission line.

 

 

How about the following for a quick and dirty test?

Get some cat3/4/5/6 Ethernet cable, and use that to hook up the signal.  Ethernet cable has an impedance of 100ohms.

The traces on the N+2 PC-board likely have an impedance between ~70 to ~90 ohms.  So, not as good as a 75ohm coax, but better than regular wire, or a ribbon cable.

See if you can get a resistor between 1K to 330 ohms (620ohms if you have your choice).  Connect that between the signal and the ground.

 

 

 

Very roughly, the digital output of the sensor has an impedance of ~5ohms to ~40ohms.

The trace impedance on the PC-board is ~75 ohms. 

The input impedance on the pin on the N+2 is ~1 mega-ohm. 

A single wire has an "infinite" impedance (not really, but we're talking quick and easy to remember).

 

When the output signal goes from the sensor to the input on the N+2, all of those different AC impedances effect the rising and falling edges.

 

With a 3 foot cable, 0-to-5V output, 40ns rise time, I'd guess that the signal would have noticeable overshoot, undershoot, and ringing, but it would still "work".

 

 

You should also guard against too much overshoot on the input signal, and therefore damaging the N+2.

After you do first do the test above, try adding an 10ohm to 33ohm resistor in-line (in series) with the signal.  Put the resistor right at the N+2 connector.  That limits the current from the overshoot.

It also limits the current going into the N+2 input - which then slows the signal's rise/fall times - which may reduce the overshoot and undershoot.

It also effects the overall trace impedance(increases it) between the connector and the N+2  (it'll be the pc-board trace impedance + the resistance). "Basically", the AC impedance of a resistor is the same as the DC resistance of the resistor.

 

 

If you can get/borrow a scope and probes, that would help.  The 40ns rise time is equiv to 25MHz.  You should use a scope and probes that have a bandwidth of ~100+MHz.  You could still use passive 10X probes.  Just make sure they are rated for the needed bandwidth.

 

 

BTW, I did a super quick search on ebay:

I found: (Analog non-storage scope)

Tektronix 2245A Oscilloscope 100MHz 4 Channel with 2 Tek P6133(150MHz) 10X Probes

Buy it now, under $250 with shipping. 

I'm sure there are many other deals and options.

 

BTW, you're not going to get a digital storage scope with the needed bandwidth sampling rate and bandwidth for a low price.

 

 

So, to use the above scope, you'd want a steady flow so that you get a steady/consistent frequency.  You can use your digital camera to take a picture.  Turn off the flash, and use either a small tripod, or some books.



#5 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 22 March 2013 - 06:51 PM

Hi Ernie,

 

Could you post a link to the data sheet for the flow sensor?

 

I see in your code that you have enabled the weak pullup resistor on the GPIO input. "Port.ResistorMode.PullUp"

Is there a reason for that?

I am wondering if your sensor has an open collector output (it switches the signal to ground, but does not pull it up to 5V).

The weak pullup might not work very well over a long cable length.

 

(When posting code it is good to add the code formatting so it looks pretty. Use the <> icon on the editor. It keeps the software people happy.)

 

Paul - one of the many other hardware "geeks"



#6 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 22 March 2013 - 10:46 PM   Best Answer

Using 3 feet of 3 wires of Belden 1700 Cat 5e

Changed pullup setting in code back to original: Port.ResistorMode.Disabled

 

It is working!  Somehow I had by thread start commented out.  Sorry!!!  Don't know how that happened. :blink:

 

 

Here is the flow sensor. 

http://www.seeedstud...nsor-p-635.html

https://www.adafruit.com/products/828

 

Can't seem to find the exact datasheet for the model YF-S201 flow sensor.



#7 cutlass

cutlass

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationNew England. :)

Posted 23 March 2013 - 01:04 AM

Using 3 feet of 3 wires of Belden 1700 Cat 5e

Changed pullup setting in code back to original: Port.ResistorMode.Disabled

 

It is working!  Somehow I had by thread start commented out.  Sorry!!!  Don't know how that happened. :blink:

 

 

Here is the flow sensor. 

http://www.seeedstud...nsor-p-635.html

https://www.adafruit.com/products/828

 

Can't seem to find the exact datasheet for the model YF-S201 flow sensor.

Glad you got it working.

 

BTW, check out the following thread:

http://forums.netdui...ixes-hot-water/

 

Looks like he's using the same/similar sensor and a N+. :)

 

After more thinking, that sensor's data sheet doesn't make much sense.  And, like a lot of the **** sold for Arduino/etc, the "data-sheet" is pathetic.  There's "no such thing" and "this is the rise/fall time" - there's always a range.  Also, falling edges are often faster than rising edges.

 

The very slow falling edge (~180ns) is also a concern unless the input is a Schmitt trigger input.  Hopefully, making the input an interrupt input also makes it an Schmitt trigger input.  The chip-level concern isn't about getting multiple interrupts from an edge, but having the input buffer transistors "in contention" for an extended period of time while the input is in the "undefined" voltage range.

 

 

I see that other flow sensors say they are "open-collector".  So, they would need a pull-up.  I wonder if this sensor also needs an pull-up.  So, IMHO, having a light pull-up (~4.7K, or on chip), is a good idea.

It's also a good idea to put a bypass capacitor near the sensor to help smooth out power noise at the sensor.

 

Good luck, and I'm glad that the sensor is working again!



#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 23 March 2013 - 06:44 PM

Hi again,

 

Glad to hear its working.

 

I followed your first link, it has a link to a Wiki page where it shows connection of your flow sensor to an Arduino.

As cutlass says, it is open collector, so it requires a pullup resistor (10K ohm).

It is best to connect this otherwise you may find the operation is not reliable.

(Open collector is where the sensor will pull the output low to ground when energised, but just leave it unconnected at other times.)

 

The internal weak pullup (inside the Netduino) should allow you to save a resistor here, but I suspect that the longer lead length posed a problem.

 

If you continue to have issues I would recommend using a 74HCxxx family logic gate to act as a buffer. (You could use any device you have to hand AND/OR/XOR/NAND/NOR.) The gate should be placed next to the sensor (with 10K pullup), it can then be used to square up the signal and drive the cable back to the Netduino with Vcc or Gnd, rather than just open or Gnd as the sensor currently does.

 

(The 15ma in the specification list is the current that the Hall effect sensor takes when it is supplied by 5V - not the amount of current the sensor can drive on its output.)

 

Have fun - Paul






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.