7i96S Analog Spindle

More
07 Feb 2023 03:53 - 07 Feb 2023 04:00 #263892 by reynolds087
I'm trying to set up an analog spindle on my 7i96S configuration. I've got the machine jogging, but I'm having trouble getting the spindle to work. I need to know which pin in the hal file to use for the analog spindle and how to configure it in the hal and ini files. The manual mentions that the 7i96S has an isolated potentiometer replacement for the spindle, but I'm not sure how to use it in LinuxCNC. Can someone help?

I want to set a 1V offset for minimum PWM voltage (0 RPM) and 3.25V for maximum PWM (5000 RPM)

Here is the excerpt from the manual:

ANALOG SPINDLE INTERFACE

The 7I96S provides one analog output for spindle control. The analog output is an isolated potentiometer replacement type device. It functions like a potentiometer with SPINDLE+ being one end of the potentiometer, SPINDLE OUT being the wiper and SPINDLE- being the other end. The voltage on SPINDLE OUT can be set to any voltage between SPINDLE- and SPINDLE+. Polarity and voltage range must always be observed for proper operation. The voltage supplied between SPINDLE+ and SPINDLE- must be between 5VDC an 18VDC with SPINDLE + always being more positive than SPINDLE-. Because the analog output is isolated, bipolar output is possible, for example with SPINDLE+ connected to 5V and SPINDLE- connected to -5V, a +-5V analog output range is created. In this case the spindle PWM must be offset so that 50% of full scale is output when a 0V output is required. Note that if bipolar output is used, the output will be forced to SPINDLE- at startup. The analog output is driven by a FPGA PWM output (normally PWM 0). Optimum PWM frequency is 10-20 KHz but frequencies from 5 KHz to 50 KHz are acceptable, lower frequencies will have higher output ripple and higher frequencies will have worse linearity.
Attachments:
Last edit: 07 Feb 2023 04:00 by reynolds087.

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

More
07 Feb 2023 13:18 #263927 by andypugh
Replied by andypugh on topic 7i96S Analog Spindle
Your 1V = 0 and 3.25V = 5000rpm requirement is unusual, so I will ignore it for the moment.

The HAL file looks OK, it should be working, at least to an extent.

Is the problem that you are not supplying 0V and 3.25V to the "potentiometer" top and bottom.

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

More
08 Feb 2023 00:53 #263995 by reynolds087
Replied by reynolds087 on topic 7i96S Analog Spindle
To be honest, I hadn't actually tried it because I just quickly selected the settings in PNCConf, and I was doubtful that it would be correct.

It looks like it is working in the sense that there is variable voltage based on my interaction with the spindle controls in Axis. The only problem is the scaling. I am applying 0V and 5V, and the output scales from 0-5V as expected. I can probably design a circuit that would provide 1V and 3.25V, it's just going to be a lot of work. The software solution would be better, unless it's really difficult.

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

More
08 Feb 2023 01:13 #263997 by andypugh
Replied by andypugh on topic 7i96S Analog Spindle
Which version of LinuxCNC are you using?
If it is 2.9+ then you can set spindle min and max limits in the ini.

Though that might not actually help.

Maybe set the analog scale to 5V full scale, then put a lincurve HAL component in the chain set up so that 0rpm in is 1V out, and 5000rpm in is 3.3V out.

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

More
08 Feb 2023 01:20 #263998 by PCW
Replied by PCW on topic 7i96S Analog Spindle
You can do the 5 to 3.25 scaling just by scaling the PWM
that is, set the PWM scale to 111111 (5000*5./2.25V)

The offset can be done with the scale or offset hal component::

loadrt scale
addf scale.0 servo- thread
setp scale.0,gain 1
setp scale.0.offset 2222
# 2222 = 1V if 11111 = 5V
net original_spindle_rpm_signal scale.0.in
net new_offset_spindle_signal scale.0.out

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

More
08 Feb 2023 01:44 - 08 Feb 2023 01:45 #263999 by reynolds087
Replied by reynolds087 on topic 7i96S Analog Spindle
Thanks, PCW.

I think the value in my case would be 7692 ?
(5000*5/3.25)

In my current spindle setup, is it this simple? as just replacing:

setp hm2_7i96s.0.pwmgen.00.scale [SPINDLE_0]OUTPUT_SCALE

with:

setp hm2_7i96s.0.pwmgen.00.scale 7692

Once that is set, do I add the rest of your code? In my case 1V = 2367
So the whole thing would be:

