I have bit locations 0-15 in RAM1 used for the 8 inputs and 8 outputs leaving 16 bits for other uses. I have 3 analog inputs but for simplicity lets take one as an example. AIP1 is sampled and the value is converted to a number between 1 and 5. I would like that number to be added to RAM1 using bit locations 16-19.
This is what I came up with. I haven't tested it yet but wanted to see what you all thought before I continued on this path. The board is a .16C so it has some of the new commands but not all and I haven't yet decided whether I am going to replace it with a newer board yet or not (a lot of manual labor to replace it).
SET RAM4 0 to clear any previous entries from ram4
ORB RAM4 0X10000 RAM4 to set bit locations 16-19 to 1 so that RAM4 has a value of at least 1 for an end result.
TSTGE AIP1 3
ORB RAM4 0X20000 RAM4 If true set bit locations 16-19 to 2
TSTGE AIP1 130
ORB RAM4 0X30000 RAM4 " " " " 3
TSTGE AIP1 142
ORB RAM4 0X40000 RAM4 " " " " 4
TSTGE AIP1 185
ORB RAM4 0X50000 RAM4 " " " " 5
ANDB RAM1 0XFFF0FFFF RAM1 Clear bit locations 16-19 in RAM1
ORB RAM4 RAM1 RAM1 Set bit locations 16-19 in RAM1 with result of RAM4
I am not 100% sure I explained it right but hopefully it makes sense.
My questions are: Did I approach this in the proper manner? Are there any faults with this approach? Is there an easier or better method?
Any comments or feedback welcome.
Thanks,
Tim
This is what I came up with. I haven't tested it yet but wanted to see what you all thought before I continued on this path. The board is a .16C so it has some of the new commands but not all and I haven't yet decided whether I am going to replace it with a newer board yet or not (a lot of manual labor to replace it).
SET RAM4 0 to clear any previous entries from ram4
ORB RAM4 0X10000 RAM4 to set bit locations 16-19 to 1 so that RAM4 has a value of at least 1 for an end result.
TSTGE AIP1 3
ORB RAM4 0X20000 RAM4 If true set bit locations 16-19 to 2
TSTGE AIP1 130
ORB RAM4 0X30000 RAM4 " " " " 3
TSTGE AIP1 142
ORB RAM4 0X40000 RAM4 " " " " 4
TSTGE AIP1 185
ORB RAM4 0X50000 RAM4 " " " " 5
ANDB RAM1 0XFFF0FFFF RAM1 Clear bit locations 16-19 in RAM1
ORB RAM4 RAM1 RAM1 Set bit locations 16-19 in RAM1 with result of RAM4
I am not 100% sure I explained it right but hopefully it makes sense.
My questions are: Did I approach this in the proper manner? Are there any faults with this approach? Is there an easier or better method?
Any comments or feedback welcome.
Thanks,
Tim