2017-11-02 06:22 AM
I am seeing very noisy measurements on shunt adc.
I attached schematics and gerbers.
Could suggest how to eliminate noise on adc lines (line connected to shunt and going to STM32F303 chip?
regards
#adc #l6206pd #noiseSolved! Go to Solution.
2017-11-24 01:59 PM
using
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE
completely breaks PWM operation.
I found out that i should indeed use trgo2update - as powerpoint presentation suggested - shown below.
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_ENABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) { Error_Handler(); }2017-11-07 01:39 AM
I see you have a strong low-pass filter between shunt and ADC input (cut freq of about 1.5k if I'm not wrong).
This could filter too much your sensing!
The current flows into the shunt only when one high side and one low side are on, so the voltage on the shunt is very discontinuous. If the cur frequency of the filter is lower than the PWM frequency you are using you kill the signal.
So, my suggestions are:
2017-11-08 09:46 AM
My aim with strong low pass filter was to average signal that I measure with adc and avoid getting noisy measurement. Any idea how to synchronize reading of adc with pwm signal in cubemx code?
I am changing PWM with __HAL_TIM_SetCompare call (cubemx). Code available here:https://github.com/zhivko/EclipseStm32/blob/master/Src/main.cpp#L254-L270
Also another idea - could it be that I am experiecing ground noise? From datasheet it seems shunt resistor should have very short ground path - see picture from datasheet? Please comment.
2017-11-09 08:52 AM
For synchronize the ADC conversion with the PWM generation you can set the TRGO signal of the timer to be generated by the 'update' event and then set the ADC to start the conversion according to this signal.
In this way, if you are using the center-aligned pulse generation, you will have a conversion event in the middle of both the ON time and OFF time of the PWM.
The conversion during the ON time can be used to sense the current and the other one is ... at your disposal
Ground noise generated by long sense paths is an high freq noise generated by commutation by inductive effects. If you sync in the middle of the ON time as described, you will sense the current far away from the peaks.
2017-11-18 12:28 PM
There is some similar code availabe at:
https://community.st.com/0D50X00009XkYIoSAN
To specify trigger happens in the middle of PWM pulse, I need to use pwm timer initialisation with:
htim1.
Init
.CounterMode
= TIM_COUNTERMODE_CENTERALIGNED1;But I still have sMasterConfig.MasterOutputTrigger question - what TIM_TRGO_?? should I use in pwm timer initialization routines, to have 2 adc measurements...
sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC1;
or
sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC2;
or in both pwm timer init routines
sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC;
?
2017-11-21 06:50 AM
The trigger event you should use is the TIM_TRGO_UPDATE.
You can set it in the CubeMX in the following way (both TIM1 and TIM8)
In this way ad update event is generated on the top and on the bottom of the up/down counting corresponding to the ''center'' of the positive and negative pulse of the PWM cycle.
In order to discriminate the two conversion events you can use the following instruction:
__HAL_TIM_DIRECTION_STATUS(&hTIMx)
When it is ''0'' you are in the ''bottom'' conversion event (the one you should use to sense the current) and when it is ''1'' you are in the ''top'' conversion event (where the current cannot be sensed).
Every time you manage the conversion result using the EOC callback you'll check the timer direction and update the ADC channel according to the next conversion (current sensing or ''at disposal'').
2017-11-22 08:11 PM
,
,
I managed to get into adc calback procedure, , after almost 30
trial and error reflashing firmware procedures. Cubemx offers alot of settings and there is quite alot of possible cocmbinations .
After almost 30 times reflashing firmware on my custom board - I managed to land inside HAL_ADC_ConvCpltCallback.
But it is called only once for each ADC instance - I use adc1 and adc3.
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
,
, , ,if (hadc->,Instance == hadc1.Instance) {,
, , , , , ,HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin),,
, , , , , ,SET_BIT((hadc1).Instance->,CR, ADC_CR_ADSTART),,
, , , , , ,HAL_ADC_Start_IT(hadc),,
, , ,} else if (hadc->,Instance == hadc3.Instance) {,
, , , , , ,HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin),,
, , , , , ,SET_BIT((hadc3).Instance->,CR, ADC_CR_ADSTART),,
, , , , , ,HAL_ADC_Start_IT(hadc),,
, , ,},
}Inside this procedure I want restart interrupt
HAL_ADC_Start_IT(hadc)
but this fails everytime since it seems adc has not completed:
if (ADC_IS_CONVERSION_ONGOING_REGULAR(hadc) == RESET)
I tried to reset adc state with:
SET_BIT((hadc1).Instance->,CR, ADC_CR_ADSTART),
but it seems CR could not be set...
what could be wrong? Code available at:
https://github.com/zhivko/EclipseStm32/blob/master/Src/main.cpp ♯ L351-L361
,2017-11-23 06:50 AM
What do you mean with: ''update the ADC channel''.
What should I do to get another HAL_ADC_ConvCpltCallback?
HAL_ADC_Start_DMA(&hadc1, (uint32_t *) DMA_ADCvalues1, 1024)
or
HAL_ADC_Start_IT(&hadc1)
namely first option fails because of condition:
if (ADC_IS_CONVERSION_ONGOING_REGULAR(hadc) == RESET)
Another question - on some powerpoint slides I see this - so - should I use TRGO2 signal as adc input trigger?
2017-11-24 07:18 AM
OH !!! in Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c I see this comment:
/* Disable the transfer complete & transfer error interrupts */
/* if the DMA mode is not CIRCULAR */Who could possibly know that transfer works only on circular buffers?? I think thi could be added in CubeMX software - I mean CubeMX shoud not allow you to to dma transfer if circular buffer is not selected - it should at least popup warning or somehow differenty message this important thing to user!
2017-11-24 01:59 PM
using
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE
completely breaks PWM operation.
I found out that i should indeed use trgo2update - as powerpoint presentation suggested - shown below.
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_ENABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) { Error_Handler(); }