Python-based control of Papilio Pro for Stepper Motor


Recommended Posts

Hi! I am trying to use a Papilio Pro to run a stepper motor since the Teensy, Arduino microcontrollers proved insufficient for my purposes. I am interfacing the Papilio pro with the L6470 IC which is going to be the motor driver. My main problem is this - I am keen on using a Python module to control the stepper motor but I have no clue as to how to go about writing the code for the Papilio Pro which will be the board that will receive the bits sent via the Python code and will reroute it through the IC which will translate that in to stepper motion. The bits here are basically my position, speed values, etc. I have plans for sending entire waveforms, say, to make the motor oscillate between two positions and so on. I was wondering how I should go about this project?

Link to comment
Share on other sites

Hi there, I'll try to answer.


The overall architecture of the system would be like this, four parts in roughly a chain:

Part 1: On computer, in Python: Connects to the serial-over-USB port on the Papilio and transmits commands.  These commands can be in whatever protocol you want, one you find, one you design, etc.

Part 2: On Papilio: Receives those commands over the serial port.

Part 3: On Papilio: Interprets them, translating them into commands taken by the L6470 IC.

Part 4: On Papilio: Communicates with the L6470 IC.


Part 1 you sound like you'd know how to do.  Part 2 is commonly called a UART, and very widely available.  Part 3 would be custom, it might be simple or complex.  Most likely, part 3 would be a SoC: The combination of a CPU with some software to run on it.  Part 4 would depend on the IC; for the L6470 IC it sounds like this would be a SPI master, also widely available.


As for languages used:  The "hardware" implemented by the FPGA is commonly done in one of two languages, Verilog or VHDL.  But an alternative exists for Papilio, called DesignLab.  A lot of people have used it, and it seems quite well suited for what you're trying to do.  As for the software part of part 3, that would depend on what you use for everything else.  With DesignLab, I believe you get an Arduino-like environment.


Other approaches do exist.  You might do part 3 entirely in logic, without a CPU or code running on it.  Probably harder that way.


The design of the protocol is wide open, and important.  It could complicate your code in parts 1 and 3.  There are a lot of possibilities.  I don't have any particular recommendations, except to make it text-based, for easier debugging.  In the recent past I've used the following:

1. Numeric parameters (in decimal), separated by dots (.), followed by alphabetic two-letter commands.

2. Each command on a single line, the first character is the command, the rest is its parameters.

3. ECMA-48.  Well-suited to what I'm doing, but not for motor control.


I'm curious, how did Arduino prove insufficient for this?  It has SPI, it has a serial port over USB, it has a development environment.  Is it lack of CPU power, memory, some additional I/O interfacing?

Link to comment
Share on other sites

If I remember correctly, the l6470 is what I would call a semi-smart stepper controller. I say semi-smart because instead of taking step and direction pulse signals it is smart enough to allow to send speed and position values and the chip does the pulses which is great. The reason I use the semi is that unlike some other smart controllers it can't take a queue of positions and join those segments like some of the expensive smart controllers can. I believe it can also be used for normal step direction also, but kind of seems like a waste to use like that.


I think it is a very underutilized chip though myself in many maker type projects.


Any more details you can give on the usage? More than 1 stepper or only 1? Linear only movements or also circular?


jaxartes has given you some good input.


I would start by installing the latest version of  designlab and looking at some of the default projects to get an idea how it works. with designlab you can probably reuse most of your arduino code as it is designed to be somewhat compatible. The zpuino though should run much  faster than the teensy arduino. Jack has some great video tutorials on the gadget factory website on using designlab and all



Hope that helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.