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.

Compiler/TMS570LS1114: Quadrature encoders on the N2HET on C

Part Number: TMS570LS1114
Other Parts Discussed in Thread: HALCOGEN

Tool/software: TI C/C++ Compiler

Hi

Im working with the Hercules TMS570LS1114 and I need to connect 9 quadrature encoders with the N2HET. I saw the application note http://www.ti.com/lit/an/spna228/spna228.pdf with the state machine. I also read this post: http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/536444/2021979 and found it quite helpful but today I was using Halcogen and on the het.h file I saw some functions for edge detection and also counters. 

I was wondering if, even when Halcogen only supports 7 captures or 7 interrupts per HET and I need 14 on HET1 and 4 in HET2, I could use C functions to do the code or if there is another code for the module to be able to do the task since I tried to replicate the post I added here and had some problems. 

Also how can I get the information about the encoders back to the CPU to use them? Do you have a C code for 1 quadrature encoder I could replicate to get the amount of quadrature readings I need?

Thanks and best regards!

C@

  • Hello Searova,

    The program example provided in the application note appears to take 15 instructions to implement. This means that only 10 will fit into the HET RAM (up to 160 messages per NHET) for each NHET instance. This means that you would have to divide the encoders between the 2 available N2HETs on the device. However, there will not be enough pins for the PIN_A, PIN_B and Index pins for each of the requested 18 encoders even if using the full N2HET1 and N2HET2 avaialble pins on the ZWT packaged device. i.e., this would require 3X14 pins for N2HET 1 which would be 42 pins when we only have 31 NHET channels on N2HET1. In addition, the other 4 on N2HET2 would require an additional 12 where 23 have 18pins but to accomodate the additional 4 encoders we can't support on N2HET1 would mean 8 total or 24 pins needed.

    In regard to interrupts, Each N2HET has 2 interrupts (level 0 and level 1). Each interrupt generation source could be funneled to one of these interrupt routines and then a switch statement used to identify the source and which encoder generated the interrupt.

    Count values would be transferred out of the NHET either by accessing with the CPU (not recommended due to arbitration related issues) or by using the HTU which is similar to a DMA and designed for this purpose.

    Relative to pogramming the NHET, it is programmed using NHET specific microcode and the program executes on a micromachine to control the timers. There could be limitations in Halcogen that may require you to write this code outside the confines of Halcogen in order to realize the full capability that you are looking for.
  • Hi Chuck

    Hope you're great.

    The application note takes 15 instructions per encoder no? channel A and B. Also, my encoders don't have an index pin. Im using only 9 encoders, which means 18 channels and the MCU has enough pins for those.


    I did not get that about the interrupts. I was asking about the generated code by Haclogen, since it has some functions to control the Capture, which I could use to get the encoders signals or even as External Interrupts. The problem is that there is no enough documentation about that in the code or on how to use them. Also, since Halcogen only allows for 7 captures or 7 interrupts I would need to manually configure 7 pins for the 7 encoders in one N2HET and 4 pins for 2 encoders in the other (this two encoders could be configured in Halcogen without major problems but the first 7 encoders, 14 channels, are the problem) and that what Im looking for.


    Im looking for a way to get the encoders data not using a state machine, since I had some problems with the simulations of the encoders using provided code for the HET compiler.


    Also about that to get the data from HTU, how would it be? if configured in Halcogen or even un the HET program....


    Thanks!!
  • Hi Chuck,

    I was wondering if this days you were able to check something about my last reply.

    Best regards!
    Searrova
  • Hello Searrova,

    Unfortunately, my knowledge of the NHET is limited so I can't answer to the level of detail needed. I am forwarding your questions to one of NHET experts who should be able to better address your questions.