Jump to content
43oh

Timer based Stepper driver


Recommended Posts

Hi all!

 

The current project I'm working on with Stellaris is a stepper (step, direction) driver. I have these TB-6560 drivers that I got on eBay for cheap (here), and I've successfully driven the motors using the 32 bit timer. I've been able to set the frequency using a variable, etc, and hoping to implement acceleration, etc. The goal is to eventually write an entire gCode interpreter and be able to drive the CNC via a serial connection that dumps gCode to the Stellaris.

 

I'm running in to a weird problem though. I'm attempting to add a control panel I got form Deal Extreme that connects via software SPI. I've been able to successfully interact with it using a library developed by Dan Oprescu. Works great in its own CCS project. I can read buttons, update the 7-seg displays, light LEDs, and everything works great. I've moved his library into my stepper project, and all hell breaks lose. As soon as I include the TH1638.h header in my stepper project I get hundreds of build errors. The really weird part is they don't seem to be coming from any of my code files. They are all coming from compiler includes in iosfwd and exception. I looked around on the web and I found something about including pre-compiled headers being a problem, but I'm a bit lost in this. I compared all the CCS project settings between the TM1638 project example, and my stepper project, and nothing seems out of place. I'm sure I'm missing something, but I have no clue how to debug this.

 

If anyone has any ideas that would be greatly appreciated. I've attached my code so far if anyone has a few minutes to look it over! I'll keep posting here as I progress through the project as well! Suggestions and pointers welcome!

 

EDIT (10-15-2012)

Here's (attached) the latest updates to my code with the solutions listed below, if anyone is interested. I'll probably copy it over to github and then post it under the code section before too long here. I want to get it a little further before I do that. I'm sure I'm doing some things wrong here and I may have to change approaches, but this is what I've got so far!

 

EDIT 2 (10-15-2012)

Here is a link to the project git repo. Feel free to clone and code! https://github.com/VirtualEnder/Stepper

Stepper.zip

Link to post
Share on other sites

I'm pretty new to this but I would think that you wouldn't include anything not relevant to the hardware you are programming.

 

What I mean is that one system is one project, the other system is another project, so you wouldn't include parts from one in the other. One board would expose an interface and protocols, and the other would connect to the interface and send / receive data in accordance with the established protocols. For instance, I'm working on a fuel injection system based on a kit I have, which has two LM3 Stellaris MCU's. I have to program one do certain things, and the other to do other things, and figure out how to get them to communicate with each other. But I wouldn't include one MCU's files into the other MCU's code because they each have different functions, and will communicate with each other over CANBUS.

 

So, in your case, you would build functionality into one device, establish what data that device can transmit and receive over SPI, and how it responds to that data, then build the other end to work with that.

 

Am I making sense or am I talking over my head? :)

 

And welcome to the board! ;)

Link to post
Share on other sites

The current project I'm working on with Stellaris is a stepper (step, direction) driver. I have these TB-6560 drivers that I got on eBay for cheap (here), and I've successfully driven the motors using the 32 bit timer. I've been able to set the frequency using a variable, etc, and hoping to implement acceleration, etc. The goal is to eventually write an entire gCode interpreter and be able to drive the CNC via a serial connection that dumps gCode to the Stellaris.

 

I am working on CNC (still software part only) for PCB's. My PC interface application load G files exported from Eagle, and use MSP430F55x with DRV8811 (http://gandalf.zemri...or_control.html) for stepper control. There are 2 Z tools (drill/mill). No need for tool change stoppage, so all job can be completed without user intervention. PC sending simplified G-Code commands to uC, and than uC informs back all the time PC about (all motors) stepping, so there is live animation on the screen about changing of all positions (X, Y, ZM, ZD). If something goes wrong on uC side, PC stops the job.

 

There is no control panel (leds/buttons) that can be more user friendly than PC interface. And my system will not have any of those, only on/off (or emergency button) and limiter switches.

 

uC side is written and optimized in assembler (min resolution 0.1 um), and it is fast. If you want to run any kind of G-Code interpreter on uC (100 MHz) side, it will be slow. I tried it at the beginning and late gave up. If you are using uart standard 115200 bps for data exchange, it will be slow again.

 

 

pcbcnc9.gif

Link to post
Share on other sites

