cancel
Showing results for 
Search instead for 
Did you mean: 

FOC 4.0 problem with ADC?

kovac
Associate II
Posted on August 08, 2014 at 12:31

Hello,

I would like to use the latest FOC library for small PMSM motor. I'm using STM32F303VCT6 MCU and I would like to use internal PGA. But motor doesn't run at all. Start sequence starts, but with very high current consuption (higher that I set in WB). I finaly fount that probably AD converter doesn't give a correct value. I see it mainly on Vbus voltage measurement. Measured value is not correct. It shoul be ~325V but reading from MCU give me a value ~189V and it fall down to ~21V after few seconds. Voltage on board is corrent, also MCU ADC works correct - I mean nothing is damaged on the board. I've check it with modified example project in StdLib for STM32F3 and it converts value from Vbus pin. So it seems to me, that something is wrong with setting of AD converter in library. ADC does not measure correct values of Vbus and probably also phase currents and that's why motor has during start so big current consuption and doesn't run. 

I'm attaching my settings in WB. 

Maybe I sould mention, that I use KEIL MDK to compile library.

Any help/tips would be helpfull.

Thanks. Daniel   

#foc-adc #mcu #foc-adc #foc #foc-adc
18 REPLIES 18
Dino COSTANZO
Associate II
Posted on August 12, 2014 at 17:35

Dear Daniel,

which hardware are you using, ST evaluation boards or custom? have you double checked the power stage\bus voltage sensing divider? any error raised from FW?

The pin assigned for bus voltage sensing - i see - is ADC12_IN9 on ADC2 , could you try assigning ADC1 instead?

Is Vmcu = 3.3V? could you double check the actual HW matches the FW configuration?

Regards,

Dino

kovac
Associate II
Posted on August 13, 2014 at 18:11

Hello Dino,

I'm using custom hardware. I've checked hardware and I can see correct voltage on the pin of MCU.

I've also tried to check AD converter with another code and the converter give me a correct value. So the HW is ok.

During start of motor FW give me a fault MC_UNDER_VOLT. This is true, because VBS_GetAvBusVoltage_V returns small value

(at a beginning ~189, after few second ~21) and it should be

ADC12_IN9 on ADC2 is set manually. Original value was ADC1, but then FW give me bus voltage ~1.

Few notes about library: I was not able to compile and run code without changing manually constant BKIN2_MODE to NONE in file

Control stage parameters.h and constant PWM_TIMER_SELECTION2 to TIM1 in file Control stage parameters motor2.h.

One of this change enable me to compile it and another to run code without ending in HardFault interrupt.

MCU voltage is 3.3V.

Beside of this I've alredy tried to use IAR compiler - behavior is absolutely the same.

My last try was to use configuration from joevn - I found it here on this forum. It is for two motors (ok I will use only one)

and of course I had to modified it little bit for my HW (I'm attaching this file).

Workbench generated files and it was possible to compile it without any problem, but during debuging code ends in MCboot function.

When I stop MCU it stuck in function ADC_GetFlagStatus.

Maybe it is a problem of this particular MCU. I would like to use another type of MCU from F3xx family - right know I don't have another MCU and time 🙂

Maybe I will try to use your STM32F3Discovery kit. It has the same MCU. At least I will only try if the voltage measurement works.

Daniel

________________

Attachments :

F12_motor_dual.stmc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hz12&d=%2Fa%2F0X0000000bJf%2F5MsiEmrcOrBogwA7FyZEBbUB0P7vUBVviEDO2gXCG28&asPdf=false
kovac
Associate II
Posted on August 15, 2014 at 21:16

So I have tried to use Discovery kit. I'm using the same type of MCU as it is used in STM32F3Discovery kit. I only added crystal and downloaded code to kit and I put trimer on pin PC3 at which I normaly measure bus voltage. And it works. FW give me correct values and it seems it really measures voltage.

Is it possible that there are some difference inside MCU? The true is, that MCU that I have were bought long time ago. Is there some errata or list of ''changes'' for MCU as it is produced during time?

Daniel

Gigi
Senior
Posted on August 25, 2014 at 10:49

Ciao Daniel

You can find the Errata Sheet in the ST.com.

Anyhow, if is possible, try to get a new micro and replace it in the custom HW in order to understand if the problem is really in that particular part.

Ciao

Gigi 

kovac
Associate II
Posted on September 02, 2014 at 13:53

Hello Gigi

 Problem solved. I bought new MCU, resolder it and it works at first try.

 

That's interesting. I have a lot of these old MCUs. That is pity, but I rather buy a new samples for new projects.

Daniel

hassanbhutta91
Associate II
Posted on December 12, 2014 at 17:35

Dear Daniel ,  i m trying to generate code for PMSM single drive from MC work bench, i gives 4 header files and one MC_it.c file. i m using Kiel u_vision4 . when i add these 4 header files and one c file and compile it it give error. can you please tell me the procedure to comiple the code and run PMSM, my controller is STM32F303VcT6.

also can you please provide me source code ?

hassanbhutta91
Associate II
Posted on December 13, 2014 at 15:33

Dear Gigi ,  i m trying to generate code for PMSM single drive from MC work bench, i gives 4 header files and one MC_it.c file. i m using Kiel u_vision4 . when i add these 4 header files and one c file and compile it it give error. can you please tell me the procedure to comiple the code and run PMSM, my controller is STM32F303VcT6.

also can you please provide me source code ?

hassanbhutta91
Associate II
Posted on December 14, 2014 at 11:17

please help me gigi sir

kovac
Associate II
Posted on December 17, 2014 at 13:13

Hello Raza,

 It is quit common, that you get a lot of error messages when you try to modify source code some how. What I can give you are just generall rules.

Use the the same (compatible or bether the latest) versions of FOC library and Workbench. 

Copy just header files to FOC library. Why you also rewrite .c file?

Mayber I should give you short explanation how to use this library.

You have to download FOC library and Workbench software from ST. Workbench software is use to customize library for your motor. At the end it generates only header files. 

FOC library is set of souce codes, compiled libraries and some other accesories.

You will have to copy this generated header files to folder  System_and_Drive_Params. You just rewrite the original files.

Then you have to open project in KEIL - FOC 4.0 has already project files for KEIL in folder \Project\KEIL\. You wil have to compile the whole project and that's it.

If you see some errors you have to read the error message and find out why and what cause these errors.

Please provide more details about errors.

Daniel