===== Documentation du composant===== https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjJ9tSfjPzKAhWK2BoKHe-HAZQQFggkMAA&url=http%3A%2F%2Fwww.ti.com%2Flit%2Fds%2Fsymlink%2Ftlv5637.pdf&usg=AFQjCNEeLRCx4uL9DCKrbjuLasJNodv4lg&cad=rja {{https://bvdp.inetdoc.net/files/iut/tp_dacspi/TPCOMDACSPI.png}} {{https://bvdp.inetdoc.net/files/iut/tp_dacspi/schema.png}} fichiers eagle: https://bvdp.inetdoc.net/files/iut/tp_dacspi/carte-arduino-tlv56-8.sch et https://bvdp.inetdoc.net/files/iut/tp_dacspi/carte-arduino-tlv56-8.brd ==== Implémenter le contrôle du DAC ===== Mettre en oeuvre les méthodes de contrôle de du DAC SPI comme vus en TD. **Il est demandé d'utiliser le mode SPI 2 même si l'analyse de la documentation du composant nous dit que les modes 1 et 2 conviennent, sinon la commande simultanée des 2 voies du DAC ne fonctionne pas!** Ecrire le code pour générer une rampe qui couvre la dynamique du DAC avec un delai de 100µs entre chaque pas. ==== Génération de signaux ==== Utiliser le DAC pour générer un signal sinusoïdal sur la voie A (en utilisant la fonction sin) et un signal sinusoïdal déphasé de 90 degrés sur la voie B (en utilisant la fonction cos). ==== Recopie de signaux ==== Implémenter la recopie d'un signal capturé sur la voie 0 du convertisseur analogique numérique de l'Arduino. =====gestion interruption timer arduino===== ====Méthode par utilisation librairie arduino Timer==== http://playground.arduino.cc/Code/Timer1 utilisant la librairie MsTimer2 décrite ici : http://www.arduino.cc/playground/Main/MsTimer2 http://www.mon-club-elec.fr/pmwiki_mon_club_elec/pmwiki.php?n=MAIN.ArduinoInitiationInterruptionsTemporisationTimer2UneSeconde ====Méthode par configuration des registres==== http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS //timer interrupts //by Amanda Ghassaei //June 2012 //http://www.instructables.com/id/Arduino-Timer-Interrupts/ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * */ //timer setup for timer0, timer1, and timer2. //For arduino uno or any board with ATMEL 328/168.. diecimila, duemilanove, lilypad, nano, mini... //this code will enable all three arduino timer interrupts. //timer0 will interrupt at 2kHz //timer1 will interrupt at 1Hz //timer2 will interrupt at 8kHz //storage variables boolean toggle0 = 0; boolean toggle1 = 0; boolean toggle2 = 0; void setup(){ //set pins as outputs pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(13, OUTPUT); cli();//stop interrupts /* //set timer0 interrupt at 2kHz TCCR0A = 0;// set entire TCCR2A register to 0 TCCR0B = 0;// same for TCCR2B TCNT0 = 0;//initialize counter value to 0 // set compare match register for 2khz increments OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256) // turn on CTC mode TCCR0A |= (1 << WGM01); // Set CS01 and CS00 bits for 64 prescaler TCCR0B |= (1 << CS01) | (1 << CS00); // enable timer compare interrupt TIMSK0 |= (1 << OCIE0A); */ //set timer1 interrupt at 1Hz TCCR1A = 0;// set entire TCCR1A register to 0 TCCR1B = 0;// same for TCCR1B TCNT1 = 0;//initialize counter value to 0 // set compare match register for 1hz increments OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536) // turn on CTC mode TCCR1B |= (1 << WGM12); // Set CS12 and CS10 bits for 1024 prescaler TCCR1B |= (1 << CS12) | (1 << CS10); // enable timer compare interrupt TIMSK1 |= (1 << OCIE1A); /* //set timer2 interrupt at 8kHz TCCR2A = 0;// set entire TCCR2A register to 0 TCCR2B = 0;// same for TCCR2B TCNT2 = 0;//initialize counter value to 0 // set compare match register for 8khz increments OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256) // turn on CTC mode TCCR2A |= (1 << WGM21); // Set CS21 bit for 8 prescaler TCCR2B |= (1 << CS21); // enable timer compare interrupt TIMSK2 |= (1 << OCIE2A); */ sei();//allow interrupts }//end setup /* ISR(TIMER0_COMPA_vect){//timer0 interrupt 2kHz toggles pin 8 //generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles for full wave- toggle high then toggle low) if (toggle0){ digitalWrite(8,HIGH); toggle0 = 0; } else{ digitalWrite(8,LOW); toggle0 = 1; } } */ ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED) //generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles for full wave- toggle high then toggle low) if (toggle1){ digitalWrite(13,HIGH); toggle1 = 0; } else{ digitalWrite(13,LOW); toggle1 = 1; } } /* ISR(TIMER2_COMPA_vect){//timer1 interrupt 8kHz toggles pin 9 //generates pulse wave of frequency 8kHz/2 = 4kHz (takes two cycles for full wave- toggle high then toggle low) if (toggle2){ digitalWrite(9,HIGH); toggle2 = 0; } else{ digitalWrite(9,LOW); toggle2 = 1; } } */ void loop(){ //do other things here } =====gestion interruption matérielle sur broches 2 et 3===== http://arduino.cc/en/Reference/AttachInterrupt =====SPI Matériel===== http://arduino.cc/en/Reference/SPI =====SPI bitbang===== http://little-scale.blogspot.fr/2007/07/spi-by-hand.html déjà implémenté correctement: http://arduino.cc/en/Reference/shiftOut =====Librairie TLV5637===== https://bvdp.inetdoc.net/files/iut/tp_dacspi/Tlv5637.zip La version 1.6 stocke les librairies dans ~/Arduino/libraries alors que la 1.0.5 stocke les librairies dans ~/sketchbook/libraries