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.

using hall sensor and insta spin motion

Other Parts Discussed in Thread: MOTORWARE, CONTROLSUITE

Hi,

I'm using the DRV8312-Kit with the C2000 Piccolo ControlCard.

I want to measure the velocity of the motor with the hall sensors, but there are some problems.

I'm using a InstaSpin Motion Project (Lab6d) of motorware_1_01_00_10.

I've looked at the example program of controlSUITE,too.

My problem:

- Is it possible that I'm able to use only eCAP1 in this project? Because I'm able to write into the ecap1 registers, but when I try to write in eCap2 or 3, there are no changes. In the headerfile "gpio.h" in the enum "GPIO_Mode_e" there is only eCAP1, too.

-in ecap1 only cap1 (with rising edge) is changing. cap2 with falling cap3 with rising and cap4 with falling edge is not changing

 

Fabian

 

  • Hi Fabian,

    I don't think this is a hardware problem from what I can tell. I have notified the C2000 team to look at this. They will know more about the Motion project and how it is setup.

  • Fabian,

    What exactly have you tried to integrate into the MotorWare project?

    Currently we don't have any examples in MotorWare for using the Capture capability. There is a set of capture drivers for the f2802x, but the f2806x actually doesn't have the matching files (there is a bug report on this issue, you can re-use the 2x version on your 6x device if needed).

    C:\ti\motorware\motorware_1_01_00_11\sw\drivers\cap\src\32b\f28x\f2802x

    However, if you look at the controlSUITE examples for the DRV8312-C2-KIT you will notice that we don't even use the eCAP peripheral for Hall interface, we are just using GPIO capture and a software timer.  Why?  Well, this is the way we did this a lonnnnnng time ago before the eCAP module, and since we don't spend much time with Halls I think the engineers just choose to re-use the GPIO method instead of porting to using the eCAP peripheral.

    C:\ti\controlSUITE\development_kits\DRV8312-C2-KIT_v128\BLDC_Sensored\f2806xhall_gpio_BLDC.h

    It's not completely straight forward to integrate controlSUITE MACROs into the MotorWare Object Oriented style, but it can be done. Or, if you are a pro at object oriented you could go ahead and write the driver for us and share :)

     

     

  • Hi Chris,

    I thought you've used the eCap models to measure the velocity, but obviously I was wrong.

    What I've done:

    I've included the ecap.h. Its in motorware, too.

    #include "sw/drivers/cap/src/32b/f28x/f2806x/ecap.h"

    Then I wanted to initialize the ecap moduls.

    I've done this with pointers to the adresses of the registers, e.g.

    volatile struct ECAP_REGS* ECapRegs_ptr;

    volatile struct ECAP_REGS ECap1Regs;

    ECapRegs_ptr=(void *)(0x00006A00);

    ...

    ECap1Regs.ECCTL1.bit.CAP1POL = EC_RISING;

    ECap1Regs.ECCTL1.bit.CAP2POL = EC_FALLING;

    ECap1Regs.ECCTL1.bit.CAP3POL = EC_RISING;

    ECap1Regs.ECCTL1.bit.CAP4POL = EC_FALLING;

    ....

    *ECapRegs_ptr=ECap1Regs;

    ----------------------------------------------------------------------------

    The suprising thing was, that this works only for the ecap1 register.

     

    Well, I'll try it with the GPIOs, now.

    Thank you for your support. 

    Fabian

  • Fabian,

    From what I can see it looks like you are creating a register structure and a pointer to a register structure.  You are changing the point to point to what I assume is the correct address, but you aren't modifying the actual register structure.  I'm also not sure the register structure is actually being allocated to overlay the actual memory of the peripheral.

    My recommendation is you download controlSUITE and use the F2806x header files from there to modify the eCAP peripheral.  Support for the eCAP peripheral in motorware isn't fully complete.

    BR,

  • Trey,

    I don't understand really, why I'm not modifying the actual register? Because I can see, that eCAP1 register is changing, and eCAP2 and 3 not?!

    I see this in debugging mode, when I look into the registers.

    I have a similar problem, when I'm trying to initialize ePWM6. I can write into some registers and in some registers I can't write, for example  CMPCTL.

    Is it not possible to do this with the pointers, like I mentioned before?

    I don't know exactly, how I have to initialize the eCap and Pwms with the included headers.

  • Hi Fabian,

    The issue here boils down to C language practices and how the C2000 is handling a copy. In your code you...

    1. Create a pointer that will point to an ECAP_REGS structure. (Ok)

    2. Create an ECAP_REGS structure (Ok)

    3. You then assign this pointer to some address of who knows what (I would not recommend this practice, but I guess this is the location of the ECAP registers)

    4. You then modify this ECAP_REGS structure (Ok)

    5. You then copy to the memory, where ever this ECAPS_REGS_PTR is pointed at, to be equal to your ECAPS_REGS structure. (Again, not a recommended practice if you don't know the behavoir of this action).

    6. I do not know how the C2000 compiler handles this copy but from your statements it appears only the first value is written.

    7. As a quick fix, I would recommend writting to each ECAP bit individually.

    8. Why do you want to use pointers here? You do know appear to gain any benefit from just using a structure and writing. The CPU will have to perform these writes regardless of which way it is done.

    As mentioned, I am not a C2000 expert so I might be missing something here.

     

  • Fabian,

    Could you post a little more of your code?  Are you doing EALLOW before modifying the registers?  How are you modifying ecap2 and ecap3?

    I need a little more info before I can really diagnose your problem.

  • Trey,

    I've done the EALLOW before modifying.

    I modified the registers in the same way, but the pointer pointed to another adress.

    As I mentioned before, I don't use the eCaps any more, I use normal gpio to "measure" the hall sensors.

    I'm sorry, I don't find the code, atm. I'll look for it next week.

     

    Have you recognized my problem with the epwm modul?

    What is the correct way to set the structs, e.g. ECapsRegs, to the right adress?

    Thank you very much for your support.