This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069F: Current regulation problem

Part Number: TMS320F28069F
Other Parts Discussed in Thread: MOTORWARE

I have designed some custom hardware for the InstaSPIN FOC firmware.  For some reason the code does not seem to be limiting the current properly when running lab 2a - it goes way too high until my supply limits it.  I have checked my current feedback voltages and they are of the proper amplitude.  My mapping, which I think is correct, is shown below.  Could you give that a quick look over to make sure?  If there is anything else that might be causing the current to not limit properly please let me know as I am a bit stuck. 

*** Connections ***

H1 - EPWM2A
L1 - WPWM2B
H2 - EPWM1A
L2 - EPWM1B
H3 - EPWM3A
L3 - EPWM3B

I1_FB - A4
I2_FB - A6
I3_FB - A2

V1_FB - A1
V2_FB - A0
V3_FB - B0
VBUS - A5


*** Feedback mapping ***

  // Conversion starts with phase one which is on EPWM2
  // EXT IA-FB
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,ADC_SocChanNumber_A4);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_0,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_0,ADC_SocSampleDelay_9_cycles);

  // EXT IA-FB
  // Duplicate conversion due to ADC Initial Conversion bug (SPRZ342)
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,ADC_SocChanNumber_A4);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_1,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_1,ADC_SocSampleDelay_9_cycles);

  // EXT IB-FB
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,ADC_SocChanNumber_A6);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_2,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_2,ADC_SocSampleDelay_9_cycles);

  // EXT IC-FB
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,ADC_SocChanNumber_A2);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_3,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_3,ADC_SocSampleDelay_9_cycles);

  // V_MOT1 -> ADCINA1
  // V_MOT2 -> ADCINA0
  // V_MOT3 -> ADCINB0
  // V_BAT -> ADCINA5

  // ADC-Vhb1
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,ADC_SocChanNumber_A1);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_4,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_4,ADC_SocSampleDelay_9_cycles);

  // ADC-Vhb2
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,ADC_SocChanNumber_A0);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_5,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_5,ADC_SocSampleDelay_9_cycles);

  // ADC-Vhb3
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,ADC_SocChanNumber_B0);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_6,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_6,ADC_SocSampleDelay_9_cycles);

  // VDCBUS
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,ADC_SocChanNumber_A5);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_7,ADC_SocTrigSrc_EPWM2_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_7,ADC_SocSampleDelay_9_cycles);
 
  **** PWM Mapping *******
 
  // initialize PWM handles
  obj->pwmHandle[0] = PWM_init((void *)PWM_ePWM2_BASE_ADDR,sizeof(PWM_Obj)); // Phase 1
  obj->pwmHandle[1] = PWM_init((void *)PWM_ePWM1_BASE_ADDR,sizeof(PWM_Obj)); // Phase 2
  obj->pwmHandle[2] = PWM_init((void *)PWM_ePWM3_BASE_ADDR,sizeof(PWM_Obj)); // Phase 3

  • Did you keep the ADC interrupt source as EOC7? Or did you change it to EOC9? Wondering why you set your SOC sample delay to 9 cycles instead of the 7 as set in Motorware

    Sean
  • I am using the source code supplied in the Motorware package for the high voltage board (since it doesn't use the SPI DRV chip and neither do I since my voltage is too high).  I simple used what was there. 

  • Any suggestions on what might be the problem or where I should start looking in order to track this issue down?

  • Can you please link your user.h so we can look over it?

    Sean
  • Attached you will find my user.h file.  I also commented out the HAL_setupFaults(halHandle) line in proj_labXX.c since I do not have my faults set up yet and they are different than the default setting so the default configuration will not allow the motor to run.

    Additionally I made the following change to hal.c so it would agree with my PWM36181.user.h configuration

      // initialize PWM handles
      obj->pwmHandle[0] = PWM_init((void *)PWM_ePWM2_BASE_ADDR,sizeof(PWM_Obj)); // Phase 1
      obj->pwmHandle[1] = PWM_init((void *)PWM_ePWM1_BASE_ADDR,sizeof(PWM_Obj)); // Phase 2
      obj->pwmHandle[2] = PWM_init((void *)PWM_ePWM3_BASE_ADDR,sizeof(PWM_Obj)); // Phase 3

  • What estimator state was in effect when you noticed this issue? Also, your current offset in user.h looks incorrect. As a rule of thumb, you can use (0.5* USER_ADC_FULL_SCALE_CURRENT_A/USER_IQ_FULL_SCALE_CURRENT_A) until you're able to calculate them using lab 3. I would change it to that from 1.65. Another question is why you have such a high full scale current (~85A) and such a low USER_MOTOR_MAX_CURRENT (0.3A) for your AXI_2212_34 motor definition

    Sean
  • The system was driving very high current into the motor when it just started measuring the windings. The low value of current in user.h was to see if that would reduce the current to the motor, which it didn't. (also the motor I am using to test it is a good deal smaller than the target motor, but easier to handle). My understanding of the offset value was that this was the midpoint VOLTAGE seen at the ADC, which is 1.65V when there is zero current. From what you say the offset is something very different than that. I will change the offset value and see if it helps. I will let you know. Thanks!
  • Measure the windings as in EST_State_Rs? Or EST_State_RoverL? I'm wondering if there is some current sensing issue on your hardware.

    Sean
  • I believe it was at the start of EST_State_Rs, it happened so quick I couldn't tell. When I look at my current sensor outputs I see them building in amplitude till they are pegging the 3.3V or 0V rail. That is about +/- 40A. So the current feedback is there just not being read or acknowledged properly
  • OK. I changed the offset and that didn't help. As soon as it starts measuring Rs it builds up the current till my limiting supply cuts it off. As I mentioned I am seeing full swings at my current sensors, but they do not appear to be being read correctly. How would you suggest I go about debugging this?
  • For lab2a, run a fresh debugging instance. Set Flag_enableSys, but do not set Flag_Run_Identify. Please check whether the value of gMotorVars.VdcBus_kV makes sense, i.e. it accurately represents your DC bus voltage. After that, please have a check of the ADC result registers. They should give close to 0.5, which is the voltage sensing bias level. Keep in mind, 0.5 will be represented differently depending on if the value is displayed in hex, decimal or per unit value

    If you aren't receiving the results you expect from the ADC, I think there may be some issue with the voltage feedback circuit on your hardware

    Sean
  • My main DC link voltage displays properly VdcBus_kV. I will check the ADC result registers and let you know what they read.
  • Sean,

    I checked out the ADC registers when the system is enabled and everything looks correct.  My current inputs are at about 1.65V (~half of the 0x0FFF value) and my voltage levels check out as well.  In the voltage measurement circuitry my maximum voltage span (3.3V at ADC) is 69.4V.  As such the voltage at the 3 motor phase ADCs is 9.4V (confirmed to be correct using a meter) and the bus voltage measured by the ADC is 23.5V, again confirmed by measuring with a meter.  So it would appear that the ADC values are indeed correct.  I double checked my phasing and everything looks correct.  Would this happen if somehow the phasing of the currents and voltages got misaligned with their respective EPWMs?   Is it normal for the for the unenergized motor phases to quiesce at a voltage above ground?   Does the HV code to anything strange with the EPWM signals that might be messing me up?  How do you suggest I proceed in the debug process?

    Thanks for your help.

  • Sean,

    As you can see for some reason the system is not looking at the current or not seeing the current levels even though it seems they are present and correct. To get the code to run I did comment out the HAL_setupFaults(halHandle); line in the lab because my faults were different and I didn't set them up yet. This shouldn't matter though should it? Are the faults used as part of sensing Rs? My understanding is that they were there for just for protection. I am grasping at straws at the moment....
  • One more piece of data. If I swap the mapping of the ADCs for phase B and phase C I can get it to run through RoverL estimation and limit the current as it should. Then it goes into over current. I am not sure it makes it all the way through RoverL but at least a good portion of it. I have checked and double checked my mapping. Perhaps one of my current channels is not reading right (though they all seem to have reasonable values). I will put a scope on all the channels and all the voltages to see what is happening. If you have any ideas please let me know. It seems like it is a mapping problem, but as I said I have checked that over and over.
  • Hi Tim,

    As you and Sean discussed,
    1. Check whether the current and voltage sensing circuit is ok, USER_ADC_FULL_SCALE_VOLTAGE_V and USER_ADC_FULL_SCALE_CURRENT_A is correct in user.h.
    2. Check the current sensing polarity is corresponding to HAL_readAdcData() in hal.h.
    3. Which gMotorVars.EstState will cause over current? And what USER_MOTOR_MAX_CURRENT in user.h? You have to check item 1&2 if you met the over current during EST_State_RoverL and EST_State_Rs.
  • Yanming,

    Thanks for the input. Here are my responses to your items. (out of original order)

    3) To restate for clarity, the current is not being limited by the firmware, even though the inputs to the ADC lines appear correct. This happens when it enters EST_State_RoverL. The current overload causes my supply to shut down (I burnt up a motor when it didn't) and so progress stops there.
    1) I have checked and the voltage and current sense circuit is performing properly and the user values are correct.
    2) I am not sure how to check that the polarity for HAL_readAdcData is correct. How would you suggest I go about checking that.

    I am hopeful that item #2 is the issue.

    Regards,
    Tim
  • Well since a reply did not seem to be forth coming I searched through some other forum entries, only to find out that like me others spent days trying to trouble shoot this problem, only to find out that it was a polarity setting that does not seem to be mentioned in the documentation. In the docs it says for positive current feedback you need to change your current bias calculation to read

    bias -= OFFSET_getOffset(obj->offsetHandle_I[cnt]);

    But it does NOT appear to tell you that to get things to work you also need to change

    pAdcData->I.value[0] = value;

    to

    pAdcData->I.value[0] = -value; (for all phases)

    in order to get things to work.

    This apparent documentation omission (at least I couldn't find it) appears to have cost a good number of people a good amount of time. I would strongly suggest adding this tidbit to the section that clearly tells how to change the bias calculation for positive feedback. I am spinning now but I damaged a couple boards and wasted a lot of time in the process.
  • Hi Tim,

    We apologize for the documentation error. The correction has been pushed to our resource who updates and publishes the iS User's Guide, but the change from Rev F to Rev G has not been updated on the web yet. With the next User's Guide revision, the documentation will make notice of the issue you experienced.

    Sean