Increment counter w...
 
Notifications
Clear all

Increment counter when rotating for long periods

10 Posts
1 Users
0 Likes
2,784 Views
(@Dan_S)
Posts: 0
New Member Guest
 

My application is using an SM23375DT motor. I have a section of hose with a weight on the other end. I want to rotate the motor until the hose fails. I use the following for the stoppage after change in torque, which is working fine:

WHILE Bt 'During trajectory...
IF TRQ<1000 'True if string broke
GOTO (10)
ENDIF
LOOP

I found the following "wraparound" code in the manual, but don't know if I've invoked it correctly or not:

IF Bw 'encoder limit reached
PRINT ("Wraparound occurred",#13)
Zw 'reset encoder
ENDIF

My problem is the counter. What would be the code for tracking revolutions, and possibly cascading that variable into another one if it overflows?
Any help would be great; I attached my .sms
Thanks to all

 
Posted : 22/10/2019 7:26 am
(@mmeyer)
Posts: 0
New Member Guest
 

Hello Dan,

The best way to track motor revolutions is with the index marker on the encoder. You can run an interrupt on the bit that captures the marker, and increment a variable. See the attached program. For wrap-around, you could add an if statement to set the variable back to 0 if it's maxed out, and increment another variable to keep track of total revolutions if that's needed. Hopefully this helps.

Meredith

 
Posted : 22/10/2019 8:34 am
(@mmeyer)
Posts: 0
New Member Guest
 

An alternative is to use the Modulo Limit, which will enable tracking of rotations at the output of a gearhead, considering the ratio. The basic idea is to set the Position Modulo Limit (PML) to the number of encoder counts you wish to define as a single count, and then interrupt on the Modulo Rollover bit (Word 3, Bit 11). See the attached program - note the bit needs to be reset.

 
Posted : 23/10/2019 8:46 am
(@Dan_S)
Posts: 0
New Member Guest
 

Thanks so much for the quick replies, mmeyer !!
Here is the what I hope will accomplish my test, to detect a break in the hose, reset the encoder bit, and track total revolutions.
I don't get any errors, but if you could take a look and give me your thoughts.
Again, thank you for increasing my understanding of these awesome little motors !!

 
Posted : 24/10/2019 4:20 am
(@mmeyer)
Posts: 0
New Member Guest
 

I recommend using only subroutines, placing your C1 and C10 after the "END" line. Note that, as written, your program does not track rotations until after a halt (call to C10) has occurred. Assuming you want to count rotations from the start of motion, you should define and enable interrupts before issuing the "G" command. Also, if you anticipate encoder wraparound to happen at any point, I would set up an interrupt on the bit as well, rather than using the current method of an IF statement, because that will only be evaluated at the point that code is executed.

 
Posted : 24/10/2019 2:48 pm
(@Dan_S)
Posts: 0
New Member Guest
 

This is AWESOME.
I was not aware of the condition to enable interrupts before the go command.
I appreciate all your support on this.
Thanks Much

 
Posted : 25/10/2019 2:58 am
(@Dan_S)
Posts: 0
New Member Guest
 

Also, I didn't know you could comment an entire line with a double apostrophe.
INCONCEIVABLE !!!

 
Posted : 25/10/2019 3:01 am
(@Dan_S)
Posts: 0
New Member Guest
 

Okay, I'm pushing my luck here, but I have one more (slightly) related question:
I have another test where I rotate to a position, but want the program to stop if the weight falls off (Hose breaks).
That part is working, but it doesn't print the value I want it to give me.
Programs works and stops, but no cycle count.
Can you have a look and see if anything's amiss?
Thanks Again,
Dan S.

 
Posted : 25/10/2019 6:44 am
(@mmeyer)
Posts: 0
New Member Guest
 

You actually only need one apostrophe for every comment, and it can be an entire line. We sometimes use multiple for spacing purposes.

 
Posted : 25/10/2019 6:58 am
(@mmeyer)
Posts: 0
New Member Guest
 

Dan,

Please email me with your current program: mmeyer@moog.com

 
Posted : 25/10/2019 6:59 am
Share: