Hello,
Newly using the SmartMotor Class 5 for a project in which i first accelerate the motor to a slow speed, whereafter i need to have an interrupt as Output after each exact rotation of the motor. The interrupt is needed because i need to trigger a line scan camera at precisely the correct moment. I cant get it going using the interrupt. Do i need to use StatusWord 5 to enable an interrupt?
Kind regards,
Twan Graus
Hello Twan Graus,
For this interrupt to function correctly, you need a couple different commands.
Ai(0) 'arm index rising edge
ITR(0, 1, 2, 1, 1) 'define interrupt when index is captured
EITR(0) 'enable interrupt 0
ITRE 'enable global interrupt scanner
It sounds like perhaps you have everything except the first line.
Thank you for your reply
This was exactly what i needed! Unfortunately with the reductor of 1:80 attached, i get just over a full rotation when i count 80 interrupts using my simple c=c+1 as interrupt program. When i print the values, i can see sometimes that it doesn't count for some time, like the values cant be read or something. Any idea what this could be? I think that it could be that my way of counting is to slow for the quick encoder wheel.
Kind regards
Twan
It could indeed be a timing issue. If you're incrementing your count variable too late in the subroutine, the interrupt may be called again before the counter can increase. Try incrementing first and see if that makes a difference.
Meredith
Thank you for your reply, i was also thinking like that, but it doesnt seem to work.
The code i have now:
EIGN(W,0) 'Disable limits ZS 'Clear faults VT=500000 'Set target velocity ADT=10 'Set acceleration/deceleration Target F 'Apply values d=0 'diameter tube p=314/100 'PI variable i=80 'Gear ratio transmission e=45 'diameter driving wheel c=0 'Variable for counting a=0 'Variable for always looping MV 'Set velocity Mode '****Main Program Body C0 WHILE 1>0 'Acts as long as no GOTO is received, startup loop X 'Ramp down TWAIT 'Wait for ramp down to end OFF 'Turn servo off LOOP 'Keep looping the while loop RETURN 'terminate sub program C12 ' 'PRINT("INTERRUPT",#13)' c=c+1 'Count each interrupt RETURNI 'End interrupt subroutine C10 ' PRINT("Selected diameter is:") PRINT(d,#13) 'Print value O=0 'Set origin encoder to 0 G 'Go WHILE a==0 'Act as long as a isnt adjusted. To stop loop, change variable a Ai(0) ' ITR(0, 1, 0, 1, 12) 'Interrupt(INT#, Status Word, Status BIt, Bit State, Label#) EITR(0) 'Enable interrupt 0 ITRE 'Enable all interrupts PRINT("C is ",c,#13)'Print value IF c==1*i*d/e ' PRINT("Starting",#13)'Print value O=0 ' ENDIF ' IF c==2*i*d/e ' PRINT("ITR1",#13)'Print value S ' ENDIF IF c==3*i*d/e ' PRINT("ITR2",#13)'Print value ENDIF ' IF c==4*i*d/e ' PRINT("ITR3",#13)'Print value ENDIF ' LOOP ' END '
I succeeded!
I used the timer example to give a pulse on a rotation. The timer triggers an interrupt which i can use for my camera.
Thanks a lot!
Good, I'm glad you were able to achieve the functionality you needed.