Jump to content
43oh

Timer based Stepper driver


Recommended Posts

I am still working on my CNC project, and have learned a lot since I originally posted on this thread. You are far ahead of me though.

 

What are you using for your PC GUI interface? wxWidgets is what I am planning on. What library are you using for your graphical display (the blue and red circuit board one)?

Link to post
Share on other sites

What are you using for your PC GUI interface? wxWidgets is what I am planning on. What library are you using for your graphical display (the blue and red circuit board one)?

 

I done huge amount of coding in C on my workplace, but when I'm doing something for myself I use Pascal/Delphi. Don't like C, but on other side I like to work in assembler for any platform. PC interface for PCBCNC is done in Delphi (using only Win32 api), and graphical library (based on DIB, writing directly to graphic memory) is done on x86 assembler. Right now I'm looking to Free Pascal, and instead of my assembler DIB, I will use DirectX (http://www.clootie.r...lphi/index.html). Anyway, my target is to run program only on Win platform, nothing else.

 

I started with fast uart and have plan to switch later to USB. Lose big amount of free time on optimizing uC code, and now, due to behavior of USB, all job will be processed on PC side. So basically, it was wasted time.

 

For this kind of device, this is best possible solution, to do all processing job on PC (1 second is enough for huge G-file, PC 2 GHz vs uC 50 MHz) where you can implement anything (acceleration, whatever), and just send to uC step (and timer setup) commands. Depending on how many data is transferred at once, USB can go till 1 MB/s without problems. I was reading Stellaris datasheet today regarding USB and DMA (because there is some bad implementation of this things on MSP430 http://forum.43oh.co...843-msp430-dma/) and everything seems OK.

 

Speed that will be able to achieve with my software is far away from needed. Didn't made same deep research, but for some motors here http://www.velmex.co...tor_torque.html maximum speed (to still have some torque) is close to 6000 steps/s. To have all 4 motors at maximum possible speed, it will be 4 * 6000 steps/s, and USB is able to deliver 1 MB/s (for example, 1 byte can be command for 1 step).

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

I done huge amount of coding in C on my workplace, but when I'm doing something for myself I use Pascal/Delphi. Don't like C, but on other side I like to work in assembler for any platform. PC interface for PCBCNC is done in Delphi (using only Win32 api), and graphical library (based on DIB, writing directly to graphic memory) is done on x86 assembler. Right now I'm looking to Free Pascal, and instead of my assembler DIB, I will use DirectX (http://www.clootie.r...lphi/index.html). Anyway, my target is to run program only on Win platform, nothing else.

 

I am not a great supporter of C++ but the wxWidgets C++ is relatively simple and not too far from plain C. Interesting that Delphi is still around. I really enjoyed programming games in Turbo Pascal when I was in school... good times!

 

I started with fast uart and have plan to switch later to USB. Lose big amount of free time on optimizing uC code, and now, due to behavior of USB, all job will be processed on PC side. So basically, it was wasted time.

 

For this kind of device, this is best possible solution, to do all processing job on PC (1 second is enough for huge G-file, PC 2 GHz vs uC 50 MHz) where you can implement anything (acceleration, whatever), and just send to uC step (and timer setup) commands. Depending on how many data is transferred at once, USB can go till 1 MB/s without problems. I was reading Stellaris datasheet today regarding USB and DMA (because there is some bad implementation of this things on MSP430 http://forum.43oh.co...843-msp430-dma/) and everything seems OK.

 

Speed that will be able to achieve with my software is far away from needed. Didn't made same deep research, but for some motors here http://www.velmex.co...tor_torque.html maximum speed (to still have some torque) is close to 6000 steps/s. To have all 4 motors at maximum possible speed, it will be 4 * 6000 steps/s, and USB is able to deliver 1 MB/s (for example, 1 byte can be command for 1 step).

 

What device driver does the USB use in Windows?? Some sort of bulk data transfer like a hard drive? I mean, how does it show up in device manager? Do you have to write your own Windows driver to get the data from it?

 

I have had a lot of trouble with the reliability of the "TUSB" MSP430 serial port emulator driver. The driver always crashes when I try to move big chunks of data through the fake COM port. I don't know if it is a TI problem or a problem with my PC, but it makes me reluctant to use USB on any projects with the MSP430. I actually installed a hardware 9-pin serial port on my PC just so I could get reliable serial communication with the MSP430 (thus avoiding USB).

 

I guess the F5xx is using a different driver though since it would be controlled by the main MCU? I saw you referenced Programmers_Guide_MSP430_USB_API.pdf on that other thread but I just downloaded it and still need to read it.

 

Our project switched from the grblshield to the TinyG due to the grblshield not supporting limit/home switches for the CNC in their code (I don't really want to get too far into AVR code to implement it - I am not familiar with it). The TinyG is from the same people and a very similar product (a MCU-based Gcode interpreter) but uses an ATxmega192A3 at 32 MHz as its MCU. Another option I looked at was LinuxCNC, but I don't like having to use a parallel port since laptops don't have them and I may need to expand functionality beyond what a parallel port can provide.

 

Honestly I may end up doing something like what you are doing. We want to get the project done quickly though so me writing my own motor controller would be fun for me but would take too long. Your reports here and on 43oh have been very interesting to me though... since we are doing pretty much the same thing. I do not have enough experience yet to understand what data transfer rate is best. It seems like you are really going for speed. I don't know what my requirements are going to be yet.

 

Have you thought about using the C2000 instead of the Stellaris? Just from the docs I would think it would be better suited to the task..? If you like assembly the C2000 instruction set seems a bit more pleasant than ARM. Although I'm sure either one would work fine.

Link to post
Share on other sites

What device driver does the USB use in Windows?? Some sort of bulk data transfer like a hard drive? I mean, how does it show up in device manager? Do you have to write your own Windows driver to get the data from it?

 

Device type is defined by firmware. When uC is connected to PC, after enumeration Win will ask for driver:

 

bm1.gif

 

It can be Generic bulk device with "winusb.sys" Win driver:

 

bm3.gif

 

It can be CDC (virtual COM port) device with "winusb.sys" Win driver:

 

bm4.gif

 

Or any other device type.

 

There is no need to write driver for CDC / generic bulk transfer, because it is supported by Win. For CDC transfer WriteFile / ReadFile are used, and for generic bulk WinUsb_WritePipe / WinUsb_ReadPipe.

 

I have had a lot of trouble with the reliability of the "TUSB" MSP430 serial port emulator driver. The driver always crashes when I try to move big chunks of data through the fake COM port. I don't know if it is a TI problem or a problem with my PC, but it makes me reluctant to use USB on any projects with the MSP430. I actually installed a hardware 9-pin serial port on my PC just so I could get reliable serial communication with the MSP430 (thus avoiding USB).

 

Don't know about TUSB. I used PL2303HXD based USB/COM cable, because it can work on any baud rate (12345 bps, 54321 bps...) and on higher rate (till 12 Mbps) than supported by TUSB, or any other USB/COM bridge chip. I'm using it for communication with MSP430F550x on 921600 bps without any problem.

 

I guess the F5xx is using a different driver though since it would be controlled by the main MCU? I saw you referenced Programmers_Guide_MSP430_USB_API.pdf on that other thread but I just downloaded it and still need to read it.

 

Our project switched from the grblshield to the TinyG due to the grblshield not supporting limit/home switches for the CNC in their code (I don't really want to get too far into AVR code to implement it - I am not familiar with it). The TinyG is from the same people and a very similar product (a MCU-based Gcode interpreter) but uses an ATxmega192A3 at 32 MHz as its MCU. Another option I looked at was LinuxCNC, but I don't like having to use a parallel port since laptops don't have them and I may need to expand functionality beyond what a parallel port can provide.

 

Honestly I may end up doing something like what you are doing. We want to get the project done quickly though so me writing my own motor controller would be fun for me but would take too long. Your reports here and on 43oh have been very interesting to me though... since we are doing pretty much the same thing. I do not have enough experience yet to understand what data transfer rate is best. It seems like you are really going for speed. I don't know what my requirements are going to be yet.

 

Have you thought about using the C2000 instead of the Stellaris? Just from the docs I would think it would be better suited to the task..? If you like assembly the C2000 instruction set seems a bit more pleasant than ARM. Although I'm sure either one would work fine.

 

MSP430F550x have enough power, and it's perfectly suited for PCBCNC project. Don't need C2000 / Stellaris. All processing will be on PC side, uC will just run the motors.

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