Machine logic block coding

Hey peoples,

Looking through the posts, it seems like most of you are a little beyond my current capabilities.

That being said, I’m trying to program this machine which is set up for block coding.
I can’t seem to use the “lambda functions” correctly, or at least I think that’s my problem.
I’d rather do it in python, but I wasn’t here for that meeting I guess.

Here’s the problem I’m running into:
When testing, I watch the blocks light up until it gets to the point where it is waiting on a signal from my Epson. So I manually give it that signal, and the program just stops with no motion.

I’m using this “lambda function” to calculate the appropriate pull distance, given the current circumference which is calculated in a separate function, so that we pull an arc length of 30mm every time.

I’ve got a forum and a sandbox for checking my JavaScript, which is the language vention’s tutorial videos say is needed for these “lambda functions.”

Anybody, got any advice?


1 Like

Hi Ryan, maybe have a look at On the hidden power and orderly nature of "lambda functions" in MachineLogic and let me know if it helps? If you’re more visual, the attached example might be easier to picture.

You could also add a message/log instruction right after your wait, and confirm that you at least get there.

Or post a bit of code or picture here?


Here’s the jist of what I have that isn’t working properly. Sorry if its not super easy to read.

Having not read through my original post here, I’ll recap the wall I’m hitting.
While testing, it gets to the “wait for input” command. (seen above)
I then simulate the signal from epsons side.
The program simply stops.

I’m fairly certain the IO’s are doing what needs to be done as I have manually checked them…like twenty times.

what I have in a JavaScript sandbox that I’ve been testing ‘rollHome’ inputs by comparing the output to an excel spreadsheet. Some of the labels may be different.

let rh = 7 //rollhome *sensor input*
const sd = 93 // starting diameter
let c = Math.PI * sd
const wc = Math.PI * 88.9254  //motor wheel circumference
const al = 30 //desired arc length

//current roll circumference
function cc(rh) {
  if (rh >= 3) {
    return Math.PI * (93 + ((rh - 2)*6));
  } else {
    return Math.PI * 93;
c = cc();
function pull(c) {
  return (30 / c) * (Math.PI * 88.9254);


Cool. First off, admittedly, the error reporting is not great at the moment. We’ll be improving this in the future. In the meantime, you might get better hints if you open your dev tools in your browser.

Regarding your program, I see a few things:

  • your instructions don’t pass any parameters to pullCalc and currentCirc (n.b. the lambdas don’t have access to anything global, they’re meant to be pure functions: they only transform their inputs; you have to pass in those arguments explicitly in the expression of your setVariable)
  • in pullCalc, PI() does not exist (use Math.PI instead)

You guys are good in my book.

Ok, let me make sure I have this right.

would I put the parameters in anywhere I’m calling the function, or just in the set variable command, or in the motion command?
I’ve tried doing so in the variables page, but it gives me an error “parameter not defined” (which I’m sure is my fault)
I will try all of these after the google call with some other people from vention.

1 Like

You can divide and conquer by just changing the very first setVariable right after the wait, and add a temporary message instruction right after. If you type the name of your variable in the message (here: circ; or you could say “Here’s the value of circ”), it’ll render it as yellow in the instruction, and it’ll interpolate it and display it (at run time) in the log window that you access easily via the UI builder.

In general yes, wherever you call a lambda, you must pass in the parameters. Typically this will be in any expression field of a MachineLogic instruction. setVariable is one of the most common such places, but you could also call a function from the position edit field of a move instruction, for example; or most other edit fields.


A picture from a similar program…


First, I just learned that you are cofounder.
Where are my manners, nice to meet you.
Also, kind of impressive in my eyes as I don’t hear about many founders or cofounders responding to forum chats, thank you.

Talking with Laurent and Simon, I got some good feed back. This is my first time in the deep end, if you will, but they were very helpful and are also telling me the pretty much the same things as you.
I’m gonna send Laurent my updated version of the current program set up, and I’m also trying to drop it here so we all can see it. I can’t seem to get that right, and the pictures wouldn’t really let you see all the variable names as I extended them for legibility. …Ironic, but I will figure it out and drop it here at that time.

I think I understand what you guys are saying, but I’m clearly doing something wrong still, so that theory is on thin ice.
However, I am now getting an error message popping up when the program stops, which feels strangely like progress.
The error reads “invalid application, changes can’t be saved.”

1 Like

I was able to find it, but I had to select all file types, and got this error when I tried to attach it here. "Sorry, the file you are trying to upload is not authorized (authorized extensions: jpg,jpeg,png,gif,heic,heif,webp,avif). I tried to open it in notepad,

I’ve just been downloading it from here(seen below). I tried to open it and notepad, save as, and upload it that way, but got the same error.
This would work for a back-up file, right?

I’m just gonna try and get some decent pictures for you.

main page with key sequences blown up.

The signature of your pullCalc, in the last picture you posted, won’t work. It must be a plain (1-dimension) argument list. You can pass in a function if you want, but on the caller side, you’ll only pass in the function name; in the function signature, you’ll only name an argument for it (the function itself); and in the body, you’ll invoke that function via the name given in the signature. Alternatively (and more commonly), you can pass in the evaluation of a function as a plain argument (as you did in your setVariable).

  • example passing in a function:
  • example passing in the evaluation of a function:
1 Like

Still learning the vocab, let me make sure I understand correctly.

I’ve switched to a hardcoding method for now, but I would like to replace any numbers in the body with variables that could be easily changed on the variables page when all is said and done. For now, I just want to make sure I’m following proper syntax.

You’re saying like this?

Also, in the child sequence should look like this with simplified arguments, right?

Should the initial value for the “pull” variable look the same as in the set variable command?

i noticed that i had Math.PI, instead of Math.PI(), so i fixed that.