how to interface with a 24V pressure sensor

rmeldo

Senior Member
Hi,


I bought a pressure sensor to measure water level in a tank (1-5 metres). The sensor requires 24V DC and it modulates the current in the range 4-20mA, according to the pressure reading.

In regards to how to interface it with the Picaxe I was thinking of putting the sensor in series with a 250 ohm resistor and measure the voltage drop across the resistor (from 1 to 5V) with the DAC of the Picaxe. This would require supplying the sensor + resistor with 29V, which seems non-standard. Also the voltage supply would need to vary according to the reading, to avoid overloading the sensor (If I provide 29V and the pressure is low, then the current is low so the voltage drop across the resistor and the sensor will see more than 24V)

Is this the way it is done, or there are other ways of doing it, like with a much smaller resistor and then by amplifying the signal before sending to the DAC?

Any pointers would be appreciated.

Thanks
Riccardo
 

hippy

Technical Support
Staff member
Someone recently posted about a water well monitoring article which I recall used a similar sensor, 24V 4-20mA output. It might be worth hunting that post down, seeing how they did it in the linked article, and there may be other examples out there considering similar sensors exist and will have been interfaced to other micros if not a PICAXE.

Added: This 24V 4-20mA interface does seem to be an industrial standard and there has been some discussion on the forum about using those so it would be worth checking out those threads -

http://www.picaxeforum.co.uk/showthread.php?8142-mA-output-on-transducers
 

AllyCat

Senior Member
Hi,

Yes, you don't need to add the 5 volt drop to the specified 24 volt supply; either the sensor will be a three-terminal device or the specification will assume a series resistance of at least 250 ohms, and maybe as high as 1 kohm.

However, as the sensing is not "ratiometric", you will need typically a "precision" 5 volt power supply for the PICaxe AND a 250 ohm resistor. Alternatively, you might use a 100 ohm metal film resistor with FVR_2048 as the ADC reference within the PICaxe.

The AliExpress link works fine for me (usually I get the French version for some unknown reason :( ) and far cheaper than the apparently similar sensor in this very recent thread

Cheers, Alan.
 

Reloadron

Senior Member
Your sensor is a two wire loop powered pressure sensor where you scale your 4 to 20 mA into a voltage. As an example in the below cartoon if R1 is a good precision 250 Ohm resistor your 4 to 20 mA current loop will produce a 1 to 5 volt output so a span of 16 mA becomes a span of 4 volts. Then convert the voltage to a convenient engineering unit. Now your 1 to 5 volts becomes 0 to 5 meters of water depth, or the unit of measure of your choice.



Ron
 

rmeldo

Senior Member
Hi,

An additional questions, this time about wiring to minimise power usage.

I am working through the implementation. So far I have done some experiments to the calibration of the sensor with the multimeter by dipping the sensor into barrel. It all seem to work fine.

The sensor is going to be powered through a buck-boost converter (https://www.ebay.co.uk/itm/123090433455) and the primary power source is going to be a battery pack (3 NiMH batteries topped up by a solar charger. All from a security light bought from Lidl).

To save battery energy I want to switch off the power to the buck boost converter. I was thinking of using a 2N700 mosfet.

The question are:

1) Should I wire the sensor to the boost converter in parallel with a diode to avoid over voltage when switching off or is the converter capable of taking care of it? The boost converter has an inductance and a capacitor but my thinking is that they are there only to smooth out the ripples from the high frequency switching of the on board chip.

2) Should I do the same on the input side of the boost converter as well? The input current would be quite substantial because it is lifting the voltage from about 3.6 to about ~14V (the minimum I can get away to power reliably the 4-20mA sensor)

I include a schematics (apologies for not being proper).

schematics.JPG

Thanks

Riccardo
 

techElder

Well-known member
Ricardo, the 2N7000 is not going to be a good choice for a high side switch. You need the complementary version; a P channel version.

What problem are you trying to solve with the diodes? Ordinary diodes aren't going to solve a positive over voltage situation. Do you have an over voltage situation? Measure it yet?
 

rmeldo

Senior Member
Thanks, I will look for a P version.

My concern is that if I am abruptly going to cut off power to a the boost converter while it is using 20mA*14V/3.6V = ~80mA then there is going to be a voltage surge, like it happens for the coil of a relay. Since the problem in that case is solved by a diode in parallel, I thought I would do the same.

It feels right, but I am not sure, hence I asked the question.

Riccardo
 

AllyCat

Senior Member
Hi,

The 2n7000 needs to be used as a low-side switch, i.e. in the "Earth" side of the converter. That may then introduce "complications" with reading the voltage across the 250 ohm resistor. Alternatively, for a high-side switch, use a Logic-Level P-channel FET, or a PNP transistor with about 1k from its base to the PICaxe output pin.

Do you mean an ADC pin ? It is possible to use the DAC pin but very "unusual". Also, Microchip recommend that the resistance in series with an ADC input (your 22k) should not exceed 10k, unless a capacitor (say 10n - 100n) is connected directly from the ADC input pin to Earth.

The Inductor in the boost converter does much more than just "filtering", but all necessary components should be on the PCB. So your extra diodes are probably not needed, but we really need a proper circuit diagram to be sure.

Cheers, Alan.
 

rmeldo

Senior Member
Hi

Thanks for the quick reply.

I meant ADC, my bad.
I will use a P channel mosfet and a 10K resistor (I got the 22k value from reading another threead on the forum).

With regards to the circuit diagram, I presume you mean the one for the boost converter. Not sure I can find that since it is an ebay purchase. Next best thing build the circuit and measure voltages with an oscilloscope?

Riccardo
 

AllyCat

Senior Member
Hi,

A circuit diagram for the converter would be "nice", but also the overall circuit diagram should identify Drain, Source and Gate of the FET (or whatever), etc. to show up the (mis-)use of high and low side switching, etc..

Why use a Buck-Boost converter when you appear to need only a boost? A simple boost converter should be less than half the price, probably more efficient and be delivered more quickly. ;)

Cheers, Alan.
 

rmeldo

Senior Member
With regards to the P mosfet

I found these for through hole mount:

https://docs-emea.rs-online.com/webdocs/13fe/0900766b813fed11.pdf


and these for surface mount:

https://docs-emea.rs-online.com/webdocs/1321/0900766b81321f1f.pdf

https://images.mcmanager.co.uk/pdf/bss84.pdf


They all have the voltage and current ratings I would need for this ans several future projects (I need to buy at least 25 from RS) and also low leakage current, which is good for my battery power application.

Am I on the right track?

Riccardo
 

rmeldo

Senior Member
Hi,


here is a (slightly) better circuit diagram. Apologies, I don't know my way around the drawing package very well. Hopefully it is an improvement.

With regards to the buck-boost, I bought two to experiment. One for regulating the voltage to the Picaxe (I don't connect directly to the batteries so that I can measure Vbat) and the other for upping the voltage to 14V for the sensor.

Having never used buck converters I picked a couple form ebay. the logic is that I could use the same type for both tasks.

I will look into a different version, but when buying form China it is often difficult to find the datasheet to go with the board.

Riccardo

schematics_KiCAD_dark_small.PNG
 

Attachments

AllyCat

Senior Member
Hi,

IMHO those FETs are not really up to the job. 12 ohms RDSon seems rather high, e.g. 1.2 volts drop at 100 mA. :( For example, 20 mA at 14 volts is 280 mW, so the converter might take up to 100 mA from your 3.6 volt supply (even assuming adequate input decoupling on the module).

I'd be looking for a switch resistance <= 1 ohm, something easily (and cheaply) available, ideally from my spares box. Perhaps something like a BC327 (PNP) at least to try out. I've not examined your schematic in detail (my eyes struggle with red-on-black with a small screen), but I think the BSS84 has Source and Drain exchanged (judging by the direction of the substrate diode).

Also I don't have much experience with off-the-shelf boost modules, but I did recently buy a couple of MT3608 boost converters for one of my own projects. From a UK seller at £2/pair that arrived within a few days, but I've still to try them out. BTW, one of the ebay listings did warn that you should check/adjust their pot setting before applying power.

Cheers, Alan.
 

rmeldo

Senior Member
Thanks for catching that. I had missed RDSon. I took another look at RS but the lowest R I could find is 5 ohm, which is still high.

I might even have a BD 327 somewhere at home.

The BC 327 has a min hfe of 100 so I would need only, say, 2mA to turn the converter on, so it is a better tradeoff.

So am i right in thinking that with 3.3 V microcontroller I should put in series with the gate a 1k6 resistor?

Thanks again
Riccardo
 

AllyCat

Senior Member
Hi,

There might be better FETs, but the BC327/337 complementary bipolars are my favourite long-established workhorse for currents where the BC547/557 are beginning to struggle (say above 50 mA). Particularly with supplies of 3 volts and below where, otherwise, care may be needed to ensure that the drive is sufficiently higher than the Threshold Voltage of a FET. With a bipolar, you only have to allow 600 mV for the base-emitter junction and a few hundred mV for the output saturation voltage of the microcontroller, when calculating the base drive resistor.

However, for a good saturation voltage, you need more base current than indicated by the hFE (which is measured significantly above the saturation voltage), A common rule of thumb is 1/10 to 1/20 of the collector current, but I'd just try around 1 k (to give about 3 mA). Any further attempt to economise on the base current might be counter-productive: If the transistor starts to come out of saturation, then the voltage across the converter will fall and it will need to draw more current to maintain the input/output power.

Cheers, Alan,
 

rmeldo

Senior Member
Thanks.

As it happens I have 337s but not 327s at home.

Just ordered some.

Hopefully ready to experiment in a couple of days.

Riccardo
 

rmeldo

Senior Member
A thought just occurred to me.

Do I need to worry about electromagnetic interference between the buck boost converter and the rest of the circuit? I will be housing a LoRa transmitter in the same enclosure.

Riccardo
 

premelec

Senior Member
EMI is a possibility - however you likely could turn on up converter/transducer - take reading - turn off up converter/transducer - then transmit Lora signal... depends on how fast readings are being made and so forth...
 

rmeldo

Senior Member
Hi,

I've been trying to troubleshoot a problem all day: I don't seem to be able to switch off the boost converter with the BC327. The circuit is attached.

I think I have worked out why. I think the reason is that I have the microcontroller downstream of a LDO to keep everything (including the LoRa module) at 3V3. The BC327 sources power directly from the battery (voltage higher than 3V3). Therefore when I turn high the pin to drive the gate of the BC327 it doesn't go high enough and therefore it doesn't kill the emitter-collector current.

Am I on the right path? Assuming I am, then how to solve it?

I thought I could drive the gate of the BC327 with a Mosfet sourcing voltage directly from the battery. I am worried however that, once the mosfet internal voltage drops have been accounted for I am going to be inthe same situation I am now.

Any advice please?

Thanks
Riccardo

buckBoost switching.PNG
 

AllyCat

Senior Member
Hi,

If the PICaxe supply is really 3.3 volts and the battery 3.7 volts, then I wouldn't expect the BC327 to conduct significantly, because the Vbe needs to be at least 500 mV or more. However, a "3.7 volt" lithium cell could be as high as 4.2 volts immediately after being taken off-charge, so connecting the 1k resistor directly to the battery might make the BC327 conduct.

But strictly, the upper output FET of the pin-driver is "sourcing" current, whilst the pin must "sink" current (away from the base) to turn the BC327 on. That certain will occur when the PICaxe's "electrostatic protection diode" comes into conduction, but that needs the battery to be at least 1 volt higher than the PICaxe's supply rail.

Maybe the upper FET driver is operating in some "reverse" mode, try switching the output OFF (not High or Low but "tri-state") by making it an input, i.e. INPUT port.pin or REVERSE port.pin. If that doesn't work, try addiing a resistor of 470 ohms - 1k across the base-emitter of the BC327 to divide down the excess voltage.

Cheers, Alan.
 

rmeldo

Senior Member
Hi
Thanks, it makes sense.
The plan is to use 3 NiMh rechargeable batteries but I had been doing the testing with a 4 pack of NiCd batteries giving 5V, hence the problem.

I switched to the right voltage and all works now, without any extra components.
Thanks again for putting me straight.
Riccardo
 
Top