CNC Controller Unit

XCore Project reviews, ideas, videos and proposals.
User avatar
BBenj
Member++
Posts: 21
Joined: Fri Sep 13, 2013 3:00 pm

CNC Controller Unit

Postby BBenj » Wed Jul 30, 2014 5:52 pm

Hello,

This project was my idea in the July competition, and I'll detail the progress here.

It is (well, will be...) a CNC controller unit, capable of driving at least 4 axis (100kHz), USB-based but with autonomous capabilities (SD card, and maybe touch screen). It will support all the features we can expect to properly control a CNC machine (spindle control, limits, homing and user I/O) and a little bit more (communication busses for extensions, remote, etc).
I'll use the xCONNECT link to be able to easily add new cores with new features.

Computer software: Qt, multi-plateform (those supported by Qt and USB lib). Using QtQuick, the graphic interface should be easily configurable.

The project will be closed-source until advanced enough to enter the open-source world. :-)


Actually I developed the control algorithm (stepper drive with trapezoidal speed curve and path planning) a long time ago but never really tested it. I tried to implement it on a FPGA, but I stopped due to an inappropriate working station (15min to create the bin file for each smallest modification... takes days to debug :-/ ). I just successfully tested the stepper drive part.

Then I discovered the XMOS processor... I use it for an other project, but the CNC controller project was already in my mind, without the time to work on it.
I have some time now :-) (and a nice board, thanks Matt! :-) )


I coded a little bit, and now I would like to test my implementation of the stepper drive part (with trapezoidal speed curve), but I can't access my CNC machine until end of august.
Thus, I'm looking for somebody who have a XMOS board (any type, it needs just one core) and a CNC machine (or stepper motor with step/dir controller), and is ready to do some tests. Nothing hard, I just need to know if the stepper drive part is working good with different settings. It should be :-P

Thanks. Feel free to ask if you have questions, ideas or anything. :-)

Benj
(My English is not very very good, I apologize if you have troubles to understand me... I do my best! Ask me until I write something better... ;-) )
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Wed Jul 30, 2014 7:53 pm

Hi BBenj

I might be able to help out, I have bipolar stepper motors that I work with regularly here as well as external Stepper driver boards that I drive from my Xmos kits etc.. I also have a dual axis Stepper driver slice board which I have just finished designing and laying out (Hope to have this project up on github & xCore by end of the week) which may be of interest to you.

let me know how I can help..

regards
Al
User avatar
BBenj
Member++
Posts: 21
Joined: Fri Sep 13, 2013 3:00 pm

Postby BBenj » Thu Jul 31, 2014 11:59 am

Hi Al,

Nice, you can help yes :-)

I attached the XC source file, it may also be useful for somebody else. It's not very optimized yet.

The program implement a trapezoidal speed curve and 3D Bresenham algorithm. The speed starts at MIN_SPEED, increase to MAX_SPEED at a constant acceleration ACC_SPEED (all in Hz) and then decrease back to MIN_SPEED. The direction bit output is reversed, and the trapezoid restarts.
You can change the step pulse length with the PULSE_LENGTH define.

I don't really care about the Bresenham algo for now, what I would like to know is:
- first if it's working :-p with a real stepper motor. I checked the signals with my scope, so it must work :-)

- the influence of the ACCELERATION_STEP_SPEED define value. The lower the value, the smoother the speed ramp (but higher CPU usage). With different ACC_SPEED & MAX_SPEED values, what is the max acceleration step possible to keep a smooth speed ramp. This value affects the CPU usage, so the higher, the better! The step should be (well, I suppose) in range of 10 to 100 times lower than the acceleration speed.

- the stability of the pulse length. The pulse seems not very stable, but my scope is quite old so I don't know if it's due to the scope itself or not. If you have a better scope, please check !

- any other details, comment, etc

You would first set the MIN_SPEED value (start/stop speed) according to your motor and driver, the pulse length according to the requirements of your driver, and the out port (4-bit) depending the board you're using. Bit 0 is the step, bit 3 is the dir.
With the default values, your motor should spin :-)

Then try to increase the MAX_SPEED, the ACC_SPEED and ACCELERATION_STEP_SPEED to the max possible without step lost.
You might need to increase the value of the dx constant variable to keep the constant speed stage. There are some debug prints to help.

Let me know if you need something else.

Your stepper driver slice board may be useful to me yes :-) I'll wait the release to know what's exactly inside :-p

Thanks !

Regards, Benj
You do not have the required permissions to view the files attached to this post.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Thu Jul 31, 2014 12:35 pm

Thanks Benj

I will take a look at this code later today, I might be able to try it out this evening with any luck, will let you know my findings.

regards
Al
User avatar
BBenj
Member++
Posts: 21
Joined: Fri Sep 13, 2013 3:00 pm

Postby BBenj » Fri Aug 01, 2014 2:03 pm

Thank you Al!

Another thing I would like to know is if, for the motor, it's the same to jump from like 1000Hz to 0 than from 1000Hz to -1000Hz (inverse direction). I think if 1000Hz is the max speed jump possible, jump from 1000 to -1000 will be too much, and needs to be 500 to -500 to keep the 1000Hz jump.

