# Spindle Uppper and Lower Limit (Or, how to change speed step size)

12 Jan 2023 05:27 - 12 Jan 2023 05:32 #261660 by Askjerry
I am rebuilding a Laguna IQ milling machine; when the VFD was originally set up by Laguna, instead of using a potentiometer or a 0v to 10v DC signal as I have done before, they basically have four wires labeled S0, S1, S2, and S3 connected. The S0 wire is basically just GROUND=ACTIVE so it will be tied to the SPINDLE ON pin that I assign in the stepconfig. (That's the easy part.)

Now to think about the rest of the problem... the other three wires form a binary number from 0 to 7 as follows...

S1 S2 S3
0    0    0      0 RPM (Stopped)
1    0    0      10,000
0    1    0      15,000
1    1    0      20,000
0    0    1      25,000
1    0    1      30,000
1    1    0      35,000
1    1    1      40,000

The spindle is designed for a MAX of 25,000 RPM which means that I have 4 allowable speed settings.... and this is fine... I do not need anything else for what I will be doing with this mill. (Manufacturer recommendation is 9,000 to 25,000 RPM, lower not recommended.)

Normally in the AXIS screen is a spindle stop button with a forward and reverse button on either side... and since I'm using the signal SPINDLE ON, I don't need to worry about FOR or REV... just controlling the speed. (Spindle ON will be tied to S0.)

How can I set the Spindle's initial speed to 10,000 RPM... then when the + or - is pressed have it stay between the range of 10,000 to 25,000 RPM? In G-Code I can use M3 S10000 as a starting point... no problem there... and I can look at the SPINDLE PID signal and work out something to set the outputs to one of 4 settings, 10K, 15K, 20K, or 25K. But if someone starts tapping on the + button... that is a buttload of taps to go from 10K to 15K... etc. Ideally... pressing the speed up/dn buttons would be limited to those 4 speeds only... a step size of 5K.

Can that be achieved?

Worst case... I'll make 5 buttons on my pyVCP panel... STOP, 10K, 15K, 20K, and 25K. But I would love a better solution for the AXIS screen.
Could the spindle control be removed?
Could the aforementioned 5 buttons be put in their place???

I will figure out a way to look at the SPINDLE PID or SPINDLE CMD signal and do some sort of range...
If SPINDLE CMD <1000 then off
If SPINDLE CMD >9999 and <14999 = 10K (Send a 100)
etc
etc

What suggestions do you have?

... thanks in advance.
Last edit: 12 Jan 2023 05:32 by Askjerry.

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

12 Jan 2023 09:43 #261673 by rodw
Gerry, mux8 will decode your bitmap to speeds. Have a look at the MPG examples and you'll get the feel for it as they use MUX4 etc but its all the same.
lincurve should be able to decode speed ranges back to your binary value.. This should let you use the S command as normal and it will pick the closest available speed.

Sounds like it will be fun!
The following user(s) said Thank You: Askjerry

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

12 Jan 2023 13:51 #261699 by andypugh
In 2.9 you can set the spindle increment size in the iNI file:
linuxcnc.org/docs/2.9/html/config/ini-co...:ini:sec:spindle-num
(5000 in your case)
Also, in [DISPLAY] set DEFAULT_SPINDLE_SPEED to 10000.

Decoding spindle speed to bits could be a bit annoying, but lincurve with the output converted to an int, and then using "bitwise" to set the IO Pins ought to work.
Or a very simple custom HAL component.
The following user(s) said Thank You: Askjerry, rodw

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

12 Jan 2023 18:51 #261723 by Askjerry
Excellent notes!

This weekend I will start to build out the file and see how far I get. Last night I tested the spindle successfully... so I know the signals work.
Now I need to decide if I should use computer #1 which has a MESA 7i76D or computer #2 which has dual parallel ports. I'm leaning on the parallel ports and saving the MESA for when I do the PUMA robot rebuild.

Thank you again for your quick response... I'll get the mill running, then start tweaking the INI, HAL, and the pyVCP files.
Jerry
The following user(s) said Thank You: rodw

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

12 Jan 2023 20:06 #261731 by rodw
Following Andy's lead, it looks like you could conver the lincurve float to an unsigned 32 with conv_float_u32
then use bitslice to break it into your 4 bits

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

13 Jan 2023 02:13 - 13 Jan 2023 05:32 #261767 by Askjerry
I had forgotten about the INI page... a true wealth of info.
linuxcnc.org/docs/2.9/html/config/ini-co...#sub:ini:sec:display
I'll play around this weekend for sure!

I just noticed my test machine is loaded with 2.7 so I'm going to have to connect to the internet and update it.
I found the commands... and it looks like we can accomplish the spindle limitations and step size.

Last edit: 13 Jan 2023 05:32 by Askjerry.

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

13 Jan 2023 05:55 #261775 by Askjerry
How do I get version 2.9??? All I see on the LinuxCNC page is 2.8.

LinuxCNC Uspace 2.8.4 64bit
LinuxCNC Uspace 2.8.4 32bit
LinuxCNC Uspace 2.8.4 armhf
LinuxCNC Docs English Spanish French Japanese (partial) Chinese

LinuxCNC Uspace 2.8.4 Dev
RTAI Kernel 4.19.195
LinuxCNC RTAI 2.8.4 for kernel 4.9.195
LinuxCNC uspace helper for RTAI kernel

Reformatting the hard drive with a new ISO is not out of the question...
The following user(s) said Thank You: rodw

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

13 Jan 2023 08:13 #261779 by rodw
Ok without installing something over the top,
edit your sources.list file to point at the bookworm debs and then do a dist-upgrade
to get to debian bookworm

then you can just type
sudo apt install linuxcnc-uspace  linuxcnc-uspace-dev
because linuxcnc is packaged in that version of debian.

Another alternative is that one of the devs has a buildbot v2 that has 2.9 on it. Not sure where it is.

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

13 Jan 2023 17:13 - 13 Jan 2023 17:33 #261808 by Askjerry
I'm sorry... but I am not familiar enough with the inner workings of Linux to know what you are talking about. If I attempt to do a

If I go into Synaptic Package manager and search for linuxcnc, I get two results...
f-engrave
truetype-tracer

I finally was able to add the
`sudo apt-key adv --keyserver hkp://keys.openpgp.org:80 --recv-key EF1B07FEE0EE663E`

And the associated
```deb http://buildbot.linuxcnc.org/ wheezy base 2.9-rtai
http://buildbot.linuxcnc.org/ wheezy base 2.9-rtai```

Items, and reload synaptic... which promptly gave me...
```PG error: http://archive.debian.org wheezy Release: The following signatures were invalid: KEYEXPIRED 1587841717 KEYEXPIRED 1668891673 KEYEXPIRED 1557241909GPG error: http://archive.debian.org wheezy/updates Release: The following signatures were invalid: KEYEXPIRED 1668892417 KEYEXPIRED 1587841717Failed to fetch http://buildbot.linuxcnc.org/dists/wheezy/Release  Unable to find expected entry 'base/source/Sources' in Release file (Wrong sources.list entry or malformed file)
Failed to fetch http://linuxcnc.org/dists/wheezy/Release  Unable to find expected entry '2.9-rt/source/Sources' in Release file (Wrong sources.list entry or malformed file)
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/main/source/Sources  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/contrib/source/Sources  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/non-free/source/Sources  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/main/binary-i386/Packages  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/contrib/binary-i386/Packages  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Failed to fetch http://archive.debian.org/debian/dists/wheezy/updates/non-free/binary-i386/Packages  404  Not Found [IP: 2001:67c:2564:a119::148:13 80]
Some index files failed to download. They have been ignored, or old ones used instead.```

So yeah... no luck... LinuxCNC is completely removed from the machine, and if there is an ISO... I'll just blow this away and start over.

Last edit: 13 Jan 2023 17:33 by Askjerry.

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

20 Jan 2023 23:58 - 21 Jan 2023 00:06 #262530 by Askjerry
So I just went to Chat GPT  (at:  beta.openai.com/playground ) and asked it...

Consider LinuxCNC
Write the code to install both lincurve and bitand into HAL.

Consider the following
00000 to 09500 = 0
09500 to 10500 = 1
10500 to 15500 = 2
15500 to 20500 = 3
20500 to 40000 = 4

```loadrt lincurve name=my_lincurve
setp my_lincurve.table 0 0 0 0 1 9500 1 2 10500 2 3 15500 3 4 20500 40000 4