| Electronics > Beginners |
| Making a sound camera |
| << < (5/13) > >> |
| MasterT:
--- Quote from: ogden on May 01, 2018, 08:37:48 pm --- --- Quote from: MasterT on May 01, 2018, 07:10:31 pm ---Don't know about esp32, but as any digital bus I2C trasfer time is defined by clock rate * number of bits. I2C standard AFAIK supports 100k, 400k, and 3.4M clock. --- End quote --- I am afraid that you confused I2S with I2C which is totally different animal: --- End quote --- Ooops, mea culpa, misreading. Didn't know esp32 could support I2S. I interfaced arduino DUE to Wm8731 over I2S /DMA, but it's for 1 CODEC - 2 channels In /Out only. Though bringing I2S into picture would make project much harder to build /program. Here is a piece of code, to give an overview of complexity: --- Code: ---void DMAC_Handler(void) { uint32_t dma_status; // digitalWrite( test_pin, HIGH); dma_status = DMAC->DMAC_EBCISR; // BUG : ISR = if (dma_status & (DMAC_EBCIER_CBTC0 << SSC_DMAC_RX_CH)) if (dma_status & (DMAC_EBCISR_BTC0 << SSC_DMAC_RX_CH)) { flag_adcv = 1; } if (dma_status & (DMAC_EBCISR_BTC0 << SSC_DMAC_TX_CH)) { flag_dacv = 1; } if(flag_adcv && (!flag_dacv)) adcdac_first = 1; if((!flag_adcv) && flag_dacv) adcdac_first = 2; // digitalWrite( test_pin, LOW); } void ssc_dma_cfg() { desc[0].ul_source_addr = (uint32_t)(&SSC->SSC_RHR); desc[0].ul_destination_addr = (uint32_t) inp[0]; desc[0].ul_ctrlA = DMAC_CTRLA_BTSIZE(INP_BUFF) |/* Set Buffer Transfer Size */ DMAC_CTRLA_SRC_WIDTH_WORD | /* Source transfer size is set to 32-bit width */ DMAC_CTRLA_DST_WIDTH_WORD; /* Destination transfer size is set to 32-bit width */ desc[0].ul_ctrlB = DMAC_CTRLB_SRC_DSCR_FETCH_DISABLE | DMAC_CTRLB_DST_DSCR_FETCH_FROM_MEM | DMAC_CTRLB_FC_PER2MEM_DMA_FC | DMAC_CTRLB_SRC_INCR_FIXED | DMAC_CTRLB_DST_INCR_INCREMENTING; desc[0].ul_descriptor_addr = (uint32_t) &desc[1]; desc[1].ul_source_addr = (uint32_t)(&SSC->SSC_RHR); desc[1].ul_destination_addr = (uint32_t) inp[1]; desc[1].ul_ctrlA = DMAC_CTRLA_BTSIZE(INP_BUFF) | DMAC_CTRLA_SRC_WIDTH_WORD | DMAC_CTRLA_DST_WIDTH_WORD; desc[1].ul_ctrlB = DMAC_CTRLB_SRC_DSCR_FETCH_DISABLE | DMAC_CTRLB_DST_DSCR_FETCH_FROM_MEM | DMAC_CTRLB_FC_PER2MEM_DMA_FC | DMAC_CTRLB_SRC_INCR_FIXED | DMAC_CTRLB_DST_INCR_INCREMENTING; desc[1].ul_descriptor_addr = (uint32_t) &desc[0]; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_SADDR = desc[0].ul_source_addr; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_DADDR = desc[0].ul_destination_addr; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_CTRLA = desc[0].ul_ctrlA; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_CTRLB = desc[0].ul_ctrlB; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_DSCR = desc[0].ul_descriptor_addr; DMAC->DMAC_CHER = DMAC_CHER_ENA0 << SSC_DMAC_RX_CH; ssc_enable_rx(SSC); // transmit desc[2].ul_source_addr = (uint32_t) out[0]; desc[2].ul_destination_addr = (uint32_t) (&SSC->SSC_THR); desc[2].ul_ctrlA = DMAC_CTRLA_BTSIZE(INP_BUFF) | DMAC_CTRLA_SRC_WIDTH_WORD | DMAC_CTRLA_DST_WIDTH_WORD; desc[2].ul_ctrlB = DMAC_CTRLB_SRC_DSCR_FETCH_FROM_MEM | DMAC_CTRLB_DST_DSCR_FETCH_DISABLE | DMAC_CTRLB_FC_MEM2PER_DMA_FC | DMAC_CTRLB_SRC_INCR_INCREMENTING | DMAC_CTRLB_DST_INCR_FIXED; desc[2].ul_descriptor_addr = (uint32_t) &desc[3]; desc[3].ul_source_addr = (uint32_t) out[1]; desc[3].ul_destination_addr = (uint32_t) (&SSC->SSC_THR); desc[3].ul_ctrlA = DMAC_CTRLA_BTSIZE(INP_BUFF) | DMAC_CTRLA_SRC_WIDTH_WORD | DMAC_CTRLA_DST_WIDTH_WORD; desc[3].ul_ctrlB = DMAC_CTRLB_SRC_DSCR_FETCH_FROM_MEM | DMAC_CTRLB_DST_DSCR_FETCH_DISABLE | DMAC_CTRLB_FC_MEM2PER_DMA_FC | DMAC_CTRLB_SRC_INCR_INCREMENTING | DMAC_CTRLB_DST_INCR_FIXED; desc[3].ul_descriptor_addr = (uint32_t) &desc[2]; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_SADDR = desc[2].ul_source_addr; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_DADDR = desc[2].ul_destination_addr; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_CTRLA = desc[2].ul_ctrlA; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_CTRLB = desc[2].ul_ctrlB; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_DSCR = desc[2].ul_descriptor_addr; DMAC->DMAC_CHER = DMAC_CHER_ENA0 << SSC_DMAC_TX_CH; ssc_enable_tx(SSC); } void init_dma() { uint32_t ul_cfg; pmc_enable_periph_clk(ID_DMAC); DMAC->DMAC_EN &= (~DMAC_EN_ENABLE); DMAC->DMAC_GCFG = (DMAC->DMAC_GCFG & (~DMAC_GCFG_ARB_CFG)) | DMAC_GCFG_ARB_CFG_ROUND_ROBIN; DMAC->DMAC_EN = DMAC_EN_ENABLE; ul_cfg = 0; ul_cfg = DMAC_CFG_SRC_PER(SSC_DMAC_RX_ID) | DMAC_CFG_SRC_H2SEL | DMAC_CFG_SOD_DISABLE | //SOD: Stop On Done DMAC_CFG_FIFOCFG_ALAP_CFG; DMAC->DMAC_CH_NUM[SSC_DMAC_RX_CH].DMAC_CFG = ul_cfg; DMAC->DMAC_CHDR = DMAC_CHDR_DIS0 << SSC_DMAC_RX_CH; //transmit ul_cfg = 0; ul_cfg = DMAC_CFG_DST_PER(SSC_DMAC_TX_ID) | DMAC_CFG_DST_H2SEL | DMAC_CFG_SOD_DISABLE | //SOD: Stop On Done DMAC_CFG_FIFOCFG_ALAP_CFG; DMAC->DMAC_CH_NUM[SSC_DMAC_TX_CH].DMAC_CFG = ul_cfg; DMAC->DMAC_CHDR = DMAC_CHDR_DIS0 << SSC_DMAC_TX_CH; // NVIC_EnableIRQ(DMAC_IRQn); DMAC->DMAC_EBCIER = DMAC_EBCIER_BTC0 << SSC_DMAC_RX_CH; DMAC->DMAC_EBCIER = DMAC_EBCIER_BTC0 << SSC_DMAC_TX_CH; DMAC->DMAC_EBCISR; } void init_ssc() { clock_opt_t rx_clk_option; data_frame_opt_t rx_data_frame_option; clock_opt_t tx_clk_option; data_frame_opt_t tx_data_frame_option; memset((uint8_t *)&rx_clk_option, 0, sizeof(clock_opt_t)); memset((uint8_t *)&rx_data_frame_option, 0, sizeof(data_frame_opt_t)); memset((uint8_t *)&tx_clk_option, 0, sizeof(clock_opt_t)); memset((uint8_t *)&tx_data_frame_option, 0, sizeof(data_frame_opt_t)); pmc_enable_periph_clk(ID_SSC); ssc_reset(SSC); rx_clk_option.ul_cks = SSC_RCMR_CKS_RK; rx_clk_option.ul_cko = SSC_RCMR_CKO_NONE; rx_clk_option.ul_cki = SSC_RCMR_CKI; //1 = The data inputs (Data and Frame Sync signals) // are sampled on Receive Clock rising edge. rx_clk_option.ul_ckg = SSC_RCMR_CKG_NONE; // bylo 0; rx_clk_option.ul_start_sel = SSC_RCMR_START_RF_RISING; rx_clk_option.ul_period = 0; rx_clk_option.ul_sttdly = 1; rx_data_frame_option.ul_datlen = BIT_LEN_PER_CHANNEL - 1; rx_data_frame_option.ul_msbf = SSC_RFMR_MSBF; rx_data_frame_option.ul_datnb = 1;//stereo rx_data_frame_option.ul_fslen = 0; rx_data_frame_option.ul_fslen_ext = 0; rx_data_frame_option.ul_fsos = SSC_RFMR_FSOS_NONE; rx_data_frame_option.ul_fsedge = SSC_RFMR_FSEDGE_POSITIVE; ssc_set_receiver(SSC, &rx_clk_option, &rx_data_frame_option); ssc_disable_rx(SSC); // ssc_disable_interrupt(SSC, 0xFFFFFFFF); tx_clk_option.ul_cks = SSC_TCMR_CKS_RK; tx_clk_option.ul_cko = SSC_TCMR_CKO_NONE; tx_clk_option.ul_cki = 0; //example Atmel. bylo SSC_TCMR_CKI; //1 = The data outputs (Data and Frame Sync signals) // are shifted out on Transmit Clock rising edge. tx_clk_option.ul_ckg = SSC_TCMR_CKG_NONE; // bylo 0. tx_clk_option.ul_start_sel = SSC_TCMR_START_RF_RISING; tx_clk_option.ul_period = 0; tx_clk_option.ul_sttdly = 1; tx_data_frame_option.ul_datlen = BIT_LEN_PER_CHANNEL - 1; tx_data_frame_option.ul_msbf = SSC_TFMR_MSBF; tx_data_frame_option.ul_datnb = 1; tx_data_frame_option.ul_fslen = 0; // :fsden=0 tx_data_frame_option.ul_fslen_ext = 0; tx_data_frame_option.ul_fsos = SSC_TFMR_FSOS_NONE; //input-slave tx_data_frame_option.ul_fsedge = SSC_TFMR_FSEDGE_POSITIVE; ssc_set_transmitter(SSC, &tx_clk_option, &tx_data_frame_option); ssc_disable_tx(SSC); ssc_disable_interrupt(SSC, 0xFFFFFFFF); } void pio_B_SSC(void) { // DUE: PA15(B)-D24, PA16(B)-A0, PA14(B)-D23 = DACLRC, DACDAT, BCLK PIOA->PIO_PDR = PIO_PA14B_TK; PIOA->PIO_IDR = PIO_PA14B_TK; PIOA->PIO_ABSR |= PIO_PA14B_TK; PIOA->PIO_PDR = PIO_PA15B_TF; PIOA->PIO_IDR = PIO_PA15B_TF; PIOA->PIO_ABSR |= PIO_PA15B_TF; PIOA->PIO_PDR = PIO_PA16B_TD; PIOA->PIO_IDR = PIO_PA16B_TD; PIOA->PIO_ABSR |= PIO_PA16B_TD; } --- End code --- |
| Marco:
--- Quote from: ogden on May 01, 2018, 08:49:23 pm ---Such clipping approach would work only in textbook example for single signal source of clean sine tone, not real world application where various complex sounds are coming from multiple sources. This application indeed needs DSP processing, thus programming. --- End quote --- He talked about using 9 LEDs ... something which only works under limited circumstances doesn't seem like a huge problem to me. This is clearly more science fair than product. |
| ogden:
--- Quote from: Marco on May 01, 2018, 10:30:26 pm --- --- Quote from: ogden on May 01, 2018, 08:49:23 pm ---Such clipping approach would work only in textbook example for single signal source of clean sine tone, not real world application where various complex sounds are coming from multiple sources. This application indeed needs DSP processing, thus programming. --- End quote --- He talked about using 9 LEDs ... something which only works under limited circumstances doesn't seem like a huge problem to me. This is clearly more science fair than product. --- End quote --- It does not matter you use 3x3 LEDs or HD display - clipping approach will work only in theory. Siemens LMS Sound Camera is product indeed: |
| daslolo:
Yes that one. They all use logarithmic spiral. Anyone knows why? @ogden What's the problem with the clipping approach? @MasterT good thing the complexity reinforce my decision of going all analog. By the way, speaking of ADC, are there ADC out there that do mass conversion all at once? Then I wouldn't have to spend time in the mCU and counter-offset the signals. Anyway I got the FFT running, and having two cores is sweet, so I might as well use programming to make this thing. https://github.com/laurentopia/M5-Signal-Multimeter |
| ogden:
--- Quote from: daslolo on May 01, 2018, 11:03:03 pm ---Yes that one. They all use logarithmic spiral. Anyone knows why? --- End quote --- IMHO reason is Marketing. Spiral just looks better than straight beams. --- Quote ---@ogden What's the problem with the clipping approach? --- End quote --- Using clipping you lose signal amplitude information. Also - even quiet hiss riding on top of sound will add so much noise and "jitter" to phase measurements that w/o averaging it will not work. If you need averaging which more or less is DSP processing - then why don't do proper DSP from very beginning, why reduce resolution to 1bit to later struggle getting it (resolution) back? --- Quote ---@MasterT good thing the complexity reinforce my decision of going all analog. --- End quote --- I would love to see working, fully analog system :) --- Quote ---By the way, speaking of ADC, are there ADC out there that do mass conversion all at once? Then I wouldn't have to spend time in the mCU and counter-offset the signals. --- End quote --- There are flash ADCs' which are very fast. Again - processing will add delay. Sound propagation is not instant after all. So it does not actually matter - you find sound direction with 1ms, 2ms or 10ms delay. |
| Navigation |
| Message Index |
| Next page |
| Previous page |