Hello guys,
after i got the both MPGs to work properly, as well as some buttons like Start/Step and Pause/Resume, a potentiometer for controlling Feed and for my Lathe project i am currently stuck with the Scale selector switch. (2 Pole, 6 position:
Aliexpress link
).
I have used the exacty same .hal settings as "Rodw" did in his
Rods "Spaceship" Scratch built Plasma Cutter buildPlasma build
Code:
# Metric units used
loadrt hm2_eth board_ip="10.10.10.10" config="firmware=hm2/7i76/7i76e.BIT num_encoders=1 num_pwmgens=0 num_stepgens=5 sserial_port_0=2xxxx"
loadrt mux4 count=1
addf mux4.0 servo-thread
loadrt or2 count=4
addf or2.3 servo-thread
setp axis.x.jog-vel-mode 0
net x-jog-counter <= hm2_7i76e.0.7i76.0.0.enc0.count
net x-jog-counter => axis.x.jog-counts
net mux-in1 or2.3.in0 <= hm2_7i76e.0.7i76.0.0.input-22 => mux4.0.sel0
net mux-in2 or2.3.in1 <= hm2_7i76e.0.7i76.0.0.input-21 => mux4.0.sel1
net x-jog-enable <= or2.3.out
net x-jog-enable => axis.x.jog-enable
setp mux4.0.in0 0.0
setp mux4.0.in1 1.0
setp mux4.0.in2 0.1
setp mux4.0.in3 0.01
net x-jog-scale mux4.0.out => axis.x.jog-scale
*I have changed "or2.3" to "or2.1", because i currently have only 2x or2
I connected PIN 3, 4, 6 and 8 together with one wire (please take a look at the picture) and connected PIN 8 to +24V, so all have +24V.
The A and B pin to input 21 and 22 on my Mesa 7i76E.
So, i think its exactly as Rodw did.
I have opened Halmeter, choosed pin "mux4.0.out" which shows "0" when the switch is turned completly to the left side, when moved one click to the right it shows "0,1mm", then next clicks always "0".
I dont understand why, i really tried to find the problem. For example i choosed other pins instead e.g. pin 6 and 8, but what i ones got was that i got 2 times 0.1mm, so i seems like its some kind of .hal config problem.
When i exchange the Pins in the below 2 lines (.input 21 will be on top, 22 on bottom), i get 1,00mm instead of 0.1mm, but all other show "0" on Halmeter.
net mux-in1 or2.3.in0 <= hm2_7i76e.0.7i76.0.0.input-22 => mux4.0.sel0
net mux-in2 or2.3.in1 <= hm2_7i76e.0.7i76.0.0.input-21 => mux4.0.sel1
When i play around with the position pins then i get e.g. (switch rotated from left to right/clockwise):
Position 1 : "0"
Position 2 : "1,00 mm"
Position 3 : "0"
Position 4 : "1,00 mm"
No matter how i change the pins i do get no other value than "0" or "1,00mm" (or 0,10 mm, when exchanging the input Pins)
I have replied to Rodw and he wrote that my Rotary switch might be not same as his, so i have to create a Truth table and check which pins are on/off on the 4 positions i need. I have tried to get some informations how to do that on youtube and google and i am pretty sure i understand it correctly and i have of course already tryed the wiring setup i thought its correct, but i still get no other Values than "0" and "1,00 mm".
Here are the table to show which pins are ON when on all 6 positions:
Position 1: A - 1 / B - 7
Position 2: A - 2 / B - 8
Position 3: A - 3 / B - 9
Position 4: A - 4 / B - 10
Position 5: A - 5 / B - 11
Position 6: A - 6 / B - 12
So, e.g. in Position 1, the Pole "A" is connected with "Pin 1" and Pole "B" with "Pin 7".
The Truth table should be as Rodw posted:
00
01
10
11
If i understand it correctly, in Position 1, Pole A and Pole B should be both on "false", so that the result is "00"
On Position 2, Pole A should be "false" and Pole B "true".
Position 3: Pole A should be "true" and Pole B "false"
Position 4: Pole A and B both "true".
If thats correct, then i should wire up those terminal Pins together and then to +24V: 3,4,8 & 10.
Short explation of my thinking

:
When the switch is in Position 1, A1 and B7 should not get +24V, to get "00"
When the switch is in Position 2, A2 should not get +24V, but B8 should get +24V, to get "01"
When the switch is in Position 3: A3 should get +24V, but B9 should not get +24V, to get "10"
When the switch is in Position 4: A4 and B10 should get both +24V to get "11"
My explenation might be wrong and difficult to understand, but if so, please ignore it.
With this wiring setup i get this values on Halmeter Pin "mux4.0.out":
Position 1: 0
Position 2: 1 (1,00 mm)
Position 3: 0
Position 4: 1 (1,00 mm)
I somehow do not believe that my thinking is correct, just because its not working as it should, but also i somehow think that the .hal setup is not correct, because i am getting values on Halmeter, but not the correct one.
I checked also those pins "mux4.0.sel0" and "mux4.0.sel1" and found out that sel1 is always "FALSE"
Also i checked pins "or2.1.in0" and "or2.1.in1" and found out that .in1 is always "FALSE.
Thats the reason i am thinking that the hal setup is wrong, but it works for Rodw, so i am currently a bit confused.
Even if everything is wrong what i did, at least you see that i did try to get it done by my self.
I hope you can help me out. I have attached my mpg.HAL and my main .HAL.
Thanks in advance.