2018-02-27 01:32 PM
Hey there,
iam a stundet and try to create a programm to test some Piezo's on some structures.
I have a STM32 Mini M4 F415 and a Connect Eve Display from mikroe.
I want to get the ADC Value of the peak when i push a plate of Piezos.(4 of them)
The i want to sort them with bubble sort and some calculations.
And after that i want to give the calculated adc value to the Display.
I tried some resolutions i saw on youtube and other Internet pages but i dont got the peaks from my adc to my Array[3] and to the Diplay over SPI.
I use the Cube MX to init my Configuration.
The Calc and sort algorithm and code is not the problem , but this connection between ADC and my array with the peaks. And the the connection to the display.
Does anybody has some links or examples? Where i can lern from?
Actually i have 4 ADC Inputs in Contuious mode .
LG
Dave
PS: Sry for my bad english language. Normally i only tried to prog some easy chips and something big like this
2018-02-28 03:42 AM
As always, you need to break the problem down into its distinct parts.
Don't try to solve the whole thing in one go!
Getting the samples from the ADC is a separate problem from displaying stuff on an LCD.
The Calc and sort algorithm and code is not the problem
How do you know that?
2018-02-28 05:29 AM
OK ,
my first problem is to get the peak value from the piezo sensor when i touch the plate where the piezo is located.
How can i configure the ADC Inputs that they record the peak and not all the time when no high input comes?
And after that : Is it possible to get the Values from the ADC to a array?
I tried this following lines.
First i configured in CubeMX the ADC in
Scan Vonversion Mode to Enabled
Continuous Mode to Enabled
Number of Conversations 4
And Sampling times to 15 Cycles.(12 bits Resolution)
Added some arrays
uint32_t
adc_buf
[
4
]
,
adc_sensor
[
4
],adc_display[4]
;
void
HAL_ADC_ConvCpltCallback
(
ADC_HandleTypeDef*
hadc
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
adc_sensor
[
i
]
=
adc_buf
[
i
]
;
// From Buf to ADC_Sensor
}
}
After that
main
(
)
{
...
MX_GPIO_Init();
MX_DMA_Init(); MX_ADC1_Init(); MX_SPI1_Init();HAL_ADC_Start_DMA
(
&
hadc1
,
(
uint32_t *
)
adc_buf
,
4
)
;
while
(
1
)
{
adc
_display
[
0
]
=
adc_sensor
[
0
]
;
adc
_display
[
1
]
=
adc_sensor
[
1
]
;
adc_display
[
2
]
=
adc_sensor
[
2
]
;
adc_display
[
3
]
=
adc_sensor
[
3
]
;
HAL_Delay
(
1000
)
;
}
}
Should be this not a correct code to get the values from the ADC Sensors on Channel 0-3 ?
2018-02-28 07:11 AM
Dave Sclegel wrote:
How can i configure the ADC Inputs that they record the peak and not all the time
You start by studying the Reference Manual for the chip - look at the ADC section for a description of the available operating modes, and see which most closely matches your requirement.
I've never had cause to look for it, but I don't recall seeing a 'peak-detect' mode. But you need to check for yourself.
If there is no suitable mode, you have 2 choices:
2018-03-01 02:15 AM
Ok, does this chip or STm32 have something like sample and hold?
I know a Arduino has on its analog inputs something like this.
LG
2018-03-01 03:19 AM
See
https://community.st.com/0D50X00009XkWdWSAV
- have you actually looked in the documentation to find out?Dave Sclegel wrote:
I know a Arduino has on its analog inputs something like this.
Arduino is open-source - so take a look to see how they do it ...