motorDSM is a submodule of [motor](https://github.com/epics-modules/motor). When motorDSM is built in the ``motor/modules`` directory, no manual configuration is needed.
motorDSM can also be built outside of motor by copying it's ``configure/EXAMPLE_RELEASE.local`` file to ``RELEASE.local`` and defining the paths to ``EPICS_BASE``, ``MOTOR``, and itself.
motorDSM contains an example IOC that is built if ``configure/CONFIG_SITE.local`` sets ``BUILD_IOCS = YES``. The example IOC can be built outside of the driver module. Copy ``iocs/dsmIOC/configure/EXAMPLE_RELEASE.local`` to ``RELEASE.local`` and uncomment and set the paths for the appropriate lines depending on whether motorDSM was built inside the motor module or independently.
You will need to set the path(s) for the serial port(s) in ``st.cmd.md90`` (for a single unit) or ``st.cmd.md90.multi`` (for multiple units).
You will also need to ensure they match the names used in ``motor.substitutions.md90`` (or ``motor.substitutions.md90.multi``).
By default, ports are assumed to be at ``/dev/ttyUSB0``, ``/dev/ttyUSB1``, etc.
You will also need to comment or uncomment lines depending on the number of drivers you have connected. For each driver, make sure you uncomment/call the following functions:
where `[controller name]` is the name of the motor to assign. Convention is to use "MD90n", starting with n=0.
**5. Intialize the IOC**
After calling `iocInit`, run the following lines for each motor. The example below uses `DSM:m0` but it should be run for each line described in motor.substitutions.md90 (or motor.substitutions.md90.multiple).
````
dbpf("DSM:m0.RTRY", "0") #sets retries to 0; this is automatic on the MD90
dbpf("DSM:m0.TWV", "0.1") #Tweak distance
dbpf("DSM:m0.VMAX", "1.0") #Sets max velocity to 1 mm/s
dbpf("DSM:m0.HVEL", "1.0") #Sets max velocity to 1 mm/s
In ``motorDSM/iocs/dsmIOC/configure``, copy ``EXAMPLE_RELEASE.local`` to ``RELEASE.local``. Comment out the "if built inside motor" lines, uncomment the "if built outside motor" lines, and set the path for ``MOTOR_DSM``.
After building, run the example IOC described at the top of this section in one terminal window.
Open another terminal window and navigate to [EPICS install directory]/epics-base/bin/linux-x86_64/ (or wherever you built EPICS base.
Use the commands `caput` and `caget` to set and read process variables.
For example, to get the current position, use `./caget DSM:m0.REP`. This reads the REP variable, which is the "Raw Encoder Position". Set m0 to m1, m2, etc. for multiple motors.