Timed exit while loop. Best way?

More
21 Jun 2013 02:31 #35847 by DaOne
Is there an elegant way of doing a conversion table in hall or classic ladder? I now am getting the weighted sum of all four inputs on my truth table however the output is different than the tool number. In looking at Johns classic ladder it looks like his weighted output number is the same as the tool position?? Needless to say mine are not. I am trying to figure out the most elegant way to handle this as I am not well versed in hal nor classic ladder yet. Here is my conversion table below. Any ideas?
pos | w-sum
1   |  1
2   |  3
3   |  2
4   |  6
5   |  7
6   |  5
7   |  13
8   |  15
9   |  14
10  |  10
11  |  11
12  |  9

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

More
21 Jun 2013 03:10 #35848 by BigJohnT
Post your wsum lines from your hal file.

JT

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

More
21 Jun 2013 03:18 #35849 by DaOne
# Tool Turret Encoder
net turret-encoder1 wsum.0.bit.0.in <= hm2_5i25.0.7i77.0.0.input-16
net turret-encoder2 wsum.0.bit.1.in <= hm2_5i25.0.7i77.0.0.input-17
net turret-encoder4 wsum.0.bit.2.in <= hm2_5i25.0.7i77.0.0.input-18
net turret-encoder8 wsum.0.bit.3.in <= hm2_5i25.0.7i77.0.0.input-19

#net sum-out <= wsum.0.sum

and my truth table looks like this
-----------------------------------------
Tool| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|
-----------------------------------------
LS15| X| X|  |  | X| X| X| X|  |  | X| X|
-----------------------------------------
LS16|  | X| X| X| X|  |  | X| X| X| X|  |
-----------------------------------------
LS17|  |  |  | X| X| X| X| X| X|  |  |  |
-----------------------------------------
LS18|  |  |  |  |  |  | X| X| X| X| X| X|
-----------------------------------------
X= ON

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

More
21 Jun 2013 04:42 #35851 by andypugh

-----------------------------------------
Tool| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|
-----------------------------------------
LS15| X| X|  |  | X| X| X| X|  |  | X| X|
-----------------------------------------
LS16|  | X| X| X| X|  |  | X| X| X| X|  |
-----------------------------------------
LS17|  |  |  | X| X| X| X| X| X|  |  |  |
-----------------------------------------
LS18|  |  |  |  |  |  | X| X| X| X| X| X|
-----------------------------------------
X= ON
That looks like gray-code.
Instead of weighted-sum you can use mux16.
You can either set the use-gray-code pin and set the input values in order (which might not work if the code is not actually gray-code) or set it running and look what the "selected" parameter shows for each turret position, and set the associated input pin to that required tool number.
www.linuxcnc.org/docs/html/man/man9/mux16.9.html

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

More
21 Jun 2013 05:06 #35852 by DaOne
Well the weighted sum works great for giving me a unique number for every position based on the four pins however it does not equal the tool number. Anyway to do a case statement or even if commands in hal? Basically I need to convert the number of the weighted sum to equal the tool number. I figure I could do it in classic ladder with 12 comparisons then set a variable that represents the current position but there must be a better way.

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

More
21 Jun 2013 05:33 #35855 by andypugh

Basically I need to convert the number of the weighted sum to equal the tool number.

Yes, but weighted sum isn't right for you changer. mux16 will do exactly what you want all by itself.
Connect one of your sense wires to each input of mux16 instead of to the weighted sum.

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

More
21 Jun 2013 06:05 #35856 by DaOne
Andy, I am having a hard time understanding mux16. Any examples that you could point me to? I did get it working doing the 12 comparisons in classic ladder and updating a variable based n the weighted sum to match the right tool number.

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

More
21 Jun 2013 06:41 #35857 by BigJohnT
Yup, you have gray code, look at the 4 bit table at the top of this page .
loadrt mux16 count=1
addf mux16.0 servo-thread
net input0 mux16.0.in00 <= your input pin LS15
net input1 mux16.0.in01 <= your input pin LS16
net input2 mux16.0.in02 <= your input pin LS17
net input3 mux16.0.in03 <= your input pin LS18

net grayout mux16.0.out-s => your classicladder pin

JT

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

More
21 Jun 2013 11:17 #35865 by DaOne
loadrt mux16 count=1
addf mux16.0 servo-thread
net turret-encoder1 mux16.0.in00 <= hm2_5i25.0.7i77.0.0.input-16
net turret-encoder2 mux16.0.in01 <= hm2_5i25.0.7i77.0.0.input-17
net turret-encoder4 mux16.0.in02 <= hm2_5i25.0.7i77.0.0.input-18
net turret-encoder8 mux16.0.in03 <= hm2_5i25.0.7i77.0.0.input-19

net enc-tool-number mux16.0.out-s => classicladder.0.s32in-02

gives me...
Debug file information:
Can not find -sec MOT -var MOT -num 1 
Can not find -sec IO -var IO -num 1 
Can not find -sec LINUXCNC -var NML_FILE -num 1 
Can not find -sec EMC -var NML_FILE -num 1 
my_LinuxCNC_machine-7i77-in_lathe.hal:88: Signal 'turret-encoder1' of type 'float' cannot add pin 'hm2_5i25.0.7i77.0.0.input-16' of type 'bit'
4895
  PID TTY      STAT   TIME COMMAND
Stopping realtime threads
Unloading hal components

I have tried playing with the syntax options on www.linuxcnc.org/docs/html/man/man9/mux16.9.html but nothing works. sel0 will allow it to load but nothing works. Maybe you can look at this for me?

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

More
21 Jun 2013 11:50 #35866 by DaOne
Should "mux16.0.use-graycode" be in there somewhere?

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

Time to create page: 0.079 seconds
Powered by Kunena Forum