2014-04-05 09:30 PM
Hi all!
I want to control 3 phase motor (I get HDD motor from old HDD), and now I can generate 3 PWM signal on 3 channels but they are same, notshift phase
120 degree! Please help me! I use STM32F4 discovery board and Keil! Thanks all2014-05-06 09:26 AM
2014-05-06 12:12 PM
This wades into an area which I'm not particularly experienced with.
ST provides some examples of it's own, and the TIM units are described, somewhat obtusely, in the reference manual. You should review these to understand what they might be capable of. My observation would be that lower frequency PWM (say sub 100 KHz) can be handled using the assorted TIM interrupts, and advancing the CCx trigger points by desired amounts. ie hardware signal placement with heavy software management. Each TIM has a single counting element. You can use multiple TIM units, and can adjust the phase relationship with each other. They will be synchronous with each other, sharing a common clock (view of time). You can trigger the ADCs from TIMs, a rate of 3x for the timebase would take samples at 120 degree offsets. Diagram specific signals, timings and relationships, it is easier to interpret.2014-06-25 09:08 PM
2014-06-26 08:31 AM
Suggest you look at
STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\TIM\TIM_6Steps You'd need to find a timer that offer inverse outputs ie (CH1, CH1N, etc), then I think you'd have to manage the placement of the edges, likely using toggle mode, and advancing the CCRx setting for the channel at the interrupt for each.2014-08-08 01:30 AM
yes Mr.Clive..now,,I can generate this pulsa, but I am not change the duty cycle which depend on input adc. by the way, how to make program for change duty cycle in three pulse?thanks you Mr.Clive
2014-08-08 08:55 AM
You'd want to alter the period, and to change the duty you'd need to actively manage the placement of the compare registers.
2014-08-10 09:19 AM
2014-08-10 11:20 AM
Like I said, you're going to actively manage the CCRx registers, under interrupt to alter the DUTY of the signal.
Toggle mode is going to intrinsically default to a 50/50 duty if you configure the registers in a passive sense. In an active mode you are going to explicitly program the position of each EDGE you want generating, and in doing so you can control the DUTY cycle. The 0% setting is 0, all OFF, the 100% setting is 40000, all ON Decide how many ADC channels you are using. If more that one, then you'll need to use DMA. For one you don't need to scan. You need to wait for each sample to be ready, and you should probably confirm to yourself that the reading you're getting is actually within the range you want.2014-08-10 04:28 PM
hmm,,Ok Mr.Clive,,but Are you have a simple interrupt program to manage a duty cycle..?because I'm never use interrupt program,,still confusing,,hehehe
Ok Mr.Clive, thanks for your suggestion,,so this programe became this:- I use adc3 for dma and use 4 chanel, because for sensing V,I input and V,I outputvoid ADC3_DMA2_Config(void){ ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; DMA_InitTypeDef DMA_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable ADC3, DMA2 and GPIO clocks ****************************************/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE); /* DMA2 Stream0 channel0 configuration **************************************/ DMA_InitStructure.DMA_Channel = DMA_Channel_2; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&read_adc; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 4; // isi untuk banyaknya channel DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); DMA_Cmd(DMA2_Stream0, ENABLE); /* Configure ADC3 Channel_0,1,2,3 pin as analog input ******************************/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &GPIO_InitStructure); /* ADC Common Init **********************************************************/ ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_15Cycles; ADC_CommonInit(&ADC_CommonInitStructure); /* ADC3 Init ****************************************************************/ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfConversion = 4; ADC_Init(ADC3, &ADC_InitStructure); /* ADC3 regular channel12 configuration *************************************/ ADC_RegularChannelConfig(ADC3, ADC_Channel_0, 1, ADC_SampleTime_480Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_1, 2, ADC_SampleTime_480Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_2, 3, ADC_SampleTime_480Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_3, 4, ADC_SampleTime_480Cycles); /* Enable DMA request after last transfer (Single-ADC mode) */ ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE); /* Enable ADC3 DMA */ ADC_DMACmd(ADC3, ENABLE); /* Enable ADC3 */ ADC_Cmd(ADC3, ENABLE);}2014-08-10 08:31 PM
No, this is not an area I have invested any time in. I'd recommend you review the examples in the firmware library, and understand the relationship between the time base and the compare registers, and how you want to modulate the signal.