Go Down

Topic: Beginner needs help with music organ/spectrum. (Read 4572 times) previous topic - next topic

thsamog

#30
May 13, 2016, 01:01 pm Last Edit: May 13, 2016, 01:07 pm by thsamog
Hello, it's been a long time.

Now we have all components and time to start building this thing.

Except we got 220K ohm resistors when we need 200K ohm resistors.
https://123d.circuits.io/circuits/1547536-car-rgb-color-organ-project#schematic

R1L & R1R

So my question is can we still use 220K ohm resistors ? Or do we NEED 200K ohm resistors ?

EDIT or maybe its better to use 270K ohm ?

Grumpy_Mike

Yes you can use 220K. It might just shift the peak of the filter frequencies by a few tens of Hz but it will not be noticeable.

thsamog

Thanks for your answer, we will get the right ones just to make sure but we will start building with 220K.

Except now we have two more problems.

1. I think one of my MSGEQ7 is broken. I switched them around and everything but still one chip shows only 0 0 0 0 0 0 0.

2. The numbers i get don't make any sense for me. Whole row is same (almost) and its like volume. When i turn music louder the numbers get bigger.

My serial output: http://laravel.io/bin/bEMnX

My code that i use is this: http://laravel.io/bin/Xyqvj

Credit goes to: http://www.eetimes.com/author.asp?doc_id=1323030&page_number=3

Grumpy_Mike

Quote
I switched them around and everything but still one chip shows only 0 0 0 0 0 0 0.
Does the 0s follow the chip or does it stay on the same side.
It is likely you have wired things wrong.


thsamog

No, if i swap the chips the 0's change side. Or if i change A4 & A5 but that one makes sense.

Grumpy_Mike

Ok so that points to one faulty chip. It could be the other is faulty as well or as I said is not wired correctly. This includes things like the bread board not making connections correctly.
The software too is a bit simplistic on the reading in side. Look at the data sheet and you will see that the software you are using doesn't make the waveform that the data sheet says it needs in order to get the samples out correctly.
You also might have swapped the reset and strobe lines lines.

thsamog

#36
Dec 10, 2016, 09:15 pm Last Edit: Dec 10, 2016, 09:23 pm by thsamog
It has been a long time but the project is not dead.

We have been tweaked it somehow and allready included an android app.
But now we have faced couple problems.

1. First we got a idea to start uploading code from bluetooth.

   We couldnt get it anyhow to work. Windows connects to it and gets right COM's.
   We got a lot of different errors but we got ' Not in sync: resp=0x** ' the most.
   Now we are using a arduino board to upload a data.

2. Then we started to move on and we tryed to get the code working with usb serial.
   Our problem is that we cant get and save data variable from serial as an string.
   I would use this string to run different profiles. Also we would like to adjust brightness.

   I have tryed different compinations from google.
   
   I have still however figuret out what is right way to control data variable and brightness       variable   differently.

Also i would like to do some saving there and here but im not sure how this would work out.

Here is code: https://github.com/alanaasmaa/RGB-Color-Organ


thsamog

I got the Serial to work. Now i can get strings, but now when i include this
Quote
if (data == "OFF")
  {
    for (int i = 0; i < 7; i++)
    {
    Palatis::SoftPWM.set(pwmLEDsLeft, 1);
    Palatis::SoftPWM.set(pwmLEDsRight, 1);
    }
  }
my code crashes. And arduino does not do anything it works like one sec and then stops working.

