Best approach for relative displacements

Post anything you want to discuss with others about the software.

Best approach for relative displacements

Postby Mark81 » Sun Jul 21, 2019 3:26 pm

Hi guys, often I cannot find an answer to my questions because I don't know the correct English words for something.
So please, if this topic was already discussed but I did a wrong search, I kindly ask you to tell me the best keywords to perform a search.

On my Z-axis I have several tools, like the spindle, laser module, a camera, a touch probe, etc...
I'm looking for the best way to create a button set in my custom screen to easily switch the XY reference among them.

Something like the webcam plugin does. I'm not looking for a ready-to-use solution. I'm able to write a macro by myself, I'm asking you an advice to make the things elegant and re-usable.

I know the relative displacements among all my tools. Say the spindle is (0, 0), laser (0, 60), camera (50, 25), touch probe (-40, -40). They are not the actual value, but it just an example.
In my screenset I place four toggle buttons (acting like an option group) with the for tools.
I would like to be able to do something like this:

  1. select the current tool (i.e. camera)
  2. manually jog the machine to a desired position
  3. zero XY axis
  4. select another tool (i.e. laser or spindle)
  5. the macro should set now the XY values to the actual position as seen from the new tool
  6. for the sake of clarity, if now I select again the camera button I should read again (0, 0)


It's ok for me to hard-code the relative displacements in the macro file.
My ugly way:

  1. create a macro file for each button (I don't know if I can pass a parameter so I can use only one macro)
  2. hard-code the positions in some vars
  3. when the macro is called (= the related button is pressed) I sum the reference position (i.e. spindle) to the current position to go back to a default coordinate system. Then, sum again the new offsets.
  4. I also need to save in a system var the current tool to avoid to change the position if I press multiple times the same button

Do you recommend a more elegant solution?
Mark81
 
Posts: 42
Joined: Thu Feb 14, 2019 4:38 pm

Re: Best approach for relative displacements

Postby dezsoe » Sun Jul 21, 2019 10:12 pm

You could simplify the code to one macro making the whole job and the button macros to call that macro. E.g. the main macro is M20000, the buttons start with M20001. M20001 contains an exec.Code("M20000 E1"); and so on. The M20000 reads the E parameter and does the things you need. Also, the M20000 will remember the last state and can change the selector buttons' state. (See #Events: a little surprise from UCCNC)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Best approach for relative displacements

Postby Mark81 » Mon Jul 22, 2019 7:48 am

Interesting! I'll give it a try.
Thanks!
Mark81
 
Posts: 42
Joined: Thu Feb 14, 2019 4:38 pm

Re: Best approach for relative displacements

Postby Battwell » Tue Jul 23, 2019 3:34 pm

on my biesse with 30 tool heads i use g52 as temporary offset- easy to add to m6 macro
then just call a tool change
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Best approach for relative displacements

Postby jonathanponz » Fri Nov 22, 2019 1:03 pm

Hello,

I am planning to buy a camera and install it to my cnc. Same concept with you. I will use the camera to 0 the x and y position plus the offset of the camera with respect to the bit.
Can you help me share some macro codes.
Thanks a lot.
jonathanponz
 
Posts: 5
Joined: Sun Mar 04, 2018 12:21 pm


Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 22 guests

cron