cancel
Showing results for 
Search instead for 
Did you mean: 

Single motor on ADC3/4

Mikk Leini
Senior
Posted on March 11, 2015 at 22:52

Hello,

Does the PMSM FOC library support single motor drive using OPAMP3/4 and ADC3/4 on STM32F303RB?

I did my own HW like that but it seems that the library still tries to check some flags of ADC1 even if none of the signals are connected to ADC1 nor 2.

PMSM manual says: the pair OPAMP3/OPAMP4 can be used additionally in a project based on STM32F303.

What does this ''additionally'' mean? That it's the second option or that it supports second motor?

#pmsm-single-drive-adc34 #opamp3\4 #foc4.1 #stm32f303
8 REPLIES 8
Mikk Leini
Senior
Posted on March 20, 2015 at 10:46

Up!

It shouldn't be hard to answer this question for ST people...

I now ordered a new PCB where motor is on OPAMP 1/2 pins but for sake of clarity please answer this question.
Gigi
ST Employee
Posted on March 20, 2015 at 17:33

Ciao,

The option is to use OPAMP3/4 and ADC3/4 instead of 1 and 2 for three shunt single motor using STM32F303.

Of course you need also to map the Bus Voltage sampling (and so the temperature feedback)  to ADC3 or 4.

So teoretically there shaould be no dependency for ADC1 and 2... but it is a configuration that usually is not common used and some bugs can hide inside.

Ciao

Gigi

Mikk Leini
Senior
Posted on March 22, 2015 at 19:52

I have three shunt topology and bus voltage and temperature are not used. ADC1/2 are left for additional sensors (not for motor). Anyway i don't use those sensor yet so nothing shouldn use ADC1/2. For testing i mapped bus voltage and temperature to random spare ADC3/4 pins also, but the library still made lot of calls to ADC_GetFlagStatus. By CPU registers i understood it looked for ADC1 injected sequence conversion flag to be set. But as ADC1 peripheral wasn't active then it got stuck in calling that function. That made me think that maybe there is some hardcoded ADC1 usage?

Gigi
ST Employee
Posted on March 23, 2015 at 08:57

I don't see (and I don't rember) any particular reason to use the ADC1 in such configuration, so I presume that is a bug.

I need to investigate.

If you can attach WB configuration that generate the problem, it can be helful.

And also if you can take a snapshot of the ''call stack'' when the FW is stopped inside the routine that checks the flag, it can help a lot.

Thanks

Ciao

Gigi

Mikk Leini
Senior
Posted on March 25, 2015 at 20:23

Hi Gigi,

Here's MC project:

http://www.robotiklubi.ee/_media/projektid/scythe/pmsm/integratedcontroller.stmc

Here's the screenshot of call stack, code and registers.

http://www.robotiklubi.ee/_media/projektid/scythe/pmsm/adc_getflagstatus_stuck.png

On entry R0 had value0x50000000 which is ADC1 status register.

R2 has value0x00000040 which isADC_FLAG_JEOS.

When outside ofADC_GetFlagStatus function i see disassembly. It continues to jump back from address0x08002AAE to0x08002AA4. By surrounding functions it might be easier to find that call in source code.

0x08002AA0 F001FD50 BL.W TIM_OC4PreloadConfig (0x08004544)

0x08002AA4 2140 MOVS r1,0x40

0x08002AA6 4638 MOV r0,r7

0x08002AA8 F7FDFB82 BL.W ADC_GetFlagStatus (0x080001B0)

0x08002AAC 2800 CMP r0,0x00

0x08002AAE D0F9 BEQ 0x08002AA4

0x08002AB0 2140 MOVS r1,0x40

0x08002AB2 4630 MOV r0,r6

0x08002AB4 F7FDFB7C BL.W ADC_GetFlagStatus (0x080001B0)

0x08002AB8 2800 CMP r0,0x00

0x08002ABA D0F9 BEQ 0x08002AB0

0x08002ABC 2140 MOVS r1,0x40

0x08002ABE 4638 MOV r0,r7

0x08002AC0 F7FDFB08 BL.W ADC_ClearFlag (0x080000D4)

0x08002AC4 2140 MOVS r1,0x40

0x08002AC6 4630 MOV r0,r6

0x08002AC8 F7FDFB04 BL.W ADC_ClearFlag (0x080000D4)

As you see R0 is read from R7.

And i found place where R7 is assigned ADC1 status reg address. This seems to be hard coded because other stuff gets into library with variables.

0x08002778 F7FDFD9F BL.W COMP_Init (0x080002BA)

0x0800277C 2101 MOVS r1,0x01

0x0800277E 6838 LDR r0,[r7,0x00]

0x08002780 F7FDFD8E BL.W COMP_Cmd (0x080002A0)

0x08002784 6838 LDR r0,[r7,0x00]

0x08002786 F7FDFDB9 BL.W COMP_LockConfig (0x080002FC)

0x0800278A 7A60 LDRB r0,[r4,0x09]

0x0800278C F8DF9398 LDR.W r9,[pc,920] ; @0x08002B28

0x08002790 F8DFA398 LDR.W r10,[pc,920] ; @0x08002B2C

0x08002794 2801 CMP r0,0x01

0x08002796 BF03 ITTTE EQ

0x08002798 F04F47A0 MOVEQ r7,0x50000000

0x0800279C 464E MOVEQ r6,r9

0x0800279E F04F0812 MOVEQ r8,0x12

0x080027A2 4657 MOVNE r7,r10

0x080027A4 BF1C ITT NE

0x080027A6 4EE2 LDRNE r6,[pc,904] ; @0x08002B30

0x080027A8 F04F082F MOVNE r8,0x2F

0x080027AC 2500 MOVS r5,0x00

0x080027AE E9CB760C STRD r7,r6,[r11,0x30]

0x080027B2 F8AB5038 STRH r5,[r11,0x38]

0x080027B6 981F LDR r0,[sp,0x7C]

0x080027B8 F1A04180 SUB r1,r0,0x40000000

0x080027BC F5B1319A SUBS r1,r1,0x13400

0x080027C0 BF04 ITT EQ

0x080027C2 2024 MOVEQ r0,0x24

0x080027C4 F8AB0038 STRHEQ r0,[r11,0x38]

0x080027C8 4638 MOV r0,r7

0x080027CA F7FDFCC0 BL.W ADC_DeInit (0x0800014E)

Gigi
ST Employee
Posted on April 02, 2015 at 08:46

I need to verify it in the code, but I can't do it now because I'm finalizing the v4.1.

I'm sorry.

Ciao

Gigi

iwos2610
Associate
Posted on July 20, 2015 at 06:06

I don't want to say that i meet the same problem(OPAMP3\4+FOC4.1+STM32F303),and i have made the test PCB````,what a pity, it sames that what i can do now is to change the hardware.

Laurent Ca...
Lead II

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards