Linked patches don't work. While the individual patches do

I wrote a program using 4 patches. main, start, stop, turn180. Start, stop and turn180 all work fine as individuals. When I combine them in the main patch only the start works.
In the main patch I have them all linked together in series using SET and DONE nodes.
I believe my problem lies in the INPUT/PULSE node in the stop and turn patches. But I am not sure. I have the INPUT (Labeled SET) and the OUTPUT/PULSE (Labeled DONE).
The INPUT/PULSE node has 3 trigger modes. NEVER, ON BOOT and CONTINUOUS. I chose ON BOOT because the others cause the motors to run continuously.
I am thinking that the ON BOOT only triggers when I upload the program, therefore it does not trigger the stop and turn180 nodes or they are triggered early ON BOOT and have no effect when their turn comes. Am I doing something wrong when I combine the 3 into the main and link them together using the SET and DONE nodes?
I am using the DEFER node in each patch between ahead of the DONE node.

Please include at least your main & start patch so we can see exactly what you are doing.

How do I do that? I am looking for a method.

Is this it?

There is a notification that new users can’t upload. ???

Does this work?

How do I send you what I have

My project for 3-3-22.xodball (15.5 KB)

Your last attempt worked. You could also paste pictures of your nodes since they are small.

The problem is that you have multiple copies of each motor controller, and they are all always active, so the motors don’t know what they should be doing. Once start node has completed, it is still telling the motors to stop. There are two ways to fix this.

1st option is “less risky”, but can end up being much more complex. This option is to only have one node for left motor and one node for right motor. The rest of your program changes what values are fed into these nodes to change your speed.

The 2nd option works with your existing code. You need to make sure only one set of motor nodes is active at any time. This is done by having the motor-ACT pin false until it is time to activate it. For your code, this likely means that instead of running delay-ACT to motor-SPD, you can hard-code motor-SPD in each node & run delay-ACT to motor-ACT.

A couple notes:

  1. You will have the same problems with the LED nodes; only one node for each LED can be active at a time.
  2. I doubt that a delay of zero will every have delay-ACT true, so your stop node won’t actually stop anything. You could set delay-T to something small like 0.1 or maybe even 0.01
  3. EDIT: you swapped DIR & !DIR pins on one motor, so it should spin, but it is less obvious than using negative number to reverse the motor. [old comment: Your turn node will not actually turn. You set SPD the same for left & right motors. Assuming you want to spin, you will need to use a positive SPD for one & negative SPD for the other (like 1 & -1, or 0.7 and -0.7 if you don’t want full speed).]
  4. You don’t stop after spinning. If you update code to disable “unused” motor nodes, it should not be a problem since that should disable PWM and stop motors when nothing is active.

Was not successful in modifying my code.
Am currently working on writing something along the lines of the first option above. Still having problems understanding some of the nomenclature.
Is there a difference between a node and a patch? If so. How do I make a node?
The code I have written so far has 2 patches one for the left motor and one for the right, My code has one motor running longer than the other which makes the Robot turn 180 degrees after a time delay. Which is my goal. I want the Robot to go forward for a time then turn 180 degrees and return to me then stop…
The reason for the difference in time is both of my patches start at the same time. Haven’t grasp how to separate them when it comes to placing them in the “main”.
Perhaps it is the L298N board control that I am not sure of. I know the EnA and EnB are the PWM enable bits and the IN1thru 4 are the directional control.
I don’t know how to change speeds for example.
And when it is appropriate to use the ACT input.
Since the Robot wheels continue to run when the ACT mode is used…
Perhaps I am using time delays where I shouldn’t be.
I really appreciate the help here, Doing my best to gain a better understanding every day.
So THANKS!!

A patch and a node are basically the same thing. A patch defines inputs, outputs, and code to connect them. A node is a copy of that patch with connections to the inputs and outputs. The two terms are sometimes used interchangeably.

You control speed by changing the motor-SPD value. 0 is stop, 1 is full speed in one direction -1 is full speed in the other direction. 0.5 would be half speed.

The motor-ACT input is used to make that copy of the node active. I’m not sure what happens if all nodes have motor-ACT false; it might keep value from node last active, or it might stop the motor.

