lvb Posted September 26, 2006 Report Share Posted September 26, 2006 I did a bit of searching on counter/timers and encoders on the NI website and in Find Examples, but did not find much regarding plotting analog data vs encoder counts. Does anyone have advice on the best method of achieving a plot of x-axis (encoder counts or pos.) vs y-axis (analog input)? The best method I can think of is: creating a 2D array that stores the timestamp of the analog sample and voltage creating a 1D array of encoder tick timestamps graphing timestamp vs voltage This is all theory, but not implementation. Please advise... Thanks! Quote Link to comment
James N Posted September 26, 2006 Report Share Posted September 26, 2006 I would recommend using the encoder input as your sample clock for the AI. So for each encoder pulse, you get an analog reading. Go to the Help->Find Example and search for "sample" or "sampling". Poke around there for some examples of how to configure the sample clock. -James Quote Link to comment
mross Posted September 26, 2006 Report Share Posted September 26, 2006 I did a bit of searching on counter/timers and encoders on the NI website and in Find Examples, but did not find much regarding plotting analog data vs encoder counts.Does anyone have advice on the best method of achieving a plot of x-axis (encoder counts or pos.) vs y-axis (analog input)? The best method I can think of is: creating a 2D array that stores the timestamp of the analog sample and voltage creating a 1D array of encoder tick timestamps graphing timestamp vs voltage This is all theory, but not implementation. Please advise... Thanks! What exactly are you measuring and what sort of decision do you need to make based on the data? This is very important to give you a useful answer, and I am not fond of spending time explaining the wrong solution. You need to decide what the encoder is for. Is it a rotary encoder? Are you intending to measure voltage as the encoder rotates? Is the encoder a linear encoder? What is the encoder resolution? Do you need to calculate very fine average speed between encoder ticks? Do you really want your data taken in the time domain? In other words clocked by the daq card clock? Or is what you really want the voltage at a particular rotational position or at a linear position (depending on the encoder), the angle or length domains? Specific to your questions: Item 1. If you acquire the voltage to a chart, then you can retrieve the chart history and each reading will be paired with a timestamp. Item 2. The only reason to time encoder ticks is to calculate speed between ticks. You can do this with timers best. It is usually silly to digitize an encoder pulse train and way too much trouble if that isn't what you really want. It is not a given that useful information is gained by knowing the average between ticks (a pseudo instantaneous speed). It is much easier and often better to know the average speed over many encoder ticks since most motors vary a bit or a lot as they rotate. If you want to digitize the encoder that is trivial if you have a fast enough daq card. Better than a timestamp is often to get the start time and just count time between readings by clocking with the on board clocks, each reading is separated by a known increment of time and you can calculate the absolute time from the start time. What good is an absolute time reading anyway? I always like accurate increments, but could care not much less about the exact absolute time. Item 3. A chart graphs voltage v timestamps. If you need XY format that is another story and not as easily done. If this is strictly theoretical, I will pass. I am more interested in real world applications or at least hypothetical real world situations. Mike Quote Link to comment
lvb Posted September 27, 2006 Author Report Share Posted September 27, 2006 Wow, thanks for the quick responses. To start out, this is a practical application in which I need to acquire and plot torque vs time and torque vs position (or encoder ticks) for a motor moving an object. The average time to capture data will be anywhere from 1-30 seconds. To get more specific what I am looking for and answer some follow-up questions: I would recommend using the encoder input as your sample clock for the AI.So for each encoder pulse, you get an analog reading. Go to the Help->Find Example and search for "sample" or "sampling". Poke around there for some examples of how to configure the sample clock. -James I took a look at: Ack&Graph Voltage-Ext Clk.vi and Cont Ack&Graph Voltage-Ext Clk.vi. However, there are two problems I may encounter with this approach: 1. I may need multiple samples between encoder ticks 1. I need to have the ability to display time on the x-axis What exactly are you measuring and what sort of decision do you need to make based on the data? This is very important to give you a useful answer, and I am not fond of spending time explaining the wrong solution. This should be answered above You need to decide what the encoder is for. Is it a rotary encoder? Are you intending to measure voltage as the encoder rotates? Is the encoder a linear encoder? What is the encoder resolution? Rotary encoder, intending to measure voltage (torque) as the encoder rotates. I do not have the specific model number, so I am not sure of the resolution. It will most likely be rotating a maximum of a few rpm/sec.Do you need to calculate very fine average speed between encoder ticks?Do you really want your data taken in the time domain? In other words clocked by the daq card clock Or is what you really want the voltage at a particular rotational position or at a linear position (depending on the encoder), the angle or length domains? Speed is not calculated, just torque vs ticks displayed. The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. Quote Link to comment
i2dx Posted September 27, 2006 Report Share Posted September 27, 2006 Wow, thanks for the quick responses. To start out, this is a practical application in which I need to acquire and plot torque vs time and torque vs position (or encoder ticks) for a motor moving an object. The average time to capture data will be anywhere from 1-30 seconds. To get more specific what I am looking for and answer some follow-up questions:I took a look at: Ack&Graph Voltage-Ext Clk.vi and Cont Ack&Graph Voltage-Ext Clk.vi. However, there are two problems I may encounter with this approach: 1. I may need multiple samples between encoder ticks 1. I need to have the ability to display time on the x-axis This should be answered above Rotary encoder, intending to measure voltage (torque) as the encoder rotates. I do not have the specific model number, so I am not sure of the resolution. It will most likely be rotating a maximum of a few rpm/sec. Speed is not calculated, just torque vs ticks displayed. The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. ok, I hope, I understood the task right, here's my way to measure (e.g.) Force over Angle: I use a 6602 and an E-Series or M-Series DAQ-Board. I create a SampleClock with one of the 6002's counters and route it via the RTSI Bus to the AI Device Both Acquisitions, Encoder and AI are timed witht the same sample clock. If you want to have AI Samples between the encoder counts, make sure your sampling rate is high enough. Make a countinious accquisition with hardware timing. with each result set go through a for loop, that calculates the average of the AI samples, with all samples with the same encoder count. store the concoder count and the AI averge in a 2d array and voila: you have an array with force over angle with an AI value corresponding to each encoder tic. the advantage of this method is that you will not into trouble, even if the tics come faster than the the max. AI sample rate ... cheers, CB Quote Link to comment
mross Posted September 27, 2006 Report Share Posted September 27, 2006 Wow, thanks for the quick responses. To start out, this is a practical application in which I need to acquire and plot torque vs time and torque vs position (or encoder ticks) for a motor moving an object. The average time to capture data will be anywhere from 1-30 seconds. To get more specific what I am looking for and answer some follow-up questions:I took a look at: Ack&Graph Voltage-Ext Clk.vi and Cont Ack&Graph Voltage-Ext Clk.vi. However, there are two problems I may encounter with this approach: 1. I may need multiple samples between encoder ticks 1. I need to have the ability to display time on the x-axis This should be answered above Rotary encoder, intending to measure voltage (torque) as the encoder rotates. I do not have the specific model number, so I am not sure of the resolution. It will most likely be rotating a maximum of a few rpm/sec. Speed is not calculated, just torque vs ticks displayed. The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. I said: What exactly are you measuring and what sort of decision do you need to make based on the data? This is very important to give you a useful answer, and I am not fond of spending time explaining the wrong solution. You said: This should be answered above Actually, you never said what decisions you need to make. I chose the wording of the question carefully. But your answer never addressed that, only some specifics about the acquisition. Your task is probably not to acquire data, it is to make some sort of choice after analyzing the data. What its that choice? You said a few rpm/sec. I assume you don't mean an acceleration and that you do mean it will be turning slowly at a a low speed so that you don't anticipate any problems acquiring the data fast enough? Assuming the second, you might be surprised how much horsepower it takes to digitaze an encoder pulse train. At some point you may want to quantify how accurately you need to measure these things and whether you have the equipment to do it. You said: Speed is not calculated, just torque vs ticks displayed. The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. If you do not need to know speed then you do not need to gather your torque data in the time domain. Just use the encoder to clock the acquisition. Then you have torque versus angular position. If you did want an estimate of speed over a rev you could count pulses from the encoder during some period and return speed from that using counter/ timers on the card (it never hurts to tell us whatdaq card you are using, the version of LV, and so on. You would be surprised what interesting suggestions/warnings you might get from this info.) For getting data clocked by an encoder I use Acquire N Scans D-Trig Ext Scan Clk.vi as a basis. A digital trigger starts the acquisition (use the Z pulse of the encoder), tell it how many readings to take (maybe the same as you ticks per rev) and you will have what you originally asked for voltage with respect to encoder ticks. I usually calculate average speed before or after the acquisition step to put in the records for the test. That is a straight forward counter timer function with the encoder gating a counter. Lastly: The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. This sounds like the cursor function that is provided with the graph indicators. Did you need something more than that? But earlier you said torque versus ticks, and now you are talking about time on the x-axis. Can you clarify? Quote Link to comment
lvb Posted September 28, 2006 Author Report Share Posted September 28, 2006 I said: What exactly are you measuring and what sort of decision do you need to make based on the data?This is very important to give you a useful answer, and I am not fond of spending time explaining the wrong solution. You said: This should be answered above Actually, you never said what decisions you need to make. I chose the wording of the question carefully. But your answer never addressed that, only some specifics about the acquisition. Your task is probably not to acquire data, it is to make some sort of choice after analyzing the data. What its that choice? Measuring a window regulator's torque vs time and torque vs encoder ticks (position). Just acquiring data and plotting, no analyzing.You said a few rpm/sec. I assume you don't mean an acceleration and that you do mean it will be turning slowly at a a low speed so that you don't anticipate any problems acquiring the data fast enough?Assuming the second, you might be surprised how much horsepower it takes to digitaze an encoder pulse train. At some point you may want to quantify how accurately you need to measure these things and whether you have the equipment to do it. I have requested the details, but have not been given them. You said: Speed is not calculated, just torque vs ticks displayed. The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. If you do not need to know speed then you do not need to gather your torque data in the time domain. Just use the encoder to clock the acquisition. Then you have torque versus angular position. If you did want an estimate of speed over a rev you could count pulses from the encoder during some period and return speed from that using counter/ timers on the card (it never hurts to tell us whatdaq card you are using, the version of LV, and so on. You would be surprised what interesting suggestions/warnings you might get from this info.) For getting data clocked by an encoder I use Acquire N Scans D-Trig Ext Scan Clk.vi as a basis. A digital trigger starts the acquisition (use the Z pulse of the encoder), tell it how many readings to take (maybe the same as you ticks per rev) and you will have what you originally asked for voltage with respect to encoder ticks. I usually calculate average speed before or after the acquisition step to put in the records for the test. That is a straight forward counter timer function with the encoder gating a counter. I would like to use the cheapest USB DAQ device available. I currently am thinking about the USB-6210. The user wishes to view two types of graphs: 1. torque vs time and 2. torque vs encoder ticks. How can they view torque vs time if an external click is used for data acquisition? Also, I am not looking for velocity.Lastly:The user needs to be able to select torque or time from an x-axis listbox. This will update the display of the acquired data plot. This sounds like the cursor function that is provided with the graph indicators. Did you need something more than that? But earlier you said torque versus ticks, and now you are talking about time on the x-axis. Can you clarify? Hmm, I am not on the same page as you here. My initial thought was to somehow display two x-axis scales (one on top and one on bottom), not quite sure how to do that, but anyways... The user needs to be able to view EITHER torque vs ticks or torque vs time. Thanks for the help! Here is a sample: Quote Link to comment
mross Posted September 28, 2006 Report Share Posted September 28, 2006 Measuring a window regulator's torque vs time and torque vs encoder ticks (position). Just acquiring data and plotting, no analyzing.I have requested the details, but have not been given them. I would like to use the cheapest USB DAQ device available. I currently am thinking about the USB-6210. The user wishes to view two types of graphs: 1. torque vs time and 2. torque vs encoder ticks. How can they view torque vs time if an external click is used for data acquisition? Also, I am not looking for velocity. Hmm, I am not on the same page as you here. My initial thought was to somehow display two x-axis scales (one on top and one on bottom), not quite sure how to do that, but anyways... The user needs to be able to view EITHER torque vs ticks or torque vs time. Thanks for the help! Here is a sample: I can't answer in detail right now, but you can't have two differnt x scales for the same data. The time ticks have to vary if the encoder ticks are uniform, or the encode tick scale has to vary (instantaneously) if the time ticks are constant. They are not both uniform and that is just the way it is. You can take two sets of data at different times under similar condtions and look at two different graphs. Or you can digitize the encoder along with the torque and extract two graphs from that, one in the time domain and one in the angle domain. It would be plointless to grapoh encoder v time, but you could do that. Digitizing the encoder is not likely to work with an el cheapo DAQ system. Especially if it is a high count encoder. You need to know your resolution to plan this out and not waste time. Maybe you can't even use an external clock with DAQ I have never thought about USB-DAQ before. You should check. My feeling is still that you need to clock with the encoder and estimate time. But nothing definitive can be said about what needs to be done without knowing what decisions will be made using the information. If this is just an experiment to see how LV works that is fine, then let's not labor over - it just play around and see what comes of it. But if this is real work then you need to figure out why you want the data, then it is possible to take it the best way. Gotta go, Mike Quote Link to comment
lvb Posted September 29, 2006 Author Report Share Posted September 29, 2006 Thanks Mike, advice taken. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.