Full code is here:
Quote
#define SOFTPWM_OUTPUT_DELAY
#include <SoftPWM.h>                                  // Include Palatis SoftPWM libary github.com/Palatis/arduino-softpwm
SOFTPWM_DEFINE_CHANNEL(3, DDRD, PORTD, PORTD3);       // Arduino pin 3
SOFTPWM_DEFINE_CHANNEL(5, DDRD, PORTD, PORTD5);       // Arduino pin 5
SOFTPWM_DEFINE_CHANNEL(6, DDRD, PORTD, PORTD6);       // Arduino pin 6
SOFTPWM_DEFINE_CHANNEL(7, DDRD, PORTD, PORTD7);       // Arduino pin 7
SOFTPWM_DEFINE_CHANNEL(8, DDRB, PORTB, PORTB0);       // Arduino pin 8
SOFTPWM_DEFINE_CHANNEL(9, DDRB, PORTB, PORTB1);       // Arduino pin 9
SOFTPWM_DEFINE_CHANNEL(10, DDRB, PORTB, PORTB2);      // Arduino pin 10
SOFTPWM_DEFINE_CHANNEL(11, DDRB, PORTB, PORTB3);      // Arduino pin 11
SOFTPWM_DEFINE_CHANNEL(12, DDRB, PORTB, PORTB4);      // Arduino pin 12
SOFTPWM_DEFINE_CHANNEL(13, DDRB, PORTB, PORTB5);      // Arduino pin 13
SOFTPWM_DEFINE_CHANNEL(14, DDRC, PORTC, PORTC0);      // Arduino pin A0
SOFTPWM_DEFINE_CHANNEL(15, DDRC, PORTC, PORTC1);      // Arduino pin A1
SOFTPWM_DEFINE_CHANNEL(16, DDRC, PORTC, PORTC2);      // Arduino pin A2
SOFTPWM_DEFINE_CHANNEL(17, DDRC, PORTC, PORTC3);      // Arduino pin A3
SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(14, 102);       // Define how many pwm channels project uses and how many steps it has
// MSGEQ7 bands = 63Hz, 160Hz, 400Hz, 1,000Hz, 2,500Hz, 6,250Hz, 16,000Hz
static volatile uint8_t v = 0;
int ctrlReset = 2;                                    // Digital pin 2 = signal to reset MSGEQ7s
int ctrlStrobe = 4;                                   // Digital pin 4 = signal to strobe (read data from) MSGEQ7s
int channelLeft = A5;                                 // Analog pin A5 = spectrum data from left channel
int channelRight = A4;                                // Analog pin A4 = spectrum data from right channel
int spectrumLeft[7];                                  // Array to store 7 bands of spectrum data from left channel
int spectrumRight[7];                                 // Array to store 7 bands of spectrum data from right channel
int pwmLEDsLeft[] = {3, 5, 6, 7, 8, 9, 10};           // Array to store data where leds are connected.
int pwmLEDsRight[] = {11, 12, 13, 14, 15, 16, 17};    // Array to store data where leds are connected.
int brightness = 50;
String data = "ON";                                          // Mode ON = Music, 2 = Still, Anything else = off
String bluetooth;

void setup()
{
  Serial.begin(9600);
  pinMode(ctrlReset, OUTPUT);                         // Define reset as output
  pinMode(ctrlStrobe, OUTPUT);                        // Define strobe as output
  digitalWrite(ctrlReset, LOW);                       // Pull the reset signal low
  digitalWrite(ctrlStrobe, HIGH);                     // Drive the strobe signal high
  Palatis::SoftPWM.begin(60);                         // Begin with 60hz pwm frequency
  //Palatis::SoftPWM.printInterruptLoad();            // Print interrupt load for diagnostic purposes
}


void loop()
{
  while (Serial.available())
  {
    delay(10);
    char c = Serial.read();
    if (c == ':')
    {
      break;
    } 
    bluetooth += c;
  }
  if (bluetooth.length() > 0) {
    data = bluetooth;
    bluetooth="";
  }
  if (data == "ON")
  {
    readMSGEQ7();
    writeLEDs();
  }
  if (data == "OFF")
  {
    for (int i = 0; i < 7; i++)
    {
    Palatis::SoftPWM.set(pwmLEDsLeft, 1);
    Palatis::SoftPWM.set(pwmLEDsRight, 1);
    }
  }
  Serial.print(data);
  Serial.print("\n");
}

void readMSGEQ7()
{                                                       // Read the seven spectrum bands from the MSGEQ7 chips
  digitalWrite(ctrlReset, HIGH);                        // Pulse the reset signal, which causes
  digitalWrite(ctrlReset, LOW);                         // the MSGEQ7s to latch the spectrum values
  delayMicroseconds(72);                                // Delay to meet minimum reset-to-strobe time
  int nF = 50;                                          // Noise filter level.
  for (int i = 0; i < 7; i++)                           // Cycle through the 7 spectrum bands
  {
    digitalWrite(ctrlStrobe, LOW);                      // Read current band (then increment to next band)
    delayMicroseconds(36);                              // Wait for outputs to settle
    spectrumLeft = analogRead(channelLeft) / 10;     // Store current values from left & right channels
    spectrumRight = analogRead(channelRight) / 10;   // Divide 0-1023 by 10 to give about 0-100
    //if (spectrumLeft < nF) spectrumLeft = 0;      // Noise filter left
    //if (spectrumRight < nF) spectrumRight = 0;    // Noise filter right
    digitalWrite(ctrlStrobe, HIGH);
    delayMicroseconds(36);                              // Delay to meet minimum strobe-to-strobe time
  }
}

void writeLEDs()
{
  for (int i = 0; i < 7; i++) {
    Palatis::SoftPWM.set(pwmLEDsLeft, spectrumLeft);
    Palatis::SoftPWM.set(pwmLEDsRight, spectrumRight);
    Serial.print(spectrumLeft);
    if (spectrumLeft < 10) Serial.print(" ");
    Serial.print(" ");
    Serial.print(spectrumRight);
    if (spectrumRight < 10) Serial.print(" ");
    Serial.print(" | ");
  }
  Serial.print("\n");
}


Go Up