Go Down

Topic: Copy code directly from the UNO (Read 2363 times) previous topic - next topic

cattledog

Try adding the pump mode condition to the repeat timer section, and not the generic auto start. The auto start should work independent of mode on start up but not be reset with the repeat dose timer.

Code: [Select]
//add repeat timer section
  static unsigned long interval = (24 * 3600000UL / (menu[7].value)) / TimeCorrect ; //10000;
  //static unsigned long interval = (24.097 * 3600000UL / (menu[7].value)) / 1.0;//This line possibly messed with the LCD characters
  static unsigned long lastTime = millis();
  if (millis() - lastTime > interval)
  {
    Serial.print("repeat timer interval ");
    Serial.print((millis() - lastTime) / 1000);
    Serial.println(" seconds");
    lastTime += interval;
    //auto_start = true;
    if (menu[4].value != 1)
      auto_start = menu[6].value;
    //menu[6].value = 1;
  }

  if (auto_start == 1 && menu_number_1 == 0) //auto_start only in Start menu
  {
    Serial.println("auto_start");
    b = ClickEncoder::Clicked;
    auto_start = 0;
  }


I'm not certain if you need to address the cal mode. You may want to try this which will only have the reset for periodic dosing

Code: [Select]
//if (menu[4].value != 1)
    if (menu[4].value == 0)
      auto_start = menu[6].value;

sisterlimonpot

#76
Jun 20, 2019, 12:09 am Last Edit: Jun 20, 2019, 12:11 am by sisterlimonpot
You are a godsend!!

in menu[4], Cal. option is hidden, I calibrate a different way... instead of calibrating to 1mL, I calibrate to 20mL. A little more accurate. then I tell it to dose 500mL to fine tune it... It's a bit barbaric and time consuming but it works surprisingly well for me.


Can you explain the difference between these 2 lines?

Code: [Select]

if (menu[4].value != 1)


if (menu[4].value == 0)


No matter which one I choose, they operate the same.


cattledog

Quote
Can you explain the difference between these 2 lines?
Code: [Select]
if (menu[4].value != 1)


This says if menu[4].value is not set to pump. It could be set to dose or cal. and it will re-trigger the auto start on the timer in both these modes.

Code: [Select]
if (menu[4].value == 0)

This says if menu[4].value is set to dose. It will only retrigger the auto start on the timer in dose.

Quote
No matter which one I choose, they operate the same.
It probably depends on the dose frequency and the length of the pump time or cal time.

Quote
in menu[4], Cal. option is hidden, I calibrate a different way...
If you never set the cal mode in menu[4] it does not matter.



 

sisterlimonpot

How hard would it be to add a ramp up to the code? I notice that a lot of times when it starts up, it clicks a lot and loses steps, thus losing accuracy.

cattledog

#79
Jun 26, 2019, 08:55 pm Last Edit: Jun 26, 2019, 09:23 pm by cattledog
It may be possible but not simple. Starting from scratch you would probably use AccelStepper.h  but I'm not sure that could be patched into the code base you have.

You may be able to modify the delay_us value as a function of count or time in pump or dose in this section. I'm not certain about cal and have not really looked at it.

Code: [Select]
boolean dose(long _steps, int _delay_us, long & inc) {
      if(inc < _steps){
        digitalWrite(MOTOR_EN_PIN,LOW);
        delayMicroseconds(_delay_us);       
        digitalWrite(MOTOR_STEP_PIN,HIGH);
        delayMicroseconds(_delay_us);
        digitalWrite(MOTOR_STEP_PIN,LOW);
        delayMicroseconds(_delay_us);
        digitalWrite(MOTOR_EN_PIN,HIGH);               
        inc++;
        return false;
      } else {
        inc=0;
        return true;
      }
}

void pump(int _delay_us) {
        digitalWrite(MOTOR_EN_PIN,LOW);
        delayMicroseconds(_delay_us);       
        digitalWrite(MOTOR_STEP_PIN,HIGH);
        delayMicroseconds(_delay_us);
        digitalWrite(MOTOR_STEP_PIN,LOW);
        delayMicroseconds(_delay_us);     
        digitalWrite(MOTOR_EN_PIN,HIGH);       
       
}



If you run the pump at the slowest speed available to you through the menu, does it miss steps at startup?

I understand the driver is a Pololu DRV8825. Can you provide a link to the motor and its specifications?

Do you know the torque required to start the rotor and how that compares to the motor specification?

