Skip to content

B g431 b current sense fixes #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 9, 2022

Conversation

sDessens
Copy link
Contributor

Only tested on B-G431B with inline current sense.

@askuric
Copy link
Member

askuric commented Aug 25, 2022

Did you try using LowsideCurretSense instead of InlineCurrentSense?
Because all the additions that you've made are already present in the _driverSyncLowSide function which is not called in for in-line class. I have moved them there in the last release to remove bg431 specific code from the driver code and because bg431 only has the low-side current sensing. So I would prefer not to use the inline code with it.

void _driverSyncLowSide(void* _driver_params, void* _cs_params){

@sDessens
Copy link
Contributor Author

That's a good point. I feel I messed up with the original implementation, we called it inline current sense, but it really implements low side current sense. I'm confused why the wiki claims inline current sensing support for this board, it seems that placing the required resistors would require very advanced soldering...

I tried using low side current sense, but it doesn't work. There are multiple problems with initialization and syncing, I will attempt a fix.

@askuric
Copy link
Member

askuric commented Aug 25, 2022

Hey @sDessens,
I'll order the board and try to fix it as well. If you don't have time dont worry about it. This PR is already a great step in finding the real reasons for why it does not work.

The docs are wrong you are right!
I've written in that way because at some point we only had your implementation of the BG431 board which was done using the inline current sese (the only one supported at the time).

So I've gone quickly through the code and can it be that the line:

LL_TIM_SetTriggerOutput(HardwareTimer_Handle[index]->handle.Instance, LL_TIM_TRGO_UPDATE);

has to be called before the timer init?

I did not have any problems with this so far for f1, f4 and g4 low-side current sensing. They all work with the TRGO UPDATE setting

LL_TIM_SetTriggerOutput(cs_params->timer_handle->getHandle()->Instance, LL_TIM_TRGO_UPDATE);

and repetition counter downsampling

if( IS_TIM_REPETITION_COUNTER_INSTANCE(cs_params->timer_handle->getHandle()->Instance) ){

that are done after the timer init. They are called when the timer is stopped and once they are called the timer is resumed.

However, the bg431 code is the only one which for now uses the DMA so this might be the issue.

@sDessens sDessens force-pushed the B-G431B-current-sense-fixes branch from 84a4aba to 370a209 Compare August 25, 2022 13:04
@sDessens
Copy link
Contributor Author

I managed to fix the problem, it turns out there was a null-pointer and this caused unpredictable behavior.

With this rebase, LowsideCurrentSense works but InlineCurrentSense does not work.

@askuric askuric changed the base branch from master to dev August 25, 2022 13:53
@askuric
Copy link
Member

askuric commented Aug 25, 2022

Awesome, thanks!

This was my fault, I've refactored the code but as I did not have the board I did not test it properly!
Thanks a lot for taking the time to debug.

@sDessens
Copy link
Contributor Author

I feel the community might be slightly confused that we switched from inline to lowside current sensing on this board. Would it be a good idea to display a warning when the user initializes inlineCurrentSense on this board. For example by displaying a debug message in _configureADCInline?

@askuric
Copy link
Member

askuric commented Aug 30, 2022

I'll make sure to update the docs for the next release. All the library examples already use the low-side current sensing so that should make things a bit easier.

I think adding the message in configure inline is a good idea, just to be make the transition a bit smoother for the people used to use inline cs.
Once you add the message we can merge it.
@runger1101001 you're fine with this?

@askuric
Copy link
Member

askuric commented Oct 9, 2022

Merging, thanks again!

@askuric askuric merged commit 10ab753 into simplefoc:dev Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants