Anaheim Sample #2 Program SAMPLE2.BAS on the CLCI2000 Disk, Initialize ADDR, Axis, HOME.TYPE.1

Page 19

SAMPLE #2 (PROGRAM SAMPLE2.BAS ON THE CLCI2000 DISK)

This sample shows two different homing routines that can be used to home the motors. The first routine callled Home Type 0, uses two switches - the first switch causes the motor to ramp down to base speed, and the second switch causes the motor to stop. The second routine, Home Type 1, uses only 1 switch - when the switch is activated the motor will ramp down to base speed, the mechanics need to be made in such a way that the switch will be deactivated when it reaches base speed. When base speed is reached, the motor will reverse direction and will stop once the switch is activated once again.

'PROGRAM FOR QUICKBASIC OR 'VISUALBASIC USING CLCISUB1.BAS

DECLARE ()...

'this representation is for all the declare statements

ADDR = &H300

'sets up the variable for the board address

AXIS = 1

'sets up the variable for axis 1

INITIALIZE ADDR, AXIS

'initializes axis 1

MOTION ADDR, AXIS, 500, 10000, 23000 'sets up the base speed, max speed, and acceleration

HOME.TYPE.1:

'home type 1 requires the switch to be activated and then deactivated (passed) 'while decelerating. The motor will then stop and reverse direction. When the 'switch is then activated, the motor will stop.

LIMIT.CONTROL ADDR, AXIS, 0, 0, 0

'soft is not active, mark is not active, home is not active

SET.OUTPUT1 ADDR, 0, 0, 0, 0, 0, 1, 0 'sets the HOME.DIR.1 to CW and all outputs off

IF HOME.INPUT(ADDR, AXIS) = 1 THEN END 'if we are already on the limit switch

HOME.CW ADDR, AXIS

'this will home the motor in the CW direction

WHILE HOME.INPUT(ADDR, AXIS) = 0

 

WEND

 

 

RAMP.TO.STOP.CW ADDR, AXIS

 

 

WAIT.FOR.STOP ADDR, AXIS

 

 

LIMIT.CONTROL ADDR, AXIS, 0, 0, 1

'soft is not active, mark is not active, home is active

SLEW.AT.BASE.CCW ADDR, AXIS

 

 

WHILE BUSY(ADDR, AXIS) = 1

 

 

WEND

 

 

LIMIT.CONTROL ADDR, AXIS, 0, 0, 0

'soft is not active, mark is not active, home is not active

RETURN

HOME.TYPE.0:

'home type 0 requires two switches - a soft limit switch, and a home limit 'switch. When the soft limit switch is activated, the software will ramp 'the motor down to base speed. The motor will continue traveling until the 'home limit switch is activated.

LIMIT.CONTROL ADDR, AXIS, 0, 0, 1 'soft is not active, mark is not active, home is active SET.OUTPUT1 ADDR, 0, 0, 0, 0, 0, 1, 0 'sets the HOME.DIR.1 to CW and all outputs off

HOME.CW ADDR, AXIS'this will home the motor in the CW direction WHILE SOFT.INPUT.CW(ADDR, AXIS) = 0

WEND

RAMP.TO.BASE.CW ADDR, AXIS END

16

Image 19
Contents CLCI2000 Series Trademarks Limited WarrantyCopyright DisclaimerTable of Contents Packing Information Main FeaturesDescription General DescriptionDPI65202 CLCI2004Ordering Information DPI65201AA2M37 AA37MFC-10AA37MMC-6 AA37MMC-10Specifications Address Settings InstallationInstalling the Board Wiring to the CLCI2000Quickstart with Quickbasic Clock Signals Connector Descriptions+5VDC Hard Limit Direction SignalsSoft Limit Home LimitInputs Encoder InputsOutputs Speed Considerations Programming with Anaheim Automation LibrariesProgramming with Quickbasic or Visualbasic for DOS Index ADR, Axis GO.CW ADR, AxisCLCISUB1.BAS Library ONE.AT.MAX.CW ADDRESS, AXIS# ONE.AT.MAX.CCW ADDRESS, AXIS#ORIGIN.INDEX.CCW ADDRESS, AXIS# RAMP.TO.STOP.CCW ADDRESS, AXIS# ORIGIN.INDEX.CW ADDRESS, AXIS#RAMP.TO.BASE.CCW ADDRESS, AXIS# RAMP.TO.BASE.CW ADDRESS, AXIS#SLEW.AT.BASE.CW ADDRESS, AXIS# SLEW.AT.BASE.CCW ADDRESS, AXIS#Index ADDR,AXIS,5000 Sample #1 Program SAMPLE1.BAS on the CLCI2000 DiskInitialize ADDR,AXIS TOP.OF.LOOP If GET.INPUTADDR,1 = 1 thenLIMIT.CONTROL ADDR, AXIS, 0, 0 Sample #2 Program SAMPLE2.BAS on the CLCI2000 DiskInitialize ADDR, Axis HOME.TYPE.1CLCISUBS.CPP Program Function Definitions Originindexcw ADDRESS, Axis Oneatmaxccw ADDRESS, AxisOneatmaxcw ADDRESS, Axis Originindexccw ADDRESS, AxisSoftinputcw ADDRESS, Axis Slewatbaseccw ADDRESS, AxisSlewatbasecw ADDRESS, Axis Softinputccw ADDRESS, AxisProgramming in Windows Using the CLCI2000 Indexer with WindowsUsing the DLL with Visual Basic for Windows Object Command1Procedure ClickAnaheim Automation DLL Library Support WIN2000.BAS Program ListingRunning the Software CLCI2004 Program GeneratorFunction Window F5 Save F1 InsertF3 Delete F4- TerminalF4 Printing a Program F1 Prog StopF2 Single Step F3 Clear ProgramCommand Window Direction + or CLCI2004 Program Generator Command DictionaryCommand Summary Command DictionaryGO Index no value Encoder Resolution any numberEncoder Window any integer Finish Move no valueJump to Line 1 to UNITS/SCALE any number Ramp Setting Register # Bits Setting Range DescriptionBase Setting not in HZ MAX Setting not in HZCommand Buffer Register Description of Command Input and Output Control Commands Initial Setup CommandsList of Equations Acceleration = MAX Speed Base Speed / TUP Page