Je viens de passer sur un nouvel arduino, le DUE, et en essayant de passer mes progammes fonctionnants sur mon UNO sous le DUE, je rencontre un problème lors de la compilation :
Excusez mon français, je ne parle pas très bien. Je vais essayer d'expliquer le problème
Ouvrez le fichier Tone.cpp
Sur la ligne 23, vous trouverez #include <wiring.h>
Supprimer cette ligne et à la place insert #include <arduino.h>
Enregistrez le fichier
Ensuite, essayez à nouveau
Difficile de donner une réponse sans ton programme.
Mon programme n'est pas en cause a vrai dire j'ai le meme soucis avec les programmes de Test de la librairie Tone (DTMFTest, RTTTL et ToneTest !)
exemple avec ToneTest
// Duelling Tones - Simultaneous tone generation.
// To mix the output of the signals to output to a small speaker (i.e. 8 Ohms or higher),
// simply use 1K Ohm resistors from each output pin and tie them together at the speaker.
// Don't forget to connect the other side of the speaker to ground!
// This example plays notes 'a' through 'g' sent over the Serial Monitor.
// 's' stops the current playing tone. Use uppercase letters for the second.
#include "Tone.h"
int notes[] = { NOTE_A3,
NOTE_B3,
NOTE_C4,
NOTE_D4,
NOTE_E4,
NOTE_F4,
NOTE_G4 };
// You can declare the tones as an array
Tone notePlayer[2];
void setup(void)
{
Serial.begin(9600);
notePlayer[0].begin(11);
notePlayer[1].begin(12);
}
void loop(void)
{
char c;
if(Serial.available())
{
c = Serial.read();
switch(c)
{
case 'a'...'g':
notePlayer[0].play(notes[c - 'a']);
Serial.println(notes[c - 'a']);
break;
case 's':
notePlayer[0].stop();
break;
case 'A'...'G':
notePlayer[1].play(notes[c - 'A']);
Serial.println(notes[c - 'A']);
break;
case 'S':
notePlayer[1].stop();
break;
default:
notePlayer[1].stop();
notePlayer[0].play(NOTE_B2);
delay(300);
notePlayer[0].stop();
delay(100);
notePlayer[1].play(NOTE_B2);
delay(300);
notePlayer[1].stop();
break;
}
}
}
Erreur :
Arduino : 1.5.8 (Windows 8), Carte : "Arduino Due (Programming Port)"
ToneTest.pde:11:17: error: 'NOTE_A3' was not declared in this scope
ToneTest.pde:12:17: error: 'NOTE_B3' was not declared in this scope
ToneTest.pde:13:17: error: 'NOTE_C4' was not declared in this scope
ToneTest.pde:14:17: error: 'NOTE_D4' was not declared in this scope
ToneTest.pde:15:17: error: 'NOTE_E4' was not declared in this scope
ToneTest.pde:16:17: error: 'NOTE_F4' was not declared in this scope
ToneTest.pde:17:17: error: 'NOTE_G4' was not declared in this scope
ToneTest.pde:20:1: error: 'Tone' does not name a type
ToneTest.pde: In function 'void setup()':
ToneTest.pde:25:3: error: 'notePlayer' was not declared in this scope
ToneTest.pde: In function 'void loop()':
ToneTest.pde:40:9: error: 'notePlayer' was not declared in this scope
ToneTest.pde:57:28: error: 'NOTE_B2' was not declared in this scope
Erreur lors de la compilation.
Excusez mon français, je ne parle pas très bien. Je vais essayer d'expliquer le problème
Ouvrez le fichier Tone.cpp
Sur la ligne 23, vous trouverez #include <wiring.h>
Supprimer cette ligne et à la place insert #include <arduino.h>
Enregistrez le fichier
Ensuite, essayez à nouveau
Très bon francais mais c'est ce que j'expliquait sur mon premier post cela a déjà été fait
Salut,
à ma connaissance, la librairie Tone n'a pas été portée pour la Due, donc à moins de coder cette fonctionnalité toi-même (ou d'en trouver une version toute faite par ailleurs), c'est mort. C'est d'ailleurs ce que le compilateur essaie de te dire avec ces messages d'erreur, mais comme souvent d'une manière totalement absconse.
Salut,
à ma connaissance, la librairie Tone n'a pas été portée pour la Due, donc à moins de coder cette fonctionnalité toi-même (ou d'en trouver une version toute faite par ailleurs), c'est mort. C'est d'ailleurs ce que le compilateur essaie de te dire avec ces messages d'erreur, mais comme souvent d'une manière totalement absconse.
Merci pour ta réponse !
Pour ce qui est de coder moi même je raye cette possibilitée !
B@tto:
tone() n'est pas portée sur DUE, la principale raison étant qu'il y a un DAC donc bien mieux qu'un tone() ...
Je ne connais pas la DUE, mais si je ne me trompe pas, la fonction tone() sort un signale carré a fréquence variable tandis qu'un DAC sort une tension variable. Je ne comprends pas ta comparaison. Ce sont deux utilisations bien différente.
Après, si c'est pour faire du son, la d'accord, c'est mieux le DAC. Mais pour un simple bip, le DAC demande plus de resource. A confirmer.
Yep tu as raison, je pensais que chez la team Arduino il aurait étoffé un peu de ce côté la mais nada ... Pourtant ça serait pas la mer à boire que de coupler le DAC avec un timer
B@tto:
Yep tu as raison, je pensais que chez la team Arduino il aurait étoffé un peu de ce côté la mais nada ... Pourtant ça serait pas la mer à boire que de coupler le DAC avec un timer
Il y a 10 timers et 8 générateurs PWM sur les microcontrôleurs SAM3X8E.
Sortir un signal carré c'est un truc qui devrait pas prendre des années à coder.
La team arduino a réellement rien à foutre de ses utilisateurs ...
Bon vu que je suis pas un dieu du codage je n'arrive pas a intégré le code dans le lien a mon projet ... enfin meme le code seul je n'arrive pas a le validé ...
Il faudrait au minimum nous donner le message d'erreur que tu obtiens ou nous décrire précisément ce qui ne fonctionne pas comme prévu si tu veux recevoir des réponses efficaces...
Arduino : 1.5.8 (Windows 8), Carte : "Arduino Due (Programming Port)"
ToneTest.pde:11:17: error: 'NOTE_A3' was not declared in this scope
ToneTest.pde:12:17: error: 'NOTE_B3' was not declared in this scope
ToneTest.pde:13:17: error: 'NOTE_C4' was not declared in this scope
ToneTest.pde:14:17: error: 'NOTE_D4' was not declared in this scope
ToneTest.pde:15:17: error: 'NOTE_E4' was not declared in this scope
ToneTest.pde:16:17: error: 'NOTE_F4' was not declared in this scope
ToneTest.pde:17:17: error: 'NOTE_G4' was not declared in this scope
ToneTest.pde:20:1: error: 'Tone' does not name a type
ToneTest.pde: In function 'void setup()':
ToneTest.pde:25:3: error: 'notePlayer' was not declared in this scope
ToneTest.pde: In function 'void loop()':
ToneTest.pde:40:9: error: 'notePlayer' was not declared in this scope
ToneTest.pde:57:28: error: 'NOTE_B2' was not declared in this scope
Erreur lors de la compilation.
J'arrive pas >< désolé mais je comprends pas comment intégrer ca a mon code !
J'essaye de l'integrer a ToneTest par exemple :
// Duelling Tones - Simultaneous tone generation.
// To mix the output of the signals to output to a small speaker (i.e. 8 Ohms or higher),
// simply use 1K Ohm resistors from each output pin and tie them together at the speaker.
// Don't forget to connect the other side of the speaker to ground!
// This example plays notes 'a' through 'g' sent over the Serial Monitor.
// 's' stops the current playing tone. Use uppercase letters for the second.
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
/*
Tone generator
v1 use timer, and toggle any digital pin in ISR
funky duration from arduino version
TODO use FindMckDivisor?
timer selected will preclude using associated pins for PWM etc.
could also do timer/pwm hardware toggle where caller controls duration
*/
// timers TC0 TC1 TC2 channels 0-2 ids 0-2 3-5 6-8 AB 0 1
// use TC1 channel 0
#define TONE_TIMER TC1
#define TONE_CHNL 0
#define TONE_IRQ TC3_IRQn
void setup(void)
{
Serial.begin(9600);
notePlayer[0].begin(11);
notePlayer[1].begin(12);
}
void loop(void)
{
char c;
if(Serial.available())
{
c = Serial.read();
switch(c)
{
case 'a'...'g':
notePlayer[0].play(notes[c - 'a']);
Serial.println(notes[c - 'a']);
break;
case 's':
notePlayer[0].stop();
break;
case 'A'...'G':
notePlayer[1].play(notes[c - 'A']);
Serial.println(notes[c - 'A']);
break;
case 'S':
notePlayer[1].stop();
break;
default:
notePlayer[1].stop();
notePlayer[0].play(NOTE_B2);
delay(300);
notePlayer[0].stop();
delay(100);
notePlayer[1].play(NOTE_B2);
delay(300);
notePlayer[1].stop();
break;
}
}
}
// TIMER_CLOCK4 84MHz/128 with 16 bit counter give 10 Hz to 656KHz
// piano 27Hz to 4KHz
static uint8_t pinEnabled[PINS_COUNT];
static uint8_t TCChanEnabled = 0;
static boolean pin_state = false ;
static Tc *chTC = TONE_TIMER;
static uint32_t chNo = TONE_CHNL;
volatile static int32_t toggle_count;
static uint32_t tone_pin;
// frequency (in hertz) and duration (in milliseconds).
void tone(uint32_t ulPin, uint32_t frequency, int32_t duration)
{
const uint32_t rc = VARIANT_MCK / 256 / frequency;
tone_pin = ulPin;
toggle_count = 0; // strange wipe out previous duration
if (duration > 0 ) toggle_count = 2 * frequency * duration / 1000;
else toggle_count = -1;
if (!TCChanEnabled) {
pmc_set_writeprotect(false);
pmc_enable_periph_clk((uint32_t)TONE_IRQ);
TC_Configure(chTC, chNo,
TC_CMR_TCCLKS_TIMER_CLOCK4 |
TC_CMR_WAVE | // Waveform mode
TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC
chTC->TC_CHANNEL[chNo].TC_IER=TC_IER_CPCS; // RC compare interrupt
chTC->TC_CHANNEL[chNo].TC_IDR=~TC_IER_CPCS;
NVIC_EnableIRQ(TONE_IRQ);
TCChanEnabled = 1;
}
if (!pinEnabled[ulPin]) {
pinMode(ulPin, OUTPUT);
pinEnabled[ulPin] = 1;
}
TC_Stop(chTC, chNo);
TC_SetRC(chTC, chNo, rc); // set frequency
TC_Start(chTC, chNo);
}
void noTone(uint32_t ulPin)
{
TC_Stop(chTC, chNo); // stop timer
digitalWrite(ulPin,LOW); // no signal on pin
}
// timer ISR TC1 ch 0
void TC3_Handler ( void ) {
TC_GetStatus(TC1, 0);
if (toggle_count != 0){
// toggle pin TODO better
digitalWrite(tone_pin,pin_state= !pin_state);
if (toggle_count > 0) toggle_count--;
} else {
noTone(tone_pin);
}
}
int notes[] = { NOTE_A3,
NOTE_B3,
NOTE_C4,
NOTE_D4,
NOTE_E4,
NOTE_F4,
NOTE_G4 };
// You can declare the tones as an array
Tone notePlayer[2];
Et j'ai ce message :
ToneTest.pde: In function 'void setup()':
ToneTest.pde:118:3: error: 'notePlayer' was not declared in this scope
ToneTest.pde: In function 'void loop()':
ToneTest.pde:133:9: error: 'notePlayer' was not declared in this scope
ToneTest.pde:133:28: error: 'notes' was not declared in this scope
ToneTest.pde: At global scope:
ToneTest.pde:234:1: error: 'Tone' does not name a type
Erreur lors de la compilation.