Cause button to change integer
- echristley
- Offline
- Premium Member
- Posts: 101
- Thank you received: 21
Gmoccapy has three buttons to control the spindle. Best I can tell is that their outputs are:
halui.spindle.0.forward which latches halui.spindle.0.runs_forward and halui.spindle.0.is-on
halui.spindle.0.reverse which latches halui.spindle.0.runs_backward and halui.spindle.0.is-on
and. . . I didn't write down the identifier for the stop, but it's there.
Unable to get LinuxCNC to load with vfdmod, I'm using mb2hal to control the spindle. And I have verified it is working with halshow. I set the value of mb2hal.spindle_set.target_state to an integer. 1: forward, 2:reverse, 5:stop
The divide I can't find a way over is how do I coerce these boolean buttons to set the proper value in a u32 pin?
PS. The next part sounds like it should be simple. The spindle speed is mainly controlled mechanically by a Reeve's drive. But, I set the VFD to a minimum frequency of 30Hz, and a max of 90 (60 being nominal for the motor). The halui component for override outputs a float between zero and 1. All I have to do there is set a multiplier of 10,000 on the mb2hal pin. The VFD will scale the output between 30 ( 0 or 0%), and 90 (10,000 or 100%). That statement is:
halui.spindle.0.override.value => mb2hal.spindle_speed.target_speed
Please Log in or Create an account to join the conversation.
- echristley
- Offline
- Premium Member
- Posts: 101
- Thank you received: 21
loadusr -W mux4 spindle
setp mux4.spindle.in0 <= 1 ; forward
setp mux4.spindle.in1 <= 2 ; reverse
setp mux4.sjpindle.in2 <= 5 ; stop
setp mux4.spindle.in3 <= 7 ; fault reset
mux4.spindle.out => mb2hal.spindle_set.target_state
Is that right? And then I just have to figure a way to get those three UI buttons so that they feed the two mux inputs:
??? => mux4.spindle.sel0
??? => mux4.spindle.sel1
Please Log in or Create an account to join the conversation.
loadrt mux8 count=1
addf mux8.0 servo-thread
setp mux8.0.in0 0.001
setp mux8.0.in1 0.01
setp mux8.0.in2 0.1
setp mux8.0.in4 1.0
net scaleX10 mux8.0.sel0 <= hm2_7i92.0.7i77.0.0.input-25
net scaleX100 mux8.0.sel1 <= hm2_7i92.0.7i77.0.0.input-26
net scaleX1000 mux8.0.sel2 <= hm2_7i92.0.7i77.0.0.input-27
net mpg-scale <= mux8.0.out
This is to set the scale for a MPG but will work for you by replacing the scale value (in) with the float you want, as you did. Then each select line need to be 'connected' to a button instead of the input above. (This example is with mux8 but is the same way for mux16).
Please Log in or Create an account to join the conversation.
You need to create a net to connect 2 pins. Pin to pin connection are NOT allowed.
This is wrong: mux4.spindle.out => mb2hal.spindle_set.target_state
You should do:
net my-target-state <= mux4.spindle.out
net my-target-state => mb2hal.spindle_set.target_state
Or the single line version:
net my-target-state mux4.spindle.out => mb2hal.spindle_set.target_state
('my-target-state' could be any name you wish for the net)
Please Log in or Create an account to join the conversation.
- echristley
- Offline
- Premium Member
- Posts: 101
- Thank you received: 21
I've tried it out, and this is tracked by halui.spindle.0.runs-forward and runs-backwards. Using both the UI buttons and the mechanical switch I have connected, these two are mutually exclusive.
forward is wired to sel1
backwards is wired to sel0
So, sel0=0 and sel1=0 then it is stopped, so I wire that to send 5.
sel0=0 and sel1=1, it is running forward, and that is wired to send 1
sel0=1 and sel1=0, it is running in reverse, and that is wired to send 2
I don't yet know a way to set both to 1, but I have the output of the mux prepared to send 7 when I do.
Please Log in or Create an account to join the conversation.
I think I've figure out that I can do this with a mux4, because the STOP state is simply when both FORWARD and REVERSE are both false.
Forward is the command, it will set runs-forward and is-on as you wrote BUT on the rising edge. Once done it is latched and the spindle will continue running until a stop command is sent.
You can see that by watching the state of forward runs-forward and is-on pins. You will also see that both forward and reverse can be false and the spindle still running.
Yes, this could work ... But you have to use the runs-forward and runs-backward status pins instead if the forward, reverse 'control' pins.
Please Log in or Create an account to join the conversation.
- echristley
- Offline
- Premium Member
- Posts: 101
- Thank you received: 21
loadusr -W mb2hal config=mb2vfd.ini
loadrt mux4 count=1
addf mux4.0 servo-thread
#stop
setp mux4.0.in0 5
#forward
setp mux4.0.in1 1
#reverse
setp mux4.0.in2 2
#fault reset
setp mux4.0.in3 7
net spindle_forward_button halui.spindle.0.runs-forward => mux4.0.sel0
net spindle_rev_button halui.spindle.0.runs-backward => mux4.0.sel1
net spindle_commanded_state mux4.0.out => mb2hal.spindle_set.target_state
Please Log in or Create an account to join the conversation.