Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: 4-20mA current loop board with Raspberry pi using Node Red
PostPosted: Sat Jul 30, 2016 11:16 pm 

Joined: Sat Jul 23, 2016 10:09 pm
Posts: 4
I am trying to figure out how to use the Libelium 4-20mA board to read 4-20mA sensors and get the data into Node Red on the Raspberry Pi. I have been able to get the 4-20mA board to read the sensor using the 4-20mA board and the Arduino Bridge board, but can't seem to figure out how to get the Raspberry Pi to read the data into a Node Red program. Does anyone know if any tutorial or where I can find more information on how to do this? I am not a programmer by trade but have messed with Arduino and Raspberry Pi for a while now so I do know some things, just not enough to get done what I want in this case.


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Mon Aug 01, 2016 7:55 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11290
Hello mgirdner,
Sorry about that but we are not experience with Node Red. Maybe any user could help you.
Regards


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Wed Aug 03, 2016 12:31 am 

Joined: Sat Jul 23, 2016 10:09 pm
Posts: 4
I have decided to start by using an Arduino Uno to read the 4-20mA board and got that working fine. I can then use the Pi to read the Uno's serial port and I send the data that way. What I found when I got this working that a 0-20mA input to the board is giving me an integer reading of 0 to 670 using the readChannel command, not the 0 to 1023 that the specs say. Any reason it wouldn't output 0-1023 for 0-20mA?


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Wed Aug 03, 2016 7:55 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11290
Hello mgirdner,
Quote:
I found when I got this working that a 0-20mA input to the board is giving me an integer reading of 0 to 670 [..]

It is not normal.
Can you test the examples provided with the library?. Please post some pictures of your hardware configuration to check it visually.
Regards.


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Thu Aug 04, 2016 2:21 pm 

Joined: Sat Jul 23, 2016 10:09 pm
Posts: 4
Here is a link to pictures of my setup:

https://www.dropbox.com/sh/3wj4fanboq6j ... 75d0a?dl=0

I am using a Fluke 4-20mA calibrator to supply the current to the test rig so I know the mA is correct. I am powering the Arduino with an external power supply. I have tried the "basic" test program on all four analog input channels with the same result - with small variations in the integer readings as would be expected.

The readCurrent command gives the correct mA reading, but the readChannel only gives 670 to 676 or so on the 20mA input and 130 to 133 on the 4mA input. Any ideas on why this is happening?


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Fri Aug 05, 2016 7:36 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11290
Hello mgirdner,

Your readings are correct. Te full scale of the ADC is 5V(1024) -> 30,30mA. You can increment the maximun channel current to 30,30mA. At 20mA the voltage in the adc is Vadc=R * 20mA= 165 *0,02=3V3. This means that at 20mA the ADC reads 3,3/5*1024 = 675,84.
This over current full scale is for 3V3 boards compatibility.

You can improve the precision adjusting the end scale to 20mA in two ways:
1.- Working with an arduino 3V3 board.
2.- Giving an external reference of 3V3 to the arduino AREF pin and merge this line in your code:
Code:
analogReference(EXTERNAL);

and modify the readVoltage() procedure to:
Code:
float currentLoop::readVoltage(uint8_t channel)
{
   return (readChannel(channel) * 3.3 /1023);
}



Check this URL:
https://www.arduino.cc/en/Reference/AnalogReference

Regards.


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Fri Aug 05, 2016 3:21 pm 

Joined: Sat Jul 23, 2016 10:09 pm
Posts: 4
Thanks, I used the 3.3 VDC pin on the Arduino to the AREF pin and the readChannel now returns 1020 at 20mA - I am doing all scaling in the Pi so I don't need the readVoltage or readCurrent commands in the Arduino.


Top
 Profile  
 
 Post subject: Re: 4-20mA current loop board with Raspberry pi using Node R
PostPosted: Mon Aug 08, 2016 7:40 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11290
Hello mgirdner;
You are welcome, thanks by your contribution and good luck with your project.
Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.