10-26-2009 04:49 PM
I'm trying to build an image matrix from an analog input (for debugging purposes I'm just using a sin waveform) and a triangular waveform. The analog input provides intensity information and the triangular waveform (which is scaled to 0->64) provides position information for the index that the analog input (an amplitude) should be stored at.
I've been struggling for a while now to build a image matrix using the analog signal as the data and the waveform for the position information (columns).
The code I have below is what I have made so far. It's based on modified code from another thread. If anyone has an ideas, or working code to do something similiar to what I have described, that could be amazing.
Thanks.
10-27-2009 05:55 PM
Hi JKlein,
So I see that you are trying to create a 64x64 image, is this correct? Are you expecting to open up this image array in another application or project? If so, then this may not be as simple as you may have thought. If you are just wanting to see this on an intensity graph, then you'll probably be okay.
Also, what was the reasoning behind using shift registers?
Do you know that you are going to have 64 points to insert into the image array? What is the intensity graph showing? If you would like to see the entire array, instead of just one row/column, then you should place a graph on the outside of the for loop. Also, if you would like to individually write each point, you can access each point of the 2D array by having nested for loops.
Could you please provide some more specifics about what you'd like to do?
Thanks,
10-28-2009 10:25 AM
Hi,
Thanks for the reply.
Basically I'm using a triangular waveform to drive a linear motor (the amplitude of the waveform sets the absolute position of the motor) and am acquring a analog signal from a sensor which is acquiring data from a surface that is attachd to the linear motor.
I would like to use the intensity graph to create an image (1D for now) of the analog signal from the sensor. The position on the intensity graph will be set by the waveform (for example, when the waveform is outputting its lowest value, data acquired from the analog sensor will be plotted into the bottom most row in the intensity graph; when the waveform is outputting its highest value, data acquired from the analog sensor will beplotted into the top most row on the intensity graph.
I think the code I posted might be confusing, so maybe just disregard it, because I think I'm pretty lost on exactly how to do this.
Thanks!
10-29-2009 11:19 AM
Hi,
I think that the best way to do this would be to insert those signal values into a 2D array. The coordinates of the signal value would be determined by the triangle wave. However, you'd have to get the actual "coordinates" from the wave in order to do this. Do you know how long/far you're going to be moving the motor before you start? If so, it wouldn't be too tough to have a preallocated array and just insert values into there as they are acquired. If not, then it may be a little trickier. Is the course of the motor predetermined? This would also be helpful.
How fast are you acquiring data/moving? Is there just one data point per motor location? How are you instructing the motor to move?
10-29-2009 02:55 PM
Hi
I was doing something similar : two motors, say XY, scanning an area and a detector measuring a voltage at every point.
In order to do this you need to use two nested loops 'if you know the number of stepsfor each motor) or two while loops with criteria for stop. The data can be in 2D arrays or arrays of clusters. Note that for efficiency one of the motors should be moving in alternance, use a shift register which you multiply by -1 to show direction
if you need more help I can post some images (that will be of little use since are pieces from a large spaghetti bowl.. that's before I learned state machine and defined type controls.... I was living under a rock !)
regards
n
10-30-2009 10:24 AM
Hi,
Thanks again for all the responses!
The course of the motor is predetermined and it will be moving back and fourth about 1mm (from peak to peak) @30Hz (maximally). I will be sampling from the sensor at the maximum possible sampling rate which is 10MHz. Ideally, I will be able to set the image size from 64 up to 2400 (for higher resolution).
Yes, there is just one data point per motor location (but the total number of motor locations will depend on what the desired resolution of the image is set to). Because I am acquiring so many samples, they will be averaged and binned according to the position of the motor. For example, when acquiring a 64 pixel image, each pixel will contain the data acquired over 1mm/64 pixels = 1/64mm. The motor is being instructed to move directly by the triangular waveform which I am outputting to analog output 1.
Thanks
justin
11-03-2009 09:41 AM
Hi Justin,
Pretty much, what you need to do is take the analog signal, and insert it into an array at the proper spot. If you are instructing the motor to move according to a triangular wave, and think of that wave as moving around the 64x64 pixel spot, then we should be able to insert the specific data point into the 2D array at that spot. Nested for loops would be useful for this application.
In terms of getting the image size to be adjustable, this could be a bit more difficult. How are you planning on doing the binning- histograms? Whatever method you're using there to get the position of the motor, I'd recommend also using for the insert into array method.