From 338c66152fd4f53178383144d9341c68313f64ce Mon Sep 17 00:00:00 2001 From: Oleksiy H Date: Mon, 20 Oct 2025 01:35:17 +0300 Subject: [PATCH] Got rid of MCP4725 library. For now MCP4725 DACs used only for gate signals, CV will be back with another DAC --- AciduinoCV.ino | 23 ++++++++++++++--------- CV.ino | 37 +++++++++++++++++++++++++++++++------ config.h | 3 +-- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/AciduinoCV.ino b/AciduinoCV.ino index 7b81c46..9c385ad 100644 --- a/AciduinoCV.ino +++ b/AciduinoCV.ino @@ -5,13 +5,8 @@ #include #include -#include "MCP4725.h" - #include "config.h" -MCP4725 DAC1(DAC_1_ADDR); -MCP4725 DAC2(DAC_2_ADDR); - bool updateCV1 = true; bool updateCV2 = true; bool sendGate1 = false; @@ -19,6 +14,8 @@ bool sendGate2 = false; uint8_t CV1Note; uint8_t CV2Note; +float DACNoteStep; + void setup() { // AcidStepSequencer Interface @@ -32,12 +29,20 @@ void setup() // last pattern user had load before power off loadLastPattern(); + DACNoteStep = (1.0 / 12.0) * 4096 / DAC_MAX_VOLTAGE; + Wire.begin(); Wire.setClock(400000); - DAC1.begin(); - DAC2.begin(); - DAC1.setMaxVoltage(5.1); - DAC2.setMaxVoltage(5.1); + Wire.beginTransmission(0x60); + Wire.write(0x40); + Wire.write(0x00); + Wire.write(0x00); + Wire.endTransmission(); + Wire.beginTransmission(0x61); + Wire.write(0x40); + Wire.write(0x00); + Wire.write(0x00); + Wire.endTransmission(); } // User interaction goes here diff --git a/CV.ino b/CV.ino index c13f802..807470f 100644 --- a/CV.ino +++ b/CV.ino @@ -3,6 +3,11 @@ float noteToVoltage(uint8_t note) { return voltage; } +uint16_t noteToValue(uint8_t note) { + uint16_t value = (note - 24) * DACNoteStep; + return value; +} + void sendCVNote(uint8_t note, uint8_t track) { if (track == 0 && note != CV1Note) { CV1Note = note; @@ -34,29 +39,49 @@ void sendGateOff(uint8_t track) { void sendVoltage(uint8_t voltage, uint8_t dac) { if (dac == 0) { - DAC1.setVoltage(voltage); + //DAC1.setVoltage(voltage); } else { - DAC2.setVoltage(voltage); + //DAC2.setVoltage(voltage); } } void processCV() { if (updateCV1) { - sendVoltage(noteToVoltage(CV1Note), 0); - updateCV1 = false; + //sendVoltage(noteToVoltage(CV1Note), 0); + //updateCV1 = false; } if (updateCV2) { //sendVoltage(noteToVoltage(CV2Note), 1); //updateCV2 = false; } if (sendGate1) { - sendVoltage(5, 1); + Wire.beginTransmission(0x60); + Wire.write(0x40); + Wire.write(0xFF); + Wire.write(0xF0); + Wire.endTransmission(); + //sendVoltage(5, 0); } else { - sendVoltage(0, 1); + Wire.beginTransmission(0x60); + Wire.write(0x40); + Wire.write(0x00); + Wire.write(0x00); + Wire.endTransmission(); + //sendVoltage(0, 0); } if (sendGate2) { + Wire.beginTransmission(0x61); + Wire.write(0x40); + Wire.write(0xFF); + Wire.write(0xF0); + Wire.endTransmission(); //sendVoltage(5, 1); } else { + Wire.beginTransmission(0x60); + Wire.write(0x40); + Wire.write(0x00); + Wire.write(0x00); + Wire.endTransmission(); //sendVoltage(0, 1); } } \ No newline at end of file diff --git a/config.h b/config.h index ee2466d..1f643f1 100644 --- a/config.h +++ b/config.h @@ -93,7 +93,6 @@ typedef enum { } BUTTON_HARDWARE_INTERFACE; // CV DACs -#define DAC_1_ADDR 0x60 -#define DAC_2_ADDR 0x61 +#define DAC_MAX_VOLTAGE 5.1 #endif