cancel
Showing results for 
Search instead for 
Did you mean: 

noob question: DAC or GPIO Analog? STM32F3-Discovery

adam239955
Associate II
Posted on July 08, 2015 at 19:07

Hi, I have got the need to track a continuously changing value and I had the idea to use D/A conversion to convert my variable into a voltage and track it with an oscilloscope or even voltmeter.

Which should this be done, can a digital value be written to the DAC and then the voltage read on some pin? Or alternatively, is it possible to use a GPIO pin with the GPIO_MODE_ANALOG set for this?

#stm32f3 #gyroscope #l3gd20 #stm32f3 #dac #gpio
5 REPLIES 5
Posted on July 08, 2015 at 19:50

You could use the DAC to generate a voltage between 0-Vref

You could use the ADC to measure a voltage between 0-Vref

From your question I'm assuming to want to track an internal variable (12-bit value, or scaled to that extent), via an external pin.

If you used two DAC pins you could drive the X/Y of the scope, and scan several values.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
adam239955
Associate II
Posted on July 08, 2015 at 21:24

Hi, yes I want to track an internal value and yes I intend to scale it to fit.

The

STM32Cube_FW_F3_V1.1.0

software doesn't have an example for this for STM32F3-Discovery, but at least it's doable.

Thanks, that's the approach I'll use.

Adam

Posted on July 08, 2015 at 23:05

The SPL has some

STM32F3-Discovery_FW_V1.0.0\Project\Peripheral_Examples\DMA_RAM_DAC

STM32F30x_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F30x_StdPeriph_Examples\DAC\DAC_SignalsGeneration

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
adam239955
Associate II
Posted on July 09, 2015 at 19:31

Thanks, I have something rudimentary working now.

I found the step-by-step-instruction in stm32f3xx_hal_dac_ex.c of the STM32Cube HAL library quite helpful too.

adam239955
Associate II
Posted on July 13, 2015 at 17:54

Using a D/A the converter I am now able to monitor the gyroscope rotational accelration around the x axis as a voltage.

I run the gyroscope at 190 Hz rate and read the oscilloscope in a thread every time the the DRDY interrupt gives a semaphore.

When the STM32F3-Discovery board is placed on a desk, the output is about 4500 mdps (milli degrees per second) velocity around the x axis. This is within the specified zero-rate level in the L3GD20 specification pdf, which says I can expect +- 15 dps. No surprise there.

I take 3000 samples (which takes about 15s) to get rid of the offset, but even then the D/A converter shows that the zero-rate level keeps drifting.

The L3GD20 Data Sheet doesn't say anything about a settling time, so I wonder what experiences others have had?