Raspberry Pi GPIO Performance? (I want to design a driver board)

More
07 Dec 2020 02:04 #191287 by T.T.
First, off, I'm new here, so I'll give a quick intro.
I'm T.T. most of my experience in cnc is with simple 3d printer stuff, so most of this will be pretty new to me. My strong suit is definitely electronics hardware design though, which brings me into my question.

I found out just yesterday that the Raspberry Pi can run LinuxCNC, and furthermore, it looks like it's capable of running a CNC directly with its GPIO pins.

My thought is this. I'd love to design a board that is can accept a Compute Module 4 (and release it as open hardware of course). My thinking is since the Pi already has a sufficient number of GPIO pins, that I'd design this board to leverage those. Before I dive into designing hardware, I wanted to make sure what I had in mind is reasonable.

My thinking is to use the GPIO to control the stepper drivers directly, and I was thinking of making the board be 5 axis capable. So, 5 sets of Step and Direction pins being controlled directly by the Pi. I know that these signals would be timing sensitive, so would the Pi even be capable of directly driving 5 axes with its GPIO?

If the Pi happens to be capable of doing the above, is it possible to use the GPIO pins in conjunction with the Pi's SPI interface? My reasoning here is to let the Pi handle all digital signals, and then for things like analog inputs or outputs, the SPI interface could simply be used. Plus, that would allow a great deal of flexibility in the design as well.

My goal is to design a sort of "all in one" solution control board. One would simply get the board, slap a CM4 in it, configure it, and it would be ready to go.

I'd love to hear the thoughts of the people who know more than me regarding this (which would probably be all of you :P )

Please Log in or Create an account to join the conversation.

More
07 Dec 2020 19:30 #191341 by tommylight

I found out just yesterday that the Raspberry Pi can run LinuxCNC, and furthermore, it looks like it's capable of running a CNC directly with its GPIO pins.

Yes it can, and no it can not.
RPI4 can run LinuxCNC, quite successfully from what i read, but it uses one of the Mesa boards for the actual step generation.
Pretty sure the GPIO can be used, but i would not call that useable.

Please Log in or Create an account to join the conversation.

More
08 Dec 2020 03:30 #191381 by wurdack
I'm in the same boat as T.T. Astonishingly, I was about to ask the same question, searched, and found the question had been asked only a few hours ago.

For educational purposes, I've decided to cobble together a CNC controller from a Raspberry. I literally just got linuxcnc building there and running against the simulated machine about 15 minutes ago.

I'm assuming the obstacle between that and a real set of stepper motors (and limit switches, and e-stop, and etc etc etc) is building the suitable interface on top of the Pi's gpio. To me that sounds like a fun project, even if that isn't practical or "useable". I'd be deeply appreciative of any pointers to where one would start with this, even if it is folly.

Please Log in or Create an account to join the conversation.

More
08 Dec 2020 15:38 #191426 by jmelson
There is also the Machinekit port of LinuxCNC for the Beagle Bone, which takes advantage of the PRU processors to do encoder counting and step generation.
While it is not as capable as outboard FPGA hardware, it is MANY times better than main-CPU software stepping.

Jon

Please Log in or Create an account to join the conversation.

More
17 Dec 2020 18:21 #192267 by T.T.
Shortly after I made this post, I actually found some info somewhere that the Pi's GPIO max theoretical step rate is something like 5kHz or so. So I realize if I do a driver board for the CM4, a different approach will need to be taken.

Correct me if I'm wrong, with the Mesa boards, the Pi handles all the motion planning, and then the mesa cards handle the raw step generation, correct?

I'm thinking what I may try is to be a step below the Mesa boards (as much as I'd love to use an FPGA, that is not a skill I have learned yet), and be a step above a regular parallel port.

The approach I was thinking was to have the Pi handle motion planning and step generation, similar to how a regular PC with a parallel port would operate. Rather than using a parallel port, I could use the Pi's hardware SPI interface and a port expander to essentially give the Pi a very fast parallel port. I've found a port expander that can operate close to a 50MHz clock rate on the SPI bus.

Please Log in or Create an account to join the conversation.

More
18 Dec 2020 01:27 #192292 by PCW
A port expander will give you more I/O pins but it will not improve
the software step rate (compared to GPIO access)

This is dependent on the OS latency.

Please Log in or Create an account to join the conversation.

More
18 Dec 2020 05:27 #192303 by T.T.
Wouldn't using a realtime kernel help with that? I know it won't solve the issue, but it would mitigate it correct?

It's been a long time since I looked into linuxcnc, and back then, most people were using pentium 4 machines with a parallel port. Do people still use parallel ports a lot? Or has everyone moved on to dedicated step generation like with the mesa cards? I kinda want to land somewhere in between a parallel port and the Mesa cards in terms of performance with this driver board.

My experience with CNC is limited to 3d printers right now, so I'm pretty new to the higher precision when it comes to subtractive manufacturing. I have no idea what I should be shooting for right now. What would be an adequate step rate to shoot for?

(also, if this somehow comes off as argumentative or rude, please know that is not my intent. Just trying to learn) :D

Please Log in or Create an account to join the conversation.

More
18 Dec 2020 16:51 #192349 by PCW
Yes, you would be using a real time kernel (LinuxCNC depends on this)
The performance of software step generation depends on the real time capabilities
of this kernel.

I suspect that the RPI4 is capable of maybe 5 to 10 KHz software step rates
(depending on kernel, kernel options, whether the RPI is running video, etc etc)

This is adequate for a wide range of applications. The trade off is that your
maximum speeds at higher microstep ratios will be limited.

For example, a 5 KHz step rate with 1/4 stepping is 625 RPM, a respectable
speed for a step motor, but at a much smoother at 32 micros steps the maximum
RPM would only be a pokey 78 RPM.

Please Log in or Create an account to join the conversation.

More
18 Dec 2020 17:21 #192354 by T.T.
Gotcha, that makes a ton of sense. So, if microstepping isn't a priority for someone, then a system doing software steps is adequate. Otherwise, a hardware step generator is critical.
I still want to make a board to accept the CM4, but now that I understand more of the limitations of software stepping, I'll definitely use a hardware step generator of some sort.

My goal is to have a 1MHz step rate per axis, and there's absolutely no way that's happening in software.

Please Log in or Create an account to join the conversation.

More
19 Dec 2020 03:49 #192420 by meo_udon
DIY 7i90SPI for Rpi is easy.
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.161 seconds
Powered by Kunena Forum