Well I feel kind of stupid, Dan helped me out on his blog. I just had forgotten to switch the primary file over to a .cpp (C++) so his object for the display was throwing errors! The library he wrote is accessed by including the header file in your main C++ file. Thanks to Dan for helping me out with that bit. (note to admins, he said he's having trouble getting his account activated on this site :| someone should check that out, he rocks!)

 

That fixed the problems with the display, now I'm getting an error on the interrupt handler. Since I've added the display code it says my IntHandler (Timer0IntHandler) is not defined even though it's defined directly above my main function.

 

Also thanks for the advice jazz. I'll probably just keep the code on the uC to simply axis, direction, step and write the gCode in software then. I'm looking to build a full CNC for wood/acrylic/aluminum etc. I'm using big Nema23 steppers with massive torque :D I'm looking to interface with common CNC software as well. I'm sure it'll be a huge project, and I may end up dumping everything I'm working on now and re-doing it, so we'll see. It's just a fun project for now.

Link to post
Share on other sites

I am working on CNC (still software part only) for PCB's. My PC interface application load G files exported from Eagle, and use MSP430F55x with DRV8811 (http://gandalf.zemri...or_control.html) for stepper control. There are 2 Z tools (drill/mill). No need for tool change stoppage, so all job can be completed without user intervention. PC sending simplified G-Code commands to uC, and than uC informs back all the time PC about (all motors) stepping, so there is live animation on the screen about changing of all positions (X, Y, ZM, ZD). If something goes wrong on uC side, PC stops the job.

 

There is no control panel (leds/buttons) that can be more user friendly than PC interface. And my system will not have any of those, only on/off (or emergency button) and limiter switches.

 

uC side is written and optimized in assembler (min resolution 0.1 um), and it is fast. If you want to run any kind of G-Code interpreter on uC (100 MHz) side, it will be slow. I tried it at the beginning and late gave up. If you are using uart standard 115200 bps for data exchange, it will be slow again.

 

What exactly does your software do? Are you drilling the traces and holes in a board? I saw some videos on Youtube of some people doing that.

 

Is your code available somewhere?

 

The reason I am asking is that I have started to get involved with a project that is very similar at a local hackerspace. We are doing the pick and place part of the board manufacturing though, not the drill/mill. I am very new at this board manufacturing stuff so I am still clueless at this point. We are using a Shapeoko hobbyist CNC machine as a starting point -- http://www.shapeoko.com.

Link to post
Share on other sites

What exactly does your software do? Are you drilling the traces and holes in a board? I saw some videos on Youtube of some people doing that.

 

Is your code available somewhere?

 

The reason I am asking is that I have started to get involved with a project that is very similar at a local hackerspace. We are doing the pick and place part of the board manufacturing though, not the drill/mill. I am very new at this board manufacturing stuff so I am still clueless at this point. We are using a Shapeoko hobbyist CNC machine as a starting point -- http://www.shapeoko.com.

 

I didn't find any user friendly application regarding PCB milling/drilling topic, and started 3 years ago to work on my own. One day, when the first board will be produced, I will put details about project on 43oh forum, because it is based on MSP430F550x. It will not be open source project, but I will explain PC/uC/stepper used interface (it will be open), give answer to all questions regarding the topic.

 

As input for PC interface application (picture posted upper), milling "singlesided.bot.etch.tap" and drilling "singlesided.bot.drill.tap" G files (exported from eagle) are used. On the right side of window, there are 2 tolls, for milling (upper) and drilling (lower). On the main part is small white dot that shows X/Y position, and on the tolls part is Z position. I made the screen shoot during milling, so milling tool is scratching the board (red scrached path, and blue will be), and drilling tool is in up position and waiting (holes on board are marked with blue plus). After one G file is processed, job with next file is started.

 

PC interface application is running on Win XP and it is connected by USB to control board (only MSP430F550x with few parts). Control board is powered by USB and have standard stepper drive connection (STEP, DIR, GND), so it will be possible to use any existing CNC device, just by reconnecting stepper drive connectors from original control board to MSP430F550x board.

 

All not X/Y/Z command regarding motors from G files are ignored, and there is configuration setup. Ratio is motor resolution value, um needed for one step. So when in G file X change in +/- 5.1 um, motor for X axis will made one fwd/bck step. Delay is used to defined minimum time between 2 steps, or stepper frequency/speed. Delay is separated, and it can be used for example, for drilling tool to go faster up than down, or for milling to go slower when board is milling and faster when toll is moving over the board without milling. There are 2 tolls on Z axis (with at least different X or Y position), and offset is used for zeroing (local X/Y/Z zero position of each tool related to real zero position). For testing and finding all configuration values calibration part is used. My target was to be able to use 4 different steppers for X/Y/ZM/ZD (different number of steps per revolution, and different speed) without any problems.

 

cfgp.gif

 

I was working a lot with DS89C4x0 (3 years ago), and started uC code with DS89C4x0 in assembler. Minimum resolution was 0.1 um, and it was working with 3 bytes numbers (for X/Y/Z). DS89C4x0 at 32 MHz, was communicating with PC by serial connection on 2 Mbps (PL2303HXD was used). At the end system was working OK, but I was looking for higher speed and direct USB connection, so later switched to MSP430F550x (0.1 um precision, 4 bytes numbers for X/Y/Z). MSP430F550x is able to process (test mode without running motors using 921600 bps serial connection) sample PCB (upper picture) in 30 seconds.

Link to post
Share on other sites

Very impressive work jazz!

 

When you switched from the DS89C4x0 to the MSP430 did you have to rewrite all your code again? (since it was in assembler) I like assembler but I don't use it mainly because I never know if I will need to change microcontrollers due to resource constraints.

 

The Shapeoko CNC the hackerspace is using has the DRV8811 but uses an ATmega328 instead (with a 'grblshield')... I'm not sure what the performance is. I plan on playing around with it a bit. It would be nice to have the same thing on MSP430 because I am a lot more familiar with it and could understand the code easier.

Link to post
Share on other sites

Very impressive work jazz!

 

When you switched from the DS89C4x0 to the MSP430 did you have to rewrite all your code again? (since it was in assembler) I like assembler but I don't use it mainly because I never know if I will need to change microcontrollers due to resource constraints.

 

The Shapeoko CNC the hackerspace is using has the DRV8811 but uses an ATmega328 instead (with a 'grblshield')... I'm not sure what the performance is. I plan on playing around with it a bit. It would be nice to have the same thing on MSP430 because I am a lot more familiar with it and could understand the code easier.

 

All my software regarding uC's is done in assembler. Don't have any problems in switching between different platforms. If you need speed (like in this project) there is no compiler that will bring you there. Optimized algorithm (main task) was done in DS89C4x0 assembler, and later rewriting to MSP430 assembler was easy job.

 

DS89C4x0 is 8-bit uC, and all numeric operation are going over one register, so I decide to try MSP430F550x later, and left the ARM as last choice. MSP430F550x is fast enough and have USB connection (or fast uart). Target is reached, no need for ARM at all.

 

If you check PCB milling videos on youtube, you can see the (low) speed of this devices, especially when the tool is going around the holes (processing big number of G code commands). This (low) speed is not related to steeper motors, it is related to slow software.

Link to post
Share on other sites

The Shapeoko CNC the hackerspace is using has the DRV8811 but uses an ATmega328 instead (with a 'grblshield')... I'm not sure what the performance is. I plan on playing around with it a bit. It would be nice to have the same thing on MSP430 because I am a lot more familiar with it and could understand the code easier.

 

ATmega328 is 8-bit 20 MHz uC, and DS89C4x0 is 8-bit 33 MHz uC, both 1 MIPS per MHz. For my project ATmega328 will be slow. Maybe it is OK for "pick and place part on PCB" (because it is similar to drilling holes, processing small number of G-code commands) but it must use fast uart and job must be done in assembler, for sure.

 

Just note regarding DS89C4x0 vs MSP430F550x speed. DS89C4x0 at 32 MHz with 2 Mbps uart was processing (test mode) sample board (mill/drill files, about 13000 G-code lines in total) more than 4 minutes, and MSP430F550x at 25 MHz with 921600 bps uart about 30 seconds. MSP430F550x with USB will go under this.

Link to post
Share on other sites

Are you going to be driving the motors using io operations? How fast can the 430 cycle pins? Also how are you handling acceleration for the steppers?

 

Nice work though, it looks really well thought out!

 

uC code will change signals on 2 output pins. At the segment start will put right value on DIR pin, and with each step will make one cycle on STEP pin. Max output frequency of general purpose I/O (by datasheet) for MSP430F550x is 25MHz.

 

Right now, there is no acceleration for steppers. Will see what will be motors behavior after I build the drivers.

Link to post
Share on other sites

I'm about to start using stepper motors with my Stellaris Launchpad via some Pololu A4988 stepper drivers for a balance bot.

 

I know this has been done a thousand times before but the idea is to use steppers rather than DC motors as a stepping stone to a more worthwhile project.

Link to post
Share on other sites
  • 3 weeks later...

After shifting from uart to USB (http://forum.43oh.co...-usb-benchmark/), project moved to completely another direction. All processing job will be done on PC side, and only step (and timer setup) commands will be send to uC. uC will respond with information regarding limiters on axis. It will be fastest software solution AFAIK, with possibility to made close to 500 * 1024 steps / second. With customized USB drivers it will be able to go even faster, but there is no need for this, because AFAIK there is no motors that are able to made so fast stepping.

Link to post
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.

Guest
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.

×
×
  • Create New...