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.

TMS570LS1224: Using the Waveform on HET IDE

Part Number: TMS570LS1224


Hi

I have been trying to run the simulation to test the code but I cannot make it work. I'm pretty sure the code works since it is based on the code someone else's uploaded a couple of years ago. I just added the extra pins I need for my project.  I have been trying to create the encoders signals but I don't seem to be able to make it run properly on the simulator... 

Here is the code I'm using.

;---------------------------------Variable Definitions--------------------------

;---------------------------------Input Encoder---------------------------------

ENCODER_MAX_STEPS_VALUE   .equ  0x0003475
ENCODER_MINUS_ONE_STEP    .equ  0x0003474

;---------------------Input Encoder Channel 1: Pin Configuration----------------

Pin_A1     .equ  10		; Signal A from QEP encoder -> N2HET1[10]
Pin_B1     .equ  12		; Signal B from QEP encoder -> N2HET1[12]

;---------------------Input Encoder Channel 2: Pin Configuration----------------

Pin_A2     .equ  14		; Signal A from QEP encoder -> N2HET1[14]
Pin_B2     .equ  30		; Signal B from QEP encoder -> N2HET1[30]

;---------------------Input Encoder Channel 3: Pin Configuration----------------

Pin_A3     .equ  16		; Signal A from QEP encoder -> N2HET1[16]
Pin_B3     .equ  29		; Signal B from QEP encoder -> N2HET1[29]

;---------------------Input Encoder Channel 4: Pin Configuration----------------

Pin_A4     .equ  27		; Signal A from QEP encoder -> N2HET1[27]
Pin_B4     .equ  22		; Signal B from QEP encoder -> N2HET1[22]

;---------------------Input Encoder Channel 6: Pin Configuration----------------

Pin_A6     .equ  31		; Signal A from QEP encoder -> N2HET1[31] 
Pin_B6     .equ  15		; Signal B from QEP encoder -> N2HET1[15] 

;---------------------Input Encoder Channel 8: Pin Configuration----------------

Pin_A8     .equ  19		; Signal A from QEP encoder -> N2HET1[19]
Pin_B8     .equ  13		; Signal B from QEP encoder -> N2HET1[13]

;---------------------Input Encoder Channel 9: Pin Configuration----------------

Pin_A9     .equ  6		; Signal A from QEP encoder -> N2HET1[6]
Pin_B9     .equ  25		; Signal B from QEP encoder -> N2HET1[25]

;---------------------Input Encoder Channel 10: Pin Configuration----------------

Pin_A10     .equ  24	; Signal A from QEP encoder -> N2HET1[24]
Pin_B10     .equ  26	; Signal B from QEP encoder -> N2HET1[26]

;---------------------Input Encoder Channel 11: Pin Configuration----------------

Pin_A11     .equ  8		; Signal A from QEP encoder -> N2HET1[8]
Pin_B11     .equ  28	; Signal B from QEP encoder -> N2HET1[28]

;---------------------Input Encoder Channel 12: Pin Configuration----------------

Pin_A12     .equ  1		; Signal A from QEP encoder -> N2HET1[1]
Pin_B12     .equ  3		; Signal B from QEP encoder -> N2HET1[3]


;-------------------------------------------------------------------------------
;---------------------------------HET Program-----------------------------------
;-------------------------------------------------------------------------------

;---------------------------------INPUT ENCODER - QEP---------------------------

;---------------------------------Start Channel 1-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A1 Fall and Pin_B1 Low or is Pin_A1 Fall and Pin_B1 High----
;-------------------------------------------------------------------------------

AFE1 BR { next = ARE1, cond_addr = AFL1, event = Fall, pin = Pin_A1}

AFL1 BR { next = BAC1, cond_addr = FOR1, event = Low, pin = Pin_B1}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A1 Rise and Pin_B1 Low or is Pin_A1 Rise and Pin_B1 High----
;-------------------------------------------------------------------------------

ARE1 BR { next = BFE1, cond_addr = ARL1, event = rise, pin = Pin_A1}

ARL1 BR { next = BAC1, cond_addr = FOR1, event = high, pin = Pin_B1}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B1 Fall and Pin_A1 Low or is Pin_B1 Fall and Pin_A1 High----
;-------------------------------------------------------------------------------

