3-Bit BCD into integer

More
10 years 1 month ago #80124 by terkaa
Hi,

I have ATC forced mode rotary switch it has 3-bit output these 3 outputs form a BCD number. My question is how to read these three binary inputs and output as integer.(for case switch)

Tero

Please Log in to join the conversation.

More
10 years 1 month ago #80125 by emcPT
Replied by emcPT on topic 3-Bit BCD into integer
you can write a simple component or you can use a already made one, if available.

Look at this
www.linuxcnc.org/docview/html//man/man9/weighted_sum.9.html

Please Log in to join the conversation.

More
10 years 1 month ago #80126 by terkaa
Replied by terkaa on topic 3-Bit BCD into integer
Hi,

I was thinking of writing a comporent. Any examples how to do this?

Tero

Please Log in to join the conversation.

More
10 years 1 month ago #80128 by andypugh
Replied by andypugh on topic 3-Bit BCD into integer
The carousel component undertands BCD.
It is also intended to be used on ATCs. But you should be able to use it to just read out the number, I think.

Please Log in to join the conversation.

More
10 years 1 month ago #80130 by terkaa
Replied by terkaa on topic 3-Bit BCD into integer
So it is this part?

case 'D': // BCD
i = 0;
pow = 1;
while (i < inst_sense){
if (i < inst_sense) d += sense(i) << (i % 4);
i++;
if (i < inst_sense) d += sense(i) << (i % 4);
i++;
if (i < inst_sense) d += sense(i) << (i % 4);
i++;
if (i < inst_sense) d += sense(i) << (i % 4);
i++;
p += d * pow;
pow *= 10;
d = 0;
}


I will try to understand it and borrow it to my code :)

Tero

Please Log in to join the conversation.

More
10 years 1 month ago #80131 by andypugh
Replied by andypugh on topic 3-Bit BCD into integer
Alternatively, why don't you tell me why the carousel company isn't right for your ATC? Perhaps it makes sense to enhance it for everyone

Please Log in to join the conversation.

More
10 years 1 month ago #80133 by terkaa
Replied by terkaa on topic 3-Bit BCD into integer
This is not for carousel position. This is for manual moving of ATC arm. Machine has two selector switches for selecting which move to make. Ie. arm_in arm_out, arm etc. These switches output BCD. And if you remember i made a custom HAL component for ATC, and now I am adding this manual functionality in case of there is something wrong with ATC like chips between tool and arm preventing automatic tool change.



Tero

Please Log in to join the conversation.

More
10 years 1 month ago #80154 by andypugh
Replied by andypugh on topic 3-Bit BCD into integer
Are there _only_ 4 bits? If so, then there is absolutely no difference between BCD and binary.

Decimal binary BCD
1 00000001 00000001
2 00000010 00000010
3 00000011 00000011
...
9 00001001 00001001
10 00001010 00010000
11 00001011 00010001
...
And the HAL "weighted sum" component is all you need.

You could also use a mux8 component

Please Log in to join the conversation.

Time to create page: 0.108 seconds
Powered by Kunena Forum