TurnTables

Classes and structures for controlling motorised rotary tables used during scan acquisition. All types are in the turntables namespace.

namespace turntables

Namespace for TurnTables library, that provides interface for controlling turn tables.

Enums

enum class TableError : uint32_t

Values:

enumerator not_controllable

Can not be controlled.

enumerator plugin_does_not_exist

Plugin controller does not exist.

enumerator usb_port_not_available

Specified USB port is not available.

enumerator ximc_not_initialized

Communication with table can not be initialized (XIMCCOntroller).

struct BuiltInTableParams
#include <TableParams.h>

Parameters used for connection and control of built-in supported rotary tables.

Public Functions

inline explicit BuiltInTableParams(const std::string &in_usb_port, const uint32_t &in_rotation_speed, const uint32_t &in_rotation_acceleration, const uint32_t &in_microsteps_per_rev)
inline explicit BuiltInTableParams(const std::string &in_usb_port)

Public Members

std::string usb_port

Identification of USB port where is rotary table plugged.

Example For Windows: “COM3” Example For Linux: “/dev/ttyUSB0”

uint32_t rotation_speed = 700

Speed of XIMCTable.

uint32_t rotation_acceleration = 1000

Acceleration/deceleration of XIMCTable.

uint32_t microsteps_per_rev = 480000

Number of micro steps of motor needed for 360 degree revolution (Standa rotary table) - this depend on the model of Standa rotary table.

class ComXimController
#include <ComXimController.h>

Interface to control the ComXim rotation table.

List of all available serial messages for a table:

CT+SPKMUTE(<is_mute>);
  Mute or unmute the beep.
    <is_mute> 0 or 1

CT+SETSPEED(<speed>);
  Set rotation speed.
    <speed> integer

CT+TRUNSINGLE(<direction>, <angle>);
  Makes a single turn.
    <direction> -1 or 1
    <angle> integer in degrees

CT+START(<direction>, <turn_mode>, <shutter>, <angle>, <wait_time>, <wait_time>, <num_repeat>);
  Starts turning in CONTINUOUS or INTERMITTENT mode.
    <direction> -1 or 1
    <turn_mode> 0 for CONTINUOUS or 1 for INTERMITTENT
    <shutter> 0 or 1
    <angle> integer in degrees
    <wait_time> integer pause length in INTERMITTENT mode
    <num_repeat> integer number of turns in INTERMITTENT mode

Public Functions

explicit ComXimController(const std::string &port_str, ComXimSettings settings = {})

Connect to a device on a specified serial port.

Parameters:
  • port_str – Serial port id, e.g. “/dev/ttyUSB0” on linux, or “COM1” on Windows.

  • settings – Controller settings.

Throws:

std::runtime_error – When connection to serial port can not be established.

~ComXimController()
bool Rotate(float angle, double timeout = 60.0)

SendRotateCommand the table by a specified angle and wait for motion to finish.

Parameters:
  • angle – Rotation angle in degrees.

  • timeout – Timeout [s] to wait for table to finish rotation before returning failure.

Public Static Functions

static bool TestSerialPort(const std::string &serial_port_id)

Check if a correct device is connected on a specified usb port.

struct ComXimSettings

Public Members

uint32_t baudrate = 115200
uint32_t serial_connection_timeout_ms = 3'000
bool enable_printing = false
class ComXimTable : public turntables::Table
#include <ComXimTable.h>

ComXim rotary table controller operated via USB.

Public Functions

explicit ComXimTable(BuiltInTableParams params)
virtual bool Rotate(float angle_deg) override

Commands table to rotate by a specific number of degrees.

Protected Functions

virtual TableStatus CheckStatus() const override

Re-check table status.

class PluginTable : public turntables::Table
#include <PluginTable.h>

Plugin rotary table controller - a table controlled by a command line application.

Public Functions

explicit PluginTable(const PluginTableParams &params)
virtual ~PluginTable()
virtual bool Rotate(float angle_deg) override

Commands table to rotate by a specific number of degrees.

Protected Functions

virtual TableStatus CheckStatus() const override

Refresh table status.

struct PluginTableParams
#include <TableParams.h>

Parameters used for connection and control of plugin-controlled rotary tables.

Public Functions

inline explicit PluginTableParams(const std::string &pbp, const std::string &pn)

Public Members

std::string plugin_base_path

Plugin base path.

std::string plugin_name

Plugin name.

struct RotationParams
#include <RotationParams.h>

Rotary Table rotation parameters.

Public Functions

inline RotationParams()

Initialize with 16 rotation steps that complete a full circle.

inline explicit RotationParams(size_t num_rotations)

Initialize with a specified number of rotation steps that complete a full circle.

inline explicit RotationParams(const std::vector<float> &angles)

Initialize with specified angles [deg].

Public Members

std::vector<float> rotation_angles = {}

Ordered list of rotation angles [deg].

std::chrono::milliseconds rotation_delay = {0}

Delay after each rotation. Allows objects to stabilize before capturing the next scan.

std::chrono::seconds timeout = {15}

Timeout after which the connection to rotation table is evaluated as not responding.

class Table
#include <Table.h>

Abstract base class for turntable controllers.

Subclassed by turntables::ComXimTable, turntables::PluginTable, turntables::XIMCTable

Public Functions

Table()
~Table()
TableStatus GetStatus() const

Get table status.

virtual bool Rotate(float angle_deg) = 0

Commands table to rotate by a specific number of degrees.

Protected Functions

virtual TableStatus CheckStatus() const = 0

Re-check table status.

class TableConnectionBuilder
#include <TableConnectionBuilder.h>

Tries to connect to a rotary table.

Public Types

using Result = std::pair<std::shared_ptr<Table>, TableStatus>

Public Functions

TableConnectionBuilder() = delete
~TableConnectionBuilder() = delete

Public Static Functions

static Result Connect(const turntables::PluginTableParams &params)

Builds a connection to a rotary table with using a plugin - a command-line controller application.

static Result Connect(const turntables::BuiltInTableParams &params)

Builds a connection to a rotary table using specified connection params or returns nullptr.

class TableDriver
#include <TableDriver.h>

Class that controls arbitrary turn table models.

Public Functions

TableDriver() = default
TableDriver(const std::shared_ptr<Table> &table)
~TableDriver()
void SetTimeout(std::chrono::seconds timeout)
bool Rotate(float angle_deg)
void StartRotation(float angle_deg)
bool WaitToFinish()
struct TableStatus

Public Functions

bool IsOk() const

Is table status Ok.

Public Members

utils::EnumFlags<TableError> errors

A list of errors.

Public Static Attributes

static const TableStatus OK

OK Status - no errors, connection to TurnTable successful.

class XIMCTable : public turntables::Table
#include <XIMCTable.h>

XIMC Rotary table controller - operated via USB connection.

Public Functions

explicit XIMCTable(const BuiltInTableParams &params)
virtual ~XIMCTable()
virtual bool Rotate(float angle_deg) override

Commands table to rotate by a specific number of degrees.

Protected Functions

virtual TableStatus CheckStatus() const override

Re-check table status.