Pulse Timer Monitor...
 
Notifications
Clear all

Pulse Timer Monitoring

9 Posts
1 Users
0 Reactions
15.6 K Views
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

So I found some code that sort of has part of what I need

I need to monitor a pulse rate in pulse per second
and Count those pulses from input IN(0)
I need to calculate how often those pulses occur

Timet=0 ‘Calibration loop, to get basic loop time
cock_time = CLK ‘Store the running clock value
WHILE Timet < 1000 ‘Loop 1,000 times for accurate measurement
Timet = Timet + 1
LOOP
cock_time = CLK - cock_time ‘clock_time = execution time in sample periods per
‘ 1000 operations
cock_time = cock_time * 1000 ‘Go from sample periods per 1k ops to
‘ sample periods per 1M ops.
divisor= cock_time/4069 ‘Divide by sample time to get seconds
‘ per 1M operations.
Timet = 0 ‘Now run the actual measuring loop
cock_time = CLK
WHILE Timet < 1000
Timet = Timet + 1
‘PUT COMMAND TO BE TIME-MEASURED HERE
LOOP

I think this would be part of it to determine the calibration
but I think the last part would need modified to monitor the time between input pulses

 
Posted : 02/06/2015 10:18 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

You may need to use multiple variables to trap the CLK variable, then compare the difference between the trapped values.

 
Posted : 11/06/2015 8:37 am
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

Yea that's how I ended up doing it

 
Posted : 11/06/2015 10:10 am
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

here is the code I put together

will post a few questions on how to do it better later

'#################################################
'Program written to test posible machine design operation
'Program contains no fault routines or major failure recovery code
'Code was written in ver 415C and ran in real time for testing
'Code was modified for Class 5 Motors
'First release 06/06/2015
h = 0 g = 1 'used to reverse input action

'MINV(1) 'un-remark this command to run the other way.
ADDR = 1 'Give the motor an address for easy detection with the SMI2 software.
EIGN(W,0)
ZS ' clear all faults
al[0] = 3 al[1] = 30 al[2] = 360 'al[2] is part trigger interval
' CLK description = DEAULT PID 4096 clicks per second
' to derive 1000 counts per secode CLK / 4.096
' to derive three counts per second watch dog timer (CLK /4.096) = 0 - 1000
al[3] = 8787 ' counts from home position to pick position
al[4] = 25581 ' counts from home position to pick position pick position last part
' 8787 (HOME TO PICK POS) + 9576 (PICK POS TO TO FIRST EXPECTED DROP TRIGGER) + 7218 (LENTH IN COUNTS FROM PART 1 to PART 30) = 25581
al[5] = 100 ' ramp time
al[6] = 20000 ' velocity for normal parts drop speed
al[7] = 50000 ' velocity for gap speed up parts drop speed
al[8] = 1000 ' full motor amps
al[9] = 10000 al[10] = -10000 ' jog speeds
al[11] = 500 ' home ramp speed
al[12] = 2000 ' home velocity speed
al[13] = 15000 ' home search velocity
EL=100 ' Amount of counts before error may be to low depending on speed
o = 50000 ' adjust for velocity for pick position first pass
m = 10000 ' adjust to required Pick Position in counts from home position
s = 0

'################################################
'IN(0) = Parts Drop Photo Eye
'IN(1) = Home Prox Input
'IN(4) = Operator Request Home
'IN(5) = Operator Request Jog Forward
'IN(6) = Operator Request Jog Reverse
'IN(7) = Operator Push To Send To Pick Place, Push Again To Run Drops
'#############################################################################

'*********************************************************
' START OF MAIN PROGRAM
C10
IF IN(4) == g
GOSUB(20)
ENDIF ' Operator Request Home
IF IN(5) == g
GOSUB(21)
ENDIF ' Operator Request Jog Forward
IF IN(6) == g
GOSUB(21)
ENDIF ' Operator Request Jog Reverse
IF IN(7) == g GOSUB(24)
ENDIF ' Operator Push to send to Pick Position, Push Again to Run Drop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GOTO10
END

'************************************************************
C20 'SUBROUTINE Home Routine ...if we're on the switch... move off... and back to it...
'then slow off and stop... Then 'set the origin away from the switch.