BFE1 BR { next = BRE1, cond_addr = BFL1, event = Fall, pin = Pin_B1}

BFL1 BR { next = BAC1, cond_addr = FOR1, event = high, pin = Pin_A1}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B1 Rise and Pin_A1 High or is Pin_B1 Rise and Pin_A1 High---
;-------------------------------------------------------------------------------

BRE1     BR      { next = AFE2, cond_addr = BRL1, event = rise, pin = Pin_B1}

BRL1     BR      { next = BAC1, cond_addr = FOR1, event = low, pin = Pin_A1}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR1     CNT     { next = AFE2, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC1     MOV32   { next = LIM1, remote = FOR1, type = REMTOREG, reg = A}

LIM1     ECMP    { next = SSUB1, cond_addr= HIL1, hr_lr=LOW, en_pin_action=off, pin=CC10, reg = A, data=0}

HIL1     ADM32   { next = AFE2, remote = FOR1, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB1    ADM32   { next = AFE2, remote = FOR1, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 1---------------------------------

;---------------------------------Start Channel 2-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A2 Fall and Pin_B2 Low or is Pin_A2 Fall and Pin_B2 High----
;-------------------------------------------------------------------------------

AFE2     BR      { next = ARE2, cond_addr = AFL2, event = Fall, pin = Pin_A2}

AFL2     BR      { next = BAC2, cond_addr = FOR2, event = Low, pin = Pin_B2}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A2 Rise and Pin_B2 Low or is Pin_A2 Rise and Pin_B2 High----
;-------------------------------------------------------------------------------

ARE2     BR      { next = BFE2, cond_addr = ARL2, event = rise, pin = Pin_A2}

ARL2     BR      { next = BAC2, cond_addr = FOR2, event = high, pin = Pin_B2}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B2 Fall and Pin_A2 Low or is Pin_B2 Fall and Pin_A2 High----
;-------------------------------------------------------------------------------

BFE2     BR      { next = BRE2, cond_addr = BFL2, event = Fall, pin = Pin_B2}

BFL2     BR      { next = BAC2, cond_addr = FOR2, event = high, pin = Pin_A2}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B2 Rise and Pin_A2 High or is Pin_B2 Rise and Pin_A2 High---
;-------------------------------------------------------------------------------

BRE2     BR      { next = AFE3, cond_addr = BRL2, event = rise, pin = Pin_B2}

BRL2     BR      { next = BAC2, cond_addr = FOR2, event = low, pin = Pin_A2}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR2     CNT     { next = AFE3, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC2     MOV32   { next = LIM2, remote = FOR2, type = REMTOREG, reg = A}

LIM2     ECMP    { next= SSUB2, cond_addr= HIL2, hr_lr=LOW, en_pin_action=off, pin=CC14, reg = A, data=0}

HIL2     ADM32   { next = AFE3, remote = FOR2, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB2     ADM32   { next = AFE3, remote = FOR2, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 2---------------------------------

;---------------------------------Start Channel 3-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A3 Fall and Pin_B3 Low or is Pin_A3 Fall and Pin_B3 High----
;-------------------------------------------------------------------------------

AFE3     BR      { next = ARE3, cond_addr = AFL3, event = Fall, pin = Pin_A3}

AFL3     BR      { next = BAC3, cond_addr = FOR3, event = Low, pin = Pin_B3}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A3 Rise and Pin_B3 Low or is Pin_A3 Rise and Pin_B3 High----
;-------------------------------------------------------------------------------

ARE3     BR      { next = BFE3, cond_addr = ARL3, event = rise, pin = Pin_A3}

ARL3     BR      { next = BAC3, cond_addr = FOR3, event = high, pin = Pin_B3}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B3 Fall and Pin_A3 Low or is Pin_B3 Fall and Pin_A3 High----
;-------------------------------------------------------------------------------

BFE3     BR      { next = BRE3, cond_addr = BFL3, event = Fall, pin = Pin_B3}

BFL3     BR      { next = BAC3, cond_addr = FOR3, event = high, pin = Pin_A3}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B3 Rise and Pin_A3 High or is Pin_B3 Rise and Pin_A3 High---
;-------------------------------------------------------------------------------

BRE3     BR      { next = AFE4, cond_addr = BRL3, event = rise, pin = Pin_B3}

BRL3     BR      { next = BAC3, cond_addr = FOR3, event = low, pin = Pin_A3}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR3     CNT     { next = AFE4, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC3     MOV32   { next = LIM3, remote = FOR3, type = REMTOREG, reg = A}

LIM3     ECMP    { next= SSUB3, cond_addr= HIL3, hr_lr=LOW, en_pin_action=off, pin=CC16, reg = A, data=0}

HIL3     ADM32   { next = AFE4, remote = FOR3, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB3     ADM32   { next = AFE4, remote = FOR3, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 3---------------------------------

;---------------------------------Start Channel 4-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A4 Fall and Pin_B4 Low or is Pin_A4 Fall and Pin_B4 High----
;-------------------------------------------------------------------------------

AFE4     BR      { next = ARE4, cond_addr = AFL4, event = Fall, pin = Pin_A4}

AFL4     BR      { next = BAC4, cond_addr = FOR4, event = Low, pin = Pin_B4}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A4 Rise and Pin_B4 Low or is Pin_A4 Rise and Pin_B4 High----
;-------------------------------------------------------------------------------

ARE4     BR      { next = BFE4, cond_addr = ARL4, event = rise, pin = Pin_A4}

ARL4     BR      { next = BAC4, cond_addr = FOR4, event = high, pin = Pin_B4}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B4 Fall and Pin_A4 Low or is Pin_B4 Fall and Pin_A4 High----
;-------------------------------------------------------------------------------

BFE4     BR      { next = BRE4, cond_addr = BFL4, event = Fall, pin = Pin_B4}

BFL4     BR      { next = BAC4, cond_addr = FOR4, event = high, pin = Pin_A4}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B4 Rise and Pin_A4 High or is Pin_B4 Rise and Pin_A4 High---
;-------------------------------------------------------------------------------

BRE4     BR      { next = AFE6, cond_addr = BRL4, event = rise, pin = Pin_B4}

BRL4     BR      { next = BAC4, cond_addr = FOR4, event = low, pin = Pin_A4}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR4     CNT     { next = AFE6, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC4     MOV32   { next = LIM4, remote = FOR4, type = REMTOREG, reg = A}

LIM4     ECMP    { next= SSUB4, cond_addr= HIL4, hr_lr=LOW, en_pin_action=off, pin=CC27, reg = A, data=0}

HIL4     ADM32   { next = AFE6, remote = FOR4, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB4     ADM32   { next = AFE6, remote = FOR4, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 4---------------------------------

;---------------------------------Start Channel 6-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A6 Fall and Pin_B6 Low or is Pin_A6 Fall and Pin_B6 High----
;-------------------------------------------------------------------------------

AFE6     BR      { next = ARE6, cond_addr = AFL6, event = Fall, pin = Pin_A6}

AFL6     BR      { next = BAC6, cond_addr = FOR6, event = Low, pin = Pin_B6}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A6 Rise and Pin_B6 Low or is Pin_A6 Rise and Pin_B6 High----
;-------------------------------------------------------------------------------

ARE6     BR      { next = BFE6, cond_addr = ARL6, event = rise, pin = Pin_A6}

ARL6     BR      { next = BAC6, cond_addr = FOR6, event = high, pin = Pin_B6}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B6 Fall and Pin_A6 Low or is Pin_B6 Fall and Pin_A6 High----
;-------------------------------------------------------------------------------

BFE6     BR      { next = BRE6, cond_addr = BFL6, event = Fall, pin = Pin_B6}

BFL6     BR      { next = BAC6, cond_addr = FOR6, event = high, pin = Pin_A6}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B6 Rise and Pin_A6 High or is Pin_B6 Rise and Pin_A6 High---
;-------------------------------------------------------------------------------

BRE6     BR      { next = AFE8, cond_addr = BRL6, event = rise, pin = Pin_B6}

BRL6     BR      { next = BAC6, cond_addr = FOR6, event = low, pin = Pin_A6}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR6     CNT     { next = AFE8, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC6     MOV32   { next = LIM6, remote = FOR6, type = REMTOREG, reg = A}

LIM6     ECMP    { next= SSUB6, cond_addr= HIL6, hr_lr=LOW, en_pin_action=off, pin=CC31, reg = A, data=0}

HIL6     ADM32   { next = AFE8, remote = FOR6, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB6     ADM32   { next = AFE8, remote = FOR6, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 6---------------------------------

;---------------------------------Start Channel 8-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A8 Fall and Pin_B8 Low or is Pin_A8 Fall and Pin_B8 High----
;-------------------------------------------------------------------------------

AFE8     BR      { next = ARE8, cond_addr = AFL8, event = Fall, pin = Pin_A8}

AFL8     BR      { next = BAC8, cond_addr = FOR8, event = Low, pin = Pin_B8}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A8 Rise and Pin_B8 Low or is Pin_A8 Rise and Pin_B8 High----
;-------------------------------------------------------------------------------

ARE8     BR      { next = BFE8, cond_addr = ARL8, event = rise, pin = Pin_A8}

ARL8     BR      { next = BAC8, cond_addr = FOR8, event = high, pin = Pin_B8}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B8 Fall and Pin_A8 Low or is Pin_B8 Fall and Pin_A8 High----
;-------------------------------------------------------------------------------

BFE8     BR      { next = BRE8, cond_addr = BFL8, event = Fall, pin = Pin_B8}

BFL8     BR      { next = BAC8, cond_addr = FOR8, event = high, pin = Pin_A8}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B8 Rise and Pin_A8 High or is Pin_B8 Rise and Pin_A8 High---
;-------------------------------------------------------------------------------

BRE8     BR      { next = AFE9, cond_addr = BRL8, event = rise, pin = Pin_B8}

BRL8     BR      { next = BAC8, cond_addr = FOR8, event = low, pin = Pin_A8}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR8     CNT     { next = AFE9, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC8     MOV32   { next = LIM8, remote = FOR8, type = REMTOREG, reg = A}

LIM8     ECMP    { next= SSUB8, cond_addr= HIL8, hr_lr=LOW, en_pin_action=off, pin=CC19, reg = A, data=0}

HIL8     ADM32   { next = AFE9, remote = FOR8, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB8     ADM32   { next = AFE9, remote = FOR8, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 8---------------------------------

;---------------------------------Start Channel 9-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A9 Fall and Pin_B9 Low or is Pin_A9 Fall and Pin_B9 High----
;-------------------------------------------------------------------------------

AFE9     BR      { next = ARE9, cond_addr = AFL9, event = Fall, pin = Pin_A9}

AFL9     BR      { next = BAC9, cond_addr = FOR9, event = Low, pin = Pin_B9}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A9 Rise and Pin_B9 Low or is Pin_A9 Rise and Pin_B9 High----
;-------------------------------------------------------------------------------

ARE9     BR      { next = BFE9, cond_addr = ARL9, event = rise, pin = Pin_A9}

ARL9     BR      { next = BAC9, cond_addr = FOR9, event = high, pin = Pin_B9}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B9 Fall and Pin_A9 Low or is Pin_B9 Fall and Pin_A9 High----
;-------------------------------------------------------------------------------

BFE9     BR      { next = BRE9, cond_addr = BFL9, event = Fall, pin = Pin_B9}

BFL9     BR      { next = BAC9, cond_addr = FOR9, event = high, pin = Pin_A9}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B9 Rise and Pin_A9 High or is Pin_B9 Rise and Pin_A9 High---
;-------------------------------------------------------------------------------

BRE9     BR      { next = AFE10, cond_addr = BRL9, event = rise, pin = Pin_B9}

BRL9     BR      { next = BAC9, cond_addr = FOR9, event = low, pin = Pin_A9}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR9     CNT     { next = AFE10, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC9     MOV32   { next = LIM9, remote = FOR9, type = REMTOREG, reg = A}

LIM9     ECMP    { next= SSUB9, cond_addr= HIL9, hr_lr=LOW, en_pin_action=off, pin=CC6, reg = A, data=0}

HIL9     ADM32   { next = AFE10, remote = FOR9, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB9     ADM32   { next = AFE10, remote = FOR9, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 9---------------------------------

;---------------------------------Start Channel 10-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A10 Fall and Pin_B10 Low or is Pin_A10 Fall and Pin_B10 High----
;-------------------------------------------------------------------------------

AFE10     BR      { next = ARE10, cond_addr = AFL10, event = Fall, pin = Pin_A10}

AFL10     BR      { next = BAC10, cond_addr = FOR10, event = Low, pin = Pin_B10}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A10 Rise and Pin_B10 Low or is Pin_A10 Rise and Pin_B10 High----
;-------------------------------------------------------------------------------

ARE10     BR      { next = BFE10, cond_addr = ARL10, event = rise, pin = Pin_A10}

ARL10     BR      { next = BAC10, cond_addr = FOR10, event = high, pin = Pin_B10}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B10 Fall and Pin_A10 Low or is Pin_B10 Fall and Pin_A10 High----
;-------------------------------------------------------------------------------

BFE10     BR      { next = BRE10, cond_addr = BFL10, event = Fall, pin = Pin_B10}

BFL10     BR      { next = BAC10, cond_addr = FOR10, event = high, pin = Pin_A10}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B10 Rise and Pin_A10 High or is Pin_B10 Rise and Pin_A10 High---
;-------------------------------------------------------------------------------

BRE10     BR      { next = AFE11, cond_addr = BRL10, event = rise, pin = Pin_B10}

BRL10     BR      { next = BAC10, cond_addr = FOR10, event = low, pin = Pin_A10}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR10     CNT     { next = AFE11, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC10     MOV32   { next = LIM10, remote = FOR10, type = REMTOREG, reg = A}

LIM10     ECMP    { next= SSUB10, cond_addr= HIL10, hr_lr=LOW, en_pin_action=off, pin=CC24, reg = A, data=0}

HIL10     ADM32   { next = AFE11, remote = FOR10, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB10     ADM32   { next = AFE11, remote = FOR10, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 10---------------------------------

;---------------------------------Start Channel 11-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A11 Fall and Pin_B11 Low or is Pin_A11 Fall and Pin_B11 High----
;-------------------------------------------------------------------------------

AFE11     BR      { next = ARE11, cond_addr = AFL11, event = Fall, pin = Pin_A11}

AFL11     BR      { next = BAC11, cond_addr = FOR11, event = Low, pin = Pin_B11}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A11 Rise and Pin_B11 Low or is Pin_A11 Rise and Pin_B11 High----
;-------------------------------------------------------------------------------

ARE11     BR      { next = BFE11, cond_addr = ARL11, event = rise, pin = Pin_A11}

ARL11     BR      { next = BAC11, cond_addr = FOR11, event = high, pin = Pin_B11}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B11 Fall and Pin_A11 Low or is Pin_B11 Fall and Pin_A11 High----
;-------------------------------------------------------------------------------

BFE11     BR      { next = BRE11, cond_addr = BFL11, event = Fall, pin = Pin_B11}

BFL11     BR      { next = BAC11, cond_addr = FOR11, event = high, pin = Pin_A11}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B11 Rise and Pin_A11 High or is Pin_B11 Rise and Pin_A11 High---
;-------------------------------------------------------------------------------

BRE11     BR      { next = AFE12, cond_addr = BRL11, event = rise, pin = Pin_B11}

BRL11     BR      { next = BAC11, cond_addr = FOR11, event = low, pin = Pin_A11}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR11     CNT     { next = AFE12, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC11     MOV32   { next = LIM11, remote = FOR11, type = REMTOREG, reg = A}

LIM11     ECMP    { next= SSUB11, cond_addr= HIL11, hr_lr=LOW, en_pin_action=off, pin=CC8, reg=B, data=0}

HIL11     ADM32   { next = AFE12, remote = FOR11, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB11     ADM32   { next = AFE12, remote = FOR11, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 11---------------------------------

;---------------------------------Start Channel 12-------------------------------

;---------------------------------Test Case 1----------------------------------- 
;----Check: Pin_A12 Fall and Pin_B12 Low or is Pin_A12 Fall and Pin_B12 High----
;-------------------------------------------------------------------------------

AFE12     BR      { next = ARE12, cond_addr = AFL12, event = Fall, pin = Pin_A12}

AFL12     BR      { next = BAC12, cond_addr = FOR12, event = Low, pin = Pin_B12}

;---------------------------------Test Case 2----------------------------------- 
;----Check: Pin_A12 Rise and Pin_B12 Low or is Pin_A12 Rise and Pin_B12 High----
;-------------------------------------------------------------------------------

ARE12     BR      { next = BFE12, cond_addr = ARL12, event = rise, pin = Pin_A12}

ARL12     BR      { next = BAC12, cond_addr = FOR12, event = high, pin = Pin_B12}

;---------------------------------Test Case 3----------------------------------- 
;----Check: Pin_B12 Fall and Pin_A12 Low or is Pin_B12 Fall and Pin_A12 High----
;-------------------------------------------------------------------------------

BFE12     BR      { next = BRE12, cond_addr = BFL12, event = Fall, pin = Pin_B12}

BFL12     BR      { next = BAC12, cond_addr = FOR12, event = high, pin = Pin_A12}

;---------------------------------Test Case 4----------------------------------- 
;----Check: Pin_B12 Rise and Pin_A12 High or is Pin_B12 Rise and Pin_A12 High---
;-------------------------------------------------------------------------------

BRE12     BR      { next = AFE1, cond_addr = BRL12, event = rise, pin = Pin_B12}

BRL12     BR      { next = BAC12, cond_addr = FOR12, event = low, pin = Pin_A12}

;----------------------------Turn Forward---------------------------------------
; This instruction presents moving steps, value is store in data field (range: 0 to ENCODER_MAX_STEPS_VALUE)
; In case data field is 0 and motor, turns backward, data = ENCODER_MAX_STEPS_VALUE

FOR12     CNT     { next = AFE1, reg = NONE, max = ENCODER_MAX_STEPS_VALUE}

;----------------------------Turn Backward--------------------------------------

BAC12     MOV32   { next = LIM12, remote = FOR12, type = REMTOREG, reg = A}

LIM12     ECMP    { next= SSUB12, cond_addr= HIL12, hr_lr=LOW, en_pin_action=off, pin=CC1, reg= B, data=0}

HIL12     ADM32   { next = AFE1, remote = FOR12, type = IM&REGTOREM, reg = A, data = ENCODER_MAX_STEPS_VALUE}

SSUB12     ADM32   { next = AFE1, remote = FOR12, type = IM&REGTOREM, reg = A, data = ENCODER_MINUS_ONE_STEP}

;---------------------------------End Channel 12---------------------------------

;---------------------------------End Input Encoder-----------------------------

;---------------------------------End Program-----------------------------------

Any idea of how to make it work on the simulator?? Thanks!

  • Can you tell us the details of the issue? Does the code work before you make the modification?

    The maximum number instructions the NHET supports is 160. How many instructions are there in your code?

    Make sure that the longest path through your code must fit within one loop resolution period (LRP). Most N2HET instructions execute in a single cycle. Please refer to Table 23-73 for the cycles used for the NHET instruction set.

  • There are 13 instructions per encoder. This code is for 10 encoders. 

    I think there is no problem with the LRP.

    The frequency of the pulses from the encoders is 6.2kHz

    amm the issue is that I created the signals, probably not in the correct way, and ran the code. I created the pulses, simulating the encoder signals, about 5 pulses in a period of 50ns. If I try and create longer pulses, it give me an error that I need a different version of the software.

    I was able to make it kind of work a couple of years ago but I could not do that this time...

  • The issue with the simulation is that it goes from 0 to 14453 and from 14453 to 0 again... similar thing happens with the code from the application note from TI about quadrature encoders. I'm guessing the problem is somewhere on the stimulus created but I dont find what the problem is. 

    I setted the signals like this

    start level repeat  pin

    0ns     0    10ns    a

    5ns     1    15ns    a

    0ns     0    12.5ns b

    7.5ns  1     17.5ns b

  • Hello Miguel,

    Is the issue related the restriction of the free SynaptiCAD waveform viewer?

    Your code has 130 instructions, so LRP is 256*Period of VCLK2 = 3.2us if VCLK2=80MHz. I think the code is not able to detect all the pulse in a period 50ns.

  • I'm not sure if is because of the free version... I think is not. 

    The VCLK2 is at 80MHz yes. 

    What do you suggest? To make the signals longer? and let it run for a while? 

    The behavior is: it goes to the maximum value, then 0 then max value again. This is with my code.

    Now, with the code from the application note, it goes to 1, 0 and max value.

    This could be related to the created stimulus?? 

  • If your code worked before, please try to uninstall/re-install the NHET IDE and SynaptiCAD waveform viewer.