LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fastest trigger with encoder and camera

Dear all

 

My last project is an encoder that is for distance measurement connected in an arduino and communicate with labview trought visa.

Now I add a camera to the project, so I need to take pictures at distance intervals.

I use the quotient & remainder, I use the distance from the encoder divide with trigger interval, for example 10m and when remainder is =0 it gives a true for the camera shot.

The problem is the trues occurs only sometimes maybe the encoder moves too fast, or arduino not send all pulses (maybe not as 1,2,3,4,5,6,7, pulses but 1, 3, 6, 10) because the visa port is too slow.

Can some one help me to creat a trigger to take more time to take ONLY ONE Picture (if the true is ON many time it takes many pictures in same distance.

 

Best regards

cpalka

0 Kudos
Message 1 of 8
(2,275 Views)

If you already have code that reads your encoder and gives you a distance value, and you want to take a picture every 10mm (or whatever), then rather than using Quotient and Remainder, use a shift register for a target location and check if current location is greater than (or less than, depending on direction of travel). 

 

Update the shift register with a new target (+ or - 10m) each time you take an image.

 

Be aware you probably also want to record locations because depending on the severity of your problems quickly updating position you might go past by some (maybe significant)  amount each time. 


GCentral
0 Kudos
Message 2 of 8
(2,237 Views)

Hi cbutcher

 

Thanks for the help

 

I attach a lit code and I would ask kindly if you could change it for your solution

 

Many thanks

cpalka

0 Kudos
Message 3 of 8
(2,217 Views)

I've attached a simple demonstration that describes what I mentioned.

I used the 2019 "Random Number (Range)" VI to create a random number between +0.1 and -0.1 and added that to the measurement also to show what will occur when the range values don't nicely fit your interval. I replaced it with the contents so that I could save back to 2013 (I think that's the version you used?)

 

An image is also shown below:

snippet.png

 

Although I'm sure it's only here for the demonstration purposes (thank you for providing a VI to use for demonstration, especially with no extra dependencies!), you also want to try and minimize the time per loop iteration (and therefore the size of the steps measured by the encoder) because as this example shows, sometimes the error will be almost 1m using a step size of 1m +- 0.1m.

If you're using only integer values you could try rounding to nearest and using the Quotient and Remainder function. If you're using something like e.g. 0.1m as the interval, you could multiply both interval and reading by 10 and then do the same (so that your unit becomes decimeters, and you again have integer values).


GCentral
0 Kudos
Message 4 of 8
(2,177 Views)

Hi cbutcher

 

That´s it!!!

 

Many thanks for the help, I will finish all code and I will test in my car to see if with speed it will take pictures a good intervals  (I would like to get 1 or 2m interval, but at 40km/h the system will have speed to do that?)

Best regards

cpalka

0 Kudos
Message 5 of 8
(2,167 Views)

Well, 40 km/h is 11.1 m/s, so you'd need about a 10Hz loop rate for 1m resolution. Depending on your hardware, that should be possible (certainly some hardware would do this with no problems, but you mentioned an Arduino for your encoder setup, so I'm guessing you're not using expensive super-high-speed cameras). I'd say you have a good chance. How does the encoder work? If it can measure more often than 10 S/s, and your camera can capture in less than 100ms, you should be fine.

Of course, the faster the encoder samples, the more accurate the range-finding synchronization to the image.


GCentral
0 Kudos
Message 6 of 8
(2,141 Views)

Hi cbutcher

 

Once again many thanks

I have an arduino nano and the encoder is connected to it. Inside arduino i have a code to count the pulses ans send it through com port. I think arduino works well with encoders.

The camera is connected in usb port and it is a microsoft HD camera and i use the vision module from labview.

I will test it with a car and i will see, of course without time delays in the loop, but my problem should be in visa com port speed, i have a 115200 baud rate.

 

Best regards

cpalka

0 Kudos
Message 7 of 8
(2,122 Views)

Hi cbutcher

 

Yesterday I tested the code and for picture interval of 1m and about 40km/h, seems works good.

I would like to ask your help if it is possible, the code should take the first picture at 0m, but it only takes the first picture at 1m, or other picture interval. 

Can you please help me how to do that?

 

Other thing, Can you help me changing your example code to calculate the speed?

 

Best regards

cpalka

 

 

 

 

0 Kudos
Message 8 of 8
(2,064 Views)