The Centroid macro language doesn't include a random number function.
Is there a way to generate random numbers during program execution using existing macro functions ? Why???, because I'm doing a project where I want to drill a random pattern of holes with each run of the program giving a different hole pattern.
I can do this in CAD/CAM, but it's cumbersome because of having to create a separate program for each program run. In other words if I want, for instance, 50 random hole pattern parts I'd have to create 50 separate programs.
Generating random numbers during program execution...??
Moderator: cnckeith
-
- Posts: 3
- Joined: Wed Oct 10, 2018 5:08 am
- Acorn CNC Controller: No
- Allin1DC CNC Controller: Yes
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC11: Yes
- CPU10 or CPU7: No
Generating random numbers during program execution...??
Last edited by doug98105 on Mon May 22, 2023 10:16 am, edited 1 time in total.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Community Expert
- Posts: 3540
- Joined: Tue Mar 22, 2016 10:03 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192 - DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: Boston, MA
- Contact:
Re: Generating random numbers during program execution...??
Based on Wikipedia:
#100 = (1103515245 * #25012 + 12345) % (2^31);
Parameter #25012 is the time in seconds from CNC12 as a seed
#100 = (1103515245 * #25012 + 12345) % (2^31);
Parameter #25012 is the time in seconds from CNC12 as a seed
Cheers,
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 447
- Joined: Fri Jan 10, 2014 11:29 am
- Acorn CNC Controller: Yes
- Plasma CNC Controller: No
- AcornSix CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Hickory CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: Yes
- CNC12: Yes
- CNC11: Yes
- CPU10 or CPU7: Yes
- Location: Howard, PA
Re: Generating random numbers during program execution...??
The system variables should allow you to put something together. #25011 or #25012 times could work in some cases, or could be a seed for a pseudorandom calculation you can find online.
If your machine has a spindle encoder, it should be a good random number in most cases, if you are machining between calculations. Spindle encoder should be somewhere in #5021 - #5028, depending on mapping.
If your machine has a spindle encoder, it should be a good random number in most cases, if you are machining between calculations. Spindle encoder should be somewhere in #5021 - #5028, depending on mapping.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 3
- Joined: Wed Oct 10, 2018 5:08 am
- Acorn CNC Controller: No
- Allin1DC CNC Controller: Yes
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC11: Yes
- CPU10 or CPU7: No
Re: Generating random numbers during program execution...??
Thanks for the replies. Using #25012 seems to do the trick. I'll do some testing the next few days to verify.
My machine doesn't have a spindle encoder so that method is out.
My machine doesn't have a spindle encoder so that method is out.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)