cancel
Showing results for 
Search instead for 
Did you mean: 

STM32M4F415 with Connect EVE

Dave Sclegel
Associate II
Posted on February 27, 2018 at 22:32

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

This discussion is locked. Please start a new topic to ask your question.
5 REPLIES 5
Posted on February 28, 2018 at 12:42

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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Dave Sclegel
Associate II
Posted on February 28, 2018 at 14:29

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 ?

Posted on February 28, 2018 at 15:11

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:

  • Sample continuously, and do the peak-detect in software;
  • Add external peak-detect hardware.
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Dave Sclegel
Associate II
Posted on March 01, 2018 at 11:15

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

Posted on March 01, 2018 at 11:19

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 ...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.