Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:03 01 Aug 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 : Water pressure sensory setup

Author Message
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 07:45am 08 Aug 2020
Copy link to clipboard 
Print this post

Hi all,

Let me start by saying this is the first time I have attempted to read voltages with an MM 28 pin.

I have two water pressure sensors  from Core electronics.

I am trying to monitor the water pressure of our stock watering system. I also would like to estimate when the pump switches on from the change in pressure.
A direct connection of the signal wire to an analogue pin seems to work BUT there are some data points which seem wrong.

What is the best way to connect up the sensors? I have read the section on analogue inputs (page 38 of MM manual) and am wondering if I can monitor analogue voltage pin.

All comments welcome.
Rob White
 
mikeb

Senior Member

Joined: 10/04/2016
Location: Australia
Posts: 174
Posted: 08:44am 08 Aug 2020
Copy link to clipboard 
Print this post

Hi Rob,
The analogue input has an upper limit 3V3.
As your pressure transducer has a max output of 5V0 @ 1600 kPa you will need to use a voltage divider to limit your signal range to this upper level.
The following circuit will do this -





Regards,
Mike B.
There are 10 kinds of people in the world.
Those that understand binary and those that don't.
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 10:04am 08 Aug 2020
Copy link to clipboard 
Print this post

Thanks Mikeb,
I will implement that tomorrow. I thought I would be OK as the max pressure of the watering system is only 400kPa
Rob White
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 01:46am 18 Aug 2020
Copy link to clipboard 
Print this post

Hi Rob,
Have had similar problem. 3 things may help:-
1 Filter input. If the voltage will never go above 3.3V use same circuit as above but leave out 8.2k and pot, increase cap to 1ouF.
2 Filter Analogue Power. For 28 pin MM add 10 ohm between +3.3V supply and Pin 28 and 10uF from pin 28 to 27 (gnd).
3 Sample the input many times and take the average.
eg.
SETPIN 2, AIN
DO
Asum = 0
FOR N=1 TO 1000
Asum = Asum + PIN(2)
NEXT
Aaverage = Asum * 0.001
PRINT Aaverage
PAUSE 1000
LOOP

Phil
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 03:06am 18 Aug 2020
Copy link to clipboard 
Print this post

PS. One I forgot.
4. The sensor ground wire should go directly  to pin 27 (An Gnd). Make sure there are no other paths to ground.
Phil
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 07:27am 18 Aug 2020
Copy link to clipboard 
Print this post

Thanks Phil,
Will make some changes. It seems to be doing the job.
Rob White
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 09:50am 18 Aug 2020
Copy link to clipboard 
Print this post

just as an aside.

I am a bit anal about the potential for voltages to exceed specs on pins so I always clamp to VCC with a schottkey diode just in case. They are pennies and if they are never needed, be happy. Better to have and not need than a dead processor.

In this example I am monitoring a 24V DC power line with a /10 divider... this could potentially exceed the 3.3V - admittedly if it does I probably have bigger problems but even so you get the idea.



Also, Phil's recommendation above about averaging over several samples will stop "surging" in value readings. I have a single function to read an analogue pin of my choice (this application has two AINs) and provide this averaging:


'Get 24V
 V24=IVSense(VSense)*10.18' calibrated *10 for divider
 
'Get drive current
 ILoad=(IVSense(ISense)-ICal)*10
 Iload=Max(0,Iload)' remove spurious negatives


'average a voltage reading for I or V
 Function IVSense(p As Integer) As Float
   Local Float x, n
   for n=1 to 25
     x=x+Pin(p)
   next
   IVSense=(x/25)
 End Function


I average over 25 samples. I did test this and it seemed that any more than 20 didn't make much difference, so 25 gives a nice extra margin of stability, but ymmv.

h
Edited 2020-08-18 23:26 by CaptainBoing
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 581
Posted: 11:47am 19 Aug 2020
Copy link to clipboard 
Print this post

The  A/D converter on the pic170  gives excellent results, if the software and hardware used give it half a chance. MMBasic and the Micromite pcb's have different priorities. Using techniques like multiple measurements, averaging, discarding some points etc will give you roughly-ok measurements but it all depends on what you are after. Maybe go the whole hog and use a separate A/D like a MCP3204 and get a digital value from that via spi.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 01:58pm 19 Aug 2020
Copy link to clipboard 
Print this post

Typically water sensors are attached to water pipes (wet area). Typically electronics do not like water, and are distanced from the water. To connect the water sensor to the electronics, you would do good to use shielded wire. Especially when pumps are in the same area. When the water pressure changes are slow, you should also add some bigger capacitors at the MX170 pins (something like 10uF...100uF) to make sure you loose all 50Hz/60Hz hum.

I am not sure averaging is needed. With 12bit resolution on the ADC and low hum levels, a single conversion might give you all the resolution you need.

One thing to check: before you connect the sensors to the MX170, check with a multimeter is there is a ground connection (i.e. copper water pipe, earth, PC earth wire, USB cable, MX170....) In that case you can get measurement errors from a ground loop as soon as you attach your shielded wire to the MX170.

