Arduino serial communication

Hallo

My problem may be a little bit hard to solve, but I really do not understand the problem at all. I have the following circuit which you can see in the picture.


I have added a kapacitor from emitter to Ground and flyback diode from emitter to Ground. The idea is to have a signal useing serial communication from a computer runnning into the RX line on 16 different Arduinos. The 16 Arduinos should be able to control a TIP122 transistor which then should be able to activate a solenoid actuator. The Arduinos have the following code on them

//Hent Midi Library
#include <MIDI.h>

//Åben et standart MIDI objekt
MIDI_CREATE_DEFAULT_INSTANCE();

// -----------------------------------------------------------------------------


// Pinouts til aktuatorne
#define GPIO0 5
#define GPIO1 6
#define GPIO2 9
#define GPIO3 10
#define GPIO4 11
#define GPIO5 3


// -----------------------------------------------------------------------------

//Unit id
const int unitIndex = 9                                                                                                                                         ;

void setup()
{
  MIDI.begin();           // Start MIDI, standard på kanal 1
  Serial.begin(115200);   //Start Serial komunikation
  
  //Sæt punouts til output
  pinMode(GPIO0, OUTPUT);
  pinMode(GPIO1, OUTPUT);
  pinMode(GPIO2, OUTPUT);
  pinMode(GPIO3, OUTPUT);
  pinMode(GPIO4, OUTPUT);
  pinMode(GPIO5, OUTPUT);
  
}

void loop()
{
  if (MIDI.read())                //Check om der kan læses en MIDI Komando
  {
    //Hvis Midi komandoen er NOTEON Læses data
    if (MIDI.getType() == midi::NoteOn) {
      //Hvis Data 1 stemmer overens med de tildelte pins skrives et analogt output der svarer til værdien af data 2
      switch (MIDI.getData1()) {
        case (21 + unitIndex * 6):
          analogWrite(GPIO0, MIDI.getData2() * 0.666 + 170.34);
          break;
        case (22 + unitIndex * 6):
          analogWrite(GPIO1, MIDI.getData2() * 0.666 + 170.34);
          break;
        case (23 + unitIndex * 6):
          analogWrite(GPIO2, MIDI.getData2() * 0.666 + 170.34);
          break;
        case (24 + unitIndex * 6):
          analogWrite(GPIO3, MIDI.getData2() * 0.666 + 170.34);
          break;
        case (25 + unitIndex * 6):
          analogWrite(GPIO4, MIDI.getData2() * 0.666 + 170.34);
          break;
        case (26 + unitIndex * 6):
          analogWrite(GPIO5, MIDI.getData2() * 0.666 + 170.34);
          break;
      }
      //Hvis Midi komandoen er NOTEOFF Læses Data
    } else if (MIDI.getType () == midi::NoteOff) { 
      //Hvis Data 1 stemmer overens med de tildelte pins slukkes den pågelende pin
      switch (MIDI.getData1()) {
        case (21 + unitIndex * 6):
          analogWrite(GPIO0, 0);
          break;
        case (22 + unitIndex * 6):
          analogWrite(GPIO1, 0);
          break;
        case (23 + unitIndex * 6):
          analogWrite(GPIO2, 0);
          break;
        case (24 + unitIndex * 6):
          analogWrite(GPIO3, 0);
          break;
        case (25 + unitIndex * 6):
          analogWrite(GPIO4, 0);
          break;
        case (26 + unitIndex * 6):
          analogWrite(GPIO5, 0);
          break;
      }
    }
  }
}

I have 16 of the circuits on 16 PCB's with code. The PCB's are chained with RST, 5V and RX via screw terminals. A picture of the PCB can be seen below

The arduino chained can be seen below

My problem is the following. I am able to connect one PCB and control the actuator with 12 V connected to the PCB via a separat cobber line on the PCB. But when i connect two or more PCB's together then i am unable to control the arduino. I can see that the LED's activate, but not in the order that i tell them to. It seems random. When i disconnect 12 V then everything works fine. I can connect all of them and they work fine, but the second i connect 12 V to the circuits then it does not work. None of the components get destroyed when placed in the PCB and 12 V is connected.

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Quick experiment:

  Serial.begin(115200);   //Start Serial komunikation
  Serial.println("system reset!\n");
  delay(777);

You don't show where 12 volts is coming from or going to, or I don't see it.

You show no flyback diodes across the load which is the solenoid.

You say it goes bad right away, do you mean irrespective of activating any solenoid(s)?

a7

Your schematic shows three connectors (P2, P4, and P3) all going to your RX and TX pins. Why?

It is because they are connected to screw terminals. For testing and installation then they are both able to be connected besidde eachother and from behind the circuit.

Unfortunately I am unable to test anything right now Because the hardware is used for a School exam project. Regarding the flyback diodes I forgot to mention that they where added later on together with a kapacitor. 12 V is the VCC line and is only connected to the collector on the transistor nothing else. I have thought alot about the problem and I have a theory. The communication comes from a computer to a Arduino without a chip. This is just to get accesse to the tx and rx line. Normally the cables are shielded to prevent noise, but my wires are around 1 meter without shielding. Could this be the problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.