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.

space vector modulation - implementation

Other Parts Discussed in Thread: HALCOGEN

Hello, 

I’m implementing space vector modulation algorithm for PMSM. I need few things to implement on microcontroller are as follows

  1. Reference vector – magnitude and phase angle 
  2. Integration of HET IDE generated ‘C ‘code to code composer. 

 

1.       Reference vector – magnitude and phase angle 

I will receive signal from gas pedal. It will be having some DC voltage.  How should I create reference vector in the form of magnitude and phase angle? 

 

2.       Integration of HET IDE generated ‘C ‘code to code composer. 

For this algorithm, I need 6 centre aligned PWMs out of this 3 inverted + 3 non inverted. I created all of these using HET IDE. If I export this code to code composer studio, it will be HEX code values. But for real time implementation part, I’m implementing in ‘C’ code. How to integrate HEX values to ‘C’ code for ex.  to change /update duty cycle during run time. There are already some functions like pwmsetduty etc.   Is it possible to use them ? 

Thank you in advance. 

Regards,

Suyog

  • Hi Suyog,

      Here is a 3phase PWM example you can reference. 

    2148.pwm3ph.zip

     You can use the HET IDE to compile the project. After the project is compile it will produce a pwm3ph.h and pwm3ph.c files. You will include these two files as part of your CCS project build. In HalCoGen, you can include these two files in the HET1 Global Timing Configuration tab. At the right hand side, click on the 'Enable Advance Config Mode / Disable BloackBox Driver' checkbox. In the Select Header 'H" file and Select Source 'C' File, specify the pwm3ph.h and pwm3ph.c as the sources. The HalCoGen will automatically load the HET code into the HET RAM for you. The memory copy function will be part of the hetInit(). 

    This is something you will see as part of the hetInit().

    /** - Fill HET RAM with opcodes and Data */
    /** - "x" in "HET_INITx_PST" denote the HET module Instance
    * Valid range of x - 0 to 9
    * For HET1 module x = 0
    * Refer HET assembler User guide for more Info
    */
    memcpy((void*)hetRAM1, (void*)HET_INIT0_PST, sizeof(HET_INIT0_PST));

    Since you write your custom HET code then the existing HET API will not work for you. The existing HET API only works for the blackbox HET program that comes with the HalCoGen.  For example, you can not use pwmSeDuty. You need to access the HET RAM directly to change any parameters. 

  • Hello,

      Thank you for your reply.

    If I'm not wrong, these are the hard cored values that we can not change during run time.    

    I am having few queries as

    1. As  I can't use HET API. How can I write the separate  function  in 'C'  file for -  changing duty cycle etc ?

    2. After importing  *.c and *.h file from HET , do I have to mention pin number in CCS ?  if not then ,   I think  we  don't even mention physical numbering anywhere else - Is it right ? In my case, is it HET[2/4/6]  ?

    3. Do we  enter  the LR prescale, LR time and other values  in that section (screenshot )?

    Regards,

    Suyog

  • Hi Suyog,

     1. You can change the HET memory content by the CPU.

     For example, if you put a label "START" on the first instruction of the HET code, you will see something like below in header file pwm3ph.h.

    #define HET_START_0 (e_HETPROGRAM0_UN.Program0_ST.START_0)

    #define pHET_START_0   0

    You can refer to the data field of this instruction in your driver code like below. Note this is just an example. You can apply to the data field of any instruction in your code.

     nhetRAM1->Instruction[pHET_START_0].Data = 1234. // Write 1234 to the data field of the instruction with the label START.

    2. In your pwm3ph.het you currently use the below HET pins. For example, you use NHET[18] pin for PHAHI and NHET[4] pin for PHALO.

    PHAHI .equ 18

    PHALO .equ 4

    PHBHI .equ 20

    PHBLO .equ 14

    PHCHI .equ 22

    PHCLO .equ 16

    In your schematic you show Ph1H to be pin EHET2. If you want NHET[2] to the pin that drives Ph1H then you will need to modify the equ above to

    PHAHI .equ 2

    PHALO        .equ       8

    and so on so forth.

    In the HET code, it makes use the AND share feature. You need to make sure you enable the AND share in HalCoGen. For example, if you want to use NHET[2] for PHAHI then you will need to make sure NHET[2] is set as an output pin (see the DIR checkbox is selected) and you enable AND share for NHET[3].

    3. Yes, you need to set up the LR prescale, LR time for the timebase per your application requirements.

  • Hello,

    I'm working on it.  Actually, I'm unable to get o/p on oscilloscope. I think, I'm making mistakes for code generation. Here's my post for code generation -    

    https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/558671

    I'll get back to you, once I'm sorted out  with this problem 

    Regards,

    Suyog

  • Hello,
    I got your point. But If I'm not wrong, this is the code for hard cored value. I want to implement these values - duty cycle increment / decrement, during run time . Can you guide me where can I find tutorial / sample program ?


    REgards,
    Suyog