scottalford75 / Remora

Remora is a free, opensource LinuxCNC component and Programmable Realtime Unit (PRU) firmware to allow LPC176x and STM32F4 micro-controller controller boards to be used in conjunction with a Raspberry Pi to implement a LinuxCNC based CNC controller.
131 stars 34 forks source link

Using Remora for controlling analog servo drivers? #70

Open cbaugher opened 5 days ago

cbaugher commented 5 days ago

I know there are no boards that do this currently, but I'm wondering if there's any reason Remora couldn't be used to run a servo controller if a suitable board was built? Specifically my use case is an old Bridgeport EZTrak that has an archaic PC based controller running analog servo drives. Everything works now, but I've had to replace several parts of the PC over the years and it's getting more and more painful when it goes down. The existing control is also terribly primitive as far as programming. It would be great to replace the PC and CRT with a nice RPi and LCD display and keep using the existing motors and drivers, since they work fine. The motors have been fitted with digital encoders so no need to read analog resolvers.

My thought was that an RP2040 could be used to read at least 2 encoders and also run a few DACs for analog output. Add an op-amp to scale the output to +/-10V and a few Optos for general IO. It sounds doable in terms of hardware but I have no idea if Remora would support such a thing.

Any thoughts on this? (Other than "just go buy a Mesa board" Lol)

cakeslob commented 4 days ago

you could probably do it now with an stm32f4 without anything special in firmware, if you dont need the analog input

Personally, I do need analog/pwm input but I dont know how to do it yet.

cbaugher commented 4 days ago

Oh really? That's interesting. How many encoders could be read reliably at say 50kHz, do you think? For this application I really only need two plus a low speed for MPG. But for a more extendable board it would be nice to read at least 4 axes plus MPG. That also lines up with a decent looking 4ch DAC I found.

Don't need analog input.

cbaugher commented 4 days ago

Does the firmware now have a way to talk to a DAC over SPI? Or could the RPi talk to the DAC directly?

cakeslob commented 4 days ago

you could have rpi talk to the dad but I dont think that would be fast enough. I dont know how to do a DAC, but for spindles that use 0-10v, we are using PWM to analog via an opamp like on the regular DB25 breakout boards

cbaugher commented 3 days ago

That would certainly be cheaper and a more direct. Only question is whether the time response would be fast enough. 1kHz DAC update rate should be fast enough for most systems. The PWM frequency would need to be a fair bit higher to reduce filtering delay. What is typical for spindle PWM frequency?

On Wed, Nov 20, 2024, 11:06 cakeslob @.***> wrote:

you could have rpi talk to the dad but I dont think that would be fast enough. I dont know how to do a DAC, but for spindles that use 0-10v, we are using PWM to analog via an opamp like on the regular DB25 breakout boards

— Reply to this email directly, view it on GitHub https://github.com/scottalford75/Remora/issues/70#issuecomment-2489133167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC6UZAAHDMWPPZNIBNPQPMD2BS6SPAVCNFSM6AAAAABSA4PFMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBZGEZTGMJWG4 . You are receiving this because you authored the thread.Message ID: @.***>

cakeslob commented 2 days ago

Hmm Im not sure, here is what the manual says for specs

https://remora-docs.readthedocs.io/en/latest/firmware/Setup-Config-File.html#pwm

cbaugher commented 1 day ago

Hmm Im not sure, here is what the manual says for specs

https://remora-docs.readthedocs.io/en/latest/firmware/Setup-Config-File.html#pwm

Ahh, ok. So the maximum PWM frequency is 5kHz. On the surface that seems low but maybe it really isn't. Ultimately what this is controlling is motor torque. Heavier filtering (to remove the 5kHz) just means the motor torque will take longer to build, thereby reducing response time. But this may be insignificant compared to the mechanical response time of the system overall.

I've been trolling through the code to try and figure out what is actually limiting the PWM frequency. Is it related to the hardware timers? Anyway, I think I just need to try it out.

Also, the software encoders appear to be limited to 30kHz. Is that referring to the full pulse frequency (full quadrature cycle) or is it the individual pulse frequency (1/4 quadrature cycle)? Either way it should be fast enough for my particular machine. But for higher speed encoders likely not. Is it possible to have more than one QEI encoder? From the code it looks like there can be only one.

cakeslob commented 18 hours ago

For the PWM, im not sure the limiting factor, or if hardware PWM can be faster than software

for the software, I think is tied to some division of the basethread if im not msitaken, so running a faster basethread on might give you more. I assume its refering to full quad, but I do not know.

For STM32 boards, it is possible to use more than 1 QEI encoder, as the STM32 has at least 4 hardware encoder channels, but the firmware needs modifactions to make that happen