leem2209
Lifetime Supporting Member
Hey folks,
I have a (kind of, but not a true) random number generator that generates a number from 1 to 500. When I press a button it stores that number into another memory word (2)
I want to convert memory word 2 in order to activate the relevant bit in a datablock (DB101) which contains 500 bits of data.
EG if the button is pressed and it stores the value of 2 into MW2, then I want it to activate DB101.DBX0.2.
MW2 value = 8 then activate DB101.DBX1.0
MW2 value = 30 then activate DB101.DBX3.6
and so on.
How do I do this conversion?
I have a (kind of, but not a true) random number generator that generates a number from 1 to 500. When I press a button it stores that number into another memory word (2)
I want to convert memory word 2 in order to activate the relevant bit in a datablock (DB101) which contains 500 bits of data.
EG if the button is pressed and it stores the value of 2 into MW2, then I want it to activate DB101.DBX0.2.
MW2 value = 8 then activate DB101.DBX1.0
MW2 value = 30 then activate DB101.DBX3.6
and so on.
How do I do this conversion?