IF IN(1)==g 'Assuming a Normally Open Switch(sinking logic)... We are already on it.
PRINT("Home Routine Already On Switch",#13)
ADT=al[11] VT=-al[13] MV G 'Move off of the Switch... which show's we're re-homing.
PRINT("Move off Switch",#13)
WHILE IN(1)==g LOOP
WAIT=2000 'Wait until we get off of the Switch... then wait for a half second.
X ADT=al[11] VT=al[13] MV G 'Decel to a Stop... then Move back to the Switch at a slow speed.
WHILE IN(1)==h LOOP 'Wait to see the Switch.
PRINT("Switch Detected",#13)
X VT=al[12] MV G 'Move off of the Switch... which show's we're re-homing
WHILE IN(1)==g LOOP 'Wait to get off the Switch.
PRINT("Moved Off Switch",#13)
X VT=-al[12] G 'Decel to a Stop... then Move back to the Switch at a slow speed.
PRINT("Move to Switch Again",#13)
WHILE IN(1)==h LOOP 'Wait to see the Switch.

PRINT("Found Switch Again",#13)
S 'Immediate Stop
TWAIT 'wait to stop
WAIT=100 'wait 100ms
O=-600 'set Origin=-600.
PRINT("Move to Absolute Position",#13)
MP ADT=al[11] VT=al[6] PT=0 G 'Switch to Mode Positon and Move to Absolute Position zero
TWAIT 'Wait to stop.
WHILE IN(1)==g LOOP 'Wait here until the "request to home" signal goes away to insure it only occurs once per request.
OFF O=0
ELSE
PRINT("Home Routine Not on switch yet",#13)
ADT=al[11] VT=al[13] MV G 'Search for the Switch... which show's we're re-homing
WHILE IN(1)==h LOOP 'Wait to see the Switch.
PRINT("Switch Detected",#13)
X VT=al[12] MV G 'Move off of the Switch... which show's we're re-homing
WHILE IN(1)==g LOOP 'Wait to get off the Switch.
PRINT("Moved Off Switch",#13)
X VT=-al[12] G 'Decel to a Stop... then Move back to the Switch at a slow speed.
PRINT("Move to Switch Again",#13)
WHILE IN(1)==h LOOP 'Wait to see the Switch.

PRINT("Found Switch Again",#13)
S 'Immediate Stop
TWAIT 'wait to stop
WAIT=100 'wait 100ms
O=-600 'set Origin=-600.
PRINT("Move to Absolute Position",#13)
MP ADT=al[11] VT=al[6] PT=0 G 'Switch to Mode Positon and Move to Absolute Position zero
TWAIT 'Wait to stop.
WHILE IN(1)==0 LOOP 'Wait here until the "request to home" signal goes away to insure it only occurs once per request.
OFF O=0
ENDIF
RETURN 'Return to the ENDLESS LOOP

'*********************************************************************************

C21 'SUBROUTINE Job FORWARD Subroutine
WHILE IN(5) == h MV ADT=al[5] VT = al[9] G
LOOP ' move forward
ADT=0 VT=0 G S OFF ' Stop jog
RETURN 'Return to the ENDLESS LOOP

'*********************************************************************************

C22 'SUBROUTINE Job REVERSE Subroutine
WHILE IN(6) == h MV ADT=al[5] VT = al[10] G
LOOP ' move reverse
ADT=0 VT=0 G S OFF ' Stop jog
RETURN 'Return to the ENDLESS LOOP

'*********************************************************************************

C23 'future code

RETURN

'*********************************************************************************

C24 ' SUBROUTINE move to Pick Position first pass SUBROUTINE
MP ADT = al[5] VT = o PT = m G TWAIT
S OFF MV WAIT = 1000
WHILE IN(7) == g LOOP
GOSUB(25)
RETURN

'************************************************************************************

C25 ' SUBROUTINE Parts Drop & Trigger Move
k = 0 l = 0
MV ADT = al[5] VT = al[6] G
CLK = 0 c = 0 z = al[4]+ m
WHILE k k k = l ENDIF ' Compare current count to last count
t = CLK / al[0] ' assign t to current CLK time
IF c = 30 ' if counted parts = 30 do not change speeds
VT = al[6] G
ELSE
PRINT (n , " interval time", #13)
IF n > al[2] VT = al[7] G ENDIF
IF n <= al[2] VT = al[6] G ENDIF
ENDIF
IF IN(0) == 0 ' look at input photo eye on parts trigger
c = c + 1 ' count the parts triggers
u = CLK / al[0] ' assign current time to time parts triggered
WHILE IN(0) == g LOOP ' wait for photo eye to clear
ENDIF
LOOP
VT = al[6] G
WHILE IN(1) == g LOOP
IF IN(1)==g 'startof relocating home when belt returns from drop parts run
PRINT("Home Reset",#13)
ADT=al[11] VT=al[12] MV G 'Move off of the Switch... which show's we're re-homing.
PRINT("Move off Switch",#13)
WHILE IN(1)==h LOOP
WAIT=500 'Wait until we get off of the Switch... then wait for a half second.
X VT=-al[12] G 'Decel to a Stop... then Move back to the Switch at a slow speed.
WHILE IN(1)==g LOOP 'Wait to see the Switch.

PRINT("Found Switch Again",#13)
S 'Immediate Stop
TWAIT 'wait to stop
WAIT=100 'wait 100ms
O=-600 'set Origin=-600.
PRINT("Move to Absolute Position",#13)
MP ADT=al[11] VT=al[13] PT=0 G 'Switch to Mode Positon and Move to Absolute Position zero
TWAIT 'Wait to stop.
WHILE IN(1)==g LOOP
ENDIF
RETURN

 
Posted : 11/06/2015 1:11 pm
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

so some of the questions are
1. should this have used encoder position to determine the drop rate or did I use the better
method
2. What if I wanted to actually index or sequence the dropping of the parts
Meaning I move, a part drops I stop the move a part drops
That would be a lot of very short moves and hard stops
would that be difficult to control.
3. After the first move to pick position, what would be the best way to just pause at the
pick position then continue the move instead of having the operator push the start button
again.
4. What if I wanted to fill an array each tine a part dropped, and keep a history of that array
5. Currently I ignore the time it starts the move to the first drop, this means that the first
part could be missing, I could not figure out how to accurately do that, any ideas

 
Posted : 12/06/2015 3:10 pm
(@csearcy)
Posts: 316
Reputable Member Guest
 

Is this like a palletizing application? ...where there is one pick point and multiple place points representing a two dimensional array?

 
Posted : 14/06/2015 2:19 pm
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

no there is a single pick place where items get loaded
then they are dropped into a rotating chute on a continuous basis till all 30 are placed

 
Posted : 14/06/2015 5:24 pm
(@asterof)
Posts: 17
Active Member Guest
Topic starter
 

how can I send a small drawing

 
Posted : 15/06/2015 9:22 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

Send it to csearcy@moog.animatics.com ...a pdf is preferred. I don't have any CAD software on this system.

Please send me an email when you get this post.

 
Posted : 15/06/2015 1:53 pm
Share: