Skip to main content
Solved

How to write a Macro to scan in XY and get efficiency

  • November 12, 2024
  • 3 replies
  • 119 views

Hossein

Hi everyone,

I am new here and trying to write a macro for a simple setup that I have. I have a beam at source with specific NA and goes through few optics and get focused on a surface with floating aperture. My inputs are relative position of source/object respect to image in X and Y and output is efficiency at “Geometric Image Analysis”. How can I write such a Macro? 

Best answer by David.Nguyen

@Hossein 

 

Efficiency from Geometric Image Analysis in ZPL

I’ll start with the efficiency of Gemetric Image Analysis. For that, I’d recommend using the IMAE Merit Function operand. From the Help File of this operand:

Then, assuming you have an IMAE operand in your Merit Function (it could also be added automatically with ZPL):

Retrieving this value in ZPL can simply be done with:

OPER(1, 10)

This ZPL command returns the Value column (identified by the number 10) at row 1 (change this value to whichever row your IMAE operand is). This is a dummy example with the Merit Function above:

XY alignment

For the XY alignment, there are many ways to go about it. But if I understood what you are trying to achieve correctly, it might be easiest to use the Field definition. In your file, under the Setup..System Explorer..Fields..Settings change Type to Object Height. Then, still in the System Explorer, tick the Aperture..Telecentric Object Space:

That way, by change the Field Y coordinate you can laterally move the incoming pencil of rays. This is an example with 3 Fields:

But instead of having 3 Fields, you can just keep one, and use ZPL change the Field Y Coordinate like so:

SYSP 103, 1, 0.02
UPDATE ALL

This changes the Y coordinate (identified by number 103) of Field 1 to the value 0.02mm.

Putting everything together

Lastly, you can scan the field through a FOR loop, and at every field value, you can retrieve the efficiency.

field_start = 0.00
field_end = 0.04
number_of_field_points = 10

field_step = ( field_end - field_start ) / number_of_field_points
FOR ii, 0, number_of_field_points, 1
	field_value = field_start + ii * field_step
	SYSP 103, 1, field_value
	UPDATE ALL
	PRINT OPER(1, 10)
NEXT

This is the result with your file:

Instead of printing, you could also do a plot, but I let you check that for yourself as the post is already quite long.

I hope this helps and take care,

 

David

View original
Did this topic help you find an answer to your question?

3 replies

Hossein
  • Author
  • Single Emitter
  • 2 replies
  • January 17, 2025

I have attached my mode to make my question clear. 


David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1089 replies
  • Answer
  • January 28, 2025

@Hossein 

 

Efficiency from Geometric Image Analysis in ZPL

I’ll start with the efficiency of Gemetric Image Analysis. For that, I’d recommend using the IMAE Merit Function operand. From the Help File of this operand:

Then, assuming you have an IMAE operand in your Merit Function (it could also be added automatically with ZPL):

Retrieving this value in ZPL can simply be done with:

OPER(1, 10)

This ZPL command returns the Value column (identified by the number 10) at row 1 (change this value to whichever row your IMAE operand is). This is a dummy example with the Merit Function above:

XY alignment

For the XY alignment, there are many ways to go about it. But if I understood what you are trying to achieve correctly, it might be easiest to use the Field definition. In your file, under the Setup..System Explorer..Fields..Settings change Type to Object Height. Then, still in the System Explorer, tick the Aperture..Telecentric Object Space:

That way, by change the Field Y coordinate you can laterally move the incoming pencil of rays. This is an example with 3 Fields:

But instead of having 3 Fields, you can just keep one, and use ZPL change the Field Y Coordinate like so:

SYSP 103, 1, 0.02
UPDATE ALL

This changes the Y coordinate (identified by number 103) of Field 1 to the value 0.02mm.

Putting everything together

Lastly, you can scan the field through a FOR loop, and at every field value, you can retrieve the efficiency.

field_start = 0.00
field_end = 0.04
number_of_field_points = 10

field_step = ( field_end - field_start ) / number_of_field_points
FOR ii, 0, number_of_field_points, 1
	field_value = field_start + ii * field_step
	SYSP 103, 1, field_value
	UPDATE ALL
	PRINT OPER(1, 10)
NEXT

This is the result with your file:

Instead of printing, you could also do a plot, but I let you check that for yourself as the post is already quite long.

I hope this helps and take care,

 

David


Hossein
  • Author
  • Single Emitter
  • 2 replies
  • January 29, 2025

Hi David,

Thank you very much for taking your time and write such a detail reply. I really appreciate it.
This code is great for start and I think by having this as a base I can elaborate it more.

Thank you so much again. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings