Interface for ST SpinFamily motor drivers
Project description
ST Spin Family Interface
A Python library for interfacing with ST Spin Family devices, specifically the ST Micro L6470, L6472, L6474, and L6480 ICs. Can be used nearly without modification with similar ICs.
Currently this project relies on spidev's SPI transfer function.
Getting Started
pip install st-spin
Add imports
import time # Used in our example
from stspin import (
SpinChain,
SpinDevice,
Constant as StConstant,
Register as StRegister,
utility,
)
Create a device chain
stChain = SpinChain(
total_devices=2,
spi_select=(0, 0),
chip_select_pin=None, # Not implemented, relies on spidev for CS pin
)
This assumes the spi device is at 0, 0.
Create devices
motorMain = stChain.create(1)
motorAux = stChain.create(0)
# Unless you absolutely need holding current,
# it is good practice to disable the power bridges
motorMain.hiZHard()
motorAux.hiZHard()
Run basic commands
motorMain.setRegister(StRegister.SpeedMax, 0x22)
motorMain.run(100)
time.sleep(3)
motorMain.hiZSoft()
time.sleep(1)
# {{{ Set some registers
motorMain.setRegister(StRegister.Acc, 0x5)
motorMain.setRegister(StRegister.Dec, 0x10)
motorAux.setRegister(StRegister.Acc, 0x20)
# }}}
# {{{ Go n steps with both motors
motorMain.move(steps=420000)
motorAux.move(steps=420000)
while motorMain.isBusy():
time.sleep(0.2)
# }}}
# Head back
motorMain.setDirection(StConstant.DirReverse)
motorMain.move(steps=420000)
while motorMain.isBusy():
time.sleep(0.2)
# }}}
# Release holding current
motorAux.hiZHard()
motorMain.hiZHard()
More details
For details on the SPI setup, see create() in [spin_chain.py] See example.py
Troubleshooting
getStatus() is your friend. Feel free to use getPrettyStatus() under utility.py. The manual is also your friend.
Q: Why is my motor stalling, loud, or both? Most likely the Back-EMF compensation is not configured properly. The correction parameters depend heavily on your motor's ke value (V/Hz), inductance, and phase resistance.
After calculating the parameters using the manufacturer's tool, set KvalAcc, SpeedInt, SlpSt, etc. using setRegister()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for st_spin-0.0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb0ccfe170052b660c411e99a17d34a029a158f8e9271d149298f0e76db1cd91 |
|
MD5 | 5ae516f321c959b67e7058a5ae7590a2 |
|
BLAKE2b-256 | 9bb221e475c6fd28ab621fba89a4b30bbc40ba83f3fe120a2efb845f0e204be2 |