Skip to main content
ionutF
Associate III
July 10, 2017
Question

Sine wave stability

  • July 10, 2017
  • 5 replies
  • 4386 views
Posted on July 10, 2017 at 07:49

Hello

I want to generate a 50Hz stable sine wave which I will amplify in order to obtain AC and DC voltage and current.

The strategy is to generate the sine wave using DAC or PWM. I used one STM32 MCU with two DAC outputs....the MCU is supplied from a 2.5V voltage reference 0.24% accuracy  because I want the sine wave to have an amplitude as constant as possible...

So far I get a sine wave with very poor performances (for example an amplitude of 1.27V with +/- 2% )...by both methodes (DAC and PWM) I guess this is due to internal DAC and timer errors...

Do you have any tips (software , hardware) in order to obtain a more stable sine wave?

#sine-waveform
    This topic has been closed for replies.

    5 replies

    AvaTar
    Senior III
    July 10, 2017
    Posted on July 10, 2017 at 08:34

    I never had sub-percent accuracy requirements when using the DAC, but a few things come to my mind.

    First, which part you are using ?

    A separate supply pin for analog peripherals (VDDA) would be essential. Not every variant has one.

    Second, even with a separate supply, analog peripherals on high-frequency clocked digital circuitry are always a compromise. Check the DAC section of the datasheet for a realistically achievable accuracy.

    The relatively high offset and temperature drift of the DAC with enabled output buffer is known.

    ionutF
    ionutFAuthor
    Associate III
    July 10, 2017
    Posted on July 10, 2017 at 12:20

    MCU:STM32F103RFT6

    The MCU job is just to generate the sine signal (DAC or PWM), it does nothing else, that is why i connected both VDD and VDDA to the precise 2.5V reference ; the current consumption is small enough ; yes I have the buffer enabled.

    Should I read back the sine wave in order to implement a PID regulator?

    AvaTar
    Senior III
    July 10, 2017
    Posted on July 10, 2017 at 12:57

    Not sure what 2.5V reference you are using, but I'm pretty sure they are not intended for supply purposes.

    Control dynamics play an important role as well.

    And connecting the reference to both VDD and VDDA defeats it's purpose IMHO.

    One of the rationales of a separate VDDA is a decoupling from VDD with it's drastic load changes, and the consequent voltage ripples.

    Have you considered an external DAC ?

    S.Ma
    Principal
    July 10, 2017
    Posted on July 10, 2017 at 14:02

    Look at the schematics of a discovery board using DAC/PWM.

    Start using a simple 3.3V supply for everything first. If the STM32 uses USB function, the supply must be >2.7V.

    Some STM32 have various decoupled supply voltages. Read carefully the datasheet for the supply voltages and range.

    If both PWM and DAC are clamped at 1.27V there is something so obvious on the HW side that it's probably an overseen bug.

    ionutF
    ionutFAuthor
    Associate III
    July 11, 2017
    Posted on July 11, 2017 at 07:18

    I intended to keep the current consumption of MCU small enough so the reference can fed it...The reference gives 5mA. I cheked it, the voltage does not drop under load

    Anyway I dropped the DAC idea and I have returned to PWM so VDDA -VDD issue does not matter anymore.

    I want to keep the system as simple as possible so I don't want to use external DAC (I want to explore and find other ways, if they exist)

    Analysing the produced sine wave I observed it varies under 1.18 V RMS and 1.08VRSM , what is curious is that the variation (that 0.1V) is sinusoidal .(rectified sinusoidal wave).

    I will try to calibrate the internal clock, if nothing gets better, then I will use an external one.

    AvaTar
    Senior III
    July 11, 2017
    Posted on July 11, 2017 at 07:29

    With PWM you will IMHO have a hard time to come close to the accuracy of the internal DAC.

    I intended to keep the current consumption of MCU small enough so the reference can fed it...The reference gives 5mA. I cheked it, the voltage does not drop under load

    The problem is the dynamic behavior. How does your reference source react on drastic load changes (load regulation) ?

    You need a scope to check VDD, for ripples in the millisecond and sub-millisecond range.

    ionutF
    ionutFAuthor
    Associate III
    July 11, 2017
    Posted on July 11, 2017 at 15:49

    I have a scope. Also a 220uF on VDD line. The reference is surprisingly good: +/- 0.1mV measured with a precise DMM.

    I gave up on the DAC because my feeling was it is harder to obtain accuracy with DAC given that it uses current, instead with PWM there are less errors because there is no analog thing involved (just a feeling)

    AVI-crak
    Senior
    July 16, 2017
    Posted on July 16, 2017 at 19:34

    The input impedance of the amplifier should be more than 100K.

    Additionally - a low-pass filter (RC enough) must be used, with a cutoff frequency three times lower than the sampling rate. In the case where the RC circuit is between the DAC and the op amp - the resistance of the resistor should be 100K or more.

    Amplifier with an input resistance of more than 10MΩ. Using a standard op-amp has limitations, it should not be overloaded !!! It is acceptable to use the op-amp as a single buffer - with the Rail-to-Rail technology for 3.3V power supply.

    Additionally.

    The DAC module has a nonlinear dynamic distortion dependence on the current vector at the repeater input. The rate of voltage rise from the midpoint to the top or bottom is noticeably lower than the rate of voltage drop from the extreme points to the mean. The static voltage has a smaller deviation, but there are more distortions in the dynamics.

    This kind of distortion is easiest to eliminate with a simple 1-20 MΩ resistor (pick up) - between the chip leg and the midpoint (enough R-R divider).

    Distortions at the most extreme points of the output range can not be eliminated. Output is a limitation of 6% of the range.

    And probably the most important thing is that the signal quality can be achieved in two ways: by increasing the bit density of the DAC, and by increasing the sampling rate.

    ionutF
    ionutFAuthor
    Associate III
    August 1, 2017
    Posted on August 01, 2017 at 14:34

    I have used another board (TI) to generate a  sinusoidal PWM, I managed to obtain 0.1% amplitude stability just with a simple MCU , no battery (powered from EV board supply), no high precision voltage reference. Still that it is far from what I want. 

    0.1% means +/- 3.3 mV from a 3.3V supply, I need maximum +/- 1mV 0.03% (ideally +/- 0.5 mV)

    What was curious is that when I fed the TI MCU from that 2.495 high accuracy voltage reference, the sine wave stability went to +/- 30..40mV