Guten Tag,
ich habe nun schon 2x 10 MSGEQ7 ICs aus China bestellt - ALLE können nicht kaputt sein, aber was ist das Problem?
Ich habe die Schaltung schon öfter (mit verschiedenen Bauteilen) aufgebaut wie im Datenblatt (Ich habe meine eigene Zeichnung angehängt - Ich verwende vorerst nur eine Seite des Stereo-Signals.) und schon diverse Codes auf meinem ELEGOO UNO R3 versucht.
Leicht von mir abgeänderter Code, aus dem WWW (Ich habe nur die Ausgabe auf dem Seriellen Monitor hinzugefügt):
// Hardware-specific defines
#define MSGEQ7_STROBE_PIN 7
#define MSGEQ7_RESET_PIN 8
#define MSGEQ7_ANALOG_PIN A0
#define NUM_FREQUENCY_BANDS 7
// Duemilanove only has 6 PWM outputs, so the last LED won't respond properly. Your
// board may have more PWM outputs. Typically you only want to monitor the lowest
// frequency bands because that is where the beat is.
int led[NUM_FREQUENCY_BANDS] = {3, 5, 6, 9, 10, 11, 0};
// There is a concept of "persistence of vision" with LED's. The LED has to be on long enough
// for the eye to recognise that it is on. When a high volume is received on a frequency band,
// The LED is turned on (at a high PWM value) and then gradually faded until the next beat in
// that frequency.
int ledPWMValue[NUM_FREQUENCY_BANDS] = {0, 0, 0, 0, 0, 0, 0};
void setup() {
// Set the LED pins as outputs
for (int i=0; i<NUM_FREQUENCY_BANDS; i++)
pinMode(led[i], OUTPUT);
Serial.begin(9600);
// Set up the MSGEQ7 IC
pinMode(MSGEQ7_ANALOG_PIN, INPUT);
pinMode(MSGEQ7_STROBE_PIN, OUTPUT);
pinMode(MSGEQ7_RESET_PIN, OUTPUT);
digitalWrite(MSGEQ7_RESET_PIN, LOW);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
}
// This loop executes around 100 times per second
void loop() {
Serial.println("---------------------LOOP START------------");
int frequencyBandVolume;
// Toggle the RESET pin of the MSGEQ7 to start reading from the lowest frequency band
digitalWrite(MSGEQ7_RESET_PIN, HIGH);
digitalWrite(MSGEQ7_RESET_PIN, LOW);
// Read the volume in every frequency band from the MSGEQ7
for (int i=0; i<NUM_FREQUENCY_BANDS; i++) {
digitalWrite(MSGEQ7_STROBE_PIN, LOW);
delayMicroseconds(30); // Allow the output to settle
frequencyBandVolume = analogRead(MSGEQ7_ANALOG_PIN);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
// The read value is 10-bit (0 to 1024). PWM needs a value from 0 to 255, so divide by 4
frequencyBandVolume = frequencyBandVolume >> 2;
// Fade the current LED value for this band
ledPWMValue[i] = ledPWMValue[i] > 7? ledPWMValue[i] - 7 : 0;
// Don't show the lower values
if (frequencyBandVolume > 70) {
// If the new volume is greater than that currently being showed then show the higher volume
if (frequencyBandVolume > ledPWMValue[i])
ledPWMValue[i] = frequencyBandVolume;
}
// Set the LED PWM value to the frequency band's volume
analogWrite(led[i], ledPWMValue[i]);
Serial.println(ledPWMValue[i]);
}
// Wait before executing this loop again
delay(10);
}
Ich habe auch schon versucht ein paar Delays hinzuzufügen, um dem Diagram im Datasheet (S 4) mehr zu entsprechen
/*
MSGEQ7 Demo app
Look for the breakout board on www.whizoo.com
This code runs on an Arduino Duemilanove, but will run on other Arduino models.
Connections:
- GND to GND on MSGEQ7 breakout board, and LED's
- 5V to VDD on MSGEQ7 breakout board
- A0 to OUT on MSGEQ7 breakout board
- D7 to STROBE on MSGEQ7 breakout board
- D8 to RESET on MSGEQ7 breakout board
- D3 to LED 0 (indicator for frequency band 0)
- D5 to LED 1 (indicator for frequency band 1)
- D6 to LED 2 (indicator for frequency band 2)
- D9 to LED 3 (indicator for frequency band 3)
- D10 to LED 4 (indicator for frequency band 4)
- D11 to LED 5 (indicator for frequency band 5)
*/
// Hardware-specific defines
#define MSGEQ7_STROBE_PIN 7
#define MSGEQ7_RESET_PIN 8
#define MSGEQ7_ANALOG_PIN A0
#define NUM_FREQUENCY_BANDS 7
// Duemilanove only has 6 PWM outputs, so the last LED won't respond properly. Your
// board may have more PWM outputs. Typically you only want to monitor the lowest
// frequency bands because that is where the beat is.
int led[NUM_FREQUENCY_BANDS] = {3, 5, 6, 9, 10, 11, 0};
// There is a concept of "persistence of vision" with LED's. The LED has to be on long enough
// for the eye to recognise that it is on. When a high volume is received on a frequency band,
// The LED is turned on (at a high PWM value) and then gradually faded until the next beat in
// that frequency.
int ledPWMValue[NUM_FREQUENCY_BANDS] = {0, 0, 0, 0, 0, 0, 0};
void setup() {
// Set the LED pins as outputs
for (int i=0; i<NUM_FREQUENCY_BANDS; i++) {
pinMode(led[i], OUTPUT);
}
Serial.begin(9600);
// Set up the MSGEQ7 IC
pinMode(MSGEQ7_ANALOG_PIN, INPUT);
pinMode(MSGEQ7_STROBE_PIN, OUTPUT);
pinMode(MSGEQ7_RESET_PIN, OUTPUT);
digitalWrite(MSGEQ7_RESET_PIN, LOW);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
}
// This loop executes around 100 times per second
void loop() {
int frequencyBandVolume;
Serial.println("----------------START-----------");
// Toggle the RESET pin of the MSGEQ7 to start reading from the lowest frequency band
digitalWrite(MSGEQ7_RESET_PIN, HIGH);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
delayMicroseconds(18); // ts 18uS
digitalWrite(MSGEQ7_STROBE_PIN, LOW);
delayMicroseconds(80); // tr - ts (tr 100uS angenommen, nicht 100nS)
digitalWrite(MSGEQ7_RESET_PIN, LOW);
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
delayMicroseconds(72); // trs
// digitalWrite(MSGEQ7_STROBE_PIN, LOW); //Vllt das hier löschen, weil in der for Schleife schon
// Read the volume in every frequency band from the MSGEQ7
for (int i=0; i<NUM_FREQUENCY_BANDS; i++) {
digitalWrite(MSGEQ7_STROBE_PIN, LOW);
delayMicroseconds(34); // to-2
frequencyBandVolume = analogRead(MSGEQ7_ANALOG_PIN);
delayMicroseconds(2); // tss/2 - to-2
digitalWrite(MSGEQ7_STROBE_PIN, HIGH);
// The read value is 10-bit (0 to 1024). PWM needs a value from 0 to 255, so divide by 4
frequencyBandVolume = frequencyBandVolume >> 2;
// Fade the current LED value for this band
ledPWMValue[i] = ledPWMValue[i] > 7? ledPWMValue[i] - 7 : 0;
// Don't show the lower values
if (frequencyBandVolume > 70) {
// If the new volume is greater than that currently being showed then show the higher volume
if (frequencyBandVolume > ledPWMValue[i])
ledPWMValue[i] = frequencyBandVolume;
}
// Set the LED PWM value to the frequency band's volume
analogWrite(led[i], ledPWMValue[i]);
Serial.println(ledPWMValue[i]);
}
//testloop für LEDS
for (int i = 0; i<NUM_FREQUENCY_BANDS; i++) {
analogWrite(led[i], LOW);
delay(30);
}
// Wait before executing this loop again
delay(10);
}
Allerdings verstehe ich auch nicht, warum im Diagram tr = 100nS doppelt so lange wie ts = 18uS ist. usw... die Proportionen sind für meine Begriffe komplett wirr und unpassend!? deshalb habe ich im Code auch ein mal 100 uS statt nS für tr angenommen. Es gab keine Änderungen in den Ausgaben.
Im Seriellen Monitor gibt dieser Code bei 2 meiner Chips für jedes Band 0 aus. Ich nehme an diese sind defekt? Bei den anderen Chips, gibt er für alle Bänder 194, für alle Bänder 204, 180 usw. aus.
Ob Musik eingespeist wird macht keinen Unterschied!
Auf jeden Fall sind alle Bänder immer identisch.
Im Datasheet auf Seite 3 ist für den IC-Pin 2 "Negative Power Supply Typically 0 Volts" - Ich habe diesen mit GND verbunden (siehe Anhang) - ist das ein Fehler? Ich verbinde die die Erde vom Sereo Kabel auch einfach mit der Erde von der Schaltung, diese Erde geht auf den GND Pin des Arduinos.
Fällt jemand ein Fehler auf? Ich danke für jede Hilfe!
Freundliche Grüße, Klausi
Bild anhängen hat nicht geklappt. Hier an anderer Stelle: IMG-20201120-100644 hosted at ImgBB — ImgBB