Hey everybody,
(I am German so I might not be able to express everything correctly, but let's try)
So I have a machine which basically kind of a CNC so it has 3 axis and moves in xyz and so on. The Mechanics are driven by four Nema17, 2A, 0,56Nm stepper (two for y axis). To control them, I use four DRV8825 Driver, which I power with a 24V 10A power supply and controlled by a Pi 4 (Using the Pi is necessary because I want a custom GUI). I only worked with Arduinos before, so I'm new to raspi stuff but I would say I have a good basic knowledge in using and programming them (in python preferably).
My first test program merely instructed the Pi to set the STEP pin High and Low with some time in between using the sleep function. I quickly realized that things are different with the Pi than they used to be with an Arduino regarding timing. I learned that the sleep function of the Pi is everything but accurate, so I generated a hardware timed PWM on the Pi which then worked perfectly. However, it seems to be impossible to generate PWMs for three axis because the Pi only has to independent PWM channels.
So Question one: Did I understand the Internet correct and the Pi 4 is physically not able to generate three independent PWMs or did I miss something?
Assuming the Pi is indeed incapable of generating three PWMs:
What might help me to control my drivers precisely?
I had several Ideas but I'm not sure which is best:
1) I read something about separate boards you can buy and let the Pi communicate with them via USB or I2C which are able to control stepper. Like the Mainboard of a 3D Printer but the problem with that is their high price and misfitting for my purpose due to too low voltage or current rating. Besides That, some of them are pre-programmed with grbl which would make everything even more complicated.
https://www.mybotshop.de/Raspberry-Pi-CNC-Board
2) A separate board for generating PWMs also communicating via I2C. But I only found these Servo extension boards which only go up to 1,5 kHz (but I need about 5kHz)
https://www.reichelt.de/entwicklerboard ... 8kQAvD_BwE
1) An Arduino UNO with the popular CNC shield (which is commonly used for DIY CNCs) where the Arduino is the I2C slave to the Pi receiving commands. But this is my last option because I guess it is the most complex solution to the problem but at lead I know the Arduino is capable of generating 3 PWMs.
https://www.roboter-bausatz.de/p/uno-cn ... rduino-uno
I would appreciate some Input. Thank you!
Merlin ^^
-
- Posts: 134
- Joined: Thu Aug 11, 2022 7:52 pm
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
To generate PWM, your RPi may command a Raspberry Pico, via UART for simple interfacing, which has 8 hardware 'time slice' that can generate 16 PWM signals. Frequency range is wide. as it was driven at 125MHz and divided down.
viewtopic.php?t=309632
https://www.codrey.com/raspberry-pi/ras ... wm-primer/
They are register-programmable (for driver programmer) in similar fashion as typical microcontrollers, including those used in Arduino.
RPi seem use software PWM and may have some limitation on the 5KHz you require? RPi can drive RC model servo which is 50Hz.
The post did not state the exact application. CNC needs precise control over multiple axis movement trajectory. Controller need to control both speed and position by sending out a certain number of pulses (from end point A to B, length is number of pulse), while the timing between each pulse needs to vary to have different speed during the motion.
RPi OS operating system has many task and may not give you accurate timing. A small microcontroller dedicated to the single task may be used. Early (not sure if still now?) 3D printer are Arduino based. Simple microcontroller using hardware interrupt timer is one of the technique.
Stepper controller generally use two pins control. Some use one pin for direction, CW or CCW. The other pin is to pulse the stepper to increment one step angle, many motor is 1.8 degrees, model depending. Some controllers have micro stepping, meaning n pulse to the controller will advance one step angle on motor.
RC model servo use one pin 'PWM'. It is 50 Hz. Pulse high time vary from about 500 to 2500 micro second (more common is 1000 to 2000, model dependent) will command the servo to turn 180 degrees.
viewtopic.php?t=309632
https://www.codrey.com/raspberry-pi/ras ... wm-primer/
They are register-programmable (for driver programmer) in similar fashion as typical microcontrollers, including those used in Arduino.
RPi seem use software PWM and may have some limitation on the 5KHz you require? RPi can drive RC model servo which is 50Hz.
The post did not state the exact application. CNC needs precise control over multiple axis movement trajectory. Controller need to control both speed and position by sending out a certain number of pulses (from end point A to B, length is number of pulse), while the timing between each pulse needs to vary to have different speed during the motion.
RPi OS operating system has many task and may not give you accurate timing. A small microcontroller dedicated to the single task may be used. Early (not sure if still now?) 3D printer are Arduino based. Simple microcontroller using hardware interrupt timer is one of the technique.
Stepper controller generally use two pins control. Some use one pin for direction, CW or CCW. The other pin is to pulse the stepper to increment one step angle, many motor is 1.8 degrees, model depending. Some controllers have micro stepping, meaning n pulse to the controller will advance one step angle on motor.
RC model servo use one pin 'PWM'. It is 50 Hz. Pulse high time vary from about 500 to 2500 micro second (more common is 1000 to 2000, model dependent) will command the servo to turn 180 degrees.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Oh no, not again.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
PWM is only a small part of a solution. There is the need to synchronize multiple axes, stop at certain points. And ramp up speed movements. No fun to program this when you know that grbl already has this. There is also grblHAL which is a port of grbl to 32 bit controllers.
Just found a nice board https://github.com/phil-barrett/PicoCNC .
Just found a nice board https://github.com/phil-barrett/PicoCNC .
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Prices vary but they are very cheap for what they can do.Like the Mainboard of a 3D Printer but the problem with that is their high price
The newer 32bit Cortex M0 or better M4 are amazing.
They have to calculate sin and cosine steps and acceleration/velocity to make steppers move in a circle.
There are 4 direction changes at 90 degree positions too.
LinuxCNC does have an older OS for the Pi if you want to try that as a pure software solution.
You still need the stepper drivers obviously.
Spare GRBL controller/driver boards for 3018 CNC machines are ready available theses days and not too expensive.
Shop around, these all in one board can be only about $40.
Black box Stepper drivers up to 5-6amps are much cheaper too now, good for 23 size motors and up.
Think wood routing machines.
The Pi is better suited to driving a grbl based board that controls the motor drivers.
I use bCNC which runs on Pi4 and give a graphic UI for CNC milling, two screens are handy, one for bCNC, the other for YT vids tuts.
Pi's running Octoprint/Klipper for 3D printer based systems, the slicer software runs on the Pi fine..
If you want a custom GUI then GUIZero might be a good place to start.
Python based and simple to get running.
bCNC is also Python based and so it is easy to hack.
Any GUI is much better done using the Pi, leave motor control to a separate dedicated micro controller.
Trying to do both requires the skill level needed to do LinuxCNC which has been in development for decades.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Thanks for the info on bCNC. It's my application of choice for my grbl CNC machine. I run it on an old Windows desktop, but it's useful to know it's viable on a Pi 4.
Oh no, not again.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
I tried lots of CNC software on Pi's, bCNC is not perfect but it works with my cheap 3018.Thanks for the info on bCNC.
Is does engraving too.
Fengrave also works on the Pi, so there are two solutions for V bit engraving.
I have not done enough yet to know which is better/easier.
I still use Lasergrbl on a x86 laptop when I swap the DC motor router out for the 2.5W laser on the 3018 (now up sized to 3040)

Have not had a chance to try bCNC with a Laser, might need modding?
The online NCViewer is good enough for basic gcode testing

I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Interesting, I use fengrave too, for situations that demand it.Gavinmc42 wrote: ↑Tue Sep 19, 2023 10:39 pmI tried lots of CNC software on Pi's, bCNC is not perfect but it works with my cheap 3018.Thanks for the info on bCNC.
Is does engraving too.
Fengrave also works on the Pi, so there are two solutions for V bit engraving.
I have not done enough yet to know which is better/easier.
I still use Lasergrbl on a x86 laptop when I swap the DC motor router out for the 2.5W laser on the 3018 (now up sized to 3040)![]()
Have not had a chance to try bCNC with a Laser, might need modding?
The online NCViewer is good enough for basic gcode testing![]()
My preferred online viewer is https://nraynaud.github.io/webgcode/
I found that NCviewer failed with certain G-code formats. I can't remember exactly, but it was maybe something like having a space between command and number, or leading zeros, or something.
I would expect bCNC to drive a laser, but I haven't tried it. After all, the laser gantry moves like a CNC gantry, and the laser power is often controlled by the spindle on/off and rpm settings, because things have a tendency to evolve that way.
Oh no, not again.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Uses the same driver board for DC motor or Laser, so the gcode is there.I would expect bCNC to drive a laser, but I haven't tried it.
I suspect bCNC can be hacked for the laser extra options.
I like the extra plugins like helical holes, a Laser test engrave/cut plugin would be in Python

