Welcome, Guest
Username Password: Remember me
  • Page:
  • 1

TOPIC: Homing when power is turned on

Homing when power is turned on 2 years, 9 months ago #1191

  • BL24
  • OFFLINE
  • Posts: 2
  • Karma: 0
I need to home the motor every time the motor is turned on, do not really want to use hard stops. Can I store a home location in memory? Any suggestions or code would be great.

Also, in the following program, when input 16 is triggered it rotates once and when input 17 is triggered it rotates back. If the input signal is still on when a subroutine is completed the motor will continue to rotate. Also, if a signal is received and shuts off in the middle of a subroutine it will not make the requested move. How do I fix these problems?

Thanks, Ben

EIGN (2)
EIGN (3)
ZS
ADT=100
VT=100000
PT=0
G
TWAIT
C10
IF IN (16)==1
GOSUB20
ENDIF
IF IN (17)==1
GOSUB30
ENDIF
GOTO(10)
END
C20
MP
ADT=100
VT=100000
PRT=4000
G
TWAIT
RETURN
C30
MP
ADT=100
VT=100000
PRT=-4000
G
TWAIT
RETURN

Re: Homing when power is turned on 2 years, 9 months ago #1192

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
Hi Ben,
Since it's an incremental encoder... not absolute... the only method besides homing to a switch or a hard stop is to home to the index marker... but this only works within one revolution of the motor.

I added a couple of lines in your subroutines that should keep it from repeating. A signal change while the subroutine is being executed shouldn't interrupt operation.

EIGN (2)
EIGN (3)
ZS
ADT=100
VT=100000
PT=0
G
TWAIT
C10
IF IN (16)==1
GOSUB20
ENDIF
IF IN (17)==1
GOSUB30
ENDIF
GOTO(10)
END
C20
MP
ADT=100
VT=100000
PRT=4000
G
TWAIT
WHILE IN(16)==1 LOOP
RETURN
C30
MP
ADT=100
VT=100000
PRT=-4000
G
TWAIT
WHILE IN(17)==1 LOOP
RETURN

Re: Homing when power is turned on 2 years, 9 months ago #1193

  • BL24
  • OFFLINE
  • Posts: 2
  • Karma: 0
Thank you for the quick response. The while loops worked very well and a constant signal will not produce a constant rotation of the motor. However, if multiple signals are sent during the first rotation they are still not detected. For example, we are sending two pulses to the motor because we want two rotations and currently we have to wait for the first rotation to be completed before the second signal can be detected. Is there a way to count the pulses to know how far we must rotate?

By the way, if there is a better way to do this please let me know.

Re: Homing when power is turned on 2 years, 9 months ago #1194

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
That's a little tricky if you only have I/O and no way to set a variable with the number of rotations. The easiest approach (with I/O)would be to use more I/O and more subroutines. You can take 4 I/O and use 3 of them to represent a binary number between 0-7... then use the 4th I/O to read the binary number and call one of 8 subroutines.
  • Page:
  • 1
Moderators: hsummer, csearcy
Time to create page: 0.41 seconds