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.

Programming thw N2HET

Other Parts Discussed in Thread: TMS570LS1115, DRV8835, HALCOGEN

Hi

I will start a project which consist on controlling 12 DC motors (brushed) using the DRV8835 and quadrature encoders, applying a control system to them and will use a TMS570LS1115 MCU.

I was reading about the N2HET and was wondering some things...

The first: I understood, for what i have read, that the N2HET is capable of handle external interrupts, like the encoder pulses, and make operations with them, increment or decrement the count for knowing the exact position of the shaft, and transfer the data to the CPU to apply the different control system of each motor, like a small MCU inside another. Or I misunderstood?

The second: How do you program the module and what software do I need? and I can program it in C?

The third: How do I use the program once made? It is like a library and I just call the different functions i created?

The four: the ePWMs provide 2 different PWMs each, same time base, different duty cycle? 

Thanks for the help!!

 

  • I will try to answer few of your questions, in the meanwhile I'll also have one of our NHET experts comment on this.

    There is some literature available on NHET related tool set already, but the following link could be a good start explaining few of the questions you have posted.

    http://www.ti.com/lit/an/spraba0b/spraba0b.pdf

    We have an NHET assembler which creates the HET opcodes and surrounding infrastructure(.c,.h) required for integrating the same to your C- program.

  • I read the PDF you suggest and I didn't find any useful information (for me)

    The NHET can be program in C?

    And my questions still there... i hope you can help me.. regards Mike

  • Miguel,

    No it is not programmable in C.  There are actually example programs in the application note and that is what they look like.  It is assembly but the NHET instructions while there are not very many of them, have many options.  So the assembly is basically  INSTRUCTION {option, option, option, }

    Some of the options are 'optional' and you'll see them in [] in the TRM. that just means that the N2HET assembler will pick the default value of the option if you don't explicitly specify one.    At the end, there are about 96 bits produced for each instruction -  32 program, 32 control and 32 data.    The data field is often read, modified by the instruction, and written back to RAM all in the same cycle.   The control field is where 'most' of the options are kept, and is not usually modified while the program is running except when you are doing something like toggling the mode of an instruction.
    For example you might have a compare instruction that is setup to make a pin go high on a match,  but also branch to an instruction (like MOV64) on a match that changes the control field of that instruction so that the next match makes the pin go low.

    The program field is generally never written during execution -- with the special exception that it has a 'remote' address field which now can be modified by select instructions.  But you won't see many examples of this in docs.
    The program field controls the flow and type of operations that the HET executes.

    The data field also acts like the 'buffer' for the CPU in some cases, depending on what the instruction is.

    The last 'big picture' point is the concept of the LRP.   The NHET works like this:

    at each loop resolution boundary:  

    • Pin Inputs are captured for the next loop
    • Pin outputs from the previous loop show up on pins (either immediately, or with an optional hi-res delay

    but during the loop you might have different instructions operating on different pins...  it won't matter the time at which these execute because as far as inputs go they are working on the captured input values and their outputs get 'posted' but don't appear on pins until the next loop boundary (plus optional delay) and this update happens on all the pins in parallel.


    The best way to get your head around this is going to be with the use of the HET IDE.   you can see everything executing.    It's a different processor than you probably are used to.   It can do some math but you're not likely going to use it as a math coprocessor.  It's really all about manipulating a large # of pins with some pattern that you program into the machine.   And this can be a lot more customized than you might get with a 'fixed function' hardware timer.  But at some point the ARM processor will wind up being used as your decision making and math engine.

  • mmmm I see... 

    I want to use the module for this: I will have 12 quadrature encoders, so thats 24 pins. I want to create an interruption every rising edge to refresh the count "degrees" and then, send the data to the CPU to tell it where the motor is and where it needs to go, with a controller, a PI for example. How would that be? The code... because I have never used assembler... S:

    Thanks for the help! 

    Mike

  • Hi Mike,

    This post might be useful to you then.  

    RE: RM48L952 N2HET Input rotary encoder

    You just need to implement multiple copies - enough for your 12 encoders.

    The PI controller is a perfect example of what wouldn't work well in N2HET, you will want that code to run on the ARM CPU.

  • Yeah... I was thinking of just using the N2HET to count and then use that info for the controller on the CPU. that woulb be correct right?

  • Hi Miguel,
    Yes that sounds right.  You could also possibly collect some time information as well as count information so you could collect raw data for velocity or acceleration in the HET but that's about where it would stop.

  • Hi Anthony

    I was reading your post, the link you pass me. Could you pls send me the code for A and B for the encoder? for rising edge and the pin selection? I will just make the count, which i need to do in CPU every time a pulse is received no? or if i can do the sum. of the pulses on the NHET could you indicate me how??

    then I can copy that for every sensor just changing the pin numbers right??

    regards!! and sorry for the inconvenience... 

  • I was looking at the HALCOGEN and saw that i only can configure 14 edge interrupts but i need 24... I can configure more pins as external interrupts?

  • Hi Mike,

    For the 2nd to last post - are you asking for different code than what was in the forum post?  If so please be specific about what you're looking for - may or may not have a good match.

    For the HalCoGen GUI because the N2HET is 'infinitely' programmable the GUI in HalCoGen assumes that you are using a 'default' HET program that ships with HalCoGen.  This program has a sprinkle of this and a smidge of that just like a HW timer might have.

    If you want something else, there is a box for selecting your own HET program:

    To use your custom HET program (say developed in the HET IDE) you would check the "Enable Advanced Config..." box.  Then select the browse buttons and browse to the .h and .c files that are generated by the HET assembler.

    (Yes that sounds backwards ... the HET assembler generating C code and H file.   But this is what happens - the ARM CPU has to load the HET program into the HET RAM on startup -- as part of hetInit().  So the .c and .h are basically your HET program turned into a C structure that can be copied to HET RAM as well as some nice stuct information that can help a little when debugging).

  • I'm a little confused to be honest... 

    For what i understood on one of your posts is that once I program one pin as external interrupt on rising edge, i can just copy that same code 24 times just changing the pin to have the pins I need right?? 

    and the same would be with the PWM, because I can arrange them in pairs and then changing the duty cycle for a variable that will be changing according to the PI.

    I think I dont need to make an entirely custom program... i think I can just copy the code for enough pins right?? 

  • Miguel,

    If you were to make multiple copies of the edge interrupt HET code you would need to put that into a custom program, since the program that ships with HalCoGen has a fixed # of edge interrupts.

    Also copying is a 'loose' term here.  You can't exactly copy the instructions bit for bit.  If you look at the instruction fields, the pin # that you want to operate on is encoded and so this needs to be modified.  So even if it's 24 copies of the same instruction, the operands would be a little different.


    The HET program the is included w. HalCoGen is also precompiled and basically hand assembled.  I don't recommend trying to modify it.  Instead enter the instructions in a .het file and run through the HET GUI to assemble it.   Pretty much for the same reason I wouldn't recommend hand assembling ARM CPU code - same thing goes for HET code.

  • Hi, sorry for the inconvenience... I installed the IDE but I cannot see the tms570ls11XX... I was wondering if you knew something about it...

    Those are all the options i can see...

    regards