If you start with the code you posted above, you should be able to delete the links from delay-ACT to motor-SPD, add links from delay-ACT to motor-ACT, and type in values for motor-SPD. This will cause each motor node to be active only when the delay node connected to it is active. My guess is that your original program will then go forward, then start spinning. You might need to add another stop node for it to stop spinning.

If that doesn’t work, post a copy of your new code and what you see happening when you run it.

Instead of showing the old code. Here are a few examples with questions. The LED’S are to conserve the battery power instead of running the motors. I do understand the difference in the INPUT NUMBER AND INPUT PULSE. Used the NUMBER here to set the speed/direction.

Example 1. How to stop the motor(s) with time delays etc.? I can see the speed set # is in the Input Number node.

Example 2. Speed/direction is set at the SPD input of the motor node. How do you control the start and stop with time delay etc.? With speed number “0”.? How do you place that number? What node or nodes?

Example 3. Runs at max speed per set delay. How to set speed/direction?

Example 4. Delay ACT to Motor ACT = no delay. Runs continuously. How to set speed/direction.

Example 5. No delay, but do have direction and speed control.

Example 6. Has delay. Again speed/direction.

Still don’t know how to sequence, Forward, Turn, Stop, Back with only one set of motor blocks.

Can you tell I am a bit confused.

THANKS AGAIN FOR YOUR TIME.

Sample Problems.xodball (24.1 KB)

I will show example using single set of motor nodes in another post, but it will be considerably more complex, and it will get worse as you add steps for the robot to take.

Starting with your original code, I changed your start node to this:
image
Two suggestions:

  1. rename this to ‘forward’ since it is actually moving forward, not just starting
  2. add a pin for time so you can reuse it with different times. You could also add a pin for speed if you want robot to travel different speeds.

An option for your turn node is to copy the forward node and add a multiply to change one motor to a negative speed:
image

Another option is to create a generic ‘move’ node that allows you to specify L/R speeds:
image
motor can take negative numbers for reverse, but LED can’t, so I used abs to make sure led-LUM is positive.

Now you should be able to create simple movement by stringing these together:

One solution for a single set of motor & LEDs:

If you only have one set of controlling nodes & they need to change what is sent, then you need to be changing the inputs for those nodes. The most obvious solution (outside of creating your own patch/node) is to use ‘select’ or ‘nth-input’. This example uses select:


The delay nodes trigger which value to use from select and pause before moving to next step. The left select controls left motor/led, the right select controls right motor/led. Each delay node links to both select, being careful to keep things lined up (the 1st delay links to select-S1, the second to select-S2, etc.). select-X1 is values to move forward, select-X2 is values to spin, etc.

Because there is a separate delay node for each step, it is easy to have different times allowed for each step. An ‘nth-input’ node might work better if all steps had the same time and a clock node could be used to increment ‘count’ used to index the nth-input nodes.

‘select’ and ‘nth-input’ work pretty well if you have an explicit set of steps that you will always take. If you start adding additional code (like obstacle avoidance using a range sensor), it can become more difficult to determine how to use select/nth-input.

Interestingly, I found in the case of a line-following robot, it was actually easier to program it with a single node for each motor using if-else instead of select or nth-input. My robot had 3 line sensors: left, middle, and right. If any sensor could see the line, an if-else would allow a speed other than zero; else the speed would be zero (line has been lost, quit moving). If the left sensor could see the line, the left motor should slow down. If the right sensor could see the line, the right motor should slow down. That is all the code that is needed. It does require tweaking the sensitivity of the sensors and slowing down the motors enough that it wasn’t constantly over-running the line when there was a turn.

WOW !! You went to a lot of trouble. I will work on it more tomorrow.
What is so confusing to me. I saw a video put out by the Dronebot Workshop. Titled Working with XOD part 2. In it he shows using multiple input numbers along with a motor patch. I tried it with the h- ××× controller. My h_ ××× controller will not accept the same connections. I can’t find the same motor controller in any library.
Perhaps you have seen it. It’s is exactly what I was looking for.
He uses multiple motor blocks.
???
Thanks for your help.
Doug

The code you sent works just fine. I have learned a lot.
THANKYOU!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.