have to stop stepper motor when elapsed time is over

wefsdf

Final_Syringe_Pump_Program_v2.ino (50.9 KB)

You have an enormous program that would take a very long time to figure out.

Can you write a short demo program that illustrates your problem ?

You are using the delay() function. You should NOT. Use millis() to manage timing as illustrated in several things at a time

All the delay()s in loop() - and maybe elsewhere - will prevent stepper.run() from being called often enough. They will also interfere with any attempt to make the code responsive.

There may be other aspects of your code (unrelated to delay() ) that also have the effect of slowing the iteration of loop().

Your code should be designed so that loop() repeats as fast as possible - certainly hundreds of times per second. Preferably thousands of times.

...R

If you take the trouble to edit your post and put your code in code tags using the code button </> so it looks like this I will then take the trouble to study it.

...R

do you studied ?

Perhaps he has, perhaps not.

You should study the forum's manual (click !) first, so you learn how to properly make posts.

Nilanj:
do you studied ?

No.

As I write this there has been no change to your Reply #2
Nor have you posted the code correctly in a later Reply.

Help us to help you. We are not being paid to look at your code.

...R

Nilanj:
sorry sir, i ask for help , sorry for post format , i am new and i dont know about that.

i am attaching a code.

As far as I can see (based on the file size) the attached code is much the same as the code attached to your Original Post - which I said was very long.

In Reply #2 you seem to have posted a much shorter piece of code. Can you either modify that Post to put the code in code tags (as requested in Reply #3) or post that shorter code as an attachment.

I am assuming that the shorter code illustrates the problem and short code is much easier to study.

If you "don't know about that" you should read the How to use the forum

...R

I know this will sound like I am being a pain-in-the-A ...

The code in Reply #9 is not a complete program that I can download and compile. I see now that neither was the code in Reply #2. But I had assumed the code in Reply #2 was a short complete program in response to my request in Reply #1

If you can't produce a short program that demonstrates the problem, can you provide an explanation of the different parts in the long program to help me to make sense of it quickly (i.e. within 10 minutes rather than 2 hours or more).

...R

you can use FLOWRATE like 600 so the time to complete the stepper is 6 seconds , but stepper will use more time to flow 1ml .

You have not posted a complete program. I can't see either the setup() or loop() function.

It is quite likely the problem is caused because your loop() is too slow and stepper.run() is not being called often enough.

I can't imagine what clock-time (hh:mm:ss) can have to do with stepper motors used in a 3D printer.

I'm not sure, either, that the AccelStepper library is suitable for the closely coordinated movements that are required by a 3D printer.

...R
Stepper Motor Basics

Jeez, I just wasted my time replying to this and now I see it is the same as in Your Other Thread.

DON'T DOUBLE POST

...R

@Nilanj, DON'T DOUBLE POST.

I have replied to your new Thread - not realizing it was the same as this. I have asked the Moderator to merge it with this Thread.

Read what I wrote in your other Thread.

How come there was no mention of a 3D printer in this Thread.

Don't expect sensible advice when you don't give all the information.

...R

as in 3d printer the build time for any object is display after we command to print , same as i want to display elapsed time when motor is running.

Nilanj:
as in 3d printer the build time for any object is display after we command to print , same as i want to display elapsed time when motor is running.

If you have no intention of engaging in a conversation in which you respond to my comments I am not going to waste my time trying to help.

...R

i did because i did not get solution sir, and than i got idea that what i want to do is same as 3d printer do , that why i post and mention about how it similar with 3d printer.

i am in trouble and dont know what to do, so asking sir. sorry about that , but still did not get correct solution.

i have to run motor to complete certain steps with certain speed with certain time.

time is elapsed. i am trying this from many days. but not got solution sir. :frowning:

Nilanj:
time is elapsed. i am trying this from many days. but not got solution sir. :frowning:

Post the most recent version of your program and also tell us what the different parts of it are supposed to do.

I am assuming your most recent version will have taken account of the various comments that have alreadey been made.

And I am not a "sir" - just an ordinary guy.

...R

i am working on syringe pump , we have to give inputs and it will calculate require steps for motor with require motor speed, and also calculate time ,

inputs are :

  1. TOTAL VOLUME
  2. INCH PER VOLUME ( ich pr volume is how much volume syringe contain pr ich)
  3. VOLUME TO INFUSE
  4. FLOWRATE

i have done all thins except that when i put timing function in stepper_run() function than motor takes more time to perform operation but infuse perfect volume.

so i think when i put time_remaining() function in stepper_run() than stepper motor will going to slow( the speed of motor will decrease , i dont know this is true but it might be possible.)

plz help me.

i am attaching the full code.

Final_Syringe_Pump_Program_v2.ino (51 KB)

Nilanj:
plz help me.

i am attaching the full code.

I have been trying for some time.

I have downloaded your code.

Now, please write a short "essay" which explains in plain English what is the intended purpose of each function in your code and explains any parts of a function that I might not immediately understand.

If your program was only 200 lines long I would not need to ask for this.

...R

in this whole code the two functions are important, first function is stepper_run() and second is time_remaining()

stepper_run() function will calculate motor speed, required steps and time in seconds.

time_remaining() function will calculate time in form of hh:mm:ss using total_time_in_secs( which is calculated in stepper_run() function)

i have already mention bro.

Nilanj:
in this whole code the two functions are important, first function is stepper_run() and second is time_remaining()

I need to understand all of the program, not just the pieces you think are important.

This is as much fun as pulling teeth.

...R