Altair Embed - STM32G070RB ADC Configuration.

Prakash S
Prakash S Altair Community Member
edited April 5 in Community Q&A

Dear All,

Greetings,

I am using the Altair Embed tool for developing the model-based motor control software for the microcontroller "STM32G070RB". Currently, I am facing difficulty in configuring ADC and Looking for support to solve it.

 Below I have mentioned the list of actions that I have done.

Step 1: STM32 Config.

image 

Step 2: PWM config to generate a trigger to ADC.

image

Step 3: ADC Config.

image

Step 4: 

image

image

After compiling it, the ADC value shows it as 0.346 irrespective of the voltage applied between (0-3.3V).

Kindly help me to solve this issue.

 

Thanks & Regards,

Prakash S.

 

Answers

  • KarenDarnell
    KarenDarnell
    Altair Employee
    edited April 1

    Hi Prakash,

    Can you attach the actual diagram to this forum thread so we can take a look at it.

    Best Regards,

    Karen

  • Prakash S
    Prakash S Altair Community Member
    edited April 2

    Hi Karen,

    Kindly find the attachment.

     

    Regards,

    Prakash S.

  • KarenDarnell
    KarenDarnell
    Altair Employee
    edited April 2

    Thanks Prakash. We'll take a look at it and see where we can help.

    Best Regards,

    Karen

  • pdarnell
    pdarnell
    Altair Employee
    edited April 2

    Hi Prakash,

    You were on the right track, your diagram worked for me, but it was hard to see it. I attached a diagram that addresses some issues.

    1) 10Hz is a bit fast to see over the JTAG, so I changed the square wave to 1Hz

    2) your ADC chan was obscured by the 10Hz signal, so I gave it it's own plot trace window

    3) There is no need for the set PWM mode block. It's only used for BLDC commutation.

    4) The monitor buffer is designed to buffer a vector of high frequency data that can be plotted  like a digital scope. You had only 1 element in your buffer. I increased it to 200, and increased sample rate on the target to 1000 Hz. I put my finger on PA5 and you can see the interesting harmonic waveform of 6 cycles per 100 1ms samples. That would give us 60 cycles per second corresponding to the power grid frequency here in the USA. The plot above shows the ADC values in blue, but it is hard to see the waveform as the JTAG bandwidth is limited to a few hundred Hz.

    image

  • pdarnell
    pdarnell
    Altair Employee
    edited April 2

    I also want to mention our eDrives library of model based motor control diagrams. It is a collection of working motor controllers for many different motor types (PMSM, BLDC, ACI, IPM, synchronous reluctance etc), many different inverters, and many different MCUs. We don't have one for the G070, but you can take one for the G4x and retarget it. That approach should speed things up greatly for you.

    Pete

  • Prakash S
    Prakash S Altair Community Member
    edited April 5

    Dear Darnell,

    Greetings, Thanks for the suggestions.

    I have tried the same as what you have suggested.

    One thing, that I have understood clearly is the ADC features of STM32G070RB  cannot be configured using Altair Embed. 

    I have tried the same process of ADC configuration in the G4 family controller, it is working fine. But if I reconfigure the same process to the G0 controller, it is not working. 

    Even in Examples -> Embedded -> STM32 - G0 doesn't have an example of ADC, but other controllers are having.

    I don't know whether my understanding is correct, but this is what I am going through now.

    Kindly correct me if I am wrong.

     

    Thanks,

    Prakash S.

     

  • pdarnell
    pdarnell
    Altair Employee
    edited April 5

    Hi Prakash,

    Did the diagram I posted work for you? I have had no problems configuring the ADC for the G070. What is your problem?

    Pete