Success, sounds like a fun project..

Volhout
PicomiteVGA PETSCII ROBOTS
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 10:38pm 19 Aug 2020
Copy link to clipboard 
Print this post

Thanks Guys,

Just to give an update. Here is some data from my system:-


Time/Date, Pressure, Depth
20/08/2020 7:18:00 AM,974,26
20/08/2020 7:18:10 AM,971,25
20/08/2020 7:18:20 AM,1013,26
20/08/2020 7:18:29 AM,1047,26
20/08/2020 7:18:39 AM,1015,26
20/08/2020 7:18:49 AM,998,25
20/08/2020 7:18:59 AM,1012,26
20/08/2020 7:19:09 AM,1025,26
20/08/2020 7:19:19 AM,968,26
20/08/2020 7:19:31 AM,976,26
20/08/2020 7:19:41 AM,976,26
20/08/2020 7:19:51 AM,971,26
20/08/2020 7:20:00 AM,1000,26
20/08/2020 7:20:10 AM,987,26
20/08/2020 7:20:20 AM,941,26
20/08/2020 7:20:29 AM,948,26
20/08/2020 7:20:39 AM,950,26
20/08/2020 7:20:49 AM,1011,26
20/08/2020 7:20:59 AM,952,26
20/08/2020 7:21:08 AM,991,26
20/08/2020 7:21:18 AM,1292,26
20/08/2020 7:21:28 AM,1710,26
20/08/2020 7:21:38 AM,1619,26
20/08/2020 7:21:47 AM,1620,26
20/08/2020 7:21:57 AM,1555,26
20/08/2020 7:22:07 AM,1555,26
20/08/2020 7:22:16 AM,1523,26
20/08/2020 7:22:26 AM,1558,26
20/08/2020 7:22:36 AM,1550,26
20/08/2020 7:22:46 AM,1556,26
20/08/2020 7:22:55 AM,1512,26
20/08/2020 7:23:05 AM,1476,26
20/08/2020 7:23:15 AM,1534,26


Units of third column are milliVolts while column 4 is the depth to the water in the tank behind.
You can see the pump start at 7:21:18. The MM is taking 10 readings discarding the max and min and averaging the 8 remaining readings. Have not worried about a conversion to pressure units as I am only interested in that just in value. I am using a jump of 200mV as the flag that the pump has started I also ignore any starts within a minute as the pump gains pressure.

My system emails me a summary like below at a fixed time each day


