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.

drv8301-LS31-kit simulink

Other Parts Discussed in Thread: HALCOGEN

Good morning,

I have the drv8301-ls31 with the tms570 control card and I was led to believe there was a way to either control the motor drive kit or to program the controller using matlab and simulink. Is this true? If so where can I look for more information about this.


Thank you,

Nate

  • Thanks for using the Hercules forum! An engineer has been notified of your question.

  • Hi Nate,

    Not sure.  Can you please send us a link or pointer to where you saw that. 

    There is a PIL package for TI hercules that you can use but it's not specific to the DRV board and it's not something that lets you run simulations on the hardware in realtime.

    There's also a 'Gui Composer' user interface but this is part of CCS ...

    However,  I wouldnt' profess to know everything that's available for the DRV kit and there's a dedicated motor control team at TI so if you saw something they produced and you point me at it - I'll try to find out more.

     

  • Hi Anthony,

    I found this forum post, is this all the information I need to know how to program the microcontroller using simulink, and that will by extension control the motor drive?

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/321675.aspx

    How would this help me accomplish my goal? Does it generate C/C++ code that can be used to program the TMS570 in CCS?


    Thanks for all your help,

    Nate

  • Nathanael,

    The webinar should be made available for offline viewing soon;  so I would suggest viewing it first.

    Processor-In-The-Loop is a simulation method that lets you check for numerical equivalency between your model running in simulink and the generated/compiled/optimized code running on the TMS570 or RM48.  It's run step-by-step and not in realtime, so it won't help you experiment with a motor drive in realtime.  However, it will let you convert your model to TMS570 C code and if you manually stitch that into a HalCoGen framework, you can run standalone. But it's primary purpose is verification not rapid prototyping.

  • Hi Anthony,

    Sorry for the delayed response, but if I am understanding you correctly I can design a motor control algorithm in simulink then use the zip file package from the other forum post to convert the algorithm into c code.


    Then where does  HalCoGen come into play? Can I use the simulink algorithm in HalCoGen some way? Or am I missing the point of HalCoGen entirely?


    Thanks,

    Nate

  • Nate,

    HalCoGen code contains the low level drivers to initialize the chip, peripherals and also some driver code to make the peripherals do things like perform ADC conversions and output PWMs.

    In Simulink you would model your controller and use the PIL package along with several MATLAB toolboxes (You need Matlab Coder, Simulink Coder, and Embedded Coder toolboxes) to turn your controller into C code.  By controller I mean purely the mathematical algorithms because we  don't have blocks to model IO yet.

    Then when you simulate this in "PIL" mode the signals that normally woudl be coming from the A/D and going out to your bridge driver are modeled and you would leave these running in simulink - only the controller code get's run in PIL.

    Note that in the PIL case, HalCoGen is used 'under the hood' to initialize the device, an to communicate over the serial port (UART) with Simulink.   But you don't need to configure it yourself - it's precofigured.

    When you want to make a standalone / embedded system, where you are running against real hardware (not a model) you need to configure your ADC and PWM as well as device initialization code and maybe even an RTOS through HalCoGen.  You would still have a traditional ADC ISR for example.  But when it comes time to run the controller, you would call the 'step' function of the generated controller, passing it ADC values as input.  You'd then take the values it returns and have to use the HalCoGen timer code to translate these outputs to settings for the PWM.

    So you're writing the IO code yourself (on top of HalCoGen's driver framework) but calling the generated controller passing in/out the values from peripherals.