Do you have a second pump\driver\arduino available as a test bed where you can play with things independent of the iGEM/Aachen code?

EDIT: Can you gain access to the driver to modify the jumpers for microstep setting? I believe you are currently set for 16. You should have more torque at lower settings. The code was originally written for 4.


sisterlimonpot

#80
Jun 27, 2019, 08:14 am Last Edit: Jun 27, 2019, 08:18 am by sisterlimonpot
If you run the pump at the slowest speed available to you through the menu, does it miss steps at startup?
No, It doesn't start skipping at start up until 50.0 ml/min, however once it gets going it's fine. When there isn't a load on the motor, it will start at 160ml/min (Don't know the RPM's or steps off the top of my head). When there is resistance in the form of peristaltic tubes, then it clicks and misses steps,

Quote
I understand the driver is a Pololu DRV8825. Can you provide a link to the motor and its specifications?
I purchased the stepper off of Amazon, it's a 17HS4401, this is all the info on the site:

Product Parameters:
Product name: Bipolar 42 Stepper Motor
Holding torque: 0.46 Nm/ 65 oz-in
Working voltage: DC 9-42V
Rated current: 1.7A
Resistance: 2.1 ohm
Inductance: 4mH
Rotor inertia: 55gcm2/ 0.30oz-in2
Weight: 0.28kg
Length: 39.5mm/ 1.56 inch
Phrase: 2
Step angle: 1.8°
Motor frame size: 42*42mm




Quote
Do you know the torque required to start the rotor and how that compares to the motor specification?
No I don't, I'm sure that there's better info out there.

Quote
Do you have a second pump\driver\arduino available as a test bed where you can play with things independent of the iGEM/Aachen code?
I have to build another one, I have everything necessary, give me 2 days and I will have it up and running.

Quote
Can you gain access to the driver to modify the jumpers for microstep setting? I believe you are currently set for 16. You should have more torque at lower settings. The code was originally written for 4.
What I can do is when I build this one (unless you tell me otherwise), I can connect M0-M2 to open outputs on the ardiuno so that all we have to do is change the code to attain different step resolutions.

EDIT: It doesn't appear that there are 2 free digital inputs for the 2 extra connections. perhaps a switch???

cattledog

Quote
No, It doesn't start skipping at start up until 50.0 ml/min
Good news. You know that there is a step rate solution to the start up.

Quote
Quote
Do you know the torque required to start the rotor and how that compares to the motor specification?
No I don't, I'm sure that there's better info out there.
Can you get a torque wrench on the pump head with the tubing present?

Quote
Rated current: 1.7A
One thing I have noticed when looking at the specifications/user info for the DRV 8825 is the current limiting pot/reference voltage. Do you know where it is set?
What voltage is running the motor, and what is the power supply?

Quote
What I can do is when I build this one (unless you tell me otherwise), I can connect M0-M2 to open outputs on the ardiuno so that all we have to do is change the code to attain different step resolutions.

EDIT: It doesn't appear that there are 2 free digital inputs for the 2 extra connections. perhaps a switch???
Regarding the investigation of microstep setting and startup torque, getting the flexibility of easily changing the setting is good. If you are limited for digital pins, you can always use the Analog pins as digital. Switches would be fine as well.

sisterlimonpot

Can you get a torque wrench on the pump head with the tubing present?
Hmm, I have an in/lb torque wrench (click type) but I don't have a deflector beam one in in/lb (which is really the only range needed in automotive)

Quote
One thing I have noticed when looking at the specifications/user info for the DRV 8825 is the current limiting pot/reference voltage. Do you know where it is set?
0.65v which if I understand it correctly is limited to 1.3A.

Quote
What voltage is running the motor, and what is the power supply?
The power supply is a 12v 5a brick. I don't know how to measure voltage to the motor without a scope, I have one that is part of my snapon modus and if I need to get it out, I can.

Quote
Regarding the investigation of microstep setting and startup torque, getting the flexibility of easily changing the setting is good. If you are limited for digital pins, you can always use the Analog pins as digital. Switches would be fine as well.
If I knew that the analog could be converted to digital, I probably would have done that from the get go. I'd prefer connecting all them so that it can be changed through code.


cattledog

Quote
0.65v which if I understand it correctly is limited to 1.3A.
That's my understanding as well.

The Pololu information says the driver can supply up to 1.5A per phase without added cooling. The motor is 1.7A rated.
Limiting the current to 1.3A may be overly conservative and will limit torque. I'd certainly try to see if there is improved starting performance at 1.5A (.75v reference).

