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

TOPIC: Limit Switch for home position

Limit Switch for home position 1 year, 4 months ago #1791

  • asterof
  • OFFLINE
  • Posts: 30
  • Karma: 0
Looked at the samples
Did not see a method to move to home position when indicated by a Limit Switch Input On IO 1

Here is what I have so far

EIGN(W,0,12) 'Assign Word 0 to IO use mask of 12 for 12 IO points
ZS 'Clear Any Status Bits
GOSUB1 'Run C1
END
'==============================================================
C1 'ROUTINE: Home to Index Using Relative Position Mode Motor Address = 1
PRINT("HOME MOTOR",#1)
MP:1 'Set Control to Position Mode
Ai(0):1 'Arm Index Internal Encoder
AT:1=1000 'Set Accel Rate
DT:1=500 'Set Deccel Rate
VT:1=10000 'Set Velocity

G 'Go Start Move
'I think I need to look for the IO point here
PT=I(0) 'Set Target Position to Index location

O=0 'Set Position to Zero
RETURN
'==============================================================

Need a suggestion, thanks

Re: Limit Switch for home position 1 year, 4 months ago #1794

  • asterof
  • OFFLINE
  • Posts: 30
  • Karma: 0
so the code got changed to this
Now I am thinking that I need an If statement
so If the home switch is already made it does not need to move
I want to use the #10 drive enable input to start a single shot loop
that checks and if it is not on the home position then a timer runs out and
C1 is called just once


EIGN(W,0,12) 'Assign Word 0 to IO use mask of 12 for 12 IO points
ZS 'Clear Any Status Bits
IF IN(10) == 1 'Is this always true to enable drive ???????
IF IN(1) != 1 'Home Switch
WAIT = 3000
GOSUB C1
END IF
END_IF
END






'==============================================================
C1 'ROUTINE: Home to Index Using Relative Position Mode Motor Address = 1
PRINT("HOME MOTOR",#1)
MV:1 'Set Control to Velocity Mode
AMPS:1=512 'Reduce power
Ai(0):1 'Arm Index Internal Encoder
AT:1=1000 'Set Accel Rate
DT:1=500 'Set Deccel Rate
VT:1=10000 'Set Velocity
G 'Go Start Move
WHILE IN(1) 'Loop, While input 1 is high
O=0 'Set origin
S 'Hard Stop, reason for reduced power setting
AMPS:1=1023 'set power back to max
G 'Go
MP 'Set Control to Position Mode
PT=0 'Set absolute target position
G 'Go Start Move but it already at position, just needed to set move complete
TWAIT 'Wait until move is complete
RETURN
'==============================================================

Re: Limit Switch for home position 1 year, 4 months ago #1795

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
You may have to switch some logic based on sink/source (ex. 1=OFF or 1=ON)... but here's a hopefully bug free example using Input(0) as the "Run Homing Routine" signal ... and Input(1) as the "Home Switch"...

'Home to Input1 (aka the 2nd pin on most of the motor connectors).
'This example assumes the direction towards the motor is negative... and away from the motor is positive.
'MINV(1) 'un-remark this command if your system runs the other way.
'This program does NOT home automatically when it is powered on. This is intended for bench setup only.
'The call to C1 should be conditional on some other interlock initiated by the machine operator.
ADDR=1 ' Give the motor an address for easy detection with the SMI2 software.

EIGN(W,0) 'Make all I/O Inputs. Note: You can change them to outputs at any time.
'Note: This is where Sink/Source matters. If you're using a D-Type motor... everything on the
'15pin D-Sub is sinking 5VDC TTL Logic... unless you have a CBLIO-ISO1 cable...
'that offers Sink or Source 24VDC I/O using internal isolated electronics.
'If you're using the -AD1 optional expanded I/O on a D-Type motor... all I/O is 24VDC Sourcing...
'The same applies to M-Type motors and all Class6 motors(where all I/O is 24VDC Sourcing).

ZS 'Clear any errors that can be cleared.
'Note: The Drive Enable Hardware input on M-Style motor should be used, but can be disabled(Not recommended).

'Input(0) will be used as a "request to home" signal. This could come from a pushbutton or a PLC output.
'Input(1) will be used as the "actual" home switch.
'Main Program Loop
WHILE 1 'Start of ENDLESS LOOP
IF IN(0)==0 GOSUB(1) ENDIF 'Call the Homing Subroutine if Pin1 is activated (be it sinking or sourcing).
'more code here... should be other IF/ENDIF type commands so this loop runs continuously.
LOOP 'End of ENDLESS LOOP
END

C1 'Home Routine ...if we're on the switch... move off... and back to it... then slow off and stop...
'setting the origin to be 8000 encoder counts away from the switch.
IF IN(1)==0 'Assuming a Normally Open Switch(sinking logic)... We are already on it.
ADT=100 VT=100000 MV G 'Move off of the Switch... which show's we're re-homing.
WHILE IN(1)==0 LOOP WAIT=500 'Wait until we get off of the Switch... then wait for a half second.
X VT=-10000 G 'Decel to a Stop... then Move back to the Switch at a slow speed.
WHILE IN(1)==1 LOOP 'Wait to see the Switch.
ENDIF
IF IN(1)==1 'Assuming sinking logic again... We are not on the Switch.. and we need to find it quickly
ADT=100 VT=-100000 MV G 'Search for the Switch... which show's we're re-homing
WHILE IN(1)==1 LOOP 'Wait to see the Switch.
X VT=100000 MV G 'Move off of the Switch... which show's we're re-homing
WHILE IN(1)==0 LOOP 'Wait to get off the Switch.
X VT=-10000 G 'Decel to a Stop... then Move back to the Switch at a slow speed.
WHILE IN(1)==1 LOOP 'Wait to see the Switch.
ENDIF
S TWAIT WAIT=100 O=-8000 'Immediate Stop... wait to stop... wait 100ms.. and set Origin=-8000.
MP ADT=1000 VT=200000 PT=0 G 'Switch to Mode Positon and Move to Absolute Position zero
TWAIT 'Wait to stop.
WHILE IN(0)==0 LOOP 'Wait here until the "request to home" signal goes away to insure it only occurs once per request.
RETURN 'Return to the ENDLESS LOOP
Last Edit: 1 year, 4 months ago by csearcy.

Re: Limit Switch for home position 1 year, 4 months ago #1797

  • asterof
  • OFFLINE
  • Posts: 30
  • Karma: 0
wow, thanks, that's more than I expected, appreciate it

Re: Limit Switch for home position 1 year, 4 months ago #1798

  • asterof
  • OFFLINE
  • Posts: 30
  • Karma: 0
csearcy, you work for Animatics I see a lot of posts from you

Re: Limit Switch for home position 1 year, 4 months ago #1799

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
Yes. I try to help when I can. I hope your system is working now. Please let me know if you have other questions or concerns.

-Chuck
  • Page:
  • 1
  • 2
Moderators: hsummer, csearcy
Time to create page: 0.79 seconds