Why 4-20mA INPUT suddenly screw up?
Ok, I've been having fun with Industruino IND 1286 until suddenly an analog port configured as 4-20mA is giving me 20 mA on 4mA input. At first, I calibrated all analog ports using calibration sketch from github. After calibration, initial testing using 4-20mA inputs were good. Application grow after I made sure analog parts were doing their jobs. Basically, the application continously read water pressure from 4-20mA pressure transmitter (simulated by a high precision loop simulator from plctools.com), maintain the water pressure by sending 0-10V output to VFD based on 4-20mA pressure input, monitor machine speed from another VFD using another 0-10V analog input, and count input pulse from proximity sensor using one Indio Digital pins. Each module worked perfectly when running by itself. However, when I combine everything into loop, I missed some pulses. I realized what I need is an INT pin which is not available. They were used by i2c and RS485. I can't use Indio's INT7 as the time of checking "changed" Indio pin is too slow. I tried to use SoftwareSerial and used an arduino dedicated for the pulse counting. However, SoftwareSerial is giving gibberish output. While I was tinkering with the Serial, suddenly 4-20mA input was giving me funny reading. At first I thought it was the power supply so I added a second Autonics SPB-060-24, 2.5A PSU just for the analog section in order to provide separation. The result was the same. At 4mA the reading is as follow:
CH-01: 22.02 mA, CH-02: 22.18 mA, CH-03: 22.07 mA, CH-04: 22.08 mA
When the loop simulator is off, the reading was around 20mA. When nothing is connected to the analog ports, the readings were 0.16 mA for all ports.
For testing, I've removed everything from digital and analog ports, except: 1 cable from IND ground to PSU -. 1 input cable to IND ANALOG INPUT.
The wiring is as follow: PSU+ === loop sim + === loop sim - === IND ANALOG INPUT === IND GND === PSU -
I've checked the loop simulator using DMM and the result is very accurate from 4mA to 20mA. Wiring:
PSU+ === loop sim + === loop sim - === DMM + === DMM COM === PSU -
Here is the code I use for testing the analog input:
const int pin_Water_Pressure = 3;
void setup() {
Serial.begin(9600);
//setup analog pins
Indio.setADCResolution(16);
Indio.analogReadMode(pin_Water_Pressure, mA);
}
void loop() {
float val = Indio.analogRead(pin_Water_Pressure);
Serial.print("Analog : ");
Serial.print(val, 2);
Serial.print(" mA");
Serial.println("");
delay(1000);
}
Here is the Indio.cpp calibration setting:
//Calibration data array for ADC, 4-20mA mode
const int ADC_current_low_raw[5] = {0,1861,1848,1857,1855};
const int ADC_current_low_uA[5] = {0,10000,10000,10000,10000};
const int ADC_current_high_raw[5] = {0,3719,3693,3711,3709};
const int ADC_current_high_uA[5] = {0,20000,20000,20000,20000};
What could be the problem here?? Why at first it worked perfectly?
UPDATE: I connected the pressure transmitter instead of the loop simulator. It is a danfoss MBS-1900 with 4-20mA output. The result is the same as the loop simulator. When connected to DMM, it reads 3.98 mA.
UPDATE #2: Out of curiosity, I assembled a brand new IND 1286 originally for reserve and the result is the same. Now I am totally puzzled..
UPDATE #3: Just tested Voltage mode is working correctly, both V10 and V10_p.
Hi Albert,
I also had problems here and there with 4-20 mA loop.
As I have not much time to investigate, I only use mA_raw mode, which gives me a 0-65536 result.
Then I map it from 4 to 20 mA using map().
But in this mode the input is a 0-20 mA instead of 4-20 mA, so the zero is at about 12.000 reading.
Btw Stefano. You gave me the idea of using different controller to share the load of a task. I intend to communicate with arduino using serial. Which serial library is compatible with IND 1286 and which of the idc14 pin can I use? Or, can I connect directly to arduino pin using the RS485 on IND1286?
Hi Stefano, Albert, the RAW readings are 0-4096 for all resolutions, they are of type 'float' to reach the indicated precision, see https://github.com/Industruino/libraries#analog-input
You should start from scratch on a new sketch to check analog in functionality. You might have damaged analog inputs. If they do work on a test sketch then you should compare to find out which instruction is causing the issue.
Hi Albert, it seems you have the INDIO connected over USB. Are you also powering it on the V+?
Can you download the latest version of the Indio library and try without calibration? https://github.com/Industruino/Indio
The RAW readings are 0-4096 for all resolutions, they are of type 'float' to reach the indicated precision, see https://github.com/Industruino/libraries#analog-input
Hi Tom. Yes, I connected the INDIO over USB for debugging and sketch upload. But the V+ is always on during the process otherwise the Serial will output "Unable to read" when reading the analog input. Btw, I already updated with the default Indio library but the result is still the same. 20mA when loop sim is off, 22.02 mA when loop sim is 4mA.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 4/17/17, 9:34 AM |
Seen: 3371 times |
Last updated: 4/18/17, 12:10 AM |
This is weird!! input = 4mA. Result: mA == 22.02ma. mA_p == 90.11%. mA_raw == 4095.94 divide by 65536 = 0.06ma.. How come all inconsistent??? same input, 3 different results.. and none were correct... Even more weird, it used to work!!