Author Topic: Problems with STM32 PMSM FOC SDK  (Read 117306 times)

0 Members and 1 Guest are viewing this topic.

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #125 on: November 24, 2016, 06:51:00 pm »
The motor should not run at all with Id > 0. Something's wrong with the encoder alignment! How much torque do you have with Iq=10000 Id=0, how much do you have with Iq=0 Id=10000?
For now I can not put Iq=0 and the motor continues to run.
But with this sequence, I can get the motor to rotate ...

That means to me that the encoder alignment produces random results...
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #126 on: November 25, 2016, 12:15:09 pm »
I'm terrible working with this.

Can I create a new USART_NewObject (pUSARTParams_t pUSARTParams) to implement my protocol?
They have repeated interrupt routines etc ... it's a bit confusing for me. But I've done very little with object-oriented programming ...
Is different from base C ...
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #127 on: November 25, 2016, 12:24:35 pm »
I'm terrible working with this.

Can I create a new USART_NewObject (pUSARTParams_t pUSARTParams) to implement my protocol?
They have repeated interrupt routines etc ... it's a bit confusing for me. But I've done very little with object-oriented programming ...
Is different from base C ...
i can on the road, can send you a uart example when at home.check out the ST HAL examples. you need to switch off the serial comms in STMCWB, dont use the FOC library for your UART stuff.
« Last Edit: November 25, 2016, 12:26:19 pm by tatus1969 »
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #128 on: November 25, 2016, 12:33:02 pm »
i can on the road, can send you a uart example when at home.check out the ST HAL examples. you need to switch off the serial comms in STMCWB, dont use the FOC library for your UART stuff.

OK.

I usually use the HAL libs. That's how I usually use ST MCUs.
But in this case it's tricky because I wanted to keep the original code and just change the protocol with a jumper.
When the jumper is ON the protocol used is the STMCWB, when the jumper is OFF the protocol used is mine.

But they have the functions of USART very scattered .. I do not like. To make changes of these I have to invent a lot.
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #129 on: November 25, 2016, 02:17:01 pm »
i can on the road, can send you a uart example when at home.check out the ST HAL examples. you need to switch off the serial comms in STMCWB, dont use the FOC library for your UART stuff.

OK.

I usually use the HAL libs. That's how I usually use ST MCUs.
But in this case it's tricky because I wanted to keep the original code and just change the protocol with a jumper.
When the jumper is ON the protocol used is the STMCWB, when the jumper is OFF the protocol used is mine.

But they have the functions of USART very scattered .. I do not like. To make changes of these I have to invent a lot.
do you need to do "hot" switching, or is it ok to decide at boot time?
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #130 on: November 25, 2016, 03:40:16 pm »
do you need to do "hot" switching, or is it ok to decide at boot time?
During boot it is ok.
It's just to be able to do the test easily without having to program.
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #131 on: November 25, 2016, 03:48:18 pm »
In my head, I just have to change the IRQ number to use an IRQ function created by me.
With this function I should be able to do what I want ...

But I do not understand what is the IRQ number (in this case is the number 0) and how do I create mine.

 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #132 on: November 25, 2016, 05:14:44 pm »
In my head, I just have to change the IRQ number to use an IRQ function created by me.
With this function I should be able to do what I want ...

But I do not understand what is the IRQ number (in this case is the number 0) and how do I create mine.


Thats not the way it would work. I haven't tried, but I think this way will work:

1. enable serial comms in STMCWB
2. a switch in stm32f10x_MC_it.c, USART_IRQHandler(), rerouting all interrupts to your specific function. The function USART_IRQHandler() is an alias (per #define) and is the interrupt handler for the UART that is selected with STMCWB, one of USART1_IRQHandler(), USART2_IRQHandler(), USART3_IRQHandler().
3. a switch in main(), calling UI_TaskInit in a different way when you want to claim the UART:   UI_TaskInit(UI_INIT_CFG & ~OPT_COM,wConfig,MC_NUM,oMCI,oMCT,s_fwVer);
4. do your own serial GPIO and UART initialization in case, like this (careful, this is code for STM32F103xB):

Code: [Select]
  GPIO_InitTypeDef GPIO_InitStructure;
  USART_InitTypeDef USART_InitStructure;
  // Init USART1 at pins PB6 (TX) and PB7 (RX)
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1, (FunctionalState)ENABLE );
  USART_InitStructure.USART_BaudRate   = 115200;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits   = USART_StopBits_1;
  USART_InitStructure.USART_Parity     = USART_Parity_No;
  USART_InitStructure.USART_Mode       = USART_Mode_Tx | USART_Mode_Rx;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_Init( USART1, &USART_InitStructure );
  GPIO_InitStructure.GPIO_Pin   = GPIO_TXD | GPIO_RXD;
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init( GPIOB, &GPIO_InitStructure );
  GPIO_PinRemapConfig(GPIO_Remap_USART1, (FunctionalState)ENABLE);
  USART_Cmd( USART1, (FunctionalState)ENABLE );
  USART_ITConfig( USART1, USART_IT_RXNE ..., (FunctionalState)ENABLE);

