BSR and DCD in SLC 500

Rcochran@ee

Member
Join Date
Sep 2013
Location
Cleveland,TN
Posts
22
:sick:I am wanting to take a word and say chop up the hex value ie. word b9:0 = DCA9
send the 9 - b10:0
then A-B10:1
then C-B10:2
then D-b10:3 I tried to MVM B9:0 to B9:1-4 then all to isolate the nibble value from all other values first. then I used a counter and set the presets for 4,8,12 for each off the A,C,D, then use a BSR for each using the dn bit to fire the shift register 1 bit at a time. but when it get to the bit 1 on any of the BSR's the last time it neve goes to zero and in the help file it says up to the next word boundary cant be used. i was trying to move them all to the first nibble the use the decode to turn on bit b12:0/9 if b10:0=9, then turn on bit b12:1/10 for "A" value of B10:1 and so on and so on i put the code in.MVM.gif

CTU.gif

CTUb.gif

DCD.gif
 
The masked move is good to isolate the bits.
Then just do the following instead of the Bit Shifts.

MOV B9:1 to B10:0
DIV B9:2 by FH and store in B10:1
DIV B9:3 by FFH and store in B10:2
DIV B9:4 by FFFH and store in B10:3


I don't have a processor handy to try this out on but it works on a calculator.

...LaRoy
 
The masked move is good to isolate the bits.
Then just do the following instead of the Bit Shifts.

MOV B9:1 to B10:0
DIV B9:2 by FH and store in B10:1
DIV B9:3 by FFH and store in B10:2
DIV B9:4 by FFFH and store in B10:3


I don't have a processor handy to try this out on but it works on a calculator.

...LaRoy
that works almost because if i have 00F0 in 9:2 and divide by FH I get 10H instead of just F. I even did it in calculator and got same results
 
Ok, this should work. I tested thru all digits.
bcdtest.rss

I found this program and pulled code from it.
Hex2String.rss I think it was posted by Ken Roach but not sure.
I could not find the original thread after I saved the file.


...LaRoy
 
I am wanting to take a word and say chop up the hex value ie. word b9:0 = DCA9
send the 9 -> B10:0

I don't see where you moved the B9:1 to B9:3 values to the B10:2 - B10:4 shift registers, so I bet it did not work very well anyway. (Maybe those moves was done on rungs 8, 9, and 10).
 
I'm at home now so I can't look at the program.

Best I remember:
The bitwise AND moves the nibbles out of word b9:0 to separate words b9:1-b9:4.
Then the DIV places the values in words b10:1-b10:4.
Then the DCD does the 4 to 1 of 16 to convert the b10 words to b11 words.

This does not use bit shift instructions.
I ran this on a processor and it works. Give it a try.
 
Sorry for the confusion. I was referring to the Rcochran's original program that tried to use the 3 BSRs.
 
Rcochran@ee,

I realized that I did not answer your question, I just gave you another way to do the same thing.

Your way will work but with a couple of changes.

1st change:
add a XIO (normally closed) contact after each counter dn bit from the respective control word. R6:0.EN R6:1.EN R6:2.EN
This is required because the counter needs to see a transition from off to on in order to count. If it is enabled all the time it will only count the first scan.

The R6:X.EN will open the logic to the counter after the BSR is enabled.

2nd change:
A Bit Shift shifts data into the register, not out of it. So in order to shift the bits to the right to align the nibbles to the least significant nibble of each word you need the length in the BSR to be 16.
Each time the BSR is executed it will insert what ever bit is at b10:49/0 into the most left bit (16) in the word and then move the bits one bit to the right.

One thing about doing it this way, it will require 24 scans to complete the BSR that is shifting 12 bits.

On the first scan (once I:2/15 in enabled) counter C5:2.CU in enabled.
With C5:2.CU enabled the BSR instruction will execute. It's done bit R6:2.DN will enable.

On the second scan with R6:2.DN enabled C5:2.CU will disable.
With C5:2.CU disabled, the BSR will not be enabled and R6:2.DN is disabled.

On the third scan with R6:2.DN disabled, we start the whole sequence of counting, bit shifting and then resetting.

Keep this in mind when using this logic that it will take 24 scans to complete. I don't know what else you are doing in the logic as you did not show all rungs. Since you are triggering from an input just make sure the data doesn't change while you are doing the bit shifts.

My previous example will complete in 1 scan.

...LaRoy
 

Similar Topics

Hello friends, When I trigger once for an application, I want to shift the 15th bit in the word address by 10 bit , so; 1000 0000 0000 0000 ->...
Replies
3
Views
1,677
Hello all I was trying to write a program for one application. In this application at two location of conveyor the dispensers are going to open...
Replies
2
Views
2,029
I am having difficulty understanding how to write this station. I have run into conflicting information and am looking for some ideas. The camera...
Replies
9
Views
2,172
Hello, I currently have an application where i need to reject poor quality product which is inspected using a vision system. The product travels...
Replies
14
Views
4,756
Would anybody have an example of a BSR or BSL. I would like to set up a shift register to check product on a turning device, so I can activate...
Replies
2
Views
3,114
Back
Top Bottom