It's not very important currently, I can fix that in the code quite easily, but as you work with stepper motors maybe you have an answer on that?

Thanks !
Regards, Benj
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Sat Aug 02, 2014 5:56 pm

Hi Benj

Just a quick update, I am still working with the steppers and will do some more this weekend, I will give you some feedback when I have it. In the meantime I created the Dual Axis Slice project and uploaded the Project files etc.. feel free to take a look, any feedback appreciated.

regards
Al
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Sun Aug 03, 2014 11:33 pm

Finally I did some basic testing (after trouble with some of my drivers), the acceleration looks good with a single axis delta, nice and smooth.

Your settings were:

Code: Select all

    const uint32_t dx = 30000;
    const uint32_t dy = 0;
    const uint32_t dz = 0;
Which meant only X Axis movements, did you mean that?

When I try setting it to this to get Y movement in addition to X movement:

Code: Select all

    const uint32_t dx = 30000;
    const uint32_t dy = 30000;
    const uint32_t dz = 0;
First direction is smooth for acceleration but de acceleration ends prematurely, then I get kind a weird resonant slower reverse direction, Then cycle repaets, just trying to figure this out.

Or did you only expect single axis acceleration for this test?

BTW I increased the Max speed to pull it out of of the annoying resonant zone.

regards
Al
User avatar
BBenj
Member++
Posts: 21
Joined: Fri Sep 13, 2013 3:00 pm

Postby BBenj » Mon Aug 04, 2014 12:57 pm

I was quite busy this WE, but I took a look at you dual stepper driver slice. Nice work, I will maybe build one if the drivers are not too expensive (didn't checked my preferred resellers yet).
Two things missing maybe: some component's values are missing in the schematic, would be useful to add them or add a BOM file. The typical application schematic of the L6474's data sheet lists some, you probably used these?
The other thing is.. a sample code :-) That would be very useful, at least to test the board.
Thanks for sharing!

And in the XCore project page, the website link contains an error: should be https://github.com/folknology/DualAxisSlice (extra "https" in the current link: http: //https//github...)

Folknology wrote:Finally I did some basic testing (after trouble with some of my drivers), the acceleration looks good with a single axis delta, nice and smooth.
Nice, it works, good :-D (well, that was expected) Thanks !
You can try to increase the acceleration delta until you lost the smoothness of the movement. (ACCELERATION_STEP_SPEED)
Folknology wrote: Your settings were:

Code: Select all

    const uint32_t dx = 30000;
    const uint32_t dy = 0;
    const uint32_t dz = 0;
Which meant only X Axis movements, did you mean that?
Yes, this setting mean only X axis movements. You can set dy or/and dz to have movements on these axis as well.
Folknology wrote: When I try setting it to this to get Y movement in addition to X movement:

Code: Select all

    const uint32_t dx = 30000;
    const uint32_t dy = 30000;
    const uint32_t dz = 0;
First direction is smooth then I get kind of half cycle in reverse direction, followed by smooth cycle in Forward direction, just trying to figure this out.
With dx and dy, you should expect on the two axis the same movements than with dx only, just a little bit slower: acceleration + constant speed + deceleration (= 1 cycle), in first direction then same in reverse direction (and loop back to first dir, etc).
Did you get that or not ? If you can, a video could help to figure this out.

The half cycle in reverse direction is not complete, you mean ? Like just accl+constant, then reverse direction immediately, skipping the deceleration or something like that ? Weird...
Folknology wrote: Or did you only expect single axis acceleration for this test?
Actually the single axis was a first simple test to check the acceleration/deceleration. The code should work with 2 or 3 axis as it works with one (tested ok with 2 on the scope).

Thanks for testing.
Regards, Benj
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Mon Aug 04, 2014 1:24 pm

Thanks for the feedback I fixed the link.

I adjusted the maxspeed to pull things out of the resonant area, they are behaving and sounding better.

When using 2 axis :

Code: Select all

#define MAX_SPEED   4000
..
..
    const uint32_t dx = 20000;
    const uint32_t dy = 20000;
    const uint32_t dz = 0;
The first direction change is brutal and seems premature, the second direction change back is fine.

Here is a video at these settings, let me know your thoughts

regards
Al
User avatar
BBenj
Member++
Posts: 21
Joined: Fri Sep 13, 2013 3:00 pm

Postby BBenj » Mon Aug 04, 2014 2:03 pm

Ok, I see. Thanks for the video.
The speed starts to decelerate too late, and thus can't reach 1000Hz in time. That's the problem.
Now to fix that.. I'm on it :-p

Using xscope, I can see that the speed is 2320Hz at the end of the cycle instead of 1000.
There is a miscalculation somewhere, I'll find it. The times printed on the console doesn't match the reality. I have a 6 second cycle, with 3s of acceleration, that's ok, but 3s are missing... (calcs gives a 9s cycle)

Regards, Benj

Who is online

Users browsing this forum: No registered users and 3 guests