Too much free time or valid test? - Page 1
Forum section: electronics / general

author: paulca
author_rank: Super Contributor
timestamp: February 21, 2023, 08:16:29 pm
content: It renders a stereo VU meter to the serial console (VT100 encoding, YMMV).I have it running at about 8-9 FPS on 115200.Code:void txt_vu(int rms, int peak, int rms2, int peak2, int base_ref) {data_ch_t *buffer = DataChan_GetBufferForRx(&debug_buffers);if (buffer == NULL) {return;}peak = fabs( peak - base_ref );peak2 = fabs(peak2 - base_ref);rms = fabs(rms - base_ref);rms2 = fabs(rms2 - base_ref);int len = snprintf((char*) buffer->buffer, 255, "[%*s%*s%*s\r\n[%*s%*s%*s\r\e[A",rms, ">", peak - rms - 1, "]", (int) fabs(base_ref) - peak, "|",rms2, ">", peak2 - rms2 - 1, "]", (int) fabs(base_ref) - peak2, "|");buffer->index = len; // **no -1DataChan_ReleaseRxBuffer(&debug_buffers);}Code:// meanwhile somewhere in while(1)if (uart_ready > 0) {data_ch_t *buffer = DataChan_GetReadyBuffer(&debug_buffers);if (buffer != NULL) {uart_ready = 0;HAL_UART_Transmit_DMA(&huart1, buffer->buffer, buffer->index);}}Code:void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {DataChan_ReleaseReadyBuffer(&debug_buffers);uart_ready = 1;}void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) {DataChan_ReleaseReadyBuffer(&debug_buffers);uart_ready = 1;}I used this to see if my NVIC priorities were working. The rms and peak values for left and right are produced at ~10Hz down sampling 1ms buffers which get used elsewhere. With interrupts mostly set to 0. Click-click-click on the DSP side of things, missing interrupts. DSP interrupts are running at 48kHz. UART DMA transfers are attempting ~10Hz.Drop the UART and it's DMA under the DSP interrupts and smooth again... although there are frame drops on the UART I can see.Just a test... I was bored... I thought it was cool abuse of sprintf. It would be nice to fill the rms bar, but that requires a loop and I'm not that board / out of time.I suppose at the same time it did kinda give the new async ISR compatible debug stuff I wrote a good testing. The terminal stays formatted pretty tightly and the DSP doesn't drop a sample. I'd say it was working.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: February 22, 2023, 10:05:52 am
content: For a test, it would make more sense to have an incrementing packet number and a timestamp read from a timer. If you log that data it's easy to iterate over it later.Or just catch UART data with a Logic analyser, which will also log timiing and delays. There will probably be some jitter, as your uC may start servicing an ISR just before it's time to start an DMA transfer.

author: cantata.tech
author_rank: Regular Contributor
timestamp: February 22, 2023, 10:52:00 am
content: It looks like a cool idea.Do you have any plans to make a project out of this ?It's not clear what environment this goes into. Linux? Arduino? something embedded?I know for my own entertainment, I'd be looking at driving a stepper-motor to make a fake/faux/emulated analogue VU meter, but that would need a microcontroller.For the desktop, windows linux whatever a vu meter would be nice but it probably exists somewhere, not sure where.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: February 22, 2023, 12:00:58 pm
content: He uses Tera Term, so that very likely is Windoze.

author: paulca
author_rank: Super Contributor
timestamp: February 22, 2023, 12:12:30 pm
content: Quote from: Doctorandus_P on February 22, 2023, 12:00:58 pmIt is windows 10, VM, running on Ubuntu. I don't like tera term, but on windows it's the best of a bad bunch.The platform is STM32 (H7).It's "live" and "realtime". No latency... well, 20 microseconds. Certainly in terms of processing the audio. Part of the exercise was running complex async stuff "in the background" without creating "clicks" in the audio stream.On making it a project? The DSP maybe. The uv_text function for UART. It should be easiler portable to use Serial.printf(); in Arduino. The complex bit is getting two competing processes running happily together, the async buffer "DataChanBuffers" are mine and I'd be happy to share them. They are STM32 specific though and not fully "dressed".

author: cv007
author_rank: Frequent Contributor
timestamp: February 22, 2023, 09:08:29 pm
content: QuoteYou can truncate strings-https://godbolt.org/z/99rfehxK1