LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to program shift register to read only when a new user is detected from user?

Solved!
Go to solution

Hi,

 

I'm currently developing a program for position control in labview. The program is quite simple, whereby user will input the distance that he wants the table to be in the labview program, and labview will send signal to move a motor that will turn a ball screw to move a table horizontally to the targetted position. The criteria is that the profile of the motor depends on the distance it needs to move, whether a two-phase (acceleration and deceleration) or three-phase (acceleration, constant velocity, deceleration) to reach the target position.

 

The problem occurs when the user wants to enter a new position (second input) for the table, as the input by user is position the table needs to be but the input required to determine which profile the motor follows depends on the distance that the table will move to get to the targetted position. Therefore, I would need a function to store the input by user temporarily, and recall it only when a new input from user is detected. By this, I would be able to use the difference of the input (input [n+1] - input[n]) and feed it to determine which profile the motor follows and the input by user can be kept as the position he wants the table to travel to (to compare with encoder).

 

I thought of using shift registers to do this, but I am not able to make it to perform the deduction ([n+1] - [n]) only when it detects a new input. When i try using shift register, it travels to the targetted position, and one it reaches it will travel back to the original position. For example, when a user input 90, it means the table needs to move to point 90. As the shift register is initialized to 0, it will move to point 90 (90-0 = 90) but upon reaching 90, the shift register sends a signal of 90 (90-90 = 0) and the table returns to it's initial position.

 

Is there any way that I can delay the reading of shift register only when a new input is detected or is there another way for me to achieve what i want?

 

I've tried searching the discussion forum and ni website but couldn't find similar problems. Thanks for your help in advance.

 

0 Kudos
Message 1 of 11
(4,262 Views)

You should use functional globals instead of using shift registers. Also, how are you detecting user input? Are you using an event structure or doing something else?

 


andylwh wrote:

I thought of using shift registers to do this, but I am not able to make it to perform the deduction ([n+1] - [n]) only when it detects a new input. When i try using shift register, it travels to the targetted position, and one it reaches it will travel back to the original position. For example, when a user input 90, it means the table needs to move to point 90. As the shift register is initialized to 0, it will move to point 90 (90-0 = 90) but upon reaching 90, the shift register sends a signal of 90 (90-90 = 0) and the table returns to it's initial position.

 


I didn't understand this paragraph; can you explain this in more detail?

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 11
(4,260 Views)

Adnan, thanks for the prompt reply.

 

The input is entered by user themselves. I'm not too sure if functional globals can solve my problem, lab is closed and I can only access on monday. Will be trying it then.

 

As for the paragraph that you are unsure, i'm using shift register in a while loop. When user enters an input (let's take this first input as 'n'), I'll pass this input through a subtraction (mathematical function) icon and the other input to subtraction icon is from the left shift register. As the shift register is initialized to 0, the output for the subtraction icon is n-0. This n-0 value is then used to decide on the phase(two-phase or three phase as explained in the first post) and moves the table to the targetted position. Once it reaches, the left shift register sends a signal of n to the subtraction icon. As the input is still n, the output of subtraction icon now becomes n-n = 0 and thus bring the table back to the starting position.

 

Let me know if you still don't understand what I'm trying to say.

 

Thanks a lot.

0 Kudos
Message 3 of 11
(4,252 Views)
Solution
Accepted by topic author andylwh
If I understand this correctly, using shift registers along with an event structure (to detect user event when the user enters a new value) should resolve the issue. Be sure to post your application (or a version of it that isolates the issue) when you get to the lab, so we can get a clear visual of the issue you are facing.
Message Edited by Adnan Z on 03-13-2009 04:04 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 11
(4,244 Views)

Also do a search on Action Engines.

 

Actually there was a Nugget posted by Ben on the subject.  I will look for it.

Message 5 of 11
(4,226 Views)
I did link it in my first post. I called it functional globals 🙂
Message Edited by Adnan Z on 03-13-2009 06:07 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 6 of 11
(4,222 Views)

Have a look here for Action Engines.

It may be more appropriate for you.

 

Message Edited by Ray.R on 03-13-2009 08:38 AM
Message 7 of 11
(4,220 Views)

Hi,

 

I've managed to get what I needed by using a shift register + event structure as suggested by Adnan. However, I face another problem after implementing SR+event. I've attached two files, first the original program and second the updated program using SR + event. (it's only the jpg file as I've forgotten to save the labview program, will upload the program by tomorrow.

 

In the original program, I have an elapsed time that is able to run continuously when I run the program. In the updated program, my elapsed time don't seem to run continuously when I run the program (as shown by elapsed time indicator). I need the elapsed time to run continuously as a input to calculate my motor profile.

 

I suppose this is caused by the introduction of the event structure, will adding a case structure to wrap the event structure solve the problem or is there another way to get pass this. Appreciate if someone could drop me a pointer or two.

 

Thanks

0 Kudos
Message 8 of 11
(4,180 Views)

Yes, the Event Structure is the culprate.

 

However, why did you use an Event Structure in the first place?

Why do you want to create an event when you change the value of Input Distance (mm)?  Did you want to re-start/reset something?

Or do you simply want to make sure you use the new value?

 

Another thing.  There is absolutely no reason for using the Local Variable, especially since there is a perfectly nice wire approx 2 inches above it.  Try to avoid using Local Variables as much as you can.

 

R

Message 9 of 11
(4,161 Views)

Ray,

 

I used event structure in order to get an output of (n+1) - (n) to be used as input for a part of the program. This is the simplest way that I know of to achieve the input. As for the local variable, I will not be using it in the program, guess i forgot to delete that away before taking the screenshot.

 

Is there any way that I can obtain the continuous elapsed time count and use the event structure at the same time ?

0 Kudos
Message 10 of 11
(4,156 Views)