I would also use DMA to further reduce UART interrupt traffic.
« Last Edit: November 25, 2016, 05:18:25 pm by tatus1969 »
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #133 on: November 25, 2016, 05:52:12 pm »
I was already debugging and realizing how their communication works.
They have many layers where they format the frame before sending.
I was do the same scheme (procedure) that you suggest.
Then I'm more sure of what to do.

Thank you!  :-+ :-+
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #134 on: November 30, 2016, 12:21:14 pm »
I have already been able to create my own communication protocol and my functions. Thank you tatus1969 for all the suport.

But meanwhile came a new EVB to test my motor in full power, the STEVAL-SPIN3201.

I changed workspace (to STM32F0xx), compiled the MC Lib, put everything original (main file, etc..) but the compiler is generating too large binary files for me to program the STSPIN32F0 (32Kb).

I already reported it to ST (using the forum and online suport), but I continue without an explanation ...



Let's start a new battle ...  |O |O
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #135 on: December 01, 2016, 07:09:48 am »
the FOC lib is quite large, it would surprise me if it would fit in 32k including your application code. i would say, wrong EVB. i can check how much code space i use.
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #136 on: December 01, 2016, 11:41:42 am »
the FOC lib is quite large, it would surprise me if it would fit in 32k including your application code. i would say, wrong EVB. i can check how much code space i use.
But they say it should work. In STMCWB this board appears in example ...
The code I was generating for the P-NUCLEO-IHM001 was about 38Kb, larger than the space on the STSPIN32F0.
They must have created some limitations, so that the code is reduced ...

 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #137 on: December 01, 2016, 05:56:51 pm »
I think that you'll not get happy with this EVB. Here is a statistic of my code as promised. Total=32512, will just fit (?).

Code: [Select]
Module ro_code ro_data rw_data so_sum
main.o 6364 169 246 6533
xprintffull.o 4186 0 0 4186
STO_CORDIC_SpeednPosFdbkClass.o 2776 0 337 2776
ICS_LM1_PWMnCurrFdbkClass.o 2200 0 13 2200
MCTasks.o 1420 552 96 1972
stm32f10x_tim.o 1464 0 0 1464
MC_Math.o 592 512 0 1104
PWMnCurrFdbkClass.o 782 0 97 782
stm32f10x_adc.o 710 0 0 710
VirtualSpeedSensor_SpeednPosFdbkClass.o 614 0 25 614
DblDiv.o 582 0 0 582
stm32f10x_gpio.o 520 0 0 520
stm32f10x_rcc.o 444 20 20 464
startup_stm32f10x_md.o 460 0 0 460
stm32f10x_i2c.o 434 0 0 434
DblMul.o 418 0 0 418
stm32f10x_dma.o 412 0 0 412
DblSub.o 384 0 0 384
PIRegulatorClass.o 364 0 225 364
stm32f10x_usart.o 294 0 0 294
xdscale.o 268 0 0 268
system_stm32f10x.o 252 4 4 256
FltDiv.o 252 0 0 252
I64DivMod.o 238 0 0 238
FltSub.o 230 0 0 230
PQD_MotorPowerMeasurementClass.o 228 0 13 228
FltMul.o 216 0 0 216
DblAdd.o 212 0 0 212
localeconv.o 108 80 80 188
RevupCtrlClass.o 184 0 125 184
xxmemxmalloc.o 176 0 8 176
SpeednTorqCtrlClass.o 172 0 33 172
CircleLimitationClass.o 168 0 5 168
StateMachineClass.o 134 0 13 134
Virtual_TemperatureSensorClass.o 134 0 5 134
FltAdd.o 132 0 0 132
xxmemxfree.o 128 0 0 128
MotorPowerMeasurementClass.o 124 0 281 124
Virtual_BusVoltageSensorClass.o 122 0 5 122
misc.o 120 0 0 120
ABImemcpy.o 118 0 0 118
SpeednPosFdbkClass.o 114 0 133 114
MCInterfaceClass.o 102 0 65 102
xencoding_sb.o 96 0 0 96
BusVoltageSensorClass.o 94 0 29 94
DblToI32.o 88 0 0 88
memchr.o 88 0 0 88
MCTuningClass.o 78 0 161 78
FltToDbl.o 78 0 0 78
TemperatureSensorClass.o 72 0 29 72
FltToS32.o 68 0 0 68
xdnorm.o 66 0 0 66
strlen.o 54 0 0 54
Gaps 52 2 0 54
Timebase.o 52 0 4 52
sprintf.o 52 0 0 52
I32ToFlt.o 50 0 0 50
stm32f10x_MC_it.o 48 0 0 48
I32ToDbl.o 48 0 0 48
DblCmpGe.o 46 0 0 46
DblCmpLe.o 46 0 0 46
copy_init3.o 46 0 0 46
MCIRQHandlerClass.o 40 0 16 40
xgetmemchunk.o 40 0 4 40
data_init3.o 40 0 0 40
Linker_created 0 39 4096 39
stm32f10x_dbgmcu.o 36 0 0 36
FltCmpGe.o 36 0 0 36
FltCmpLe.o 36 0 0 36
FltToU32.o 36 0 0 36
zero_init3.o 34 0 0 34
xmbtowc.o 32 0 0 32
FltCmpEq.o 28 0 0 28
xwctomb.o 26 0 0 26
stm32f10x_it.o 24 0 0 24
cmain.o 22 0 0 22
strchr.o 22 0 0 22
setlocale.o 20 0 116 20
exit.o 20 0 0 20
div.o 14 0 0 14
cstartup_M.o 12 0 0 12
xmbcurmax.o 10 0 0 10
xsprout.o 10 0 0 10
cexit.o 10 0 0 10
exit.o 4 0 0 4
low_level_init.o 4 0 0 4
xtls.o 2 0 0 2
I64DivZer.o 2 0 0 2
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #138 on: December 02, 2016, 09:14:40 am »
I think that you'll not get happy with this EVB. Here is a statistic of my code as promised. Total=32512, will just fit (?).
I don't believe.

