Skip to content

memory-hole/amtenc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amtenc

Library for reading positions from CUI Devices/Same Sky 12-bit AMT absolute encoders

This implements the protocol for 12-bit encoders and has been tested with RS-485 variants (AMT21-series). It should work with any variant that is accessible via an interface that appears as a serial device and would be trivial to change to support 14-bit position data, but I haven't done this because I don't have a 14-bit encoder on hand.

Note that these encoders are synchronous, so this library has been implemented accordingly.

Physical Assembly

AMT21-series

To connect an AMT212A, AMT213A, AMT212E, or AMT213E, you'll need the following:

  • FTDI USB-RS485-WE-1800-BT
  • Molex 502578-0601 connector plug body/housing
  • 4x Molex 2157111122 pre-crimped leads

If in doubt, check the documentation for both the FTDI adapter and the encoders. The contact positions are counted left-to-right from the back side of the Molex connector plug body/housing with the clip pointing up. Match the colored wires on the FTDI adapter cable to these positions:

  1. Red (5V)
  2. Yellow (B)
  3. Orange (A)
  4. Black (GND)

Plug the completed USB to RS-485 adapter into an open USB port on your computer and the other end into your encoder.

AMT24-series

These use a different Molex connector plug/housing. See the documentation for details.

Quickstart

Assuming all the defaults are correct for your environment: You have a 2Mbaud variant encoder, you have connected the encoder to your computer using a USB to RS-485 cable that appears as /dev/ttyUSB0 (described above), and you have permissions to access this device, the following is all you need to do to see it read positions with a 100ms delay between each read:

git clone https://github.com/memory-hole/amtenc.git && cd amtenc
python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
python3 amtenc.py

Prerequisites

The only dependency outside python3 is the pyserial library (pyserial/pyserial GitHub Repo, pyserial PyPI Project).

Included is a requirements.txt for the lone requirement:

pip install -r requirements.txt

Alternatively, you can install the library system-wide:

Debian / Raspberry Pi OS / Ubuntu

sudo apt-get install python3-pyserial

Alpine Linux

apk add py3-pyserial

pip

pip3 install pyserial

Use

The following assumes that you have an A variant encoder with a 2Mbaud serial rate. If you don't, you'll need to adjust the baud and timeout values to work with your encoder.

Copy the amtenc.py file into your project and import it:

from amtenc import AMT_12bit

Elsewhere, you can initialize it like so:

enc = AMT_12bit()

Then you can read it:

position, valid = enc.read()

Licensing

Note that in addition to the MIT license that applies to this code, it in turn depends on the following libraries with the indicated licenses:

Library License
pyserial BSD-3-Clause

About

Library for reading from CUI/Same Sky 12-bit AMT absolute encoders

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages