12-19-2011 03:43 AM
Hi,
I'm trying to generate a digital output(or pulse) at a certain angle of encoder when a motor is running.
My problem is as follows.
1) My window is window 7, LabVIEW 2011 Professional, PCI-6259 DAQ Card.
2) I have a encoder with 360 pulse per one revolution.
3) I make a button upon a labview's front panel.
4) I make a numeric control upon a labview's front panel, it's label name is "start angle".
5) I make a numeric control upon a labview's front panel, it's label name is "stop angle".
6) when I press down the button(true), digital output 5V(high) pulse should be generated at the start angle point.
and then need to be kept as 5V(high) continuously.
7) when I press down the button(false) one more, digital output 0V(low) pulse should be generated at the stop angle point, and then need to be kept as 0V(low) continuously.
If anyone has any idea how to do this, it would be greatly appreciated.
I hope to take a brief example or picture about this problem.
Save me please, fredik
12-19-2011 08:09 AM
This is a fairly standard LabVIEW coding problem. There are quite a few ways to solve it, but I would probably go with a two loop solution.
First loop is used only for UI interactions. It contains a WHILE loop with an event structure. When an event happens (e.g. button press), a command is sent to the second loop using a queue.
The second loop contains a state machine / task handler for data acquisition and control. The states (implemented with case structure) will be things like running, waiting for start angle, waiting for stop angle, etc. The tasks (also implemented with case structures) will be things like start generation, stop generation, set output high, etc. The response to the task will depend on what state the system is in.
The typical command sent through the queue is a cluster containing a typedef enum (the command) and a variant (the data). Modern designs would use LabVIEW objects for the command, but let's walk before we run. Look up producer/consumer and state machines architectures and write a couple of test programs using these before you write your final program. Good luck!
12-19-2011 07:13 PM
Thanks for your reply.
I guess that the keypoint of this problem is to acquire the angle from the encoder.
I should acquire the angle from the encoder, but at the same time I need to generate the digital output(or pulse) at the angle which I acquire from the encoder.
Is it possible to do such a thing?
12-21-2011 09:12 AM
You should be able to get the angle, either directly or indirectly, using your DAQ card for inputs. How you get this will depend on your exact encoder and what it outputs. You should be able to find input functions in the DAQ palettes for most of the common encoder outputs.
Put the angle input in the same loop as the pulse output code (only two loops!). Read the angle. If it is your start angle and you have pressed the start button, output the start pulse. Similarly for the stop pulse. Use of some sort of state machine will make your life much easier here. For example, if you are waiting for the start or stop angles, you should be taking continuous angle measurements. If you are not waiting, no reason to take angle measurements.