Page 1 of 1

Sampling discriminator audio from Uniden scanner

Posted: Tue Jul 02, 2019 4:00 pm
by shane91c
Hello,

I am trying to use ESP32 Arduino to develop an application that captures discriminator audio from a Uniden Bc355n scanner.

For reference, my multimeter suggests that there voltage from the discriminator tap is 1.8Vrms - so according to the documentation this should be easily measurable by the ESP32 ADC.

However, all code I have tried result in either all-zeros or some noise hovering around 0x7fff

Here is my setup code:

Code: Select all

  i2s_config_t cfg = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),
    .sample_rate = 48000,
    .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
    .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
    .communication_format = I2S_COMM_FORMAT_PCM_SHORT,
    .intr_alloc_flags = 0,
    .dma_buf_count = 4,
    .dma_buf_len = 960,
    .use_apll = 1,
    .tx_desc_auto_clear = 0 ,
    .fixed_mclk = 0
  };

  if (i2s_driver_install(I2S_NUM_0, &cfg, 0, NULL) == ESP_OK) {
    Serial.println("I2S Driver Ready");
  }
  

  adc_set_data_width(ADC_UNIT_1, ADC_WIDTH_BIT_12);
  adc1_config_channel_atten(ADC1_CHANNEL_7, ADC_ATTEN_DB_2_5);

  
  
  if (i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_7) == ESP_OK) {
    Serial.println("ADC Mode Ready");
  } else {
    Serial.println("ADC MODE FAILED!");
  }

  if (i2s_adc_enable(I2S_NUM_0) == ESP_OK) {
    Serial.println("ADC Enabled");
  }

And in a loop I transmit the data via UDP broadcast for testing:

Code: Select all

  static uint16_t buffer[960] = {0};
  static size_t bytes_read = 0;
  static size_t total_read = 0;
  static int led_state = 0;

  bytes_read = 0;
  total_read = 0;

  while (total_read < 48000) {
    uint64_t start = micros();
    
    i2s_read(I2S_NUM_0, &buffer, sizeof(buffer), &bytes_read, portMAX_DELAY);
    delay(20);
    
    total_read += bytes_read;

    if (total_read >= 48000) {
      total_read = 0;
      led_state ^= 1;
      digitalWrite(BLUE_LED, led_state);
    }

    udp.beginPacket("255.255.255.255", 1991);
    udp.write((uint8_t*) buffer, sizeof(buffer));
    udp.endPacket();
  }



Can anyone shed some light on this?