How to use nimsrdcontrol with the NIMSRD system



How to use the nimsrdcontrol interface with the NIMSRD system

Michael Stealey

stealey@ucla.edu

August 9, 2006

Introduction:

Nimsrdcontrol is a python application that provides control of the NIMSRD system via an interactive terminal or file based interaction. Nimsrdcontrol was designed to provide the end user with an easy means of controlling the NIMSRD system manually for calibration and movement and then to offer file-based interactive control capable of working with any application that has the ability to read and write to files all in one package.

Dependencies:

There are multiple files required that either need to reside within the same user directory, or be included into the $PYTHONPATH variable for the system to operate properly.

1. nimsrdmenu.py

a. nimsrdmenu_config.txt

2. nimsrd.py

a. nimsrd_config.txt

3. keyboardcontrol.py

4. motor.py

Because control of the NIMSRD system is via RS232, an additional requirement is that pyserial be installed on the system prior to use. Information for pyserial can be found at:

If you are using a Windows based machine, the easiest way to ensure compliancy is to install enthought’s python package that includes pyserial, as well as many other useful packages.

File overview:

nimsrdmenu.py

1. provides terminal interactive mode

2. provides file-based interactive mode

a. move.txt

i. format:

x < x-pos(m) >

y < y-pos(m) >

v < vel(m/s) >

a < acc(m/s^2) >

b. position.txt

i. format:

x-position(m) y-position(m) x-velocity(m/s) y-velocity(m/s)

c. allposition.txt

i. format

timestamp x-position(m) y-position(m)

timestamp x-position(m) y-position(m)



d. interrupt.txt

i. flag = ‘0’ indicates system state is good

ii. flag = ‘menu’ indicates exit file-based mode and return to interactive mode

iii. flag = ‘kill’ indicates to kill all motor motion and return to the control loop

e. done.txt

i. flag = ‘0’ when system is in motion

ii. flag = ‘1’ when system is done moving

3. configuration file (must reside at same level as nimsrdmenu.py)

a. nimsrdmenu_config.txt

# file to check for movement destination

# form: x

# y

# v

# a

movefile move.txt

# file to check for completion of a move

donefile done.txt

# file to check for current position of system

# form: x-pos y-pos x-vel y-vel

positionfile position.txt

# appended positional file

# user responsible for deletion

allpositionfile allposition.txt

# file to check for an interruption for any reason

interruptfile interrupt.txt

nimsrd.py

1. extends the functionality of keyboardcontrol.py

2. adds functionality to the base system

a. calibrate system

b. move

c. position

d. set velocity

e. set acceleration

f. status of system

g. in motion flags

3. configuration file (must reside at same level as nimsrd.py)

a. nimsrd_config.txt

# motor resolution and steps per meter (do not change)

resolution 4096

stepspermeter 59172

# system velocity in m/s

velocity 0.5

# system acceleration in m/2^2

acceleration 0.25

# system serial port name

portname COM1

keyboardcontrol.py

1. imports the functionality of motor.py

2. add functionality to the base motor controls via the keyboard

a. Windows OS control

b. Linux OS control

motor.py

1. base module for Vix500IE controller and motor configuration

2. provides basic functions to the user

a. move (+/- distance)

b. position

c. reset

d. mode

e. stop

f. kill

g. velocity

h. acceleration

i. status

j. in motion

Starting the application:

If you are using a Linux machine make sure that the nimsrdmenu.py file is set to be executable. This can be done by typing $> chmod +x nimsrdmenu.py

The nimsrdmenu application can be launched either by:

1. from the command line type: $> python nimsrdmenu.py (Linux & Windows)

2. from the command line type: $> ./nimsrdmenu.py (Linux & Windows)

3. from within the directory, double click on the nimsrdmenu icon

a. Windows will open a new cmd window and execute within it

b. Linux will prompt to open a new terminal window, say yes and run from with in it

User menus:

- screen shots are from a Windows machine

When the nimsrdmenu application is first launched the user will be presented with a main menu screen as follows:

[pic]

By default the serial port used is ‘/dev/ttyS0’ on Linux or ‘COM1’ on Windows. The serial port to be used should be specified as a string in the nimsrd_config.txt file.

The resolution of 4096 is dependent on the motor being used and should not be changed. The steps per meter are based upon the size of the spool being used to hold the cable and should only be changed if the exact parameters are known.

Velocity defaults to 0.5 m/s and acceleration to 0.25 m/s^2, but can be changed by the user at any point in time once the system has started.

When the system is started, it will not be calibrated and will not allow commands move, position or file-based until calibration has been completed. Additionally on startup the motor distance parameters are set to zero to ensure maximal positioning freedom.

Move node: (m)

If the system has not been calibrated, the user will receive a response as follows:

$> Enter choice: m

System must be calibrated prior to issuing move command...

Once the system has been calibrated, the user can interact with the system by entering x and y positional values for the node to move to.

$> Enter choice: m

Current position: -0.000 0.000

Next position x (m): 1

Next position y (m): .5

0.018 0.009 0.06 0.06

0.052 0.025 0.13 0.12

0.101 0.049 0.19 0.19

0.165 0.082 0.25 0.26

0.248 0.123 0.32 0.32

0.345 0.171 0.39 0.38

0.458 0.227 0.45 0.44

0.582 0.290 0.48 0.49

0.689 0.343 0.42 0.42

0.782 0.390 0.36 0.37

0.857 0.428 0.30 0.30

0.917 0.459 0.23 0.24

0.961 0.480 0.17 0.17

0.988 0.494 0.11 0.11

0.999 0.500 0.04 0.05

stopped moving

1.000 0.500 0.00 0.00

As the node moves towards the destination the user is presented with intermediate values for x-position (m), y-position (m), x-velocity (m/s) and y-velocity (m/s). By default bounds will be enforced by the system based upon the first and last x-positions of the calibrated transect. The default y-positions enforced will be +/- 1 meter around y=0.

Positional Query: (p)

If the system has not been calibrated, the user will receive a response as follows:

$> Enter choice: p

System must be calibrated prior to positional query...

Once the system has been calibrated (by loading a file or using the calibration option) the option p is used to query the position of the node based off of the actual motor distance at that time.

$> Enter choice: p

position = ( 2.000 -0.250 )

v = 0.50 m/s a = 0.25 m/s^2

The positional value can be incorrect depending on when it is used. If a user queries for position immediately after loading a calibration file, there is a strong possibility that the systems actual position and the newly loaded calibration file will not match up. This is fixed by using the keyboard control (option k) to move the node back to the origin, and then resetting the motor distances (option r). At this point the newly loaded calibration file and the actual motor distance will coincide with each other.

Keyboard Control: (k)

[pic]

Due to the manner in which the code base was written, the keyboard control interface does not have a perception of movement in m/s, but rather in revolutions per second. The keyboard control will default to a velocity = 4 rps and an acceleration of 2 rps^2.

Moving the node is accomplished by pressing an arrow key in the direction of intended travel. Pressing the arrow key once will start the node moving in the direction specified at the set velocity and acceleration. Pressing the space-bar will stop the node movement using a rate of deceleration equal to that used for acceleration. If the node appears to be in danger of colliding with an object in the transect, the k-key can be used to immediately kill all motor movement. This could result in unwanted jarring of the payload on the node depending on the velocity at the time the k-key is pressed.

At this time the p-option has not been implemented since it is not required for the node to be calibrated in order to use the keyboard control. This may appear in future revisions of the system, but for the time being has been eliminated from the interface.

Acceleration and velocity parameters can be changed from the default by using the a-key or v-key respectively. It should be noted that the entered values will be in revolutions per second (rps) and not in meters per second (m/s) as is seen in the main menu.

The motor distances can also be reset by using the r-key. This is useful when defining the origin of the transect for a newly loaded calibration file, or for making adjustments to the system if slippage should occur.

It should be noted that on Linux systems the user may see output from the system that looks like:

^[[D^[[A^[[B^[[C

This is a byproduct of the method being used to capture user input and should be ignored as it will not interfere with the operation of the system.

When operating in keyboard mode it is the users responsibility to keep the node within the domain of the transect. The boundary enforcement is disabled when in keyboard mode to allow the user maximal freedom of movement.

Velocity Adjust: (v)

The user has the option to change the velocity from the default of 0.5 m/s by using the v-key.

$> Enter choice: v

Enter New Velocity (m/s): 1.25

Velocity Set to 1.25 m/s

The system will allow a range of input from 0.01 to over 10 m/s and it is the users responsibility to operate in a zone that is safe for the transect that has been deployed in.

Acceleration Adjust: (a)

The user has the option to change the acceleration from the default of 0.25 m/s^2 by using the a-key.

$> Enter choice: a

Enter New Acceleration (m/s^2): .5

Acceleration Set to 0.50 m/s^2

The system will allow a range of input from 0.01 to over 10 m/s^2 and it is the users responsibility to operate in a zone that is safe for the transect that has been deployed in.

Calibrate System: (c)

[pic]

If a calibration file already exists for the transect being used, load it using the (l)oad calibration file menu option.

If the transect has not been calibrated yet, use the (c)alibrate system menu option to bring up the calibration menu.

When in calibration mode, the keyboard commands are the same as when in keyboard control mode. Once the node is in motion using the space-bar will cause the motors do decelerate at the rate of the systems acceleration (default of 0.25 m/s^2), and the ‘k’ key will cause the motors to decelerate at a rate of 200 rps. Use of the ‘k’ key could cause a sudden jolt in the system depending upon the velocity and weight of the node.

Once the user has positioned the payload at the (0,0) position of the transect, press ‘l’ (L-key) to begin logging calibration points. The user will be prompted to enter the x-position of the node in meters. Zero should always be the beginning of the transect as this also flags the system to initially reset the motor distances to ensure consistency if slippage should ever occur.

Continue logging points in meters as prompted by the system until the end of the transect has been reached. At this point press the ‘s’ key to save the collected points into a file for future use.

At this time the p-option has not been implemented since it is not required for the node to be calibrated in order to use the keyboard control. This may appear in future revisions of the system, but for the time being has been eliminated from the interface.

Boundary Information: (b)

By default the boundary is set to the min and max values for x of the calibrated transect and to +/- 1 m around the y=0 (or surface) position. The boundary conditions are also enforced by default.

$> Enter choice: b

-----------------BOUNDS OPTIONS-----------------

(p)rint current boundary points

(e)nable boundary checking

(d)isable boundary checking

(c)lear boundary points

(s)et boundary points

$> Enter choice: p

Current bounds:

enabled = True

x_min = 0.0

x_max = 6.0

y_min = -1.0

y_max = 1.0

From the boundary menu it is possible to display the current status of the boundary conditions, enable or disable the enforcement of bounds, clear or set new bounds. All x and y values are in meters and the enabled flag is Boolean.

When bounds are enforced the system will first check all moves requested against the boundary conditions of the system. If the destination is outside of the boundary, the system will inform the user and then proceed to move the node to the closest position to the desired destination while staying within the bounds of the system. See example below where x_min is set to 0.0:

Current position: 0.000 -0.000

Next position x (m): -0.2

Next position y (m): -0.5

Boundary Violation...

Adjusting move to (0.0, -0.5)

Load Calibration File: (l)

Whenever the system is started it has no sense of calibration or position. It is possible to load these values directly from a file that exists from a previous calibration of the transect and should be used each time the system is reset or restarted.

$> Enter choice: l

Enter calibration filename: motor_data_2024.txt

A valid file will elicit no response from the system, however an invalid filename will prompt an error message to the user

$> Enter choice: l

Enter calibration filename: motor_data_2023.txt

Failed to open the file named: 'motor_data_2023.txt'...

File Based Mode: (f)

If the system has not been calibrated, the user will receive a response as follows:

$> Enter choice: f

System must be calibrated prior to using file-based mode...

Once the system has been calibrated it is possible to allow another application to interact with it via the (f)ile based mode of operation. In file based mode the system will only respond to interaction with the following files (as presented in the file overview section):

1. move.txt

2. done.txt

3. position.txt

4. interrupt.txt

A typical interaction could be as follows:

1. the users application writes the position to move to in the move.txt file

a. the NIMSRD system detects the new destination in the file and begins to move towards it

b. the position.txt file is updated by the system at a rate of ~10Hz with the nodes current position

2. the user application may want to make use of the position.txt file to track the nodes progress

3. the user application also polls the done.txt file to watch for a ‘1’ to be written to it which indicates that the NIMSRD system has completed its move to the destination indicated in the move.txt file

4. at this point the user may choose to pause at the given location for a sensor reading or move to a new location based on the goals of the driving application

Status of Motors: (s)

The status of the motors can be observed by using the s-key. It should be noted that this process may takes many seconds. The information presented can be used to determine whether the motor is operating within safe bounds and could be used as part of a power on self test (POST) method in future revisions.

Enter choice: s

Motor status will take a few seconds to retrieve...

1STATUS

ViX500IE-Servo Copyright 2003 Parker-Hannifin

Firmware: REV 2.3 Nov 05 2003 10:40:09 Map No: 12

Control card revision 2 Servo drive

Power card revision 5 Servo power stage E500

Configured for resolver feedback

FPGA_ID (read)......... 20c0 FPGA_ID (file)....... 20c0

MOTOR TYPE ............ 7551 RESOLUTION .......... 4096

CONT. STALL CURRENT ... 4.2 Amps POLES ............... 4

PEAK CURRENT (PC)...... 298 % TRACKING LIMIT (TL).. 4096

INDEX POSITION (IX).... 512

MOTOR SUPPLY........... 79 V AUX SUPPLY........... 5.2 V

I/O SUPPLY............. 24 V I/O CONFIGURATION.... 8160

INTERNAL TEMPERATURE... 43 C HEATSINK TEMPERATURE. 38 C

INCREMENTAL INDEXING (MI)

VELOCITY (V)........... 7.220 DISTANCE (D)......... 0

ACCELERATION (AA)...... 3.61 DECELERATION (AD).... 3.61

CURRENT POSITION (PA).. 7 ERROR (PE)........... -7

POSITION MODULUS (PM).. 0

AXIS: READY

DRIVE FAULTS (DF): 0000_0000_0000_0000_0000_0000_0000_0000

DRIVE STATUS (ST): 0000_0000_1000_0000_0001_0000_0000_0010

USER FAULTS (UF): 1000_0000_0000_0000_0000_0000_0000_0000

Quit and Exit: (q)

Exiting the application will simply return control back to the terminal or consol from which the application was spawned.

Known Issues:

If the nimsrdmenu application is exited either intentionally or unintentionally the user will need to reload the calibration file and reset the origin before continuing the scan.

To be added to as the system warrants…

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download