setp hm2_7i96s.0.pwmgen.00.scale 7692
loadrt scale
addf scale.0 servo- thread
setp scale.0,gain 1
setp scale.0.offset 2367
# 2367 = 1V if 7692 = 5V
net original_spindle_rpm_signal scale.0.in
net new_offset_spindle_signal scale.0.out

This is my current spindle config:

setp pid.s.Pgain [SPINDLE_0]P
setp pid.s.Igain [SPINDLE_0]I
setp pid.s.Dgain [SPINDLE_0]D
setp pid.s.bias [SPINDLE_0]BIAS
setp pid.s.FF0 [SPINDLE_0]FF0
setp pid.s.FF1 [SPINDLE_0]FF1
setp pid.s.FF2 [SPINDLE_0]FF2
setp pid.s.deadband [SPINDLE_0]DEADBAND
setp pid.s.maxoutput [SPINDLE_0]MAX_OUTPUT
setp pid.s.error-previous-target true

net spindle-index-enable => pid.s.index-enable
net spindle-enable => pid.s.enable
net spindle-vel-cmd-rpm-abs => pid.s.command
net spindle-vel-fb-rpm-abs => pid.s.feedback
net spindle-output <= pid.s.output

# ---PWM Generator signals/setup---

setp hm2_7i96s.0.pwmgen.00.output-type 1
setp hm2_7i96s.0.pwmgen.00.scale [SPINDLE_0]OUTPUT_SCALE


net spindle-vel-cmd-rpm => hm2_7i96s.0.pwmgen.00.value
net spindle-enable => hm2_7i96s.0.pwmgen.00.enable

# ---setup spindle control signals---

net spindle-vel-cmd-rps <= spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm <= spindle.0.speed-out
net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-enable <= spindle.0.on
net spindle-cw <= spindle.0.forward
net spindle-ccw <= spindle.0.reverse
net spindle-brake <= spindle.0.brake
net spindle-revs => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
net spindle-index-enable <=> spindle.0.index-enable

# ---Setup spindle at speed signals---

sets spindle-at-speed true
Last edit: 08 Feb 2023 01:45 by reynolds087.

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

More
08 Feb 2023 02:49 #264000 by PCW
Replied by PCW on topic 7i96S Analog Spindle

I think the value in my case would be 7692 ?
(5000*5/3.25)

That was my first guess, but the actual range from 0 to 5000 RPM is not 0 to 3.25V but rather
1 to 3.25V, a span of 2.25V (with a added fixed offset of 1V)

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

More
08 Feb 2023 04:22 #264004 by reynolds087
Replied by reynolds087 on topic 7i96S Analog Spindle
Ah, that makes sense!

Here is what I am still unsure about:

Can I simply replace:

setp hm2_7i96s.0.pwmgen.00.scale [SPINDLE_0]OUTPUT_SCALE

with:

setp hm2_7i96s.0.pwmgen.00.scale 11111

Also,
I think I sort of understand the code you provided for the offset, but the last two lines have me confused.

net original_spindle_rpm_signal scale.0.in
net new_offset_spindle_signal scale.0.out

I'm assuming that 'original_spindle_rpm signal' is a placeholder, and I should actually use this?

spindle-vel-cmd-rpm

And do I need to do anything other than substitute that into the code you provided? Are there more steps to map the scaling into my existing config like do I need to connect anything else to 'new_offset_spindle_signal' or just that one net will take care of it?

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

More
08 Feb 2023 14:51 #264052 by PCW
Replied by PCW on topic 7i96S Analog Spindle
You can set the PWM scale in the hal file but would normally set the PWM scale in the ini file
(the OUTPUT_SCALE value in the SPINDLE_0 section)

Yes, the original would be something like "spindle-vel-cmd-rpm"
I don't know the actual name because it depends on how the hal file was made
(signals like spindle-vel-cmd-rpm are arbitrary but of course must be used consistently
through a specific configuration)

As a side note, spindle-vel-cmd-rpm is possibly wrong
as the 7I96S PWM should be connected to a unsigned
value (probably something like spindle-vel-cmd-rpm-abs)

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

More
09 Feb 2023 02:25 - 09 Feb 2023 02:25 #264090 by reynolds087
Replied by reynolds087 on topic 7i96S Analog Spindle
I've made the changes,but it doesn't work. I put the new code in the "Custom Spindle PWM Scaling" section in the HAL file. If I comment out these two lines, and command 5000rpm, I get 2.3V, which is expected.

net spindle-vel-cmd-rpm-abs scale.0.in
net new_offset_spindle_signal scale.0.out


But with those lines included, the spindle does not work at all.
Attachments:
Last edit: 09 Feb 2023 02:25 by reynolds087.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum