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.

RM48 InstaSpin



Hello forum, 

I have a question about wanting to take the InstaSpin program and control it with my own analog input. 

I have already configured a module that reads the input from my analog device and now want to convert the output of that device into something that can control the motor signal.

I have been reading the sample code given in the InstaSpin package and it has a lot to do with the GUI to control the motor output.  I was wondering where my starting point should be if I have already configured a program to read in analog input. 

The input from the analog device would be on a range from 2-3V and I have read in some values to get similar readings from the ADC; although not completely accurate I might add. 

If this question is too broad, a more narrow question would be to ask how I can include the DRV object class so that I am able to assign converted values to the RPM attribute of the DRV object.

"DRV_Obj *obj = (DRV_Obj *) handle;"

Thank you for your support,

Marcos.

  • Hi Marcos,

    I have referred your question to one of our experts who should get back with you shortly on this.  

    Thanks for your patience,

    Paul

  • I don't understand your question.

    Do you mean that you want to control the speed and/or other things through an external analog device?

    The RM46 project does support control through the Hyperterminal. http://www.ti.com/tool/drv8301-rm46-kit. The RM46 project is very similar to the RM48 project.

    In the RM46 project:

      switch (drv.SCI_Command)
      {
       case '3':
        gGUIObj.CtrlType = 0;
        gGUIObj.DutyCmd = 0.3;
        PutText(drv.ecmpHandle, "Duty Cycle Mode Enabled\r\n");
        break;
       case '4':
        gGUIObj.CtrlType = 1;
        gGUIObj.TorqueCmd = 0.3;
        PutText(drv.ecmpHandle, "Current Mode Enabled\r\n");
        break;
       case '5':
        gGUIObj.CtrlType = 2;
        gGUIObj.SpdCmd = 0.3;
        PutText(drv.ecmpHandle, "Velocity Mode Enabled\r\n");
        break;
       case '6':
        gGUIObj.CtrlType = 3;
        gGUIObj.SpdCmd = 0.3;
        PutText(drv.ecmpHandle, "Cascade (Current + Velocity) Mode Enabled\r\n");
        break;
       case '7':
        gGUIObj.DutyCmd = 0;
        gGUIObj.CtrlType = 0;
        gGUIObj.SpdCmd = 0;
        gGUIObj.TorqueCmd = 0;
        PutText(drv.ecmpHandle, "Motor Stopped\r\n");
        break;
       case '8':
        drv.ecmpHandle->DiagFlag = !drv.ecmpHandle->DiagFlag;
        PutText(drv.ecmpHandle, "Watchdog Diagnostics Flag Toggled\r\n");
        break;
      } 

    Here   gGUIObj.SpdCmd = 0.3; defines the speed.

     v->speedRPM = v->baseRPM * v->speed;

    the default baseRPM is 1800RPM.

    Regards,

    Haixiao

  • I have been looking at this specific method in the RM48 version of this package and it looks something like this:

    switch( drv->controlMode )
    {
    case(CURRENT):
    drv->ref = gui->TorqueCmd;
    drv->currentMode = 1;
    drv->velocityMode = 0;
    break;
    case(VELOCITY):
    drv->ref = gui->SpdCmd;
    drv->currentMode = 0;
    drv->velocityMode = 2;
    break;
    case(CASCADE):
    drv->ref = gui->SpdCmd;
    drv->currentMode = 1;
    drv->velocityMode = 2;
    break;
    default:
    drv->ref = gui->DutyCmd;
    drv->currentMode = 0;
    drv->velocityMode = 0;
    break;
    }

    drv->dFuncStartup = gui->DFuncStartup;
    drv->rampUpTime = gui->RampUpTime;
    drv->beginStartRPM = gui->BeginStartRPM;
    drv->endStartRPM = gui->EndStartRPM;
    drv->advancedStartup = gui->AdvancedStartup;
    drv->commErrorMax = gui->CommErrorMax;
    drv->tripCnt = gui->TripCnt;
    drv->currentStartup = gui->CurrentStartup;
    drv->iMax = gui->IMax;
    drv->minVDC = gui->MinVDC;
    drv->maxVDC = gui->MaxVDC;

    // Update monitor values
    gui->SpeedRPM = drv->speedRPM;
    gui->CurrentDisplay = gui->CurrentDisplay = drv->iDCFdbk*drv->mod6Handle->cntDirection;
    gui->Poles = drv->poles;

    gui->IMotor = gui->IMotor = drv->iDCFdbk*RW_CURRENT_GAIN*drv->mod6Handle->cntDirection;
    gui->VBus = drv->vDCBus*RW_DCBUS_GAIN;
    gui->BemfA = drv->iqVaIn;
    gui->BemfB = drv->iqVbIn;
    gui->BemfC = drv->iqVcIn;

    gui->SpdMotor = SPEED_MEAS_CAP_Get_Speed_Output(drv->speedHandle);

    gui->OTFlg = DRV_get_overTempFlg(drvHandle);
    gui->OVFlg = DRV_get_overVoltageFlg(drvHandle);
    gui->FaultMotor = DRV_get_bridgeFaultFlg(drvHandle);

    I realize that this code has a lot of GUI feedback but I was wondering if drv->ref is the variable that controls the knob on the actual GUI. 

    So in the end, the question, clearly stated, is that I have a voltage signal that runs anywhere from 2-3 volts and I wish to use this in place of the knob from the GUI. What I have done so far is changed the switch statement to have a raw number as drv->ref, and was unsuccessful in spinning the motor at a constant speed. If there is a different approach I should be taking, please let me know. I have also included the external voltage to be read in by the ADC.

    Let me know if I can clear up the question anymore. Your advice is always helpful.

  • What you need to do is to change gui->SpdCmd instead of changing drv->ref. Or,

    You can commend the

    drv->ref = gui->SpdCmd;

    I am afraid there is more than one place in the project. After that change the drv->ref to whatever value you want.

    Regards,

    Haixiao

  • So I went through the project and edited the lines where

    drv->rev = gui->SpdCmd

    and all the lines that contain gui->SpdCmd.

    I was able to get some voltages being output, however, the behavior is chaotic.

    Since I was able to get the different phases to output, although all of the voltages were the same, I will now ask a different question. 

    Within the code, I don't think that just drv->ref is what controls the speed, solely.  

    There are line that mention AdcResults1[x].value. These lines are gathering ADC data, even while nothing is being fed into the ADC. There are several different values that do this and I was wondering what these were. 

    Also, since I changed the drv->ref and gui->SpdCmd to the different values with little result, I was wondering what the range of this variable was? is it -.95 ~ .95 like in the GUI knob?

    Thank you.

  • There are four modes in the InstaSpin project, currect,  velocity, cascade, duty cycle, the drv->ref only impact the velocity and cascade mode.Speed does not control the other mode.

    Which mode are you in?

    Regards,

    Haixiao

  • Hello Haixiao,

    I am working with Marcos. We are using the velocity mode by giving the drv->ref a fixed value.

    thank you,

    Danny 

     

  • 0844.sys_main.c

    0. No GuiComposer is needed to run this project.

    1. Replace the sys_main.c with this one

    2. Compile, link and download to the RM48

    3. Setup the Hyperterminal, 19.2k, no parity, 1 stop bit.

    4. Reset the RM48, should see the menu on the Hyperterminal

    5. Press '1' in the Hyperterminal to enable the motor

    6. Press '5' to start the motor in Cascade mode.

    7. Press '6', or '7' to increase the speed or decrease speed.

    8. Press '8' to stop the motor.

    During this process, to modify the speed, I change gGUIObj.SpdCmd. You can compare the old sys_main.c and this one to see the difference.

    Regards,

    Haixiao

  • Marcos, Danny,

    Did Haixiao's directions resolve your issue?  If so please hit the green "verify answer" button on Haixiao's post and we will close the thread.

    Thanks!

    Paul