Turning Eggs

Howdy …I’m also a newbie … working on a incubator and need something to turn my eggs every 3 hrs or so … got hold of some threaded rod, two bearings and built an actuator of sorts but included 2 limit switches … thats all hunky dory but not too sure on the programming side …could one of u check it for me and make a suggestion?

#include <Stepper.h>
const int spr = 200; //steps per revolution
int limittop = 12; // pin for top limit switch
int limitbottom = 13;//pin for bottom limit switch
Stepper mystepper(spr, 8, 9, 10, 11);
int count = 0;

void setup() {
Serial.begin (9600);
pinMode(limittop,INPUT);
pinMode(limitbottom,INPUT);

}

void loop() { // I know i don’t need a count …but when compiling it it kept giving me an error … with the count it compiles …
for (digitalRead(limittop) = LOW; count++;) {
mystepper.step(spr);
delay(100);} //top section just moves it up to top limit and backs it off a tad…waiting 3 hrs then hopefull reverses
mystepper.step(-spr);
delay(10800000UL);
for (digitalRead(limitbottom) = LOW; count++;) {
mystepper.step(-spr);
delay(100);}
mystepper.step(spr); // bottom section moves down to limit …stops moves back a tad waits 3hrs …loop will start again!
delay(10800000UL);

}

not trying to do anything complicated …just move up …wait 3 hrs …then move down and wait 3hrs … if there’s a power cut … hopefully it will just reset and move to the top switch again …any suggestions??

Howdy …I’m also a newbie … working on a incubator and need something to turn my eggs every 3 hrs or so … got hold of some threaded rod, two bearings and built an actuator of sorts but included 2 limit switches … thats all hunky dory but not too sure on the programming side …could one of u check it for me and make a suggestion?

#include <Stepper.h>
const int spr = 200; //steps per revolution
int limittop = 12; // pin for top limit switch
int limitbottom = 13;//pin for bottom limit switch
Stepper mystepper(spr, 8, 9, 10, 11);
int count = 0;

void setup() {
Serial.begin (9600);
pinMode(limittop,INPUT);
pinMode(limitbottom,INPUT);

}

void loop() { // I know i don’t need a count …but when compiling it it kept giving me an error … with the count it compiles …
for (digitalRead(limittop) = LOW; count++;) {
mystepper.step(spr);
delay(100);} //top section just moves it up to top limit and backs it off a tad…waiting 3 hrs then hopefull reverses
mystepper.step(-spr);
delay(10800000UL);
for (digitalRead(limitbottom) = LOW; count++;) {
mystepper.step(-spr);
delay(100);}
mystepper.step(spr); // bottom section moves down to limit …stops moves back a tad waits 3hrs …loop will start again!
delay(10800000UL);

}

not trying to do anything complicated …just move up …wait 3 hrs …then move down and wait 3hrs … if there’s a power cut … hopefully it will just reset and move to the top switch again …any suggestions?? ps limit switches are on …’‘normally open’’ … so when button pushed will turn high with 5v … stepper motor and driver are … 28byj 12volt which i’m connecting externally with uln 2003 driver …

20K-farmer:
Howdy ...I'm also a newbie .... working on a incubator and need something to turn my eggs every 3 hrs or so

As this is a completely new question I have suggested to the moderator to move your Post to its own Thread.

...R

Thread split.

20K-farmer:

void loop() { // I know i don't need a count ...but when compiling it it kept giving me an error .. with the count it compiles ..

for (digitalRead(limittop) = LOW; count++;) {

I guess the real solution is not to use FOR in this case.

What are you trying to achieve with the FOR? Perhaps IF would be suitable?

...R

I’d rewrite it using a switch/case. There are three possible motor conditions: 1. Off; 2. Move left; 3. Move right.

Make states 1-4. Case 1 drives the motor left until the limit switch is hit then backs off and stops, state variable is set to ‘2’ and the state ‘1’ ends. State ‘2’ enables a three hour timer. When timer is done, state is changed to ‘3’ which runs motor right, etc.

Suggest you use a 'gear motor' instead of a 'stepping motor'.

.

Instead of a for(;; ) you should use a while(). The for(;; ) has three parts, the init, the conditional, and the increment. You put your conditional in the init, and an increment in the conditional.

Try this:while (digitalRead(limittop) == LOW) {

As long as you're using pull-down resistors on your limit switches, it looks like it should work OK.

Robin 2 ... no prob ... still learning my way around here ..cheers mate! yea ..thought about it ...thinking i'm going to go with a ''while statement ''' ...while the limit switch hasn't been touch ...keep moving in a direction....

dougp ... not to sure on how to use the switch case yet ... will read up on it ... programmed turbo pascal back in the late 80's early 90's ... 30 odd years ago ... still wiping off the cob webs here !!!

larryd ... already been geared ...4 revolutions of the stepper will only raise the lifter about 1mm on the threaded rod and i have about 160mm of travel... my trays that hold the eggs are pretty well balanced and i don't need it to lift much ... i have more than ample torque! Got nema23's if i really wanna get serious and lift the entire incubator!

Jimmus ... yip... realise that now, force to do some reading ... think you spot on with that comment ... more up my ally too!

Thanks for all the posts ...appreciate it!

here’s the basic set up … just imagine two limit switches at either end!

Moderator edit: add img and url

20K-farmer:
//top section just moves it up to top limit and backs it off a tad...

What's the reasoning behind this?

20K-farmer:
thinking i'm going to go with a ''while statement '''

I try to avoid WHILE and FOR loops unless I know they will complete in a millsec or two as they block other actions.

Allow loop() to do the repetition - that's what it is for - and use IF the check when the condition has been reached.

If all you want to do is move from one limit switch to the other that can be done with very simple code like this pseudo code

void loop() {
  checkSwitches()
  updateDirection() // based on whether a switch is pressed
  moveOneStep() // in the direction already set
}

...R

Ok decided to add pics so u guys can see whats what .... the first pic is the incubator ... 2 tilting spring loaded shelves that just need to be tilted ... attached to the top shelf is a cable that extends out the top through a small vent hole ... pointless keeping the arduino in 60-70 percent humidity !!

Second pic ( in the next post ...file too large) is the actuator i built ... it is the same setup as a commond x-axis you'll find on any cnc machine ... the reason i built it in this fashion is purely to increase the torque ... as the stepper spins ... it spins the threaded rod ... which inturn raises or lowers the "nut" ( black nylon rectangle) ... i havent included the limit switches but one would be at the one end (lets call it the top ..) and the other at the other end ... so when the nut is lifted .. it will activate the limit switch and let it know that it has reached its top ...

Thats it !! The incubator is already a function unit ...i have other controls for temp ...humidity etc .. i just need it to tilt the rack ... keep it there for 3-4 hours .. then release it so the spring pulls it back down where its kept for 3-4 hours before the cycle begins again ... i could put in a large wheel that would pull the cable up and down ... but then id loose torque

Pic 1

Neither pictures nor links to them are visible.

20K-farmer:
in the next post ...file too large

Do us a favour and reduce images to 640 x 480 (or 1280 x 960 max) before posting

...R