Help adjusting numbers

hello I was wondering if someone can help me with this one. I am trying to increase and decrease numbers from the counter start-stop using the buttons. it all works fine until I make a connection to the counter start-stop. I’m pretty sure I’m missing something simple but I’m new at this and I’m having trouble finding information to fix it. any help would be greatly appreciated. thank you.

It is not obvious what you are trying to do, or what your counter(start-stop) node is doing. I’m going to guess that counter is supposed to track where the stepper motor is currently positioned and you want to be able to run it in either direction.

The first issue is that the stepper node is going to take some time to complete. If you change counter faster than that, counter & stepper will no longer be in sync. You could disable the INC button while stepper is running using a flip-flop & gate node.

The next issue is you will need to change the counter-STEP value between positive and negative to be able to count up and down (or use nkrkv/encoder/count that has INC & DEC pins). You will also need to change stepper-N between positive and negative for the motor to move in the same direction as the counter.

There are multiple ways to change the STEP & N values. The most obvious is if-else nodes, perhaps with flip-flop that is SET or RST by buttons with output tied to if-else-COND. You could also use select nodes. A round-about way would be to use one select node to choose between +1 & -1, then multiply the value you want by the select output (probably the only advantage of this is you only have one copy of the input #, so you can’t change one copy and forget to change the 2nd copy)

I don’t know what you are trying to use the count nodes for or what the counter start/stop pins that take numbers are for, so I don’t know what else to tell you without additional information about what you are trying to do.

Thank you for your reply. sorry for the lack of information the purpose of this program is To run a automatic pipe cutter. the stepper motor is there to drive a tube or wire to a set distance which needs to be variable and the servo is there to operate a cutter I need to be able to set how many cuts I wish to do and what length-steps the tube or wire needs to be. I hope this clears things up thank you. if you need any more information please do not hesitate to ask.

To answer the question on the counter start stop node I am trying to adjust the Start pin so I can increase and decrease That value with the buttons but for some reason it will not allowing me to make an adjustment. This is the only node I could find to break a loop at a set point. Is there another way of breaking a loop ?

That is quite a bit different than what your code implies. Current code moves the stepper motor every time count is changed. You want to be able to set some number for count, then run stepper based on that count. This means stepper distance (stepper-N) should be based on count, not a static value.

To figure out how to use count with stepper-N, you need to determine what units you are measuring and how many steps are needed for that distance (for example, you could measure in mm, cm, or inches, but each would need different number of steps to move tube that far). Unless you do fractional steps, you will not be able to move smaller steps than your chosen units (mm, cm, etc.).

image
This example allows you to select count (using nkrkv/encoder/count that has INC & DEC pins). When 3rd button is pressed, run stepper motor that distance (assumes 150 steps to move count distance–adjust for your setup). Your existing code to run servo should work with this. Watch node could be replaced with LCD output to see what current count is.

Thank you for your reply. Your example works fine when changing the number of steps On the Stepper Node But unfortunately will not let me change the Start number value on the Counter start stop.



Thank you for your time hope to hear from you soon.

[Ramblings that assume you are trying to move “count” distance instead of making “count” cuts – I decided to leave it here in case someone is doing the opposite]

Looking at your previous comments, I’m not sure what you meant by using the counter start/stop to “break a loop at a set point”. You are telling the stepper node how many steps to take (how far to move the pipe). There is no loop to break if you pass the correct number to stepper-N to move the full distance. That is what the multiply node is for in my example. If count is in mm and it takes 150 steps to move 1 mm, then you would need to move 3 x 150 steps to move 3 mm (hence the multiply count by 150). I don’t understand how you expect to move the pipe different distances based on count if you are always telling the stepper to take 3200 steps (the value you’ve hard-coded into stepper-N).

If you are trying to call the stepper node “count” times to move the full distance, then you probably can’t use stepper-DONE to indicate when it is time to cut; that pin is going to fire “count” times as you try to move the pipe the full length for one cut. You are also going to have a problem if counter-TICK pulses too rapidly; stepper is going to get a signal to start over before it finishes the 1st move, so you will not move the pipe the full distance. If the TICK pulses are farther apart, you move the pipe a little, stop, move the pipe again, stop…etc. until time to cut. It is much more efficient to calculate number of pulses to move the pipe the full length and only call the stepper node once for each move. If you really want to call the stepper function “count” times for each move, flip-n-times might be an option (but I think stepper should only be called once for each move).

Maybe I’m misunderstanding & you want to make “count” cuts of the pipe, each of length 3200 steps. That might be closer to what you have coded above. If this is what you are trying to do, the biggest problem with your solution is that counter-TICK has to be slow enough for stepper to finish moving the pipe, and the cutter to activate and retract between each tick. You could program the ticks to be long enough (flip-n-times can be used for this), or you could have a separate counter to track how many cuts have been made. When the cutter is done retracting, check if cuts done has reached cuts desired yet; if it hasn’t, repeat process, else stop until button is pressed again. The biggest advantage of creating a loop and counting progress is you don’t have to calculate (or guess) how far apart the ticks need to be (which will probably result in time waiting for next tick just to be sure it is not too soon). If waiting extra time for next tick is not a problem and you are not likely to change length of pipe (which will require a different amount of time to move that far), then you might not care.

If you decide to use flip-n-times, flip-n-times-OUT will flip to True “count” times. You can use this directly as a pulse for stepper-GO, or use a pulse-on-true to explicitly convert the boolean to a pulse. You will need flip-n-times-Ton plus flip-n-times-Toff to be a long enough time for the move/cut cycle to finish before it sends the next pulse. flip-n-time-Nc will be the count of how many cuts have been made (or is in the process of being made, actually).

I guess I should pay more attention to details. I see in your latest code you added defer after cutter retract to incr counter start/stop again. This indicates you probably are trying to make “count” cuts in a pipe, not move “count” distance before cutting.

Seeing code for this counter node would help, but I’m guessing if you used counter-STEP of 1, counter-START of 0, and linked count output to counter-STOP, it might work for you. I’m just guessing what counter start/stop is doing, but it looks like you are starting at “count” and INCR by one until you get to zero. Since you are past 0 when you start, nothing ever happens. If you end up with an extra cut every time, switch counter-START to 1 instead of 0.

This is the counter start-stop I am trying to use I am starting to think this node will not allow me to make a adjustments Via the buttons to the start pin. Is there a different or better note I can use?


Sorry I feel that I am explaining myself very poorly so we’ll try again. I am trying to increase the number on the start pin of the (counter start stop) i.e. to 10 then start the program with the button and repeat the operation counting down to 0 then the program will stop.

Thank you for your patience.

Looks like my last post was correct. You need to counter-START to be 0 instead of counter-STOP. Move the wire from count to counter-STOP instead of counter-START.

Thank you very much it is now working. It did not work for me the first time because I didn’t realise the screen would not update until I started running the program. I was expecting the display to adjust before running the program so learn something new. Once again thank you very much for your time and patience.

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