Increasing the current and decreasing the micro-stepping may get you where you want. What is the flow rate you are trying to start at without missing steps?

If not we'll have to investigate how to get the startup below 50ml/min (or whatever the new performance limit is with the hardware changes) and then ramp it up.

cattledog

I'd like to understand the missing steps issue a bit more.

It is my understanding that if steps are missed, the motor will jump to a full step position.

Clearly this can affect fine positioning or two axis diagonal movements when the stepper is used for this purpose. With a peristaltic pump, I would think that the total fluid dispense would be independent of how smooth the startup happens. The rollers are still moving over the same length of tube, just not in fine increments. Micro dosing could be an issue with fine positioning at the end count, but this is a stopping issue and not a starting one.

You may not like how the motor sounds, but I'm not clear that start up skips are are truly an issue for dosing accuracy.

Do you have any data on the magnitude of the problem you are seeing. For example if you are trying a specific dose at the 50ml/min rate with no start up skips, and another at 200ml/min with start up skips, what is the difference in dosing?


sisterlimonpot

That's my understanding as well.

The Pololu information says the driver can supply up to 1.5A per phase without added cooling. The motor is 1.7A rated.
Limiting the current to 1.3A may be overly conservative and will limit torque. I'd certainly try to see if there is improved starting performance at 1.5A (.75v reference).

Increasing the current and decreasing the micro-stepping may get you where you want. What is the flow rate you are trying to start at without missing steps?

If not we'll have to investigate how to get the startup below 50ml/min (or whatever the new performance limit is with the hardware changes) and then ramp it up.
I bumped it up to 0.8v. (1.6A)that pot is extremely touchy.

I'd like to understand the missing steps issue a bit more.

It is my understanding that if steps are missed, the motor will jump to a full step position.

Clearly this can affect fine positioning or two axis diagonal movements when the stepper is used for this purpose. With a peristaltic pump, I would think that the total fluid dispense would be independent of how smooth the startup happens. The rollers are still moving over the same length of tube, just not in fine increments. Micro dosing could be an issue with fine positioning at the end count, but this is a stopping issue and not a starting one.
Pretty much as you described with the exception of the resistance in the double headed pump is too much to the point that it clicks but fails to rotate. I'm uploading a video to show you what's going on.

Quote
You may not like how the motor sounds, but I'm not clear that start up skips are are truly an issue for dosing accuracy.
It can be when it misses an entire dosing period and fails to rotate to dose the acquired amount.

Quote
Do you have any data on the magnitude of the problem you are seeing. For example if you are trying a specific dose at the 50ml/min rate with no start up skips, and another at 200ml/min with start up skips, what is the difference in dosing?

I wish I could get it up tp 200ml/min, if it could ramp up, I'm sure we can get it to speeds faster than that, however at that point I would be concerned with heat caused by friction prematurely wearing out the PharMed tubing. I think the video will answer the question as to why this test wouldn't yield anything other than the obvious conclusion.


http://www.youtube.com/watch?v=A4PR283_LRA


As you can see in the video, after I give it some assistance, it does the job. When I set it to dose 3ml it fails to do so at that speed. I lower it by 10ml/mil until it can run freely.

Do you agree that a ramp program will fix the problem?



cattledog

Thanks for the video. Clearly there is a mismatch between the starting torque required and the motor. You have already increased the current by 20%.  Maybe, just maybe, the microstep setting will help. I also do not understand the difference seen in the video of the startup when you were decreasing rates to get the pump to run, and then when you began increasing the rate. The pump showed different abilities. Is the startup torque dependent upon the resting position of the rotor?

Quote
Do you agree that a ramp program will fix the problem?
If there is always a minimum speed setting that starts reliably, then a ramp from that speed should work. Whether or not we can patch the ramp into the beast of a program you inherited from iGEM/Aachen is a different matter.

The pump performance in the video looks completely different from the what was shown in the two Reef2Reef threads about the pump and your tank.

https://www.reef2reef.com/threads/my-rendition-of-300.550019/page-5

https://www.reef2reef.com/threads/my-version-of-a-diy-paristaltic-pump.525792/

The pump head looks different from the yellow rotor model seen in the previous videos. It looks like there is a cover and outer bearing? What else is different? If the tubing inside is dry and not wetted, does that make a difference?

