Problem in creating a 4-20mA loop with Arduino Dues

In short: HW-685 board malfunctions everytime Arduino #2 board is connected to PC via USB and 4-20mA generated with XTR105 IC drops everytime Arduino #2 DAC is connected to Arduino #1 via analog port.

Hello there,

I've been trying to interface an Arduino Due with industrial equipments and controllers that mainly communicate with analog 4-20mA.

The main idea is to, for example, develop a PID controller on simulink, generate C/C++ code, upload it to the Arduino Due and connect it to a real industrial process that uses 4-20mA as input and as feedback from a transmitter. This DUE should be able to send 4-20mA proportional to the virtual PID output and read an analog voltage proportional to the 4-20mA feedback from the transmitter.

Or, I could develop a mathematical model of an industrial process on simulink, upload it to the DUE in order to control it in real time with a physical controller, using the same methods.

Or even use two arduino DUEs, one with a PID controller and the other with an industrial process, both simulated in real time and one controlling the other.

For that, the DUEs should have at least two types of signal converter circuits:

1) Voltage to Current: Since i'm using the DUEs DACs, i should convert 0.55-2.75V to 4-20mA.
2) Current to Voltage: The DUE's input voltage range it 0-3.3V, so, i need to convert 4-20mA to 0-3.3V.

I'm working with two solutions for these circuits. For circuit 1 I'm using the IC XTR105 to generate the current and for circuit 2 i'm using the HW-685 board. Both are actually working well (isolated) so far.

The problem is, since I don't have any industrial equipment in my house and my university is closed due to COVID, it is hard to test the whole thing with everything working at the same time. I'm having to test it using the last example that I gave (two DUEs, one acting as a controller and the other as a process). I'm trying to use every circuit and I know that when using two Arduino DUEs, using all of that voltage to current and then current to voltage is definetely not needed, but since I will need all of this for the industrial equipment, I'm trying to make sure everything is working properly.

Please, refer to the attachment "test_circuit.png" to better understand the following part.

Since I'm trying to test the analog communication, I'm not uploading any C/C++ controller code to the board, Instead, I'm using a potentiometer to generate a virtual 4-20 scale and taking that and writing in the DAC0 of Arduino #1. This gives me a 0.55-2.75V as an ouput for Arduino #1.

Using the XTR105 circuit I can generate 4-20mA proportional to this 0.55-2.75V scale. But for that, I need to power the IC with an external DC power supply higher than 9V.

The output current from the XTR105 would be connected to, let's say, a valve that is restraining the flow of a liquid to fill a tank up. And a level transmitter would output 4-20mA proportional to the liquid level. I would take this output scale and hook it to the HW-685 board that converts it to 0-3.3V, making it possible to close the loop with the DUE.

