MicroLYNX Analog Joystick
The following example demonstrates the set up and use of the MicroLYNX Joystick module.
- Set the following values in your program (or you can set them in immediate mode using IMS terminal):
MSEL=256 'Motor Resolution Select Variable MUNIT 51200 'Motor Units Variable ADS 1=10,2,1 'Analog Input Setup Variable: Aunit, 'Joystick Interface, Linear JSE=1 'Joystick Enabled JSDB=20 'Joystick Dead Band
Perform the IJSC (Calibrate Joystick Instruction) command procedure as described in the MicroLYNX software reference. The IJSC will set up your Joystick Center and Joystick Full Scale.
Once the IJSC command is executed you can use the print command to find the set values of the JSC and JSFS or set the values you set manually. If the motor seems to creep at a slow rate JSC can be adjusted along with the JSDB (dead band). Increasing the deadband will stop the motor from creeping.
- Values determined in our example by using the IJSC command (values will very based on the joystick you are using) are:
JSC=2038
JSFS=2038
- The velocity of the motor will not be limited by the values of VI and VM however, the acceleration is affected by VI. From 0 to the value of VI the motor will not ramp up to speed. Instead the motor will instantly run at the velocity set by moving the joystick. Once you exceed the value of VI the motor will follow the acceleration and deceleration ramps set by ACCL and DECL. To set your maximum velocity and the actual velocity based on the joystick, use the following formulas:
Maximum Velocity
AUNIT=Analog User Units
Max Velocity = (Aunit *Munit /MSEL * 200) revs/secActual Velocity
Micro Step Per Joystick Count = AUNIT * MUNIT / JSFSJoystick count is a function of the actual joystick position
Velocity (microsteps per second) = (Joystick count - JSDB) * Microstep per Joystick Count
(Formula for Velocity is based on a joystick count greater than the Joystick Deadband. Position of Joystick will determine plus or minus velocity.)
Velocity (Revolutions per second) = Velocity (microsteps per second) / MUNIT
NOTE: Joystick count is determined by the actual position of the joystick. To determine what the value is use Print AIN 1.
Once you get the value for AIN 1 use this formula:Actual Joystick Count = (AIN 1/AUNIT) * JSFS
You can type in the values noted above to test and observe how the commands effect and work together.
Example:
Actual Joystick Count = 1000
Max Velocity (revolution per second) = Aunit*Munit/MSEL*200
Max Velocity (revolution per second) =10(51,200)/(256)*200= 10 revs/sec.
Microstep
Per Joystick Count = AUNIT * MUNIT / JSFS
Microstep Per Joystick Count =10(51,200)/2038=251.22
Velocity (microsteps per second) = (Joystick Count JSDB ) * Microstep per Joystick Count
Velocity (microsteps per second) = (1000-20)*251.22= 246195.6 micro steps/sec
Position of Joystick will determine plus or minus velocity using Joystick Center (JSC).
The actual Joystick count is from 0 to 4096. In this example we used 1000 counts.
Analog to Digital Counts = Actual Joystick Count - JSC
Analog to Digital Counts = 1000 - 2038
Analog to Digital Counts = -1038
NOTE: Direction is determined by plus or minus counts
External DC Voltage Control
If you are using a 0-5 VDC signal for joystick operation. You can determine the velocity based on the milli-volts per joystick count. The analog joystick module has a 12 bit A to D converter. The resolution is therefore 0-4096 counts. With 5 VDC and a resolution of 4096 you will get 1.22 mV (5 / 4096 = 1.2207 mV) per joystick count, this is a constant.
The JSC command can be set from 0 thru 4096 count. Using the default JSC =2048 you will have 2048 counts to left of joystick center and 2048 counts to the right of Joystick center. On one side of the joystick you have 0 - 2.5 VDC and from the other side of the joystick center you have 2.5 - 5 VDC. The following example will demonstrate how to determine velocity based on analog input voltage. Velocity with 5 Volts DC input.
MUNIT= 51200
AUNIT= 10 'set in ADS command below
JSC=2048
JSFS=2048
JSDB=20
ADS 1=10,2,1
K= 1.2207 mV/joystick count (constant)
With 5 Volts input, the velocity can be calculated by using the following formulas:
JSC=2048
The analog voltage is 5 V to the input, with a joystick center of 2048:
Analog Voltage In = 5 VDC(input) - 2.5 (voltage read with JCS = 2048 * K)
Analog Voltage In = 2.5 VDC (Print AIN returns 10)
Micro Step Per Joystick Count = AUNIT * MUNIT / JSFS
Micro Step Per Joystick Count =10(51,200)/2048=250Actual Joystick Count = (AIN/AUNIT) * JSFS = 2048
Velocity (microsteps per second) = (Joystick Count - JSDB) * Micro Step per Joystick Count
Velocity (microsteps per second) = (2048-20)*250= 507000 micro steps/secVelocity (microsteps per second) = ((Analog Voltage In / K) - JSDB) * Micro Step Per Joystick Count
Velocity (microsteps per second) = ((2.5V / 1.2207 mV) - 20) * 250
= 507001Velocity (revolution per second) = Velocity (microsteps per second) / MUNIT
= 507001 / 51200
= 9.9 revs/sec
