I’m very new to python however i am given to work with Simple High-Power Motor Controller (SMC) 18v25 which is connected to a motor and a limiting switch. I need to write a program in python to simply move the motor until the limiting switch is pressed and the motor will stop. How do i start?
If you are not familiar with Python, then you should start there. I recommend looking at the beginner’s guide on the official Python website to help you get started. You can see the full documentation for Python here.
Once you get familiar and comfortable with the language, you can start writing a simple program to control the simple motor controller (SMC) by sending it a few commands via its serial interface. You might consider looking at maestro.py, which is a Python class written by one of our forum members that controls our Maestro servo controller via its serial interface. The Maestro uses the same communication protocols as the SMC, so looking at the class’ functions should give you an idea of how to send serial commands in Python. If you have not done so already, you should familiarize yourself with the SMC’s serial interface by reading through the “Using the Serial Interface” section of its user’s guide.
By the way, you can try using the Serial Transmitter Utility to get better acquainted with the SMC’s serial commands and figure out what commands you need to send to get the desired behavior.
I can’t seem to solve the “UserWarning: Unknown distribution option: 'use_2to3” problem
From the output, it looks like pyserial is installed. I was able to reproduce the warning on my VirtualBox running Ubuntu 16.04 but was able to run a test script with maestro.py without any other complications. If you have pip installed, you can run
pip freeze in a terminal to see if pyserial is installed and which version.
Where did you install maestro.py on your system? A screenshot of the directory would be best.
I checked and my pyserial is version is 3.3 is that why i wouldn’t work because i’m running it on python2.7 idle? i’m not sure i have maestro.py installed. How do i do that? I have pyserial-2.7 though
It sounds like you probably do not have maestro.py installed. You can download the ZIP file for maestro.py from its GitHub page by clicking on the “Clone or download” button near the top of that page and selecting “Download ZIP”. Then unzip the file and place it in the same directory as your test.py.
By the way, please note that the maestro.py code will not work with your SMC without major modifications. I had suggested looking at that code so that you can use it as a template for sending serial commands to the SMC via its virtual serial port.
Hi, i downloaded maestro.py and put in the same directory but it still couldn’t work.
So i tried to write to the usb sending commands like this
It works however i need to click on “resume” on the SmcCenter before i can run the program, is there anyway i can move the motor without clicking on “resume” and just run the program?
You need to send the Exit Safe Start command (0x83), which is what clicking the Resume button in the Simple Motor Control Center does, before setting the speed in your code. The Exit Safe Start command is required before the motor can run if the Input Mode is Serial/USB and the Safe Start mode is not disabled. For more information about that command, see its description under the “Binary Commands” section of the SMC user’s guide.
If sending that command doesn’t help, can you send the settings file from your SMC and pictures showing how you have everything connected in your setup (e.g. limit switches, power supply, and motor)? To save the settings file, click File->Save Settings File… inside the Simple Motor Control Center.
I missed out that part! Thanks so much, everything works fine for now!