Download BACHELOR THESIS

Transcript
//make string from measured volage
str[2] = data % 10 + ’0’;
data /= 10;
str[1] = data % 10 + ’0’;
data /= 10;
str[0] = data % 10 + ’0’;
The conversion result is then send via USB/USART as string of decimals on the terminal screen.
To clear screen before next result is send to the terminal needed number of Backspace character
is send. I also recommend reduce blinking of terminal by adding a short delay after each
conversion loop.
//return cursor
for(i = 0; i < 6; i++ )
{
printChar(0x08);
}
This application is not difficult to understand but explain fundamental concepts how to implement communication with analog sensors like temperature sensors are.
4.8.2
Oscilloscope realization with STM32 ADC and DMA
An oscilloscope is a type of electronic test instrument that allows signal voltages to be viewed
as a two-dimensional graph of one or more electrical potential differences plotted as a function
of time. The oscilloscope is one of the most versatile and widely-used electronic instruments.
Digital oscilloscopes use an ADC and memory to record and show a digital representation
of a waveform, yielding much more flexibility for analysis, and display than is possible with
a classic analog oscilloscope. The following example shows howto implement digital oscilloscope based on STM32 ADC, DMA and internal RAM without any additional circuit required.
STM32 ADC is capable of sampling 1Ms/s in continuous mode with usage of DMA transfer.
ADC is 10-bit but only 8 MSB are used (PC client application is capable to precede only 8 bit
long samples). The signal input in this case is port B pin 1 and the sampled data is sent to the
computer via USART. Then the data is viewed on computer in NRP viewer.
The main program (figure 4.21) first does the initialization of ADC, RCC, USART and DMA
units and then wait for the command to start signal sampling. Once the command is received
43