19/08/2020 6:25:45 AM 1470 <== Pump ON, previous ON 51.5 mins ago Depth =  24
19/08/2020 6:57:04 AM 1281 <== Pump ON, previous ON 31.3 mins ago Depth =  25
19/08/2020 6:59:30 AM 1166 <== Pump ON, previous ON 2.4 mins ago Depth =  25
19/08/2020 7:01:27 AM 1292 <== Pump ON, previous ON 1.9 mins ago Depth =  25
19/08/2020 7:03:14 AM 1238 <== Pump ON, previous ON 1.8 mins ago Depth =  25
19/08/2020 7:05:30 AM 1417 <== Pump ON, previous ON 2.3 mins ago Depth =  25
19/08/2020 7:08:35 AM 1479 <== Pump ON, previous ON 3.1 mins ago Depth =  26
19/08/2020 7:11:50 AM 1251 <== Pump ON, previous ON 3.2 mins ago Depth =  26
19/08/2020 7:27:32 AM 1329 <== Pump ON, previous ON 15.7 mins ago Depth =  24
19/08/2020 7:54:06 AM 1603 <== Pump ON, previous ON 26.6 mins ago Depth =  24
19/08/2020 8:26:49 AM 1322 <== Pump ON, previous ON 32.7 mins ago Depth =  26
19/08/2020 9:00:11 AM 1393 <== Pump ON, previous ON 33.4 mins ago Depth =  24
19/08/2020 9:06:01 AM 1546 <== Pump ON, previous ON 5.8 mins ago Depth =  24
19/08/2020 9:18:10 AM 1525 <== Pump ON, previous ON 12.1 mins ago Depth =  24
19/08/2020 9:39:52 AM 1179 <== Pump ON, previous ON 21.7 mins ago Depth =  24
19/08/2020 10:05:56 AM 1565 <== Pump ON, previous ON 26.1 mins ago Depth =  25
19/08/2020 10:33:06 AM 1462 <== Pump ON, previous ON 6.8 mins ago Depth =  24
19/08/2020 11:01:17 AM 1441 <== Pump ON, previous ON 28.2 mins ago Depth =  26
19/08/2020 11:32:04 AM 1421 <== Pump ON, previous ON 30.8 mins ago Depth =  26
19/08/2020 12:02:30 PM 1522 <== Pump ON, previous ON 30.4 mins ago Depth =  24
19/08/2020 12:39:06 PM 1606 <== Pump ON, previous ON 36.6 mins ago Depth =  25
19/08/2020 1:14:34 PM 1583 <== Pump ON, previous ON 35.5 mins ago Depth =  24
19/08/2020 1:52:00 PM 1411 <== Pump ON, previous ON 37.4 mins ago Depth =  26
19/08/2020 2:32:39 PM 1263 <== Pump ON, previous ON 40.7 mins ago Depth =  25
19/08/2020 3:17:40 PM 1400 <== Pump ON, previous ON 45 mins ago Depth =  25
19/08/2020 4:05:26 PM 1633 <== Pump ON, previous ON 47.8 mins ago Depth =  24
19/08/2020 4:54:41 PM 1488 <== Pump ON, previous ON 49.3 mins ago Depth =  24
19/08/2020 5:46:49 PM 1216 <== Pump ON, previous ON 52.1 mins ago Depth =  24
19/08/2020 6:41:34 PM 1601 <== Pump ON, previous ON 54.7 mins ago Depth =  24
19/08/2020 7:29:59 PM 1205 <== Pump ON, previous ON 48.4 mins ago Depth =  24
19/08/2020 8:07:48 PM 1390 <== Pump ON, previous ON 37.8 mins ago Depth =  25
19/08/2020 8:45:32 PM 1223 <== Pump ON, previous ON 37.7 mins ago Depth =  24
19/08/2020 9:23:55 PM 1264 <== Pump ON, previous ON 38.4 mins ago Depth =  24
19/08/2020 10:02:57 PM 1489 <== Pump ON, previous ON 39 mins ago Depth =  24
19/08/2020 10:42:48 PM 1482 <== Pump ON, previous ON 39.9 mins ago Depth =  24
19/08/2020 11:22:52 PM 1121 <== Pump ON, previous ON 40.1 mins ago Depth =  24
20/08/2020 12:03:01 AM 1167 <== Pump ON, previous ON 40.2 mins ago Depth =  24
20/08/2020 12:43:10 AM 1346 <== Pump ON, previous ON 40.2 mins ago Depth =  24
20/08/2020 1:24:08 AM 1247 <== Pump ON, previous ON 41 mins ago Depth =  26
20/08/2020 2:06:04 AM 1567 <== Pump ON, previous ON 41.9 mins ago Depth =  26
20/08/2020 2:49:38 AM 1547 <== Pump ON, previous ON 43.6 mins ago Depth =  26
20/08/2020 3:34:09 AM 1158 <== Pump ON, previous ON 44.5 mins ago Depth =  25
20/08/2020 4:18:51 AM 1247 <== Pump ON, previous ON 44.7 mins ago Depth =  24
20/08/2020 5:04:40 AM 1483 <== Pump ON, previous ON 45.8 mins ago Depth =  24
20/08/2020 5:50:58 AM 1216 <== Pump ON, previous ON 46.3 mins ago Depth =  24


Yes the early short on/off periods are correct the cattle had a big drink before the bad weather of yesterday set in!

Here are two images (not sure how they got on their sides!) an overall shot and inside the box. The 20mm conduit supplies 12V dc while the large pipe is the tank filler.


Inside needs some tiding up work but contains a MM170 on one of Big Mick's boards, the depth sensor board sits vertically (ringed by the yellow and white twisted pair wires), The signal conditioning board lies on the bottom of the case at this time while you can see the HC-12 top left.



At the PC end there is another HC-12 and USB-Serial converter. Software wise I am running a VB.NET console app to communicate with logger, record the data and send the emails.

Thanks again all for your help.
Rob White
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 02:12am 20 Aug 2020
Copy link to clipboard 
Print this post

G'Day you lot

On the subject of averaging, I built a battery testing system that discharged the battery down to a preset voltage and then re-charged. At the end of the cycle I had a good idea of Amp hrs and a fully charged battery.
I took 10 voltage readings, rejected the highest and lowest and averaged the remaining 8. Probably all unnecessary but I wanted to avoid noise and it was fun. Rob is probably not worried by noise because one dud reading will not matter.

Peter
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 07:38am 20 Aug 2020
Copy link to clipboard 
Print this post

@Bizzie

Nice work! I love real-world uses like this. I still get a buzz from really useful stuff like this.

Consider putting a silica gel pack in the enclosure.
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 10:57pm 20 Aug 2020
Copy link to clipboard 
Print this post

@CaptainBoing

Thank you. This project has a little more to it that what you see on the surface and your to thank for that! While not using your networking software from Fruits of the shed directly. I am developing a system where the loggers (of any data types - Pump pressure, Tank levels, Rain gauges etc) chache their data and then when polled send the data out a serial connection. There may be a HC-12 link in that line.

A big thank you to all on TBS who have helped me over the years.
Rob White
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 07:46am 21 Aug 2020
Copy link to clipboard 
Print this post

wow! glad to help. Micromites make all this stuff really easy.

I never intended for that code to stay intact if it gets used anywhere else, just to get the creative juices flowing.

Star networks are not uncommon using HC-12's but I could never find a complete "worked out guide" when I put that protocol together for my snooker hall metering - hence the article.

Your monitoring is looking good, and with a good protocol it is easy to add new sites - keep us in the loop as it progresses.
 
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