LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problems with shift register

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

 

0 Kudos
Message 1 of 33
(5,573 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 33
(5,567 Views)

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

0 Kudos
Message 3 of 33
(5,551 Views)

Hi ANKU,

                  I think the attachments(in LabVIEW 8.6) are useful to solve ur problem.... It is just concept...

Thanks,

Sivabalan.V 

Download All
0 Kudos
Message 4 of 33
(5,531 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 33
(5,512 Views)

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.

 

 

0 Kudos
Message 6 of 33
(5,496 Views)

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.

 

 

 

 

Message Edited by Ray.R on 04-06-2010 08:40 AM
Download All
0 Kudos
Message 7 of 33
(5,485 Views)

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.

 

  • Never use unbundle for a type def cluster.  use the unbundle by name to improve readability
  • The =0 cases were not necessary at all as then you immidiatly compared to see if it was a 0x01,0x10 or 0x40. I removed them.
  • The index array function can be expanded by dragging the bottom of the icon down. It improves readability and reduces clutter.
  • Why wereyou using DBLs to represent a count?  I changed to U32s And I can change te representation of the indicators to make sense(hex display)  Sae with the comments,  when you express a number as hex use either 0xFF or 80h to make it clear.
  • The connector pane (OUCH)!  see the differance?  use the 4:2:2:4 as a default- if you need more terminals rethink your code structure.  There arecases for more bu you really should ask "Can I do this simpler?" first.
  • Boolean Case structures (especially those that use the output of 😃 are not self-documenting and are always rube-goldberg code)  Note that I use the value as the case selector.
  • Auto clean-up is a good idea! but fix it afterwards.

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! Smiley Wink

Check-fxd.png

Message Edited by Jeff Bohrer on 04-06-2010 08:20 AM

"Should be" isn't "Is" -Jay
Message 8 of 33
(5,475 Views)

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.

 

 

0 Kudos
Message 9 of 33
(5,465 Views)

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.

0 Kudos
Message 10 of 33
(5,464 Views)