Been thinking about making another bigger frame for using the laser on, spare controller is about the only part I don't have.
Run it Core XY for speed, Foam board vibration cutter and maybe Vinyl cutter blade add on too?
Will try that other viewer, NCviewer has caused me issues too.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Just looked at those bCNC plugins, Dragknife and Pyro are there.
Pyro engraver? Had not thought of that, could be interesting.
Mod it for laser?
Pyro engraver? Had not thought of that, could be interesting.
Mod it for laser?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
@OP
You don't say what you are trying to do.
pigpio waves may meet your needs.
http://abyz.me.uk/rpi/pigpio/cif.html#gpioWaveCreate
You don't say what you are trying to do.
pigpio waves may meet your needs.
http://abyz.me.uk/rpi/pigpio/cif.html#gpioWaveCreate
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
I have not used the picoCNC board mentioned above, but do use the Teensy based board designed and made by the same guy, and have never had any problems with it.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Thank you all for your massive input!
In order to give some more information: I'm not building a classic CNC for working with materials. The machine's purpose is only to "hold/push" an object in three dimensions, hence the similarity to a CNC. Because of that, I'm currently not interested in using grbl because I plan on giving the machine input via a ps4 controller which the machine shall execute, save and repeat. Additionally, one should also be able to manipulate the "position date" in realtime so the machine executes pre-given position commands but also takes changes made in that very moment into account. That's why I ignored grbl as an option because grbl works in Gcode and I would have to convert raw joystick data into that and account for realtime manipulation on top of that. If someone disagrees in that point however, I'm all ears. Maybe I just missed something.
However, I came to the conclusion, that I need another piece of Hardware which can reliable generate at least 3 independent PWMs. I took a look at the Pi Pico but from my point of view I don't see a reason to not just use an Arduino UNO/Nano (because I already used them a lot) connected via UART which generates the PWMs. One Contra might be the different voltage levels on the Arduino and the Pi: I guess I would have to either use a level converter if I use the Arduino to just control to the STEP pin of my drivers OR to let the Arduino control everything (DIR, STEP, EN pin of drivers) so there wouldn't be any mixed voltages on the drivers.
Merlin
In order to give some more information: I'm not building a classic CNC for working with materials. The machine's purpose is only to "hold/push" an object in three dimensions, hence the similarity to a CNC. Because of that, I'm currently not interested in using grbl because I plan on giving the machine input via a ps4 controller which the machine shall execute, save and repeat. Additionally, one should also be able to manipulate the "position date" in realtime so the machine executes pre-given position commands but also takes changes made in that very moment into account. That's why I ignored grbl as an option because grbl works in Gcode and I would have to convert raw joystick data into that and account for realtime manipulation on top of that. If someone disagrees in that point however, I'm all ears. Maybe I just missed something.
However, I came to the conclusion, that I need another piece of Hardware which can reliable generate at least 3 independent PWMs. I took a look at the Pi Pico but from my point of view I don't see a reason to not just use an Arduino UNO/Nano (because I already used them a lot) connected via UART which generates the PWMs. One Contra might be the different voltage levels on the Arduino and the Pi: I guess I would have to either use a level converter if I use the Arduino to just control to the STEP pin of my drivers OR to let the Arduino control everything (DIR, STEP, EN pin of drivers) so there wouldn't be any mixed voltages on the drivers.
Merlin

Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
It is odd to be using PWM to move steppers. You can't control the end position very easily.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
The Pico is 32 bit and there is a GrblHAL port for it.Pi Pico but from my point of view I don't see a reason to not just use an Arduino UNO
https://github.com/grblHAL/drivers
Controlling 4 axis at once is not easy, there is some serious math for the kinematic solutions.
The Pi has two PWMs but PWM is not exactly what you need.
The step pulse is usually a fixed width with calculated times to the next pulse.
That calculation time must handle the real world max acceleration, peak velocity profile of the hardware, on multiple axis at the same time.
You might be able to plug the joystick directly into the microcontroller if it has USB and HID library code.
Old analog joysticks with gameport interface would work too if the microcontroller has 4 Analog inputs.
USB interface fixes voltage level issues, adding USB/HID issues

