Skip to main content

Controller for VSMD CAN motor

Project description

VSMD

Controller for VSMD can motor

Debug model

Explained by doc file VSMD1X6_SERIES_V1.0.pdf, it's easy to convert can.message to meaningful frame.

bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000)

while True:
    for msg in bus:
    print("\n%2d\n" % cnt)

    # set debug = true make it to show inf of can-frame
    can_frame = VsmdCanFrame(msg, debug=True)

For an example,say frame 0004079F#0020000000000000 , it can be interpreted as below:

************************************************************                                                                                                             
| Main:  |                                                                                                                                                               
+ Raw                    :  0004079f#0020000000000000
+ Sender                 :  vcan0
+ Extent ID Frame        :  00000000001000000011110011111
+ DLC                    :  8
+ Data Frame             :  ['00200000', '00000000']

| Extend ID Frame |
+ Source Device          :  Pi
+ Target Device          :  BroadCast
+ Command Word           :  11
+ CMD or Register ADR    :  READ_DATA_REGS

| Action |
+ CW Means               :  CMD
| Data Frame |
+ Command                :  [('Data Reg Start:', <DataRegTable.CID: ['0000000', 'Channel ID', 'Determined by motor']>), ('Data Reg count:', 32)]                        
************************************************************

Quick VSMD-CAN setup and drive

See in CommonCMD in VSMD1X6.py

Generate your own CMD

I have sealed most type of command of VSMD in script,you can import them like this:

from VSMD import CommonCMD

Which contains these sub-function:

  • enable_motor(device: str)

    ENA 0x01

    CAN motor is allowed to move after ENA is ON

  • disable_motor(device: str)

    OFF 0x02

    Make CAN motor ignore move cmd. Often used for broadcast

  • move_motor(device: str, speed: int)

    MOV 0x05

    Move motor with specific speed. This is somehow dangerous

  • stop_motor(device: str)

    STP 0x04

    Stop the motor now.

  • move_to(device: str, pos: int)

    POS 0x06

    Mode to absolute pos.

  • move_dis(device: str, dis: int)

    RMV 0x0B

    Mode to relative pos.

  • read_status_regs(device: str, reg: StatusRegTable, cnt: int)

    READ STATUS REGS 0x1E

    Follow the PDF

  • read_data_regs(device: str, reg: DataRegTable, cnt: int)

    READ DATA REGS 0x1F

    Follow the PDF

  • write_data_regs(device: str, reg: DataRegTable, data):

    Note that you must use save after write some registers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

VSMD-0.1.7.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

VSMD-0.1.7-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file VSMD-0.1.7.tar.gz.

File metadata

  • Download URL: VSMD-0.1.7.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4

File hashes

Hashes for VSMD-0.1.7.tar.gz
Algorithm Hash digest
SHA256 43dcaf1ce8895b183bc730076eed748438a6f3b87f91e5e91e986ea6c5edc963
MD5 a0c9834ac69ffeda813e6badd81ed102
BLAKE2b-256 28a21d92b3f318c49bad9747dc7762ab2a8d810812fd3de9b1d4521ba2ef062b

See more details on using hashes here.

File details

Details for the file VSMD-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: VSMD-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4

File hashes

Hashes for VSMD-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7455ec329a409143d433c1dac4a94c41ddaef7507040460a13fd5fb0f4cceb4e
MD5 9a2086f831e4280b89409a312f38b251
BLAKE2b-256 38ca4f0ffcc064c69cbe8eea360f0a5f9fedf9b1cbf4a2b40e00ccff806cc9aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page