But, since I don't have none of this equipment at home, I'm trying to send this output current directly to the HW-685 board and hooking the output voltage to another DUE (Arduino #2).

My first test would be to take a look at the serial monitor of Arduino #2 to see if I'm reading 0-4095 if I use AnalogReadResolution(12) (0-4095 would be proportional to the output 0-3.3V from HW-685). But here, the first problem arrives: as you can see, I need to power up the second Arduino with an external power supply to provide enough voltage for the HW-685 board (through Vin port). It seems like it is working, but whenever I connect the USB cable to the PC (in order to check the serial monitor), the HW-685 stops working properly (the output voltage of the board drops) as if there is some problem with the supply voltage. I can't understand why this is happening since the Vin port should provide the highest voltage that the board is receiving (external power supply in this case). I'm suspecting the board is with some kind of problem and needs to be replaced, so I bought two more DUEs and I'm waiting for them to arrive to test it.

To keep the tests going, I connected a LED to Arduino #2 and i'm varying it brightness with the HW-685 output voltage. This is to get some kind of visual feedback of the way Arduino #2 is interpreting the converter board output.

Since I need to understand if the feedback loop works (have a signal from Arduino #2, proportional to the signal from Arduino #1, returning to Arduino #1), I'm connecting DAC1 of Arduino #2 to Arduino #1 to check its serial monitor. At the end, I was expecting to turn potentiometer in Arduino #1 and see the voltage coming form Arduino #2 varying proportionally. But here comes the second problem: whenever I connect the GND from Arduino #2 to Arduino #1, the 4-20mA current output from the XTR105 circuit drops. It seems like something is consuming this current, but I can't see what. I'm even able to see a variable scale in the serial monitor, but it is not correct since the current from xtr105 scale drops (I'm able to see the current via power suppler display).

If someone needs to check the XTR105 circuit, please refer to the attachment "xtr105.png"

Below, I'm putting the codes from Arduinos #1 and #2. I understand there are a lot of thing that are not necessary in this codes like the conversion from 0-4095 to 4-20 and then the backwards conversion, but I was expecting it to work even with these kind of things.

ARDUINO #01 CODE:

int pot = A0;
void setup() {
  Serial.begin(9600);
  pinMode(pot,INPUT);
  pinMode(A9,INPUT);
  pinMode(DAC0, OUTPUT);
}

void loop() {
analogReadResolution(12);
analogWriteResolution(12);
EnviaSinal(DAC0, LeSinal(pot, 0));
Serial.println(analogRead(A9));
}

float EnviaSinal(int pino_escrita, float entrada){
  //Função que escalona o sinal de 4-20 para 0-4095 (0-3.3V) e escreve no pino_escrita
  //que deve ser um dos DACS (0.55-2.75V)
  float sinal = (4095.0/16.0)*(entrada - 20.0) + 4095.0;
  analogWrite(pino_escrita, sinal);
}

float LeSinal (int pino_leitura, float offset){
  //Função que le o sinal de 0-4095 (0-3.3V) e escaolona para 4-20
  float sinal = (analogRead(pino_leitura) - 4095.0)*(16.0/4095.0) + 20.0;
  if (sinal < 3.95) {sinal = 4.0;}
  if (sinal > 19.95) {sinal = 20.0;} 
  return sinal + offset;
}

ARDUINO #02 CODE:

void setup() {
  Serial.begin(9600);
  pinMode(A8,INPUT);
  pinMode(2, OUTPUT);
  pinMode(DAC1, OUTPUT);
}
void loop() {
  analogReadResolution(12);
  analogWriteResolution(12);
  analogWrite(2, analogRead(A8));
  analogWrite(DAC1, analogRead(A8));
}

I kindly ask for advices on these problems and I'm open to suggestions and critics on the solutions I'm implementing.

wiring_V2.pdf (109 KB)

It is an art to present a question in such a way that people will read it through....
Can You filter out the real question?

Railroader:
It is an art to present a question in such a way that people will read it through....
Can You filter out the real question?

Thanks for the tip!!

The biggest problem I'm facing is when I'm trying to connect the feedback voltage signal from Arduino #2 to Arduino #1, the current output from the XTR105 IC drops. I'm trying to understand why this is happening!

That sounds strange.

Unfortunatly You posted a picture, not a wiring diagram. Magnifying that picture, it blurrs out and is not readable enough.

The different GNDs are unclear to me. Your instrument delivers voltage I think. Why not, as a test, temporarily skip the volt - current loop - volt conversion between the instrument and DUE 2?

Toltchok:
Thanks for the tip!!

The biggest problem I’m facing is when I’m trying to connect the feedback voltage signal from Arduino #2 to Arduino #1, the current output from the XTR105 IC drops. I’m trying to understand why this is happening!

voltage drop usually caused by powering many loads from one source of power supply.
i think you need to put decoupling 1 uF capacitor near xtr105 IC,

Railroader:
That sounds strange.

Unfortunatly You posted a picture, not a wiring diagram. Magnifying that picture, it blurrs out and is not readable enough.

The different GNDs are unclear to me. Your instrument delivers voltage I think. Why not, as a test, temporarily skip the volt - current loop - volt conversion between the instrument and DUE 2?

The different GNDs you are mentioning are the ones coming from both arduinos? In the end they are connected together and that's when I see the current and voltage drop. I think somehow the Arduino #2 is consuming the current that should be delivered to the XTR105 IC.

I'm trying to make sure the converting circuits are working properly. That's why I chose not to skip it.

rzk:
voltage drop usually caused by powering many loads from one source of power supply.
i think you need to put decoupling 1 mF capacitor near xtr105 IC,

Thanks for the support. Isn't the 0.01 uF capacitor in the XTR105 circuit working as a decoupling capacitor?

Make a proper wiring. Poetry doesn't work.

Railroader:
Make a proper wiring. Poetry doesn't work.

Made it.

I attached it as a PDF file so it won't lose quality.

The problem happens everytime the red wire in the wiring diagram is connected!

Where is the power to the XTR102 coming in?
Is the DUE1 supplied with the same source as the DUE2?
What is that 9 volt battery? Have You checked its voltage during the troubling condition?

Railroader:
Where is the power to the XTR102 coming in?
Is the DUE1 supplied with the same source as the DUE2?
What is that 9 volt battery? Have You checked its voltage during the troubling condition?

I updated the wiring so it gets less confusing. Please take a look at the wiring_V2 PDF.

The XTR105 IC is been powered by the variable dc power supply.
The DUE1 is supplied by usb port with 5V.
There is no 9V battery as the last wiring suggested, I updated it.

Is there a connection between the DUEs GNDs and the 2 power supply GNDs, the USB and the 8.4 supply, and the >9 volt supply?
Does any component have a raise in temperature?

Does the Arduino 1 DAC output drop when You make that connection?

Railroader:
Is there a connection between the DUEs GNDs and the 2 power supply GNDs, the USB and the 8.4 supply, and the >9 volt supply?
Does any component have a raise in temperature?

There is no common GND between everything. Maybe that's the issue. I'll test it out.

I did not noticed any raise in temperature with or without the connection.

Railroader:
Does the Arduino 1 DAC output drop when You make that connection?

It does not drop. It statys close to the expected range of 0.55-2.75V.

Railroader:
Is there a connection between the DUEs GNDs and the 2 power supply GNDs, the USB and the 8.4 supply, and the >9 volt supply?

Toltchok:
There is no common GND between everything. Maybe that's the issue. I'll test it out.

I tested and the voltage dropped even before the connection is made. Somehow it seems like the power supply is getting messed up everytime the GNDs from the arduinos are connected.

Whenever I read Arduino 2's DAC output with a multimeter, the output range seems to be working fine and there is not current drop from the FA-3003 power supply. It only happens when I try to hook tihis output to Arduino 1 and the GNDs are connected.

Toltchok:
I tested and the voltage dropped even before the connection is made. Somehow it seems like the power supply is getting messed up everytime the GNDs from the arduinos are connected.

Is the Pc powered by its battery by mains? The same question about the supply of DUE1, is it powered by mains?

Is the Pc powered by its battery by mains? The same question about the supply of DUE1, is it powered by mains?

Toltchok:
I tested and the voltage dropped even before the connection is made. Somehow it seems like the power supply is getting messed up everytime the GNDs from the arduinos are connected.

What if You connect that GND but not the DAC output? Does the XTR105 signal drop?

Railroader:
Is the Pc powered by its battery by mains? The same question about the supply of DUE1, is it powered by mains?What if You connect that GND but not the DAC output? Does the XTR105 signal drop?

Yes, connecting the GND is enought to drop. I can notice the drop by the power supply display and the LED brightness.

Something that I noticed is that when I connect the FA-3003 power supply GND to DUE1 GND, the same problem happens. So maybe the root of the problem is this and not DUE2 GND to DUE1 GND.

Okey. Maybe we've got the loose end. Can that Pc run on its internal battery for a test? An alternative could to use an USB power bank as supply and not the Pc.

I suspect a mains gnd to possibly be the trouble.

Railroader:
Okey. Maybe we've got the loose end. Can that Pc run on its internal battery for a test? An alternative could to use an USB power bank as supply and not the Pc.

I suspect a mains gnd to possibly be the trouble.

Tried with PC running on its battery and got the same result., unfortunately no success.