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.

How to Evaluate Instaspin FOC with external switch control

Other Parts Discussed in Thread: MOTORWARE, DRV8301, BOOSTXL-DRV8301

I am using  c2000 28207F  launchpad and DRV-8301 BOOSTXL  PACK.

I have successfully spin BLDC motor (24 v ,3000 r.p.m., 2.5 A) with  the GUI and  ccs V6.0. now I want to make standalone application..having external speed control (such as potentiometer or any switch control.)

Motor remains spinning when USB connection is removed ...BUT motor fail to spin  as soon as power supply is switched off and again enabling power supply (without usb connection.)

Does  anyone knows how to make standalone application having  external speed control  (with bypassing the computer and GUI)  ?

  • Its c2000 28027F launchpad and DRV 8301 boostxl pack.
  • Hello,

    Please turn off S1 (Boot Switch) position 3 to work standalone. This will disconnect the JTAG connection. Turn it on again if you want to load the program and run from debugger/GUI.

    Best regards,

    Maria

  • its not working ..motor does not spin when i switched off 24 v supply and again power it on
    I have tried two things
    (1) firstly switch S1 position have (110) that is c2000 launch pad in getmode.
    (2) then S4= OFF and S1=(110) still there is no effect.
    please tell me how i first store the progrme in ROM by using code composer v6.0
    and switch S1 position (110) or (xx0).
  • Hello,

    Your code is there in the flash if you use flash setting (not RAM) and then switching OFF S1 (boot switch) position 3 will make your MCU running in standalone mode. No need to turn OFF S4 (Serial Switch).

    Are you using InstaSPIN Motorware project lab? Which lab is that you use to spin your motor?

    If you use Motorware project lab, your motor won't spin in standalone mode because some flags need to be set.

    These flags can be set in debugger mode but not in standalone mode so in this case you need to modify your Motorware code.

    The flags are: gMotorVars.Flag_enableSys (to enable/disable the whole process) and gMotorVars.Flag_Run_Identify (to enable/disable the motor run).

    So yes, you need to control these flags from external, for example from GPIO7 and GPIO12 which are free.

    You can follow the document that mentioned in this thread to learn about reading GPIO from SPST button (Chapter 6.5).

    And in your main project, you can modify your code, for example:

    //while(!(gMotorVars.Flag_enableSys));

    while(!(gSw1)) // loop: waiting the button to be switched ON

    {

    gMotorVars.Flag_enableSys = false; //still false

    }

    // Not in the loop anymore (the switch is ON)

    gMotorVars.Flag_enableSys = true;

    And then for another flag, you can modify your code for example:

    // loop while the enable system flag is true
        while(gMotorVars.Flag_enableSys)
          {
      ...
            if(CTRL_isError(ctrlHandle))
              {
               ...
              }
            else
              {
                // update the controller state
                bool flag_ctrlStateChanged = CTRL_updateState(ctrlHandle);

                // enable or disable the control

    if(gSw2) //if another switch is ON

    {gMotorVars.Flag_Run_Identify = true;}

    else {gMotorVars.Flag_Run_Identify = false;} // If another switch is OFF

    CTRL_setFlag_enableCtrl(ctrlHandle, gMotorVars.Flag_Run_Identify);

    ....

    }

    I don't test the code above, those ones are only to show you the light.

    So I hope you can modify the code by your own and run your motor externally.

    Good luck!

    Best regards,

    Maria

  • hey thanks for the help..

    Is there similar kind of the harware interrupt projects contain in the CONTROL SUITE so that I can reffer it.

    because control suit provides the example project for c2000 28027f launchpad.

    as i am new with the software language (c coding) is there is any online vedio available to put some light on software part of c2000.

     

    again thanks for help. your solutions is really helped me.

  • Now Please tell me how to connect the Potentiometer to my C2000f28027f and BoostXL_8301 kit Combination so that i can vary my motor speed Externally.

    There is code and hardware setup given  in the Motorware_2014  HAL Tutorial,,BUT its only for the [[[[_c2000F2806x and a drv8301kit_revD combination__]]]

    The Hardware Connection for Potentiometer Adding is as follows for [[[[__c2000F2806x and a drv8301kit_revD combination__]]]]

    THE C code is like this;which  I supposed to be add in HAL.c and  HAL.h files; if i have the c2000F2806x and a drv8301kit_revD combination :::

    But I wanted it to be apply  in the c2000F28027f  and BoostXL_DRV8301  Combination.

    can you please tell me the corresponding pin number of c2000F28027f  MicroController ;which i have to be change in above program.

    Because there are ADC channels available in C2000F28027f  controller.

    Please tell me what change(that is pin number ) I have to made in that above program mentioned, according to {{{ c2000F28027f }}} controller.

     

  • you should be able to follow the example using F2806x + DRV8301 EVM and apply it to the F28027F + BOOSTXL-DRV8301. You are providing the pot to an ADC channel so should obviously use that ADC channel.
  • so you say that I can use that same pin shown in previous example  with  the c20000+ BoostXL DRV8301 combination..

    But that pin  (ADC - BO)  is not available in c2000f28027f  micro controller.

    The only pin seen is shown in following fig. with the orange marking that is pin number 13 of c2000f28027f  microcontroller.

    so can I use the pin number 13 (ADC_IN_B1)  to connect potentiometer with microcontroller for controlling speed of the motor.

    soo only I need to replace with new pin number  in the  HAL.c file and HAL.h file of program which mentioned in previous post.?????

  • "so you say that I can use that same pin shown in previous example with the c20000+ BoostXL DRV8301 combination.."

    I never stated that.

    "so can I use the pin number 13 (ADC_IN_B1) to connect potentiometer with microcontroller for controlling speed of the motor."

    is this ADC channel available on the Launchpad header? Is this where you have hooked up your own pot?
  • Hello,
    In hal.c you can see these lines:
    //configure the SOCs for drv8301nxfet_revB
    // sample the first sample twice due to errata sprz342f
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,ADC_SocChanNumber_B1);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,ADC_SocChanNumber_B1);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,ADC_SocChanNumber_B3);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,ADC_SocChanNumber_B7);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,ADC_SocChanNumber_A3);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,ADC_SocChanNumber_A1);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,ADC_SocChanNumber_A0);
    ...
    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,ADC_SocChanNumber_A7);
    ...

    It means ADC B1, B3, B7, A3, A1, A0, A7 are used. Also A5 for temperature sensor. So you can choose another ADC that are not used to connect the Potentiometer.
  • in hal.c there is  befination for the B1,B3,B7,A3,A1,A0,A7

    //configure the SOCs for drv8301nxfet_revB

     // sample the first sample twice due to errata sprz342f

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,ADC_SocChanNumber_B1);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_0,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_0,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,ADC_SocChanNumber_B1);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_1,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_1,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,ADC_SocChanNumber_B3);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_2,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_2,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,ADC_SocChanNumber_B7);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_3,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_3,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,ADC_SocChanNumber_A3);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_4,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_4,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,ADC_SocChanNumber_A1);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_5,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_5,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,ADC_SocChanNumber_A0);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_6,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_6,ADC_SocSampleDelay_7_cycles);

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,ADC_SocChanNumber_A7);

     ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_7,ADC_SocTrigSrc_EPWM1_ADCSOCA);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_7,ADC_SocSampleDelay_7_cycles);

     // Potentiometer

     // Configure it so that ADCINT1 will trigger a potentiometer conversion

     ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_8,ADC_SocChanNumber_A4);

     ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_8, ADC_Int1TriggersSOC);

     ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_8,ADC_SocSampleDelay_9_cycles);

    SO I HAVE CONNECTED THE POTENTIOMETER TO THE PIN A4 as shown in the last threee lines.

    but there is  no any change in the {{_ gPotentiometer_}}  variable and its also does not reflects these change to the " _iq SpeedRef_krpm;"  variable as this variable  changes the motor speed.

     I have take the 5V supply and ground  from the c2000f28027f board pins number as (PIN_1 in JUMPER_5) ,(PIN_1 in JUMPER_2) itself.

    but no effect on potentiometer variable .

    is am I doing something wrong or I have to change some lines in the HAL.c and HAL.h file 

    program ?.(that is mentioned in previous to previous  post ).

  • PLEASE TELL WHICH A.D.C. PIN SHOULD I USE FOR C2000F28027F AND BoostXL_drv8301 kit combination. i am using motorware_14 and ccs v_6.

    as mentined in motorware example guide they have connected potentiometer to the PIN NUMBER B0

    but for C2000F28027F - BoostXL_drv8301 kit combination pin number B0   is  not available,, soo I have made change in the file that is ; I replace pin number B0 by the pin B4 and in second time   pin A6 to connect the potentiometer... like this shown in the third line of HAL.c file (bellow file)

    Hal.c

    // Potentiometer

    // Configure it so that ADCINT1 will trigger a potentiometer conversion

    ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_8,ADC_SocChanNumber_B4);

    ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_8, ADC_Int1TriggersSOC);

    ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_8,ADC_SocSampleDelay_9_cycles);

    but motor speed is not varied with changing the potentiometer knob.

    also its not reflecting the ADC conversion values to the Speed_Refference variable.

    please tell what others changes i have to make in that HAL.c file so that i can get the external speed control.

    I am using the c2000 launchpads  {{{{3.3 v supply and ground terminals}}}}  for powering the potentiometer.



  • according to the User's Guide you have the following ADC channels from the F28027F

    // These 5 are free, not connected to anything on the BOOSTXL J1

    ADCINA6

    ADCINB4

    ADCINA4

    ADCINA2

    ADCINB2

    // these 7 are used for the currents and voltages to J5

     ADCINB1

    ADCINB3

    ADCINB7

    ADCINA3

    ADCINA1

    ADCINA0

     ADCINA7

    sandesh warwadekar said:
    but motor speed is not varied with changing the potentiometer knob.

    also its not reflecting the ADC conversion values to the Speed_Refference variable.

    You have to do something with the converted value. It doesn't happen by magic.

    did you add the Hal_readPot function?

    with the same

    ADC_ResultNumber_# from the AdcSetSoc functions?  And are you sure that you didn't duplicate any of the SOC or ResultNumbers??

    once you have this value what are you going to do with it?  you will need to correlate this 0 to 1.0 value with a speed or torque setting for your gMotorVars.xxx variables.

  • First  you ask have you add the Hal_ReadPot Function?

    yes its is added in the Project_lab5.c  file in the {{{ interrupt void mainISR(void) function   }}

    you can see it in the bellow figure, denoted by yellow color.

    As I said earlier, I have made changes in the Hal.c and Hal.h file which is described in motorware hardware   module.

    you please check the hal.c where I had connected the potentiometer  to the pin number A4 (shown in line 887 of the picture bellow highlighted by yellow color.)

    Also you ask something about the conversion of the potentiometer value into the  0 to 1.0 value with a speed or torque setting for my  gMotorVars.refspeed variables, it can be shown in the following hal.h figure.

    and potentiometer value is stored in the  {{_ADC_ResultNumber_8_}}  and I am sure that it is not duplicating any  of the SOC or ResultNumbers...please see in above fig.

    please help me because everything is done according to the harware module and still its not happnig

    potentiometer value is not changing and its not updating the  gMotorVars.reffspeed  variable.

  • HAL_readPotentiometerData is a function you need to call. Are you calling this in your project and setting it to a variable?
    If so, verify the range of values you get when you move the pot.

    once you've done that you can look at doing something with this value.

    there are also a couple other posts on this topic if you search
  • Thanks ChrisClearman for your support and giving yours valuable time for me.

    Now the potentiometer is sucessfully interfaced with the c2000 on pin number (ADCIN14).

    you can see the potentiometer values which have been converted into Q-24 format

    The Initial Potentiometer value is saved in {{{ gPotentiometer }}} variable:

    Now you please see the  Intermidiate  potentiometer value in the {{{ gPotentiometer }}}} variable as follows

    Now the last pot value in Q-24 format is in following  fig.

    As you can see the pot value is sucessufully converted into the Q-24 format

    but now this value is not  gets updating  in the {{{ SpeedRef_krpm }} variable.

    hence motor speed is not varies with changing pot value.

    For this i have tried following combination but its not works.

    (1) In {{{  typedef struct _MOTOR_Vars_t_ }} ,I   replace the variable  {{{SpeedRef_krpm }}} with the variable name as gPotentiometer  as follows ;

    typedef struct _MOTOR_Vars_t_
    {

    _iq IdRef_A;
    _iq IqRef_A;
    _iq gPotentiometer ;

    but its not working  even in the standalone mode (without pc)

    please tell me what  corresponding changes i have to make in the variable SpeedRef_krpm  so that I can get the change in motor speed with potentiometer  or The potentiometer value can be updated in the variable {{{ SpeedRef_krpm }}} 

  • Hello,

    You should SET the speed using   CTRL_setSpd_ref_krpm() to make it works.

    In proj_lab05b.c, in main loop, you can find:

    if(EST_isMotorIdentified(obj->estHandle))

             {

               // set the current ramp

               EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);

               gMotorVars.Flag_MotorIdentified = true;

               // set the speed reference

               CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

    ....

    So you can modify it into:

    if(EST_isMotorIdentified(obj->estHandle))
              {

                // set the current ramp
                EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
                gMotorVars.Flag_MotorIdentified = true;


    //Added by Maria
              gMotorVars.SpeedRef_krpm = _IQ(gPotentiometer); //Note: Whether you need to convert to IQ or not, plese check it by yourself


                // set the speed reference
                CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

    Best regards,

    Maria

  • first of all very much thanks to miss Maria Todorova, for giving me such a very valuable suggestion.

    I have edited the program as per you suggested, but first time its not works that is the variable SpeedRef_krpm is not updated with potentiometer variation BUT THEN as you suggested in that line {{{_//Added by Maria
              gMotorVars.SpeedRef_krpm = _IQ(gPotentiometer); //Note: Whether you need to convert to IQ or not, plese check it by yourself_}}}}

    I made one simple change  in yours program as follows:

    if(EST_isMotorIdentified(obj->estHandle))
              {

                // set the current ramp
                EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
                gMotorVars.Flag_MotorIdentified = true;


    //Added by Maria
              gMotorVars.SpeedRef_krpm = gPotentiometer ; //Note: Whether you need to convert to IQ or not, plese check it by yourself


                // set the speed reference
                CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

     

     

    And its simply works.....Hurrrreeee ... thanks for giving yours valuable time and helping me to tackle  this problem.

    Now at this moment the  DRV8301 boosterpack is being gets hot after five to six minutes of continuous

    operation

    I AM NOW UPDATING THE MOTORS PARAMETERS AND LETS HOPE ITS WILL NOT GETS HOT..

    Also please tell me that how I can set the continuous current  rating of 5 A through the boosterpack so that my motor can take some little load.

    motor rating is as follows:

    ({{{_ Motor is of 48V, 500W, 10A BLDC  Hub motor.}}}}

    but I am applying the 24V, 5A due to my boosterpack limitations.

    but drv8301 boostXL  becomes hot at (24 v, 5 A) after 5 to 10 minutes.

    due you knows some solutions on this????

  •  Thought my motor runs smoothly there is problem occurs with above logic.

    Suppose my Acceleration paddle is gives me a value as  (gPotentiometer value as =0.265). that at the zero position of my acceleration paddle,, i get the 265 RMP.

    Now if my vehicle is goes on slope (( that is on down side of the road )) then my motors runs at  greater speed than that of the 265 rpm and my whole system will fails, and not works.

    To avoid this problem i have to do following :::

    At the  zero position of my acceleration paddle; my {{{_c2000 and DRV8301 BoostXl kit_}}}  should be at the DISABLE state (that is  Flag_enableSys  and  Flag__Run_Identify  should be zero.)

    And ; at some intermediate position of my acceleration paddle  (that is at  gPotentiometer = 0.320) . At this gPotentiometer value ,my system becomes enable and starts spinning my motor at respective speed. that is (_Flag_enableSys  and  Flag__Run_Identify  should be  at one or enable position..)

    so I have modifies the code in the  proj_lab05b.c, in main loop, as follows.::3

    if(EST_isMotorIdentified(obj->estHandle))
    {

                // set the current ramp
                EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
                gMotorVars.Flag_MotorIdentified = true;

    gMotorVars.SpeedRef_krpm = gPotentiometer; 

    if(gMotorVars.SpeedRef_krpm  >=0.265)

    {

     CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

    }

    else 

    {

    gMotorVars.Flag_enableSys  = false;

    gMotorVars._Run_Identify_ = false;

    }

    But its not Working ,,motor remains runs at the 235 Rpm at initial position of the acceleration paddle.

    please tell me what changes I have to made so that I can get the correct logical sequence and my E-bike will run.

  • After editing the correct motor parameters that is:::

    motor resistance

    motor inductance

    motor flux

    My motor is ready to spin in stand alone mode with smoothly.

    BUTTTTT>>>

    Motor takes 15 to 16 secants to get the initial 200 RPM speed (that at the starting time) ..after that motor speed varies instantly..

    At initial ( that is at the starting time)  system is varying torque and  this causes 15 seconds time lag at the initial state.

    what should i do so that I can get  200 RPM instantly at the start without any time lag.

    what I have to make corresponding changes in the motor parameters to spin motor immediately at starting state.???


    And which motor variable I have to vary so that I can have current of 5 A to flows in the motor continuously (so that I can have the maximum torque) ???

  • if you work through the labs you would understand some of the start-up flags that can affect the time. There is also a section in SPRUHJ1 that discusses start-up.

    "And which motor variable I have to vary so that I can have current of 5 A to flows in the motor continuously (so that I can have the maximum torque) ???"

    this is not how motors work. You are only controlling the voltage to the bus and the switching of the inverter. The motor only draws what is required based on the load.  With no load you will be drawing a minimal current.  That is also the purpose of FOC, to minimize the current use for the torque required.

  • Yes absolutely true, that motor only draws a current what is required based on the load..
    but my motor have full load current of 40 A and (( DRVBoostXl drive )) having a 10 A max capacity.
    but here I am not loading my motor at full load, the load on motor is just somewhat greater than the No Load.

    Then how I can ensures that (( DRVBoostXl drive )) will not carry current more than 10 A. current

    Is It depends on the {{{{{_iq RsOnLineCurrent_A}}}}} variable setting value or not???
    because after setting this flag value equal to (5) ,, then GUI software shows that 0.5 A of the
    current in RsOnLineCurrent variable.
  • if you are using a speed controller then user.h
    #define USER_MOTOR_MAX_CURRENT
    will limit the maximum output of the speed controller (which is the input to the Iq_Ref_A).

    if you are just using Torque mode THERE IS NO SOFTWARE LIMIT. You need to limit Iq_Ref_A yourself.

    Note that Iq_Ref_A != Total current

    You will note that the total bus current will be much less than USER_MOTOR_MAX_CURRENT
  • My Acceleration paddle give me gPotentiometer  variable value of  0.2800(in Q-24 format) at the initial (zero position)

    so I want my system disable till  gPotentiometer  variable will reach to value 0.3000.

    for this I have made changes in the  proj_lab05b.c, in main loop which is as follows::

    if(EST_isMotorIdentified(obj->estHandle))
          {

                         // set the current ramp
                           EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
                          gMotorVars.Flag_MotorIdentified = true;

                           gMotorVars.SpeedRef_krpm = gPotentiometer;

    if (gMotorVars.SpeedRef_krpm<=0.300)
    {
    gMotorVars.Flag_enableSys = false;
    }
    else
    {
    gMotorVars.Flag_enableSys = true ;
    CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

    }

     and at the main.h I have set the  enableSys system flag false as bellow

    #define MOTOR_Vars_INIT

    {

    false, \
    true, \
    true, \

    }

    but its nor working ..system is not enabling after gPotentiometer value reaches value 0.3100 and greater.

    please tell how I can set the enable system flag AS A TRUE after  gPotentiometer variable reaches to value greater that 0.3000//////

  • to get above logic(mentioned in above post ) I have added one more potentiometer at channel A6 and I keep that potentiometr value set to 1(in Q-24 format) that is I am applying 3.3 v always to that potentiometer.

    I have corrected the code as bellow:::

    for this I have made changes in the  proj_lab05b.c, in main loop which is as follows::

    gPotentiometer1 = HAL_readPotentiometerData1(halHandle);//ADC channel at this pin is kept to either 3.3 v or a 0.00 v

    gPotentiometer = HAL_readPotentiometerData(halHandle);


    if(EST_isMotorIdentified(obj->estHandle))
    {
    // set the current ramp
    EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
    gMotorVars.Flag_MotorIdentified = true;


    // set the speed reference

    if (gPotentiometer1 >=0.5)
    {

    gMotorVars.SpeedRef_krpm = gPotentiometer; 
    CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);
    }


    else
    {
     //gMotorVars.Flag_enableSys = false;
    gMotorVars.Flag_Run_Identify =false;

    }

    if (gPotentiometer1 >=0.5)

    {
     //gMotorVars.Flag_enableSys = true;
    gMotorVars.Flag_Run_Identify =true;

    }

    for above logic ;;whenever I connect A6 pin to 0.00 V*(Ground) then I can get in blockin state  ((motor  stops and rotor is at block position.)) and after connecting ADC_A6 pin to 3.3V the motors stars spinnig again. The flags are as follows in block condotion:::

    Flag_enableSys=1
    Run_Identify;=0
    MotorIdentified;=1

    But I wanted that rotor should be in free state   ,,,though it is  in the stationary condition.

    AND IF I enable that commented (gMotorVars.Flag_enableSys = true;) line ,;then after connecting pin A6 (ADC_A6)

     pin to ground system stops and rotor becomes free(not in block condition , can be rotates easily) but System fails to spins again when I connected ADC_A6 pin to the 3.3V..

    Please tell WHAT I should do to get my motor not in block state when I connected ADC_A6 pin to ground  and  motor should again  

    comeback to spinnig state when I connect ADC_A6 pin to 3.3 V.

  • I am using FOC programe  (lab 5B ) in MOTRWARE_14 , 

    Does any one knows how to enable the Flag_{{{{ enableSys }}}} through external ADC pin channel.

    I have connected potentiometer to  ADC pin number {{ ADC_14 }}}  which gives me values in between (0 to 1).

    once  enableSys  flag is disable  using bellow logic ; its cant enable by using ADC_14 pin VALUES.
    I have to  restarts system again ;then this flag is set to 1 and motor spins.

    I have connected two potentiometer as follows

    (1)first Potentiometer value stored in variable gPotentiometer and its used to control motor speed.

    (2)second  Potentiometer value stored in variable gPotentiometer1 and its used to enable or disable the (c2000f28027f & DRV BoostXL 8301 )

     changes in the  proj_lab05b.c, in main loop

    if(EST_isMotorIdentified(obj->estHandle))
    {
    // set the current ramp
    EST_setMaxCurrentSlope_pu(obj->estHandle,gMaxCurrentSlope);
    gMotorVars.Flag_MotorIdentified = true;


    // set the speed reference

    if (gPotentiometer1 >=0.5)

    {

    gMotorVars.SpeedRef_krpm = gPotentiometer; 
    CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);
    }

    else

    {
     gMotorVars.Flag_enableSys = false;
    gMotorVars.Flag_Run_Identify =false;
    }

    if (gPotentiometer1 >=0)

    {
     gMotorVars.Flag_enableSys = true;
    gMotorVars.Flag_Run_Identify =true;
    }

     but gMotorVars.Flag_enableSys flag is not set to true once it gets disable ;;;I have to restart the system again .

    what corresponding changes i have to make so that  gMotorVars.Flag_enableSys  flag can set or reset from gPotentiometer1 variable.

  • Can you check that actually it is ever entered your IF condition:

    if (gPotentiometer1 >=0)

    {

    // Has it ever entered here?
     gMotorVars.Flag_enableSys = true;
    gMotorVars.Flag_Run_Identify =true;
    }

  • yes I have entered gMotorVars.Flag_enableSys = true

    if (gPotentiometer1 >=0.5)

    {

    gMotorVars.SpeedRef_krpm = gPotentiometer;

    CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);

    }

    else

    {

    gMotorVars.Flag_enableSys = false;

    gMotorVars.Flag_Run_Identify =false;

    }

    if (gPotentiometer1 >=0)

    {

    gMotorVars.Flag_enableSys = true;

    gMotorVars.Flag_Run_Identify =true;

    }

    program executes that first if & else  condition.. that is {{{ (gPotentiometer1 >=0.5)}}}} and its disable the gMotorVars.Flag_enableSys  flag and  its corresponding else statement.

    But when gPotentiometer1 >=0 then my controller doesn't enables the{{{{ gMotorVars.Flag_enableSys}}}}  as a True. and I can not observe any changes in enable_sys and run_motor flag system.

    please help me or suggest any changes in the programe sp that enable_system flag can be  set true when my variable (gPotentiometer1 ) have value greater that 0.

  • You want to say in your above first statement that for gPotentiometer1 >= 0.5, it will set the speed but then if it is less than 0.5, the system will be disable. OK.
    But then if gPotentiometer1 >=0 and gPotentiometer1 <=0.5, what do you want to happen? Disable and then enable?

  • I just want  to implement the  "" COASTING""    on my E-bike project.

    its like FLYING START OF THE BLDC  hub MOTOR .

    that is when my motor is going downside (on slope)  my c2000F28027F  and DRV8301 BoostXL should be disable, and motor should spins freely and whole energy developed is given to battery(REGENERATION) 

    and again when I am on the plane road my system should be enable with the simple switch action.

    that switch action is implemented by that gPotentiomotor1  variable value.(either 3.3V or 0 V) and  that is my plan.

    Can you please tell me what changes I have to made in above program so that I can disable or enable my system .??