Modify current sense

cancel
Showing results for 
Search instead for 
Did you mean: 

Modify current sense

1,311 Views
jacobm
Contributor II

I need to modify the freedom project to work with my custom design, the voltage and current range is easy enough to change but I have two in phase current sense rather than 3 low side. What is the correct way to set it up for this configuration.

 

The documentation says to open the project in KDS and replace the 3 shunt file with the two shunt one. Do I just enable feedback_2ph.c save the project and launch KMS to flash it? Secondly how do I specify which phases the sensors are on? I have sensors on phase a & c but feedback_2ph looks like it's configured for Ia and Ib, the documentation doesn't say how to modify it. Since they are in phase is there anyway to take advantage of being able to measure current at all times?

Labels (1)
10 Replies

441 Views
linestream-adam
Senior Contributor I

The feedback current processing is entirely open loop. It should be possible to write the software to use this sensor and perform sensorless foc. I've never tried it, but I believe it is possible.

0 Kudos

441 Views
philip_drake
NXP Employee
NXP Employee

Remove the feedback_3ph.c file with a right mouse click and delete, then with a right mouse click --> properties remove the check from the box before Exclude from resource build .

pastedImage_1.png

If you don't go ahead and add the following line you will get compile warnings or errors(depending on your IDE).

#include "adc_sys.h"

Since there are only two phase currents measured they are referred to as Phase A and Phase B.  So to properly assign the channels use Table 7 in the Adapting KMS for customer hardware document to change the ADC assignments for the ADC channel you connected to and are calling Phase B.  This would be the channel sampled during Sample A on ADC1.  In adc_sys.c you need to change the #define for that sample and channel.

/**

* @def ADC1_SAMPLEA_CHANNEL

* @brief Channel to sample for motor control on ADC 1 Sample A

* Phase B Current

*/

From:

#define ADC1_SAMPLEA_CHANNEL (kAdc16Chn0)

To:

#define ADC1_SAMPLEA_CHANNEL (kAdc16Chn3)

Then when feedback_2ph.c is called it will pick up the phase current you have connected.

I hope this helps.

Best Regards,

Philip

441 Views
jacobm
Contributor II

Thanks for the help,

Two other questions,

1. I'm trying to work out which pins the FRDM-MC-LVPMSM uses for phase voltage sensing data, I think they might have accidentally put the BLDC version in the documentation, it doesn't seem to have phase voltage sense in the schematics. Any idea which pins the kv31 freedom board expects to us to measure phase voltage?

2. The 4th dc bus current sense, is that optional and just used for detecting overcurrent or shorts? Do I need to disable anything in the code to run with it disconnected and just use phase current sense?

0 Kudos

441 Views
philip_drake
NXP Employee
NXP Employee

Back to the original question.  I was corrected by the KMS system architect that the change from using current sense C in the place of current sense B in the feedback_2ph.c operation will have issuses with angle calculation. Here is what he told me:

" I'm concerned about him simply re-mapping the channels since they go into the 3 phase to 2 phase transform.  That could cause issues with the angle estimation.

 

He would be better served by keeping the A & C samples mapped where they should be and modifying the code so that it does the reconstruction based on A & C samples.  In the feedback_3ph.c file there is an example of all 3 different types of reconstruction in the following switch statement:

 

if (svpwmState != SVPWM_NORM)

        {

            switch(svpwmSector)

            {

 

All he would need to do it look for which case is calculating the missing sample, in this case B which is:

case SVPWM_SECT2 :

case SVPWM_SECT3 :

 

He can then copy that code into feedback_2ph.c to replace the code that reconstructs the C sample."

Now to your other questions:

FOC control for PMSM or BLDC motors only use the 3 phase current or 2 phase current sense the DCBus current and the BC voltage to provide feedback. There are no voltage sense requirements.

There are several videos created to teach you about KMS --HERE.  I suggest the "Introducing Concepts of FOC Motor Control" video as well as the discussion in the KMS API reference manual.

pastedImage_3.png

Regards,

Philip

0 Kudos

441 Views
jacobm
Contributor II

I see what you mean now, KMS FOC doesn't use phase voltage even for motor detection? I just saw phase voltages in the tower version schematics and assumed they were used. I still don't quite understand the DCB current pin is this needed for basic FOC functions or is it there for industrial applications that use a braking circuit?

At the moment I'm stuck due to KMS reporting an ADC offset error and current sense calibration failure, is it looking for phase B current sense and DCB current? Do I need to disable those pins or change anything to get the ADC to initialize? 

0 Kudos

441 Views
linestream-adam
Senior Contributor I

Jacob,

KMS does not use the phase voltage for it's sensorless algorithm.  It only requires the phase currents and the DC bus voltage.  The TWR board is designed to work with both FOC (where phase current and DC bus voltage are used) and Trapezodial (where phase voltage and DCB current are used).  

 

The DC bus current isn't required for FOC functionality.  It is provided so that you could do some sort of derating or have protection against pushing too much current through your motor and power stage.  

 

The file feedback_2ph.c was written assuming you have A & B phase sense.  So there are a lot of places where it refers to having phase B current that are not applicable in your application.  You will need to modify the other places in the file where it is using the phase B measurement and replace it with your phase C measurement.  The first one that comes to mind is the function FEEDBACK_runOffsetCalibration.  

441 Views
jacobm
Contributor II

Thanks for the detailed information, I ended up just rewiring it so phase c became phase b for testing and I got it spinning.

When using your software what is considered the optimal current sensing solution? There's many different topology options and current sense methods and it's always a trade off between bandwidth, accuracy, cost and where they're placed in the circuit.

Are there any recommendation for current sense bandwidth?

When using two in phase current is it able to make use of the ability to sample current at any time or does it just behave as if they are two low side shuts and three low side senses offer more performance?

0 Kudos

441 Views
linestream-adam
Senior Contributor I

Yeah, instead of rewriting the code, that might have been the easier path.

Jacob Martyr wrote:

When using your software what is considered the optimal current sensing solution? There's many different topology options and current sense methods and it's always a trade off between bandwidth, accuracy, cost and where they're placed in the circuit.

The optimal current sensing solution is going to be application dependent.  The software is flexible enough to handle almost any type of current sensing.  You will need to choose the best for your application goals.  Shunt-based measurement is inexpensive but since it can only measure when the low side resistor is enabled you can't run in the overmodulation region (and therefore at maximum possible torque) with only 2 sensors.  Hall-based measurement is more expensive but allows for overmodulation when only using 2 sensors.

Jacob Martyr wrote:

Are there any recommendation for current sense bandwidth?

You would want the current sense bandwidth to be greater than the highest fundamental frequency.  Using a bandwidth equal to your pwm frequency would be the simplest.  I'm more of a sw guy though.

Jacob Martyr wrote:

When using two in phase current is it able to make use of the ability to sample current at any time or does it just behave as if they are two low side shuts and three low side senses offer more performance?

There isn't much point to sampling the current faster than the PWM period since that is the only chance to update the control effort.  You could change the point in the PWM period that the current is sampled, but the most important thing is that the currents are sampled at the same instant in time.  The major control advantage to using two Hall-based current sensors is that it allows for overmodulation while to get that same performance requires three shunt-based current sensors.

441 Views
raselmahmud
Contributor I

can i use single high side dc link current sensing in kms project, as single-shunt technique alternative

0 Kudos

441 Views
raselmahmud
Contributor I

i want to use single hall Effect-Based Linear Current Sensor IC

(ACS712 Integrated Hall Effect-Based Linear Current Sensor IC)

0 Kudos