harvdawg68
Posts: 2
Joined: Wed Mar 15, 2017 5:00 am

4-20mA output

Wed Mar 15, 2017 5:07 am

Is it possible to have multiple 4-20mA outputs with a pi? I would need it to be 8 channels. Thanks in advance.

texy
Forum Moderator
Forum Moderator
Posts: 5144
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: 4-20mA output

Wed Mar 15, 2017 9:51 am

Hi,
the maximum current output from the GPIO lines is 50mA TOTAL, so the short answer is no - at least not without additional hardware. But that additional hardware, could only be a transistor and a couple of resistors per channel....
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: 4-20mA output

Wed Mar 15, 2017 9:55 am

the Pi doesn't have analogue outputs, something like this would help you.
Doug.
Building Management Systems Engineer.

User avatar
davidcoton
Posts: 3202
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: 4-20mA output

Wed Mar 15, 2017 9:59 am

It's nothing to do with GPIO current limits. 4-20mA is an analogue signal, the Pi GPIOs are digital. You will need extra hardware (sorry I don't use 4-20mA so I have no clues), but probably connected to USB or to the i2c bus since there won't be enough GPIO outputs without a bit of fuss (multiplexing). It will be more complex than a single transistor!
@BMSDoug: that is an input board, OP wants outputs :!: :!:
"Thanks for saving my life." See https://www.raspberrypi.org/forums/viewtopic.php?p=1327656#p1327656
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”

texy
Forum Moderator
Forum Moderator
Posts: 5144
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: 4-20mA output

Wed Mar 15, 2017 10:05 am

Sorry. I assumed he was talking about digital output current levels.......
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

scotty101
Posts: 3185
Joined: Fri Jun 08, 2012 6:03 pm

Re: 4-20mA output

Wed Mar 15, 2017 11:24 am

There are boards out there that support 4-20mA inputs in to the pi, but I've never seen a transmitter HAT.

As stated already, the pi doesn't have analogue outputs so for you to do this you will first need a Digital to Analogue Converter (DAC), depending on the level of accuracy you need you might get away with using PWM from the gpio pins and an RC filter to give you a variable voltage output. If you need higher accuracy then you'd need a dedicated DAC HAT or IC.

Then you need to convert that voltage output to a current. Some quick research finds the following page which takes a voltage input and outputs on a 'current loop/4-20mA' circuit.

https://www.hackster.io/ArduPic/4-20-ma ... ue1-82691a
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

harvdawg68
Posts: 2
Joined: Wed Mar 15, 2017 5:00 am

Re: 4-20mA output

Wed Mar 15, 2017 2:41 pm

The project I'm working on is going consist of a modbus input and then outputs those signals as 4-20mA signals. Adding hardware is no issue I just want to keep the form factor as small as possible.

scotty101
Posts: 3185
Joined: Fri Jun 08, 2012 6:03 pm

Re: 4-20mA output

Wed Mar 15, 2017 3:07 pm

Then you might find that a dedicated industrial PLC is more suitable than a raspberry pi. Industrial PLCs tend to have Modbus and 4-20mA support already.

Edit: TI make some voltage to current loop converters http://www.ti.com/lit/ds/symlink/xtr117.pdf <- Figure 4 shows how you could use PWM to control the output rather than requiring an ADC.
They also have SPI to current loop converters! https://www.maximintegrated.com/en/prod ... 15500.html
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: 4-20mA output

Thu Mar 16, 2017 11:17 am

davidcoton wrote:It's nothing to do with GPIO current limits. 4-20mA is an analogue signal, the Pi GPIOs are digital. You will need extra hardware (sorry I don't use 4-20mA so I have no clues), but probably connected to USB or to the i2c bus since there won't be enough GPIO outputs without a bit of fuss (multiplexing). It will be more complex than a single transistor!
@BMSDoug: that is an input board, OP wants outputs :!: :!:
You are absolutely right, I thought (incorrectly) that I had linked to an output board.

Two x 4-20mA output boards are available https://widgetlords.com/collections/pi- ... -interface. This board is hardwired to use GPIO 4 as the chip select for the SPI interface, with some hardware hacking you could change the chip select to a different pin and therefor have 4 of these connected at once (getting pretty expensive).

I've not seen much else capable of outputting 4-20mA signals.
Doug.
Building Management Systems Engineer.

User avatar
CFLanger
Posts: 36
Joined: Fri Feb 06, 2015 5:04 pm
Contact: Website

Re: 4-20mA output

Thu Apr 12, 2018 7:53 pm

look at AD5421.
CFLanger
Senior Software Engineer at
www.ljtechnologies.com

henmina53
Posts: 18
Joined: Thu Apr 05, 2018 4:49 am

Re: 4-20mA output

Mon Apr 16, 2018 11:02 am

How many channel does this IC has?? Can we use more than two sensors at a time with AD5421 ?
Is it follows the I2C baesd protocols or not ?

scotty101
Posts: 3185
Joined: Fri Jun 08, 2012 6:03 pm

Re: 4-20mA output

Mon Apr 16, 2018 11:27 am

henmina53 wrote:
Mon Apr 16, 2018 11:02 am
How many channel does this IC has?? Can we use more than two sensors at a time with AD5421 ?
Is it follows the I2C baesd protocols or not ?
Did you check the datasheet? http://www.analog.com/media/en/technica ... AD5421.pdf

1 channel, uses SPI protocol (not I2C) so you could have multiple devices connected.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

vlturner
Posts: 7
Joined: Mon Mar 14, 2016 11:26 pm

Re: 4-20mA output

Sat Aug 18, 2018 4:58 am

Anyone set up a 4-20maloop on this board?

https://pi-plates.com/daqc2-users-guide/

It should be quite possible and just need a little refresher from the community.

I need to read this sensor.

https://www.liquidlevel.com/continuous- ... lm-series/

vlturner
Posts: 7
Joined: Mon Mar 14, 2016 11:26 pm

Re: 4-20mA output

Sat Aug 18, 2018 5:02 am

I think this may just act as the intermediary

https://www.ebay.com/i/352397647538?chn=ps

ghellquist
Posts: 68
Joined: Thu Aug 02, 2012 8:47 am
Location: Stockholm Sweden

Re: 4-20mA output

Sat Aug 18, 2018 7:50 am

Not a suggestion for buying, only a link to a product under for sale:
https://www.raspberrypi.org/forums/view ... 3&t=218521
//Gunnar

vlturner
Posts: 7
Joined: Mon Mar 14, 2016 11:26 pm

Re: 4-20mA output

Sat Aug 18, 2018 5:26 pm

The links lead here.....

Funding Canceled
Funding for this project was canceled by the project creator on Aug 18 2018

Brandon92
Posts: 501
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: 4-20mA output

Sat Aug 18, 2018 6:03 pm

vlturner wrote:
Sat Aug 18, 2018 4:58 am
I need to read this sensor.

https://www.liquidlevel.com/continuous- ... lm-series/
The sensor is just a potentiometer:
The sensor is a 3-wire potentiometer
So, you can use this exapmle in the other link of you:
5.4.1 Using a Potentiometer to Generate a Variable Voltage
By the way, is that an expensive senor. It looks interesting for my project.

Return to “General discussion”