Posted by SillyOldDuffer on 01/09/2022 18:03:00:
Excellent!!!
If anyone had asked I'd have bet money Parallel Printer ports had gone the way of the Parish Pump! Useful to know they still exist because parallel pins were by far the easiest way of connecting a multi-user/multi-tasking computer to external electronics.
Any idea how a parallel port's performance compares with twiddling pins on a Raspberry Pi 4? What's the highest frequency a parallel pin can output, and what's the highest frequency that can be put on an input that a program can reliably work with?
I've experimented with a Pi4 in various real-time modes to see how fast it's IO pins can be made to go and results are both good and bad. Output is quick except for awkward pauses due to the scheduler. High-speed input is erratic because there's no way I know of directly handling an IO interrupt in Linux or Windows. Thus inputs are either delayed by the operating system or a CPU has to be dedicated to reading a pin continually in a loop, which is hot, messy and not expandable. And still misses some inputs due to the scheduler taking the CPU out every so often.
Does a Parallel Port on a PCI-card overcome these problems, or is a PCI parallel port's performance similar to the original – designed to work a relatively slow printer?
My concern isn't CNC specific, it's more a general interest in interfacing computers to fast real-world events without extra hardware.
Dave
Hello!
SO – Linuxcnc runs a real time kernel. You test the real time latency of the computer. How fast you can read/twiddle the bits is based on that. So – if you use the printer port you are relying on the computer to do the high speed stuff (PWM, Step generation, encoder reading and so on) So you normally have 2 real time threads when doing it all in the computer.
Base thread (fast thread that does the high speed reading and pulse generation)
servo thread (usually 1 to 5khz that does the trajectory planning and pid calcs and such)
(side note – when you have external interface hardware – like Mesa – the high speed stuff gets moved to the external hardware – so you don't have the base thread anymore. You still have a 1-5khz real time thread in the computer)
The base thread speed really depends on how well the computer can run the realtime kernel. The computer I am using in the video is a 3rd gen i5 HP. It has pretty decent latency and allows for a base thread of around 40-50 khz. I have not seen computer hardware get much higher than that with linux/linuxcnc.
I have not seen much of a difference between onboard, pci and pci-e printer port cards. (other than some features are there or not depending on how it was made)
I have have tested linuxcnc with gpio on the rpi 4 – the base thread I got was 20khz – but because some functionality is missing in the linuxcnc gpio driver – you can only get 10khz step pulses. (the printer port driver for linuxcnc has a reset function which allows you to output steps at the base period frequency.) The rpi4 does play nice with Mesa hardware – I use an ethernet to run the below machines.. Spi is an option to.
Here is the same machine running off the printer port.. (audio even sucks worse than my normal sucky audio)