You could use the Pi 32bit timers to control one axis at a time, move X then move Y then Z etc.
All right angle movements, no curves or angles.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
I disagree.MoerlinD wrote: ↑Wed Sep 20, 2023 10:19 amThat's why I ignored grbl as an option because grbl works in Gcode and I would have to convert raw joystick data into that and account for realtime manipulation on top of that. If someone disagrees in that point however, I'm all ears. Maybe I just missed something.
Earlier you mentioned the CNC shield "where the Arduino is the I2C slave to the Pi receiving commands." This is not true. The Arduino is controlled over a serial link.
"because grbl works in Gcode" is a non-reason. Whatever you build will need a "move to (x,y,z)" function to drive the motors. This can be achieved simply by issuing a line of Gcode.
Also "I would have to convert raw joystick data into that and account for realtime manipulation on top of that." You're going to have to do that anyway.
I'd recommend that you start with the Arduino shield running grbl. Watch out for the grbl version supported by the board. It's easy to figure out, but some boards were designed for version 0.8, whereas the pinout changed for version 1.1.
If it doesn't work then you can roll your own software for the Arduino. You're still going to need the Pi, Arduino, and motor drivers, so the hardware will stay the same.
Oh no, not again.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Not very clear what OP wants, but if there is "visual feedback" when controlling the positions then a simple PWM control could be sufficient. And although OP mentioned "precise control" it is not clear how precise it needs to be.
Give it a try. I would use a pico to generate the pulses, generating all signals for the stepper driver. USB serial could be used from RPI so send the values (dir, pwm rate, en) for each motor driver.
Do not forget the limit switches (Endschalter) wired to the pico to protect hardware.
With this setup it should be easily to move from PWM to grblHAT on pico and receiving gcode from Pi. On Pi, the joystick control could - in a program - update target positions which from time to time are sent as gcode to pico. Update rates 50 to 100ms.
Give it a try. I would use a pico to generate the pulses, generating all signals for the stepper driver. USB serial could be used from RPI so send the values (dir, pwm rate, en) for each motor driver.
Do not forget the limit switches (Endschalter) wired to the pico to protect hardware.
With this setup it should be easily to move from PWM to grblHAT on pico and receiving gcode from Pi. On Pi, the joystick control could - in a program - update target positions which from time to time are sent as gcode to pico. Update rates 50 to 100ms.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Where does PWM come into this?ghp wrote: ↑Thu Sep 21, 2023 5:46 amNot very clear what OP wants, but if there is "visual feedback" when controlling the positions then a simple PWM control could be sufficient. And although OP mentioned "precise control" it is not clear how precise it needs to be.
Give it a try. I would use a pico to generate the pulses, generating all signals for the stepper driver. USB serial could be used from RPI so send the values (dir, pwm rate, en) for each motor driver.
Do not forget the limit switches (Endschalter) wired to the pico to protect hardware.
With this setup it should be easily to move from PWM to grblHAT on pico and receiving gcode from Pi. On Pi, the joystick control could - in a program - update target positions which from time to time are sent as gcode to pico. Update rates 50 to 100ms.
Oh no, not again.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
My impression is that OP had the idea to control the stepper pulses with PWM and OP thinks that using grbl is overly complicated.
As OP described there is 'visual feedback' from the joystick to the position of the system so PWM generated stepper pulses could possibly do the job. With motor controllers, of course (DIR, STEP, EN).
When using a pico to control the stepper allows for PWM controlled stepper signals (what OP wants). The RPi needs to send commands to the pico (PWM rate, dir, en); pico could run a micropython program to produce the control signals. Pi is busy only in reading the joystick and sending control messages. USB serial can be used to transmit the commands, not too much need for signal level adjustments.
This setup opens a migration path from PWM signals to grblHAL on pico and using gcode for the commands without the need to rewire all the hardware.
I would propose to use pico as its faster and cheaper as the arduino uno ATmega328 where grbl usually runs.
As OP described there is 'visual feedback' from the joystick to the position of the system so PWM generated stepper pulses could possibly do the job. With motor controllers, of course (DIR, STEP, EN).
When using a pico to control the stepper allows for PWM controlled stepper signals (what OP wants). The RPi needs to send commands to the pico (PWM rate, dir, en); pico could run a micropython program to produce the control signals. Pi is busy only in reading the joystick and sending control messages. USB serial can be used to transmit the commands, not too much need for signal level adjustments.
This setup opens a migration path from PWM signals to grblHAL on pico and using gcode for the commands without the need to rewire all the hardware.
I would propose to use pico as its faster and cheaper as the arduino uno ATmega328 where grbl usually runs.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
From what the OP has said he might as well use pigpio to generate the "PWM". It will do the needed speed on any spare GPIO.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Ok, there are many new things for me in here and I think I need to share more or less my whole idea cause from what I see It seems not that simply now.
My project:
I'm trying to build a Machine whose purpose it is to apply force on another static object in front of the construction.
It has three axis (x, y, z, where y has two mots, the others just one). Axis are driven by leadscrews which by themselves are driven by Nema17 Stepper (unipol. 24V, 2A, 56Ncm). My requirement for precision is relatively low, maybe to a few mm, the Object doesn't really care. Most important is applying the force, but that's a mechanical subject not electrical. Therefore, it is open loop so no encoder or distance measurement systems. As somebody said: "visual feedback". because it is open loop, I don't need to use something like a PID controller.
Interaction: A user shall be able to control the movement of all axis via a controller which has to joysticks. As I described before, the PI's task is to take that data from the controller and control the Stepper accordingly (which is the part I need help with). Furthermore, the Pi shall be able to save the executed sequence of motions and repeat them if commanded. Additionally, It should be possible to interferier with the joysticks into the the replayed motion while it's playing.
E.g. when you "teach" it a straight line along the z axis, you replay it and move the joystick responsible for moving along x axis, you end up still having a evenly linear movement on Z but you also got some jitter along x and when you manipulate both x and y values, the same happens but on one axis more. Or when you use the same Z axis line as before and manipulate Z itself it would get faster or slower for the time you give new input. May be that there a some flaws in my logic or I explained it poorly cause other language and so on, so when you don't get it, feel free to ask or propose logic.
Moving on: I have two limit switches on each axis for safety, so when an axis collides with the frame it will hit the limit switch which is hardwired to the the stepper drivers and thus shut them down. To "home" my axis I have three additional inductive sensors which will tell my Pi when each axis is at "pos 0". From then on, because of open loop, I only can command movement relative, which is fine though as mentioned before.
Why I came to you with PWM:
My Idea, regarding programing, was to directly transform the value of a joystick into the speed of the mots. I imagined the according code to be a mapping function which matches the max value of the joystick to a pre-set mot max speed (0Joystick remains 0Hz) which also accounts for acceleration control. I order to save this motion I then can simply track not the position but the speed over time which should give me a list of PWM frequencies linked to their executed time. The Pi then goes ahead and lets out the PWM for each axis to the right time as it was monitored. And when I manipulate the data I just add the current joystick value to the velocity value currently executed. If that makes sense to someone...
Merlin
My project:
I'm trying to build a Machine whose purpose it is to apply force on another static object in front of the construction.
It has three axis (x, y, z, where y has two mots, the others just one). Axis are driven by leadscrews which by themselves are driven by Nema17 Stepper (unipol. 24V, 2A, 56Ncm). My requirement for precision is relatively low, maybe to a few mm, the Object doesn't really care. Most important is applying the force, but that's a mechanical subject not electrical. Therefore, it is open loop so no encoder or distance measurement systems. As somebody said: "visual feedback". because it is open loop, I don't need to use something like a PID controller.
Interaction: A user shall be able to control the movement of all axis via a controller which has to joysticks. As I described before, the PI's task is to take that data from the controller and control the Stepper accordingly (which is the part I need help with). Furthermore, the Pi shall be able to save the executed sequence of motions and repeat them if commanded. Additionally, It should be possible to interferier with the joysticks into the the replayed motion while it's playing.
E.g. when you "teach" it a straight line along the z axis, you replay it and move the joystick responsible for moving along x axis, you end up still having a evenly linear movement on Z but you also got some jitter along x and when you manipulate both x and y values, the same happens but on one axis more. Or when you use the same Z axis line as before and manipulate Z itself it would get faster or slower for the time you give new input. May be that there a some flaws in my logic or I explained it poorly cause other language and so on, so when you don't get it, feel free to ask or propose logic.
Moving on: I have two limit switches on each axis for safety, so when an axis collides with the frame it will hit the limit switch which is hardwired to the the stepper drivers and thus shut them down. To "home" my axis I have three additional inductive sensors which will tell my Pi when each axis is at "pos 0". From then on, because of open loop, I only can command movement relative, which is fine though as mentioned before.
Why I came to you with PWM:
My Idea, regarding programing, was to directly transform the value of a joystick into the speed of the mots. I imagined the according code to be a mapping function which matches the max value of the joystick to a pre-set mot max speed (0Joystick remains 0Hz) which also accounts for acceleration control. I order to save this motion I then can simply track not the position but the speed over time which should give me a list of PWM frequencies linked to their executed time. The Pi then goes ahead and lets out the PWM for each axis to the right time as it was monitored. And when I manipulate the data I just add the current joystick value to the velocity value currently executed. If that makes sense to someone...
Merlin

Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
I Also want to respond to some replies:
I'm sorry, I'm a bit confused: someone said grblHAL and this is grblHAT. is this a typo? if not, where is the difference?
I guess that's more than enough. Just out of curiosity though, does that mean I could generate 16 PWMs with different freq. and dutyc. at the same time or can I only do 8 because every slice has It's specific freq. and you can take two PWM from it with two different dutyc. but not different freq.? Like when you modify the time registers on an ATmega328?David16962 wrote: which has 8 hardware 'time slice' that can generate 16 PWM signals
If I use PWM, I choose the freq. according to my needed speed and calculate the dutyc. so that my Pulse is always 5us like demanded it the DRV8825 DatasheetGavinmc42 wrote: The step pulse is usually a fixed width with calculated times to the next pulse.
ghp wrote: With this setup it should be easily to move from PWM to grblHAT on pico and receiving gcode from Pi
I'm sorry, I'm a bit confused: someone said grblHAL and this is grblHAT. is this a typo? if not, where is the difference?
yes, but I thought I need hardware timed PWM cause otherwise the mot won't make it at higher speeds and pigpio says there is "hardware timed" PWM on every GPIO but only with limited freq. There is also a function called somethin like "set hardware pwm()" but this only works for two PWMs cause the Pi4 only has to pwm channels. or do I miss somwthin?joan wrote: From what the OP has said he might as well use pigpio to generate the "PWM". It will do the needed speed on any spare GPIO.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
Typo !I'm sorry, I'm a bit confused: someone said grblHAL and this is grblHAT. is this a typo? if not, where is the difference?
grbl is a great software which allows precise control of steppers in CNC applications and runs on ATmega328, e.g. arduinoUNO.
grblHAL is a port of this software to many different 32bit processors including raspberry pico.
Remark on the PWM part: assume you run the stepper of one axis at 15 rotations per second, 200 steps per rotation and 8 microsteps. This needs 24kHz frequency. 15 rotations per second are 900rpm, quite fast for a stepper.
RPi is running Linux meaning that precise timing can't be guaranteed. Assume 10ms timing inaccuracy when stopping a PWM at this rate, you end up with 240 step error or 54 degrees error.
grbl is made for precision. And will avoid this error. Your application 'should not think speed, but position'.
Re: 4 Stepper simultaneously with Pi 4 for a (sort of) CNC
I now have a Debian Bookworm Pi OS with LinuxCNC on it.
https://forum.linuxcnc.org/9-installing ... -pi-4b-400
Most Stepper hats seem to be 2 axis.
Hmm new "Ultra Quiet LV8729" drivers.
A simple breadboard with 4 drivers would not be too hard to wire up.
Depends if you need limit switches.
12 pins for 4 axis step/dir/en, 9 pins if you connect the two Y axis driver inputs together.
With 24 GPIO there are some spare for limit switches etc.
You could make make a switch based joystick controller?
3018 mill conversion using Arduino CNC hat
https://forum.linuxcnc.org/9-installing ... -pins-only
https://forum.linuxcnc.org/9-installing ... -pi-4b-400
Most Stepper hats seem to be 2 axis.
Hmm new "Ultra Quiet LV8729" drivers.
A simple breadboard with 4 drivers would not be too hard to wire up.
Depends if you need limit switches.
12 pins for 4 axis step/dir/en, 9 pins if you connect the two Y axis driver inputs together.
With 24 GPIO there are some spare for limit switches etc.
You could make make a switch based joystick controller?
3018 mill conversion using Arduino CNC hat

https://forum.linuxcnc.org/9-installing ... -pins-only
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges