04-06-2010 02:55 AM
Hi
I am using couple of shift registers to count a how many times a particular number appears in the ouput. Then i have display the addition of these number on the front panel. The problem is that one of the shift registers is starting from 1 instead of 0 and so the counter is not working correctly. Can anyone tell me what is wrong with the code ?
The shift register called Counter for the number "01" always starts counting from 1. How can i correct this ? I have to check to see if i get the numbers 16, 64 and 01 in the ouput from a Lin network. The counter for 16 and 64 is working correctly but the counter for 01 is not working. What is wrong in the code ?
I have attached the code.
Thank you
04-06-2010 02:59 AM
It might be a good idea to initialize the shift registers to make sure they start at 0 (unless you want the memory function).
Else it'll always 'start' at 1 if the previous case, the comparison with 'Array element 2 = 1?' is true.
/Y
04-06-2010 03:28 AM
Hi,
Thank you for your quick reply.
In order to initialize the shift register, i should place a numeric contant 0 to the left side of the side register ? But if i do that, everytime the shift register is gettin is gettin reset to 0. I need to count to see if i get the number 01 two times... but by intializing the register to 0, everytime its gettin reset to 0 causing the counter never to count up. Can you help me with this problem ?
Thank you
04-06-2010 04:53 AM
Hi ANKU,
I think the attachments(in LabVIEW 8.6) are useful to solve ur problem.... It is just concept...
Thanks,
Sivabalan.V
04-06-2010 05:51 AM
No, a shift register remembers its value between loops, the initialized value is only used once. The 2nd lap it uses the value from the 1st 'shift out'.
Somehow your first case must always be true, as you seem to get the +1.
/Y
04-06-2010 07:15 AM
ANKU wrote:In order to initialize the shift register, i should place a numeric contant 0 to the left side of the side register ? But if i do that, everytime the shift register is gettin is gettin reset to 0. I need to count to see if i get the number 01 two times... but by intializing the register to 0, everytime its gettin reset to 0 causing the counter never to count up.
When I read your post, it sounds like you want to use an ActionEngine. You can do a search on the topic.
In an ActionEngine, you do not initialize the shift register from outside the loop. It gets initialized by the state machine. The shift register(s) will remember past calls, as long as the VI (AE) is loaded in memory. You would need to initialize it before using it.
04-06-2010 07:37 AM - edited 04-06-2010 07:40 AM
I've made a code snippet of your code which now includes the ActionEngine. I will post the AE as well.
I left your code intact, but I'm not sure exactly what you want to do with the rest of the code. I'm sure it can be simplified. There was a missing control, so it is left out of the snippet.
The ActionEngine has a boolean output on the connector pane which is set to TRUE only if the count == 2. It also provides an output terminal for the count.
04-06-2010 08:18 AM - edited 04-06-2010 08:20 AM
ANKU-
I took the time to clean up your code just a bit and I'll offer some commments that may be helpful Please don't think I'm picking on you. This code does do the same thing except I initialized the SRs.
Result: Code is clean compact and readable without the Navagation window. so we have a place to start to figure out what bugs may be left. I don't think this code functions similar to your original statement of the design so we'll need amplification of what the code should do.--- Add this to the vi documantation as well to help us debug the code.
and - have fun!
04-06-2010 08:45 AM
Hi Jeff,
Thank you for all the suggestions, i will work on them. I am new to labview and am working on trying to improve my optimization skill in programming.
I am using labview 8.0, so can you send me the code in version 8. I would really appreciate it. I will run the code and let you know how it works. I need to check to see if i get 10 and 40 and then twice 01. If all this number comes then that would give me one pass cycle. So i need to keep checking the number of times i get these set of numbers. So that is the reason why i am adding the counter outputs.
04-06-2010 08:46 AM
Hi Ray,
I am not so sure about action engines. But will read up on it. Can you send me the code in version 8.0 as i am using labview 8.0.
Thank you.