Hi
I am trying to generate angle based output with the N2HET software angle generator.
Tools used are RM46L852 on a LaunchpadXL2 board, CCS 6.1 with TI Compiler and HET IDE.
I am using N2HET_2 to simulate a toothed wheel signal. This part of the project is working fine and producing a signal that represents a 6-1 or 6 toothed wheel rotating at 10000RPM (tooth period = 1ms).
The toothed wheel output is connected to pin N2HET1_2. The angular output is from pin N2HET1_1.
The code used in N2HET1 is as below:
; Angle Counter
L00 APCNT { type=FALL2FALL, prv=ON , data=0 , period=0, irq=OFF };
L01 SCNT { step=8 , gapstart=33, data=0 };
L02 ACNT { edge=FALLING , gapend =47, data=47 };
; Angle Output Channel 1
OUT1 ACMP { next=L00, en_pin_action=ON, cond_addr=OUT1CLR, pin=1, action=SET , reg=B, data=0 };
OUT1CLR MOV64 { next=L00, remote=OUT1, comp_mode=ECMP, en_pin_action=ON, cond_addr=OUT1SET, pin=1, action=CLEAR, reg=B, data=23 };
OUT1SET MOV64 { next=L00, remote=OUT1, comp_mode=ECMP, en_pin_action=ON, cond_addr=OUT1CLR, pin=1, action=SET , reg=B, data=0 };
The Gap Start and Gap End were calculated based on the formula in the TRM for a 6 - 1 wheel.
Gap Start = (Step Width * (actual teeth on gear - 1)) + 1 = 33
Gap End = (Step Width * (total teeth on gear including missing)) - 1 = 47
The ACMP instruction is intended to produce at pulse rising at the beginning of the cycle and falling halfway through (rise at first falling edge fall at fourth).
The output seen on N2HET1_1 is not what I expected. The high pulse tends to span 6 or seven "teeth" of the input wheel and the low part 3 or 4 teeth. Assuming this is some kind of syncing error with the missing tooth I moved to simulating a 6 tooth wheel with no missing teeth.
Gap Start = 41, Gap End = 47.
This lead to a regular output signal with an output period of 7 teeth rise to rise with high duration of 4 teeth and low duration of 3.
After some more experimentation I found that a Gap Start and Gap End of 39 gave a cycle of six teeth. With ACMP rise = 0 and fall = 19 (half duty?) the high period is 3.5 teeth and the low 2.5 teeth.
I would have expected with a SCNT step value of 8 to have 8 counts per tooth giving a cycle overflow of 48 counts. Hence Gap End = 48 - 1 (47).
This appears to be reflected in the ACMP instruction. Using a potentiometer as input to vary the ACMP falling edge I can cleanly move from data = 0 to 39 which I would expect to be the full cycle. This seems to only span from the second falling edge in the cycle onwards.
With OUT1CLR (ACMP falling edge) data = 0: Falling edge is same angle as rising so causes high pulse of cycle length (6 teeth) then low pulse of cycle length and so on.
With OUT1CLR (ACMP falling edge) data = 1: Output rises at the first falling edge of cycle and falls just after the second falling edge of the cycle. This is where I would expect a data value of 8 to cause the falling edge to be.
With each increment of OUT1CLR up to data = 39 the falling edge is shifted smoothly along the cycle as expect.
This behavior seems to be the same with different Gap End values. The ACMP instruction is unable to set an edge within the first tooth except for data = 0 which is the very first falling edge of the cycle.
Any input would be greatly appreciated. Perhaps I have misunderstood the settings of the Gap Start and Gap End values or it is something I have completely missed. I can provide scope captures later to better explain the issue but someone may know what is going wrong in the meantime.
As a side question, I initially intended to use the HWAG but it appears it is only suitable for toothed wheels with no missing teeth or two missing teeth. Is this true?
Thanks for taking the time to read.
Rob
EDIT (31/03/2015) : Added Scope traces and corresponding notes.
Channel 1 is NHET1 Pin 2 (Input from toothed wheel signal). 1KHz 50% Duty signal to simulate 6 teeth on wheel rotating at 10000RPM.
Channel 2 is NHET1 Pin 1 (ACMP output pin). Controlled by an ACMP instruction which sets the pin to rise at ACNT 0 and fall at a varying position. Angle counter gap start and gap end along with ACMP intended start and end values are embedded into each image.
Cursors are set on the expected cycle length ( 1 engine revolution = 6 teeth ).
With ACMP set data = 0 and ACMP clear data = 0 an output which inverts once every cycle length is created. It can be seen the cycle length is 7 teeth long instead of the 6 teeth I would have expected with a Step Width of 8 and Gap End of 47.
With ACMP set data = 0 and ACMP clear data = 1 the output created is a ~1.125ms positive pulse. I would have expected ~0.125ms pulse.
ACMP set data = 0 and ACMP clear data = 7 generates a ~1.875ms positive pulse. I would have expected a ~1.00ms pulse.
The pulse width varies in a linear fashion with the increase of ACMP clear data up to 48 (overflow to 0). The ACMP seems not able to set an event within the first tooth event.
It seems like the ACNT instruction is not setting the NAF for the ACMP instruction to see during the first tooth and extending the whole cycle length by one no matter the value of Gap End.
What am I doing wrong here? I need to be able to generate an output that varies across the whole cycle range. Any help would be much appreciated.
Regards
Rob