It looks to me like there has been some mechanical change from the previous pump head that has put you into a very different place where the motor torque is totally inadequate. If you could get a torque wrench on the rotor you could investigate. I do not believe you would have gotten this far in the project if this was the performance from the beginning. Some of the startup flow rates in the previous videos are well within the current stall range.

I will take a look at patching the software, but I am not optimistic, particularly as there are the pump, dose, and cal modes to fix and the run code is somewhat different in the three modes.

Can you get back to the earlier pump head? Can you find a stronger motor which fits the mechanical frame? If you are totally limited to the current pump head design and motor, then you may have to operate the system at the low flow rate which works reliably.

sisterlimonpot

Quote
I also do not understand the difference seen in the video of the startup when you were decreasing rates to get the pump to run, and then when you began increasing the rate. The pump showed different abilities. Is the startup torque dependent upon the resting position of the rotor?
I can only think of 2 scenerios: once the pharmed tube warms up, it has less drag on the motor. The other is that once the motor gets to an operating temperature, it performs with better torque.

One way to rule out one scenario is like you said, to measure the rotational drag with a torque wrench, on a 'cold'  pump verses one that has been running for 10 minutes.

I can make an adapter to fit a 1/4" beam type torque wrench onto the extruded portion of the rotating head. I will just make a visit to one of the auto parts stores to get a cheap torque wrench. If not Amazon sells them and I can have it here in 2 days.

Quote
The pump head looks different from the yellow rotor model seen in the previous videos. It looks like there is a cover and outer bearing? What else is different? If the tubing inside is dry and not wetted, does that make a difference?
This newer pump has 2 pharmed tubes that it has to push/pull liquid through. I made this one for automatic water changes, it was given the bigger stepper motor (the older one was a 0.4A motor) and the new design to accommodate the extra components. One tube removes old tank water while the other adds new salt water. Due to location of where the pump has to sit, one tube assembly will be doing a lot of pulling and the other will be doing mostly pushing. Which required independent occlusion adjustment to get them to equal fluid volume, hence the robust design. The outer bearing was added as a support to prevent wobble.

Quote
The pump performance in the video looks completely different from the what was shown in the two Reef2Reef threads about the pump and your tank.
that video was shot after hours of use, It was well 'warmed up' at that point. Plus, I haven't adjusted the occlusion on either of the separate tubes.

Quote
Whether or not we can patch the ramp into the beast of a program you inherited from iGEM/Aachen is a different matter.
that made me laugh.

Quote
Can you get back to the earlier pump head? Can you find a stronger motor which fits the mechanical frame? If you are totally limited to the current pump head design and motor, then you may have to operate the system at the low flow rate which works reliably.
All of these are options.

If ramp up couldn't be added then operating at a lower speed was going to be the bandaid fix, or simply set the speed to 8ml/min and have it run 24/7 to change out roughly 3 gallons a day.

With the current state of the code and design, I can easily have the job performed by 2 pumps instead on one with exacting accuracy.

I can also redesign the entire box and accommodate a larger neman 24 motor. If I were to step up the motor, then cooling would have to be added, and i'm not sure if the current electronics would be capable of handling the larger motor, I guess if I stayed at 12v and simply upped the amperage, I could get away with the current equipment. Would you agree?


cattledog

#89
Jun 28, 2019, 08:20 pm Last Edit: Jun 28, 2019, 08:22 pm by cattledog
Thanks for all the clarifications.

I think that quantifying the torque requirements on the new dual tube pump head is the place to start. When you understand the motor requirments and all those implications, you can make decisions about the best design--dual tube, dual pump, slow operation, etc.

Quote
I can also redesign the entire box and accommodate a larger neman 24 motor. If I were to step up the motor, then cooling would have to be added, and i'm not sure if the current electronics would be capable of handling the larger motor, I guess if I stayed at 12v and simply upped the amperage, I could get away with the current equipment. Would you agree?
The DRV8825 can supply 2.2A with cooling for the IC. so that may be marginal for a larger motor. I think you have a 12v/5A power supply.

Quote
that made me laugh.
It made me cry  :P

I think the first and easiest place to start would be with the pump mode which is continuous and the ramp in delay_us can be made dependent on time, and not steps.
I have some ideas on on how to do this, so I'll give it a shot.

Does it sound OK to ramp up to final pump speed over 1 minute?
Does the pump always start at 8/ml min or is there a higher value which is safe to use?

One thing I would like to understand is how do you exit pump mode, and actually stop the pump. Is there a menu selection procedure other than simply turning off the power?

EDIT: Please attach the current version of the code to your next post.






Go Up