Spindle control RS485

More
27 Mar 2024 14:55 - 27 Mar 2024 15:01 #296901 by guitarcarrot
Hi,

I'm trying to set up my spindle to be controlled over RS485 adapter through AXIS (using M3 commands etc.)

I've just changed from a ParPort BoB to a Mesa 7i96s and thus had to reconfigure using Pncconf as opposed to Stepconf. Inspecting the Hal files, it appears there are big differences between the spindle sections created by the two wizards (PID stuff etc.?!)

I've had this set up working before when using the BoB and have tested the communcation is working using  halrun commands below:

halrun
loadusr -W hy_vfd -d /dev/ttyUSB0 -r 19200
show pin
setp hy_vfd.enable 1
setp hy_vfd.spindle-forward 1
setp hy_vfd.spindle-on 1
setp hy_vfd.speed-command 10000


The guide I followed last time was from this video: 
(with the changes from the top comment)

Is anybody able to help me understand how to setup my hal files for the new Mesa set up please?

Thanks!

 
Attachments:
Last edit: 27 Mar 2024 15:01 by guitarcarrot.

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

More
27 Mar 2024 15:36 - 27 Mar 2024 15:41 #296906 by PCW
Replied by PCW on topic Spindle control RS485
You should be able to delete all the lines in the  spindle section
of mesa.hal that mention "pid" and then  add something like this:

loadusr -W hy_vfd -d /dev/ttyUSB0 -r 19200
net spindle-enable hy_vfd.enable  hy_vfd.spindle-on
net spindle-cw setp hy_vfd.spindle-forward
net spindle-vel-cmd-rpm hy_vfd.speed-command

You might want hy_vfd.enable to be controlled by machine-on
not sure what its exact function is
Last edit: 27 Mar 2024 15:41 by PCW.

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

More
27 Mar 2024 15:41 - 27 Mar 2024 15:48 #296909 by guitarcarrot
Replied by guitarcarrot on topic Spindle control RS485
HI, thanks for the quick response, I'm sitting in front of the machine now so will try that.

Will I still need the commands that are currently in the custom.hal?
Last edit: 27 Mar 2024 15:48 by guitarcarrot.

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

More
27 Mar 2024 15:45 #296910 by PCW
Replied by PCW on topic Spindle control RS485
They should be OK since only the very lowest level spindle control is affected

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

More
27 Mar 2024 15:52 #296912 by guitarcarrot
Replied by guitarcarrot on topic Spindle control RS485
Ok I'll get rid of it to avoid confusion.

I'm getting an error from the setp command in the middle of your code, is that supposed to be there?

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

More
27 Mar 2024 17:44 - 27 Mar 2024 18:53 #296928 by guitarcarrot
Replied by guitarcarrot on topic Spindle control RS485
I have tried all the different permutations I can think of with and can't get anything to work.

loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600

net spindle-cmd-rpm-abs => vfd.speed-command
net spindle-fwd spindle.0.forward => vfd.spindle-forward
net spindle-rev spindle.0.reverse => vfd.spindle-reverse
net on spindle.0.on => vfd.spindle-on

I don't think I understand the flow of commands here, for instance what is this line doing?

net spindle-rev spindle.0.reverse => vfd.spindle-reverse

Is it creating a signal called spindle-rev that takes the status of a variable called spindle.0.reverse and sending/setting the variable vfd.spindle-reverse equal to that? this is then passed through the hy_vfd HAL component to the VFD through the RS485 connection?

# signal source destination destination
net xStep stepgen.0.out => parport.0.pin-02-out parport.0.pin-08-out


 
Last edit: 27 Mar 2024 18:53 by guitarcarrot.

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

More
27 Mar 2024 19:55 #296936 by PCW
Replied by PCW on topic Spindle control RS485
Yes, by itself:

net spindle-rev spindle.0.reverse => vfd.spindle-reverse

will create a new signal "spindle-rev" and connect motions spindle.0.reverse
output pin to input pin vfd.spindle-reverse

(assuming both pins exist and are not connected to another signal)

I though the VFD pin were hy_xxxx...

You can use halshow to debug this by watching the VFD hal pins

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

More
27 Mar 2024 21:31 #296941 by guitarcarrot
Replied by guitarcarrot on topic Spindle control RS485
I think I have created a "pointer" of some description to hy_vfd called vfd (to avoid having to write it in full each time)

loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600
^Loads a hal component hy_vfd, named as vfd, on ttyUSB0
net spindle-cmd-rpm-abs => vfd.speed-command
^ creates a signal called "spindle-cmd-rpm-abs" and connects it to the vfd.speed-command pin (this sets the speed of the spindle)
net spindle-fwd spindle.0.forward => vfd.spindle-forward
^ creates a signal called "spindle-fwd" and connects spindle.0.forward to vfd.spindle-forward (this sets the spindle direction to fwd)
net spindle-rev spindle.0.reverse => vfd.spindle-reverse
^ creates a signal called "spindle-rev" and connects spindle.0.reverse to vfd.spindle-reverse (this sets the spindle direction to reverse)
net on spindle.0.on => vfd.spindle-on
^ creates a signal called "on" and connects spindle.0.on to vfd.spindle-on (this activates the spindle?)

The next part of the puzzle for me is understanding how the signals get from AXIS to the vfd. My assumption would be that the signals "spindle-cmd-rpm-abs" etc. are set in the "setup spindle control signals" section of the machineName.hal as per below?

Would I be correct in saying that the g-code is interpretted for instance, "M3 S6000" and that sets the states of the relevant spindle.0.xxx pins. The nets below then connect those pins to the spindle-xxx pins.# ---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-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
net spindle-index-enable <=> spindle.0.index-enable

As these spindle-xxx pins are different to the pins that are connected to the vfd pins discussed at the top of this post (e.g. spindle-vel-cmd-rpm-abs =/= spindle-cmd-rpm-abs) this signal is not being passed through the chain to the vfd?

am I correctly interpretting how to data is passed through the system or got the completely wrong end of the stick?


 

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

More
27 Mar 2024 22:21 - 27 Mar 2024 22:22 #296943 by PCW
Replied by PCW on topic Spindle control RS485
One thing to note is that net commands create or connect to a signal
For example:

net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs
 
creates the signal spindle-vel-cmd-rpm-abs and links it to
LinuxCNC motion pin spindle-vel-cmd-rpm-abs

Then

net spindle-vel-cmd-rpm-abs => vfd.speed-command

connects the signal spindle-vel-cmd-rpm-abs to vfd.speed-command

Note that this can be done in one net command:

net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs => vfd.speed-command

Its also important to note that signal names are completely arbitrary

so

net the_blue_wire <= spindle.0.speed-out-abs
net the_blue_wire => vfd.speed-command

would be identical to

net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-vel-cmd-rpm-abs => vfd.speed-command

Though perhaps harder to read...
 
Last edit: 27 Mar 2024 22:22 by PCW.

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

More
28 Mar 2024 10:38 #296980 by guitarcarrot
Replied by guitarcarrot on topic Spindle control RS485
Hi, I think I understand it all now much better than I did before this post, so thanks for bearing with me.

The halshow is such a useful tool! it became obvious that all the other pins were being set correcty, but the vfd.spindle-command pin wasn't getting a signal (due to the mismatch in the .hal). So I fixed the mismatch (spindle-vel-cmd-rpm-abs =/= spindle-cmd-rpm-abs) and everything started working as expected.

Thanks again for this, and for the mesa cards, they're brilliant!

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

Time to create page: 0.161 seconds
Powered by Kunena Forum