wndqls99
Posts: 2
Joined: Mon Nov 11, 2019 1:27 am

Two adruino are connected to the raspberry via usb, but one is reconnected during processing code is running

Mon Nov 11, 2019 1:40 am

I try to solve this a month..but still problem...



I want to make below led-matrix spectrum.

Thumbnail image
Image

https://youtu.be/X35HbE7k3DA




※Environment

Device UML
Image

One Raspberry pi 3 : 2019-09-26-raspbian-buster-full

Two arduino uno with each matrix shield and 16x32 matrix

One usb Microphone



If i attached two arduino Uno to raspberry pi and try to run Processing code(.pde) , one of them is reattached to raspberry pi.

The other one is still working well..

If i connect these arduinos to windows and running pde file...It works well.
(two matrix are showing spectrum well)

What should I do???
Is this code problem? or raspberry problem?

I really need to solve this...





I already tried....

1. Reloaded ino code to both arduino Uno.
(both arduino has same code)

2. Changed boardrate number 115200 -> other number
(but it must be 115200 to running well)

3. Add arduino to udev rules like below link.
https://www.intorobotics.com/how-to-set ... no-devices

4. Cross exchange each matrix and arduino.

5. Try to use arduino mega with same code.




Here is the arduino code(.ino) and Processing Code(.pde)
https://github.com/snskreationz/Real-Ti ... m-Analyzer

arduino Uno Matrix Pin number

Code: Select all

#define CLK 8
#define LAT 10
#define OE  9
#define A   A0
#define B   A1
#define C   A2

Main processing code

Code: Select all

import ddf.minim.analysis.*;
import ddf.minim.*;
import processing.serial.*; 
 
Serial port1; 
Serial port2;
 
Minim minim;
AudioInput in;
FFT fft;

int buffer_size = 4096; 
float sample_rate = 200000;

int freq_width = 250; // <-O-> set the frequency range for each band over 400hz. larger bands will have less intensity per band. smaller bands would result in the overall range being limited

//arrays to hold the 64 bands' data
int[] freq_array = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float[] freq_height = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup()
{
  size(200, 200);

  minim = new Minim(this);
  port1 = new Serial(this, "COM8" , 115200); // <-O-> set baud rate and port for first RGB matrix
// Here can be changed to "/dev/ttyACM0" via Raspberry pi
  //port2 = new Serial(this, "COM5" , 115200); // <-O-> set baud rate and port for second RGB matrix
// Here can be changed to "/dev/ttyACM1" via Raspberry pi
 
  in = minim.getLineIn(Minim.MONO,buffer_size,sample_rate);
 
  // create an FFT object that has a time-domain buffer 
  // the same size as line-in's sample buffer
  fft = new FFT(in.bufferSize(), in.sampleRate());
  // Tapered window important for log-domain display
  fft.window(FFT.HAMMING);
}

Here are the kernel logs for Raspebrry pi

Code: Select all

Nov 11 00:17:27 raspberrypi kernel: [ 5974.165722] Under-voltage detected! (0x00050005)
Nov 11 00:17:27 raspberrypi kernel: [ 5974.665649] usb 1-1.3: new full-speed USB device number 9 using dwc_otg
Nov 11 00:17:27 raspberrypi kernel: [ 5974.809539] usb 1-1.3: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
Nov 11 00:17:27 raspberrypi kernel: [ 5974.809556] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=220
Nov 11 00:17:27 raspberrypi kernel: [ 5974.809566] usb 1-1.3: Manufacturer: Arduino (www.arduino.cc)
Nov 11 00:17:27 raspberrypi kernel: [ 5974.809576] usb 1-1.3: SerialNumber: 55639313932351518040
Nov 11 00:17:27 raspberrypi kernel: [ 5974.810729] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device ---------------------> connected first arduino
Nov 11 00:17:28 raspberrypi kernel: [ 5975.685661] usb 1-1.2: new full-speed USB device number 10 using dwc_otg
Nov 11 00:17:28 raspberrypi kernel: [ 5975.829541] usb 1-1.2: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
Nov 11 00:17:28 raspberrypi kernel: [ 5975.829558] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
Nov 11 00:17:28 raspberrypi kernel: [ 5975.829569] usb 1-1.2: Manufacturer: Arduino (www.arduino.cc)
Nov 11 00:17:28 raspberrypi kernel: [ 5975.829578] usb 1-1.2: SerialNumber: 8563431373935121D0B2
Nov 11 00:17:28 raspberrypi kernel: [ 5975.830752] cdc_acm 1-1.2:1.0: ttyACM1: USB ACM device --------------------->  connected second arduino
Nov 11 00:17:33 raspberrypi kernel: [ 5980.405877] Voltage normalised (0x00000000) --------------------->  almost at this time starting processing code
Nov 11 00:17:37 raspberrypi kernel: [ 5985.121964] usb 1-1.2: USB disconnect, device number 10
Nov 11 00:17:37 raspberrypi kernel: [ 5985.122315] cdc_acm 1-1.2:1.0: failed to set dtr/rts
Nov 11 00:17:38 raspberrypi kernel: [ 5985.425669] usb 1-1.2: new full-speed USB device number 11 using dwc_otg
Nov 11 00:17:38 raspberrypi kernel: [ 5985.569812] usb 1-1.2: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
Nov 11 00:17:38 raspberrypi kernel: [ 5985.569831] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
Nov 11 00:17:38 raspberrypi kernel: [ 5985.569843] usb 1-1.2: Manufacturer: Arduino (www.arduino.cc)
Nov 11 00:17:38 raspberrypi kernel: [ 5985.569853] usb 1-1.2: SerialNumber: 8563431373935121D0B2
Nov 11 00:17:38 raspberrypi kernel: [ 5985.571468] cdc_acm 1-1.2:1.0: ttyACM2: USB ACM device --------------------->  reattached second arduino automatically
Nov 11 00:17:39 raspberrypi kernel: [ 5986.645829] Under-voltage detected! (0x00050005)
Nov 11 00:17:43 raspberrypi kernel: [ 5990.805775] Voltage normalised (0x00000000)




I really want to run both arduino spectrum via raspberry pi.

MarkDH102
Posts: 352
Joined: Fri Feb 13, 2015 3:18 pm

Re: Two adruino are connected to the raspberry via usb, but one is reconnected during processing code is running

Mon Nov 11, 2019 7:31 am

The only thing that I can see is an undervoltage on the Pi.
How are you powering the Arduinos? 3V3 or 5V? From the Pi or from a separate power supply?
Maybe the voltage on the Arduino is dropping enough to cause the BOD (brown out detector) on the Arduino ATMEGA328 chip to become activated thus forcing a reset of the Arduino? The brown out detector threshold is set in the bootloader of the Arduino.

wndqls99
Posts: 2
Joined: Mon Nov 11, 2019 1:27 am

Re: Two adruino are connected to the raspberry via usb, but one is reconnected during processing code is running

Mon Nov 11, 2019 12:41 pm

MarkDH102 wrote:
Mon Nov 11, 2019 7:31 am
The only thing that I can see is an undervoltage on the Pi.
How are you powering the Arduinos? 3V3 or 5V? From the Pi or from a separate power supply?
Maybe the voltage on the Arduino is dropping enough to cause the BOD (brown out detector) on the Arduino ATMEGA328 chip to become activated thus forcing a reset of the Arduino? The brown out detector threshold is set in the bootloader of the Arduino.
Thank you for answer my question!
Your right... it's under-voltage problem.. BOD (brown out detector)...
I given more power to arduino and it works fine:)

User avatar
scruss
Posts: 2542
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Two adruino are connected to the raspberry via usb, but one is reconnected during processing code is running

Mon Nov 11, 2019 2:07 pm

As your Arduinos also have unique serial numbers (in kernel logs, SerialNumber), you can also identify which is which by the entries in /dev/serial/

But the undervoltage is an extra and unwanted issue.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Return to “General discussion”