Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC bias injection #159

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <DRA818.h>
#include <driver/adc.h>
#include <driver/i2s.h>
#include <driver/dac.h>
#include <esp_task_wdt.h>

const byte FIRMWARE_VER[8] = {'0', '0', '0', '0', '0', '0', '0', '5'}; // Should be 8 characters representing a zero-padded version, like 00000001.
Expand Down Expand Up @@ -168,7 +169,7 @@ void initI2SRx() {

// Initialize ADC
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_0);
adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_12);

static const i2s_config_t i2sRxConfig = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),
Expand All @@ -186,6 +187,8 @@ void initI2SRx() {

ESP_ERROR_CHECK(i2s_driver_install(I2S_NUM_0, &i2sRxConfig, 0, NULL));
ESP_ERROR_CHECK(i2s_set_adc_mode(I2S_ADC_UNIT, I2S_ADC_CHANNEL));
dac_output_enable(DAC_CHANNEL_2); // GPIO26 (DAC1)
dac_output_voltage(DAC_CHANNEL_2, 138);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What DC voltage does this generate?

Copy link
Collaborator Author

@dkaukov dkaukov Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SmittyHalibut,

The SA818 datasheet lists the audio output amplitude at 0.7v, though in practice it's closer to 2v Vpp (probably datasheet states RMS value).

To accommodate this, I opted for ADC_ATTEN_DB_12, which provides an input range of 150 mV to 2450 mV (Espressif ADC Reference).

Theoretically, the ideal bias point would be at the center of this range:
[(2450 + 150) / 2 = 1.3v]

However, in practice, I’ve found 1.75v to work better for my boards. By "better," I mean that in 12-bit mode, it reads around 2048, which aligns with the center of the ADC range.

}

void initI2STx() {
Expand Down