Bonjour,
Avec le scan I2C les deux cartes k8000 branchés j'obtiens ceci
Scanning...
I2C device found at address 0x20 !
I2C device found at address 0x22 !
I2C device found at address 0x38 !
I2C device found at address 0x39 !
I2C device found at address 0x3C !
I2C device found at address 0x3D !
I2C device found at address 0x48 !
I2C device found at address 0x4A !
done
Alors la configuration Carte 00 dip swtich 1 sur OFF et 2 sur OFF
Premier PCF8574 => 0x38
Second PCF8574 => 0x39
DAC => 0x20
ADC => 0x48
Si je ne me trompe pas depuis cela ont peut utiliser les commande habituel :
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
// device address is specified in datasheet
Wire.write(val); // sends value byte
Wire.endTransmission(); // stop transmitting
Attention je pense si j'ai bien vu la datasheet du DAC il faut lui écrire une configuration suivant l'utilisation de celui ci.
Les entrée sortie pour écrire il suffit de lui envoyer la valeur entre 0 et 255 et pour les lires il suffit d'un Wire.read() qui vous renvoie la valeur qui lui est apposé sur ses entrées
Pour le DAC voila une source
//
// Title : ADDA-Umsetzer mit PCF8591
// Author : Claus Kühnel
// Date : 2010-03-14
// Id : PCF8591.pde
// Version : 0018
// Micro : Arduino 2009 w/ ATmega328
//
// DISCLAIMER:
// The author is in no way responsible for any problems or damage caused by
// using this code. Use at your own risk.
//
// LICENSE:
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
// -----------------------------------------------------------------------------------------
// Verbindungen I2C-Analog - Arduino
// SCL SDA GND +5V
// I2C-Analog ST1-SCL ST1-SDA ST1-GND ST1-5V
// Arduino A5 A4 GND 5
//
#include <Wire.h>
#define PCF8591 (0x9E >> 1) // Deviceadresse = 7
#define PCF8591_DAC_ENABLE 0x40
#define PCF8591_ADC_CH0 0x40
#define PCF8591_ADC_CH1 0x41
#define PCF8591_ADC_CH2 0x42
#define PCF8591_ADC_CH3 0x43
#define PURPOSE "Test of PCF8591"
const byte LED = 13;
byte adc_value, dac_value=0;
void putDAC(byte dac_value)
{
Wire.beginTransmission(PCF8591);
Wire.send(PCF8591_DAC_ENABLE);
Wire.send(dac_value);
Wire.endTransmission();
}
byte getADC(byte config)
{
Wire.beginTransmission(PCF8591);
Wire.send(config);
Wire.endTransmission();
Wire.requestFrom((int) PCF8591,2);
while (Wire.available())
{
adc_value = Wire.receive();
adc_value = Wire.receive();
}
return adc_value;
}
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(19200);
Wire.begin();
Serial.println(PURPOSE);
Serial.println("DAC\tADC\tADC-DAC");
}
void loop()
{
putDAC(dac_value); // DAC Wert setzen
digitalWrite(LED, 1); // LED ein
delay(10);
adc_value = getADC(PCF8591_ADC_CH0); // ADC Wert von Kanal0 auslesen
digitalWrite(LED, 0); // LED aus
Serial.print(dac_value, HEX); // DAC Wert ausgeben
Serial.print("\t");
Serial.print(adc_value, HEX); // ADC Wert ausgeben
Serial.print("\t");
Serial.println(dac_value - adc_value); // Abweichung berechnen und ausgeben
dac_value++;
delay(200);
}
Qui a une idée de base tout ce qui a été donnée ici ?