2 Wire Communication

Hi All.

I have always wanted to try out the below idea for 2 wire communication that I have been carrying in my head . And surprisingly it works :slight_smile: Chuffed with my self.

But I get a feeling its a very unusual way of doing it. Initially I thought I would not be able to put a load on it but i placed a motor, specifically a small DC motor because I wanted to see how it behaves.

The NPN iRL520 transitor will power the 2nd arduino and the capacitor is there to smooth out the PWM signal. and the diode is to block the signal from being affected by the CAP.

I then generate 3 different signals on Arduino 1 and then use pulsein() on Arduino 2 to read them again and I can read different PWM signals reliably I can clearly distinguish between the 3 different signals, which can then be used to let power through to 3 different loads using more NPN FETs

One draw back is a voltage drop approximatly 2V, the diode alone creates a drop and aswell as the effect from PWM on the negative side of the Arduino 2/Capacitor.

But I guess that can be fixed by upping the voltage of the source and then use a regulator to get to the desired voltage

You really don't have 2 wire communications. What you have there is a transistor being used as a low side switch for another arduino. You are turning arduino2 on and off with pwm. I forsee you needing another arduino soon.

Where did you hook up a motor to? How did you use pulseIn and read results? USB and serial monitor?

That circuit looks unworkable to me - have you drawn it correctly? The capacitor will make the output
of the FET a DC level near ground whenever the FET is switching, or if the capacitor is too small, a
sawtooth wave.

This isn't a great power input to anything, and you lose the shared ground.

The diode / resistor part doesn't look like it should work, as these will swing with the 2nd Arduino's
ground potential, conveying nothing.

I suggest some study of how power and signal can be modulated together and separated, as if power-over-
ethernet, for the conventional approaches to this problem.

Well isnt any SMPS a on off signal, this is just way dirtier ?. (I'm not using this for anything its just an idea that I had in my mind)

I agree it may deteriorate very quickly. I also have a feeling the CAP prevents that from happening.
I'm willing to destroy it by leaving it on for a couple of days to see if it will in-deed crash and burn.

The motor is connected to the Negative line after the cap and positive line at the bottom.

I read the signals using pulesin and then use an if statement to light up 3 different LEDs to confirm that PulseIn recognizes the different signals sent from Arduino 1. Off coarse you cannot use serial t confirm the signals because then you are effectively powering it via the USB port. I didnt test the signals via the IO 0 and 1 pins.

Tonight I will share the sketch.

Ok so it looks like my wonky circuit is indeed unusual! :slight_smile:

But I have to make it clear though, It works, Maybe not viable for an application, but it works , I willing to make a youtube vid if you like. or even better why not try it your self. I will post the sketch tonight

tinman13kup:
You really don't have 2 wire communications.

Well, yes, he does! This is quite similar to the operation of the Dallas One-Wire devices such as the DS18B20 temperature sensor, but only in one direction.

It is most certainly inefficient, but the biggest problem in this case is that it is switching the ground leg, meaning that the second device must be completely isolated from any other connections. It in some way resembles 20 mA loop communication where the sensor device is powered by the communication link. It obviously could be rearranged with a little more complexity, so that the supply rather than the ground line was switched.

And - the diagram is wrong! :astonished: The capacitor should be after the diode, not directly across the communication line. :grinning:

I switched the negative line because its the only Transistor I had at hand.

The drawing isnt wrong the CAP is after the diode look closley, the cap is not accross the comm line its across the power line.

EDIT , You are RIGHT it is wrong! :slight_smile: The Diode should be in line of the neg towards the cap.

I updated the picture.

Below is the sketch for Arduino 2

unsigned long Duration;
void setup() {
pinMode(13, OUTPUT);
pinMode(8, INPUT);
}

void loop() {

if(Duration>=24700 && Duration<=25000 ){digitalWrite(10, HIGH); digitalWrite(11, LOW);digitalWrite(12, LOW); }
if(Duration>=29700 && Duration<=30000 ){digitalWrite(11, HIGH); digitalWrite(10, LOW);digitalWrite(12, LOW);}
if(Duration>=34700 && Duration<=35000 ){digitalWrite(12, HIGH); digitalWrite(10, LOW);digitalWrite(11, LOW);}
if(Duration>=39700 && Duration<=40000 )
{
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
}
//Turn off All LEDS
if(Duration>=9700 && Duration<=10000 )
{
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
}
Duration = pulseIn(8, LOW);

}

And the sketch for Arduino 1

int PWMDelay=10;
int Counter =0;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);

}
void loop() {
Counter++;
if(Counter>=1000){Counter=0;PWMDelay=10;}

//Send Different Signals based on counter
if(Counter>=200){PWMDelay=25;}
if(Counter>=400){PWMDelay=30;}
if(Counter>=600){PWMDelay=35;}
if(Counter>=800){PWMDelay=40;}

Serial.println(Counter);

digitalWrite(13, HIGH);
delay(PWMDelay);
digitalWrite(13, LOW);
delay(PWMDelay);

}

PWM on an IRL520 without current limiting resistor also doesn't bode too well for the pin driving the gate... That gate takes 12 nC of charge, so similar to a 12 nF capacitor.

wvmarle:
PWM on an IRL520 without current limiting resistor also doesn't bode too well for the pin driving the gate... That gate takes 12 nC of charge, so similar to a 12 nF capacitor.

12nC of charge @ 5V is more like 2.4 nF cap. If it is dangerous for the pin is interesting (and AFAIK unanswered) question.