But it is normal for the manufacturer to say that this SoC is fully compatible with the SDK, but then everything indicates that it will not work ??
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #139 on: December 02, 2016, 09:55:21 am »
I've been compiling for the STM32F030 and it ran 42056. But this MCU family, the STM32F030, has a flash of up to 128Kb, which is no problem.

The STM32F031, inside the STSPIN32F0, only have flash memory up to 32Kb.

[EDIT 1]
In document RN0085, it says that the STM32F030C6 is supported, but only has 32Kb ...
In fact, all the STM32FxxxC6 have 32Kb.



« Last Edit: December 02, 2016, 10:13:29 am by Dave_PT »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #140 on: December 02, 2016, 04:50:26 pm »
I think that you'll not get happy with this EVB. Here is a statistic of my code as promised. Total=32512, will just fit (?).
I don't believe.

But it is normal for the manufacturer to say that this SoC is fully compatible with the SDK, but then everything indicates that it will not work ??
i am curious about the response from ST 8) my guess: marketing bubble, nobody tested it
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #141 on: December 02, 2016, 04:57:15 pm »
I think that you'll not get happy with this EVB. Here is a statistic of my code as promised. Total=32512, will just fit (?).
I don't believe.

But it is normal for the manufacturer to say that this SoC is fully compatible with the SDK, but then everything indicates that it will not work ??
i am curious about the response from ST 8) my guess: marketing bubble, nobody tested it

It is curious, because in fact they have created "projects" to use with this SoC ... but apparently they did not test.
This Soc was ideal for my application because I have some space limitations.

The ST forum is under maintenance until December 5th.
Through online support, I can not get any answers so far.
So it's a bit complicated to move forward ...  :-//
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #143 on: December 02, 2016, 06:10:08 pm »
We Are The Watt - Resistance Is Futile!
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #144 on: December 03, 2016, 10:18:14 am »
This Soc was ideal for my application because I have some space limitations.
That's a good idea of ST to include the gate drivers. But it seems to be brand new, so you'll probably be one of the "external" beta testers. I usually try to avoid this. How about packing two motor controllers in a larger STM32F4, and add six gate drivers in 4x4 WSON each? Could be similar in size.
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #145 on: December 05, 2016, 09:38:33 am »
What a crap ...  :palm:
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #146 on: December 06, 2016, 11:55:13 am »
I am designing a PCB to use the STM32F302R8 and drive my motor in full power.

I still await ST official response about STSPINF0 ....
« Last Edit: December 06, 2016, 11:58:40 am by Dave_PT »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #147 on: December 10, 2016, 01:20:52 pm »
I am designing a PCB to use the STM32F302R8 and drive my motor in full power.

I still await ST official response about STSPINF0 ....
isn't that one a bit oversized? AFAIK the FOC library neither uses the DSP nor the FPU (it's all based on fixpoint integer arithmetic). I started with a STM32F405, but then went down to a STM32F103CBU6 in my current design, small, cheap and more than enough for the task.
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #148 on: December 12, 2016, 09:27:36 am »
isn't that one a bit oversized? AFAIK the FOC library neither uses the DSP nor the FPU (it's all based on fixpoint integer arithmetic). I started with a STM32F405, but then went down to a STM32F103CBU6 in my current design, small, cheap and more than enough for the task.

Yes it is oversized.
But as I'm late so the first board stays like this...  :phew: :phew:
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #149 on: January 25, 2017, 06:31:31 pm »
Overvoltage starts to be a problem.

I came back to see your recommendation to use a zener diode.
When the motor decelerate, the VBus rises to 35V.

One zener diode of 27V, 5W should be enough to control, right?

As a precaution I will use a 24V TVS as well.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf