[Solved] Connect 2 Arduinos with one Power Supply

Hey guys,

at the moment I'm working on a project for a temperature regulation. I have a touchscreen which displays the actual temperature and a given temperature which you can set with a rotary encoder. See the first image I attached.

For this I use an Arduino Due and an Arduino Uno (I had special reasons, why I needed 2, dont say "Well, just use 1!"). The power supply is connected to both of them so I just need one plug and one power supply, look @ the second image.

This works fairly well until I e.g. want to change the desired temperature. After I turn the rotary encoder around for a while, the arduino suddenly freezes, or thinks I pressed the button (the rotary encoder can be pressed), although I didnt. Sometimes the display starts to draw strange things, black boxes where normally the numbers are... When I now connect one of the arduinos with power over usb, the Arduino works perfectly again. Then I can turn around how much I like, everything's working fine. The problem is just when both are connected to power.

What's the problem here? My power supply works up to 1500mA, I measured the actual drain for both, it's about 250mA, so there shouldn't be problems with the current.

Any thoughts?

Thanks in advance.

MP

Edit: I cant upload the images as an attachment for "security reasons" so here you go:
#1:


#2:

We need a circuit of how everything is connected and programs used.

Weedpharma

We don't appreciate pictures that when you click on them lots of spam windows open up.

Hi

We don't appreciate pictures that when you click on them lots of spam windows open up.

Do a right click and save the image.

What is the voltage that you are supplying to the controllers.
If its 12V you may be overheating the 5V regulators on the controller boards due to the 7V drop.
Try 9V or as low as 7V to see if that improves it.

Tom.... :slight_smile:

Well, actually I wanted to regularly upload the images to the forum first, as I said, but it didn't work. And unfortunately I don't have a server to which I could upload them. May you provide me with a website, where I can upload them without any ads? I cant find one...
Edit: Better?

I'm supplying 9V. Later, when I'm back at the lab, I'm going to have a look @ it with a scope, maybe the power supply is quite unstable or maybe I can see some drops...

A circuit... Do you know a simple program to draw circuits? Paint/Gimp is quite a pain, but I dont want a program where I have to search/create the components first. Just want to draw it easily.

I can provide you some code snippets later about the problematic components, the whole code is rather complex and chaotic.

Hi,
If you use REPLY rather than QUICK REPLY and it has an attachment facility, so you can post your files as an attachment.

Of site storage can be a pain in the proverbial.

Tom.... :slight_smile:

How exactly do you connect the power supply to the boards? To Vin or Vcc? What voltage?

Do you have critical voltages measured by analogRead? Then fluctuations in Vcc will influence the readings. In this case use a different (stable) reference voltage (3.3 or 1.1V).

Just have a look at the second image. I simply soldered the two power jacks together. And 9V.
Well, the rotary encoder itself is read over high/low, so digitalread and the check if it is pressed, too.
But I think it's not a problem of the periphery itself since I also have wrong things displayed on the screen, too.

Background: There are 2 different states in my program. Active and not active. In non-active mode I can set the desired temperature, the value blinks all the time on the display. When I change it via rotary encoder the new temp will be displayed immediately. When I press the rotary encoder, the state changes in active. The blinking stops and the program compares desired and actual temp, doing things when it exceeds the tolerance.

When there is just the one power supply connected the Arduino sometimes thinks someone pressed the encoder although I didn't. And when I turn the rotary encoder and it should change the value on the display sometimes it hangs, just display the half number or sometimes just weird black boxes. When I turn around again, it's displayed right again.
Everything's working flawlessy when both are connected to their own power supply, so it's not program related!

How exactly do you connect the two power supplies? A common ground is required in either case - did you connect the Gnd lines even if two supplies are used?

Look @ this pic... That's all and it's always connected like this. No matter if I plug it into the external jack or in one of those jacks or in one jack and the other arduino over usb. And the problem is, when I just use 1 ps:

Your problem is nothing to do with connecting the power to two Arduinos. So you need to show us what you have for the rest of it. A schematic please, just draw one with a pen and paper photpgraph the results and attach it.
You have read the how to use this forum sticky haven't you?

Hi,
Can you tell us the part number/make of the encoder please?
Does it need output pullup resistors. that is, is the encoder output open-collector?

Tom...... :slight_smile:

Pin config:

pinMode(encoderSwitchPin, INPUT_PULLUP);
pinMode(encoder0PinA, INPUT_PULLUP);
pinMode(encoder0PinB, INPUT_PULLUP);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(relaisPin, OUTPUT);

Awfully drawn circuit but should do it, look @ attachment

The display sits directly on the Due, I didn't draw it.

I actually don't know which rotary encoder I used and I can't find any part number or the number is covered by the two-component adhesive.

Edit: This time I could upload it to attachment, don't know why I got the error in my first post

Are you connecting the I2C from the Due to the Uno without any level shifters? Maybe you are using a libiary on the UNO that disables the internal pull up resistors?

Not sure what the line round it't all is.

The line around just means the box ^^

Actually I thought about using level shifters, bcs of that 3,3V - 5V thingy, but I've tested the communication, it worked flawlessly all the time, high and low are recognized well all the time, and I've already read in several threads of people who've done it the same way, that it didn't make any problems cause the arduino is quite tolerant.

If it's the best for the pins... Dunno, if they are defective one day, I will know and spread the news :smiley:

But that shouldn't be related to my problem. Arduino Uno is somehow just for saving values and reloading them when the system is restarted.

Ok if you are just going to argue and ignore advice I am out of here. What is the point in putting more effort into a post when the recipient is so unresponsive.
Good luck.
Good bye.

MajorPain931:
Actually I thought about using level shifters, bcs of that 3,3V - 5V thingy, but I've tested the communication, it worked flawlessly all the time, high and low are recognized well all the time, and I've already read in several threads of people who've done it the same way, that it didn't make any problems cause the arduino is quite tolerant.

I wouldn't have the nerve to post something like:

  • I have exceeded the maximum permissible ratings for a device.
  • It doesn't work.
  • How do I fix it?

After I turn the rotary encoder around for a while, the arduino suddenly freezes, ...

Could be a coding problem. Did you post any code?

Why ignore? Why shouldn't I be able to give my own opinion about it? That's my point of view, if you think it should be related, you are free to explain it and I will listen to you and do everything to check it. I took every advice serious until now and thought about it, what do you expect? Sorry if u have the feeling of me ignoring your advices but if I'm sure that it's not related, because I tested it why shouldn't I write it?

About the I²C and why I think it's not the problem: I know it may not be a good solution and MAY damage the boards pins, but if I cut the connection between the arduinos (Due still runs then) I have the same problems. If I would've problems with my I²C connection I would never ask here for help, because I would test level shifters first, but that's not my concern.

Additional fact: When I'm in this hanging or bugging state and I just touch the USB Port of the Arduino with a USB cable or probably any grounded cable the Arduino starts working again.
EDIT: Yes, connecting the USB port of the Due to ground solves the problem. I actually don't know why but that's fact. A wire from my power supply's ground to the usb port should do the trick. Thanks everybody, even if I may have made some ppl grumpy, sry for that ^^

Code, here you go, all variables used in the interrupts are volatile:
For detection which way the encoder was turned (Once had a more compact code, but didn't work all the time, this one works):

attachInterrupt(encoder0PinA, updateEncoder, CHANGE);                         
attachInterrupt(encoder0PinB, updateEncoder, CHANGE);

void updateEncoder() {       
    switch (pos) {
      case 0:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == LOW && digitalRead(encoder0PinB) == HIGH) {
            pos = 1;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          } else if (digitalRead(encoder0PinA) == HIGH && digitalRead(encoder0PinB) == LOW) {
            pos = -1;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          }
        }
        break;
      case 1:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == LOW && digitalRead(encoder0PinB) == LOW) {
            pos = 2;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          }
        }
        break;
      case 2:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == HIGH && digitalRead(encoder0PinB) == LOW) {
            pos = 3;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          }
        }
        break;
      case 3:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == HIGH && digitalRead(encoder0PinB) == HIGH) {
            pos = 0;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
            tempsoll++;
          }
        }
        break;
      case -1:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == LOW && digitalRead(encoder0PinB) == LOW) {
            pos = -2;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          }
        }
        break;
      case -2:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == LOW && digitalRead(encoder0PinB) == HIGH) {
            pos = -3;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
          }
        }
        break;
      case -3:
        if (!(digitalRead(encoder0PinA) == state1Vorher && digitalRead(encoder0PinB) == state2Vorher)) {
          if (digitalRead(encoder0PinA) == HIGH && digitalRead(encoder0PinB) == HIGH) {
            pos = 0;
            state1Vorher = digitalRead(encoder0PinA);
            state2Vorher = digitalRead(encoder0PinB);
            tempsoll--;
          }
        }
        break;
    }
  }
}

And for the Encoder Switch:

 attachInterrupt(encoderSwitchPin, encoderSwitch, FALLING);

void encoderSwitch() {        
  if (encSwitchCounter.done() && startCounter > 3000) {         
    encSwitchCounter.reset();
    aktiv = !aktiv;                          //That's the switch between the monitoring and the set state I mentioned
    aktivchecked = false;
    checkfailure();             //Recheck if temp is out of tolerance
    istre();                        //Redraw the temperature to screen
  }
}