DAC8554
- Войдите на сайт для отправки комментариев
Сб, 20/09/2014 - 14:19
Есть в наличии ЦАП DAC8554 16 бит 4-х канальный, как сделать раздельное управление каналами при помощи кнопок.
Модуль блюпупа, делитель напряжения и LCD можно не принимать во внимание, с этим все в порядке

Почитать datasheet? Не?
Да вот даташит http://www.ti.com/lit/ds/symlink/dac8554.pdf
Пробовал MCP4922, в протеусе все работает, но там два канала и на нее есть библиотека.
Как быть с 8554?
Так же. Подключаете по spi (только тут 3 проводный он, ибо в обратку ничего не ожидается) и шлете команды согласно ентой бамажки. Там все расписано.
Вот так будет работать? Puhlyaviy что скажете? В плане необходимо будет раздельное (независимое) управление каналами ЦАП. Проверить в реале пока нет возможности и в протеусе нет модели DAC8554...
DAC8554.H /************************************************************************* ** Device: DAC8554 ** ** File: DAC8554.h - Library for get out analog voltage ** *************************************************************************/ #ifndef DAC8554_h #define DAC8554_h #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif class DAC8554 { public: DAC8554(int SDI, int SCK,int CS, boolean DAC, boolean DAC1); void setValue(int Value); private: int _DATAOUT; int _SPICLOCK; int _SLAVESELECT; boolean _DAC; boolean _DAC1; void sendSPIHeader(); void sendIntValueSPI(int value); void sendSPIClock(); }; #endif /******************************** * * * DAC=LOW DAC1=LOW => DAC_A select * * DAC=LOW DAC1=HIGH => DAC_B select * * DAC=HIGH DAC1=LOW => DAC_C select * * DAC=HIGH DAC1=HIGH => DAC_D select * * * ********************************/DAC8554.CCP
/************************************************************************* ** Device: DAC8554 ** ** File: DAC8554.h - Library for get out analog voltage ** **************************************************************************/ #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include "DAC8554.h" DAC8554::DAC8554(int SDI, int SCK, int CS, boolean DAC, boolean DAC1) { _DATAOUT = SDI; _SPICLOCK = SCK; _SLAVESELECT = CS; _DAC = DAC; _DAC1 = DAC1; pinMode(_DATAOUT,OUTPUT); pinMode(_SPICLOCK,OUTPUT); pinMode(_SLAVESELECT,OUTPUT); } //************************************************************************ void DAC8554::setValue(int Value) { sendIntValueSPI(Value); } //************************************************************************ void DAC8554::sendSPIClock() { digitalWrite(_SPICLOCK, HIGH); digitalWrite(_SPICLOCK, LOW); delay(1); } //************************************************************************ void DAC8554::sendSPIHeader() { // bit 23 Adress select A1 pin 14 DAC8554 // 0 // 1 digitalWrite(_DATAOUT,LOW); sendSPIClock(); // bit 22 Adress select A0 pin 13 DAC8554 // 0 // 1 digitalWrite(_DATAOUT,LOW); sendSPIClock(); // bit 21 LD 1 // 0 // 1 digitalWrite(_DATAOUT,LOW); sendSPIClock(); // bit 20 21 LD 0 // 0 // 1 digitalWrite(_DATAOUT,LOW); sendSPIClock(); // bit 19 // 0 // 1 digitalWrite(_DATAOUT,LOW); sendSPIClock(); // bit 18 // 0/0 write to DAC_A // 0/1 write to DAC_B // 1/0 write to DAC_C // 1/1 write to DAC_D digitalWrite(_DATAOUT,_DAC1); sendSPIClock(); // bit 17 // 0/0 write to DAC_A // 0/1 write to DAC_B // 1/0 write to DAC_C // 1/1 write to DAC_D digitalWrite(_DATAOUT,_DAC); sendSPIClock(); } //************************************************************************ void DAC8554::sendIntValueSPI(int value) { // initiate data transfer with 8554 digitalWrite(_SLAVESELECT,LOW); // send 4 bit header sendSPIHeader(); // send data for(int i=16;i>=0;i--){ digitalWrite(_DATAOUT,((value&(1<<i)))>>i); sendSPIClock(); } // finish data transfer digitalWrite(_SLAVESELECT,HIGH); }/************************************************************************* ** DAC8554.h - Library for get out analog voltage ** *************************************************************************/ #include "DAC8554.h" #define AI1 A1 //Analog input monitor 1 #define AI2 A2 //Analog input monitor 2 #define AI3 A3 //Analog input monitor 3 #define AI4 A4 //Analog input monitor 4 //define AnalogOutput (MOSI_pin, SCK_pin, CS_pin, DAC_x, DAC1_x); //, GAIN) DAC8554 AnalogOutput1(11,13,12,LOW, LOW); //,HIGH); //define AnalogOutput1 for MEGA_board, select DAC_A DAC8554 AnalogOutput2(11,13,12,HIGH,LOW); //,LOW); //define AnalogOutput2 for MEGA_board, select DAC_B DAC8554 AnalogOutput3(11,13,12,LOW,HIGH); //,LOW); //define AnalogOutput3 for MEGA_board, select DAC_С DAC8554 AnalogOutput4(11,13,12,HIGH,HIGH); //,LOW); //define AnalogOutput4 for MEGA_board, select DAC_В /************************ * | UNO * * -------------------- * * SCK_pin | 13 * * MOSI_pin | 11 * * CS_pin | 12 * ********************************* * DAC=LOW DAC1=LOW => DAC_A select * * DAC=LOW DAC1=HIGH => DAC_B select * * DAC=HIGH DAC1=LOW => DAC_C select * * DAC=HIGH DAC1=HIGH => DAC_D select * * * * GAIN=LOW => 2x gain select * * GAIN=HIGH => 1x gain select * ********************************/ //***************************************************************** void setup() { AnalogOutput1.setValue(4000); AnalogOutput2.setValue(0); AnalogOutput3.setValue(0); AnalogOutput4.setValue(0); delay(1000); pinMode(AI1,INPUT); //Voltage measurement pin1 pinMode(AI2,INPUT); //Voltage measurement pin2 pinMode(AI3,INPUT); //Voltage measurement pin3 pinMode(AI4,INPUT); //Voltage measurement pin4 Serial.begin(9600); //Init serial interface Serial.println("Ready"); } //***************************************************************** void loop() { for (int i=0; i<65536; i+=64) { Serial.print(i,DEC); AnalogOutput1.setValue(i); //set voltage for AnalogOutput1 AnalogOutput2.setValue(i); //set volateg for AnalogOutput2 AnalogOutput3.setValue(i); //set voltage for AnalogOutput3 AnalogOutput4.setValue(i); //set volateg for AnalogOutput4 Serial.print(";"); delay(10); int AO1 = analogRead(AI1); //check the input voltage AI1 (pin A1) int AO2 = analogRead(AI2); //check the input voltage AI2 (pin A2) int AO3 = analogRead(AI3); //check the input voltage AI1 (pin A3) int AO4 = analogRead(AI4); //check the input voltage AI2 (pin A4) delay(10); Serial.print("AO1="); Serial.print(AO1); Serial.print(" ; AO2="); Serial.println(AO2); Serial.print("AO3="); Serial.print(AO3); Serial.print(" ; AO4="); Serial.println(AO4); } }не может читать схематику.