https://github.com/alleninstitute/pytic

PyTic - An Object-Oriented Python Wrapper for Pololu Tic Stepper Drivers

https://github.com/alleninstitute/pytic

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 1 committers (100.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

PyTic - An Object-Oriented Python Wrapper for Pololu Tic Stepper Drivers

Basic Info
  • Host: GitHub
  • Owner: AllenInstitute
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 494 KB
Statistics
  • Stars: 11
  • Watchers: 7
  • Forks: 7
  • Open Issues: 9
  • Releases: 0
Created almost 8 years ago · Last pushed 12 months ago
Metadata Files
Readme Contributing License

README.md

PyTic v0.0.4

pololu tic


Introduction

PyTic is an object-oriented Python wrapper for the Pololu Tic stepper driver series. The wrapper interacts with the stepper driver device using the API described in the Pololu-Tic-Software GitHub page using the ctypes library. The device comunication protocol is USB.


Installation

Prerequisites

PyTic requires the Tic Software and Drivers for Windows msi provided by Pololu to be installed as a prerequisite. Other operating system drivers can be found on the Pololu Tic Resources, but are not currently supported by this Python package.

Pip Install

To install the PyTic package on a Windows machine equipped with Python 2.7 or higher, run the following pip command:

console C:\> pip install pytic

  • Note: Only Windows x64 machines are supported at this time.

Package Architecture

PyTic encompasses almost all functionality present in the original C-API with some additional features. The Pololu Tic Stepper Driver is represented in Python using the pytic.PyTic() object.

```console

| Package Relation Tree |

PyTic [Tic Object] |-- Settings [Structure Interface Object] |- Pin Settings [Structure Interface Object] [List] |-- Variables [Structure Interface Object] |- Pin Info [Structure Interface Object] [List] |-- Logger [Notification]

PyTic_Protocol [Module] |-- Tic Constants [Dictionary] ```

PyTic Protocol (C-Constants Dictionary)

The Pololu Tic C-API uses CAPS_DEFINED_CONSTANTS for setting many of its parameters that represent an integer value. These contants set parameters such as pin function, step mode, etc. The PyTic package auto-imports these values from the tic_protocol.h header file and stores them in a Python dictionary named tic_constants in the pytic_protocol module. See Using Settings in the Example Code section to see how to use this dictionary in contect.

Error Handling

All Pololu Tic C-API functions when dynamically imported into PyTic are wrapped in a higher-order function error handler called TED(), short for [T]ic [E]rror [D]ecoder. TED() will make all Tic wrapped functions return 0 from a successful call and 1 from a call that generated an error. In addition, TED() performs low-level bit mask decoding and writes the enumerated error value to the PyTic object internal log. This log can be output the ther terminal or file using the standard logging library.


Example Code

Outlined in this section are several examples of how to use PyTic to control a Pololu Tic Stepper Driver. The objective of this section is to show the PyTic syntax used to implement the Pololu Tic Stepper Driver C-API as opposed to detail each of the available functions. For a full list of commands, settings, and variable information please refer to either the Pololu Tic Manual, the Pololu Tic C-API, or this package's source code.

Simple Program

The simple program below demonstrates how to connect to a Pololu Tic Stepper Driver device over USB and move to several positions after the previous position has been reached.

```python import pytic from time import sleep

- Initialization -------------------------------------------

tic = pytic.PyTic()

Connect to first available Tic Device serial number over USB

serialnums = tic.listconnecteddeviceserialnumbers() tic.connecttoserialnumber(serial_nums[0])

Load configuration file and apply settings

tic.settings.load_config('path\to\config.yml') tic.settings.apply()

- Motion Command Sequence ----------------------------------

Zero current motor position

tic.haltandset_position(0)

Energize Motor

tic.energize() tic.exitsafestart()

Move to listed positions

positions = [1000, 2000, 3000, 0] for p in positions: tic.settargetposition(p) while tic.variables.currentposition != tic.variables.targetposition: sleep(0.1)

De-energize motor and get error status

tic.entersafestart() tic.deenergize() print(tic.variables.error_status) ```

  • Note: Modified settings will not take effect until PyTic.settings.apply() method is called. This is to avoid unnecessary writes to non-volitile memory.

Using Settings

The PyTic.settings structure interface object is used to alter device settings stored in non-volitile memory. As detailed above in PyTic Protocol, some of these settings have enumerated constants to maintain a user-friendly interaction. The code sample below demonstrates how to interact with PyTic.settings using the tic_constant dictionary. To avoid unnecissary writes to non-volitile memory, the PyTic.settings.apply() function must be called for the new settings to take effect.

```python

... assume PyTic object initialized and connected to device as 'tic'

Load Tic Constant Dictionary

tc = pytic.pyticprotocol.ticconstant

Modify individual properties of composite settings object

tic.settings.product = tc['TICPRODUCTT825'] tic.settings.stepmode = tc['TICSTEPMODEMICROSTEP16']

Turn the Serial RX Pin into a generic digital user input

pin = tc['TICPINNUMRX'] tic.settings.pinsetting[pin].func = tc['TICPINFUNCUSERINPUT'] tic.settings.pin_setting[pin].pullup = True

Required to burn new settings to Tic non-volitile memory

tic.settings.apply()

```


Logging

PyTic uses the logging package to display Tic status messages. The default logging level is logging.DEBUG. For less verbose logging, set PyTic.log_level = logging.CRITICAL. The log name is PyTic for users that would like to have a parent-object handle the logging information.


Example YAML Configuration File

PyTic settings can be set invidually using the PyTic.settings structure interface in the script or all-at-once using a YAML config file and the PyTic.settings.load_config('\\path\\to\\config.yml') function. Here is an example YAML config file with some usage notes,

yaml tic_settings: # required header for load_config fcn. product: TIC_PRODUCT_T825 auto_clear_driver_error: True # ** These 4 settings ** ignore_err_line_high: True # ** were experimentally ** serial_crc_enabled: False # ** determined to stabalize ** command_timeout: 0 # ** device performance ** max_speed: 180000000 # pulses/s * 10^-4 starting_speed: 0 # pulses/s * 10^-4 max_accel: 9000000 # pulses/s^2 * 10^-2 max_decel: 9000000 # pulses/s^2 * 10^-2 step_mode: TIC_STEP_MODE_MICROSTEP16 current_limit: 640 # mA, Only select values acceptable, See notes. decay_mode: TIC_DECAY_MODE_T825_FAST pin_settings: # Ex. Modifying Default Pin Fcn. - pin_num: TIC_PIN_NUM_RX func: TIC_PIN_FUNC_USER_INPUT pullup: True analog: False # - pin_id: TIC_PIN_NUM_TX # ... modifying a 2nd pin ... # func: TIC_PIN_FUNC_USER_INPUT # polarity: True # analog: False

Notes: * CAPS_DEFINED_CONSTANTS are keys for the tic_constant dictionary located in pytic_protocol.py. Refer to section Using Settings for more details on the dictionary and its use. * current_limit only accepts select values detailed in the Pololu Tic Manual


Dependencies

Dependencies include the following,

  • PyYAML

Level of Support Notice

This code is currently not supported. It is being released to the community AS IS without any guarantee of support. The community is welcome to submit issues, but should not expect an active response.


External Resources

External resources include the following,

Owner

  • Name: Allen Institute
  • Login: AllenInstitute
  • Kind: organization
  • Location: Seattle, WA

Please visit http://alleninstitute.github.io/ for more information.

GitHub Events

Total
  • Watch event: 2
  • Member event: 1
  • Issue comment event: 2
  • Pull request event: 4
  • Fork event: 2
Last Year
  • Watch event: 2
  • Member event: 1
  • Issue comment event: 2
  • Pull request event: 4
  • Fork event: 2

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 64
  • Total Committers: 1
  • Avg Commits per committer: 64.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
ALLENINST\danc d****c@a****g 64
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 7
  • Total pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 month
  • Total issue authors: 7
  • Total pull request authors: 2
  • Average comments per issue: 1.71
  • Average comments per pull request: 0.17
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 month
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.2
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChristineKitchens (1)
  • EdV2 (1)
  • jabdoa2 (1)
  • ananya-sp (1)
  • frankbraker (1)
  • JGVD21 (1)
  • inregards2pluto (1)
Pull Request Authors
  • jlmoraleshellin (5)
  • outofculture (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 90 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 2
  • Total maintainers: 2
pypi.org: pytic

An object-oriented Python wrapper for Pololu Tic Stepper Controllers.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 90 Last month
Rankings
Dependent packages count: 10.1%
Forks count: 14.2%
Stargazers count: 18.5%
Dependent repos count: 21.5%
Average: 23.9%
Downloads: 55.1%
Maintainers (2)
Last synced: 11 months ago

Dependencies

setup.py pypi
  • PyYAML *