I'm new to programming and I can't get my head around this problem I'm trying to figure out, I thought it would be a simple program but obviously way pass my knowledge level...
If it is as easy as i thought i would be can someone write the program and a quick explanation of how it works so i can learn from this?
What i'm trying to do is control an egg turner without using any delay()
so basically i wanna add limit switches at each end so when it hits the limit switch, it will pause for an hour then resume turning to motor till it reaches the other end and hit the limit switch and pause for an hour and continue that process forever.
The egg turner motor keeps spinning in one direction with a lever that makes the egg trays rock back and forth so i don't need it to reverse the motor, just to resume after an hour.
i get totally lost when i'm trying to figure out what the program should be doing while its at one end holding that limit switch in a high state. I can't write the switch low while its being held pressed high by the egg turner...
my plan is to use Arduino nano, relays, and micro limit switches that can be wire either normally open or normally closed.
anyone know how this can be done?
Total noob here so I apologize in advance if this is actually simple , I've been reading on limit switches and egg turner programming and a lot of ppl just use timers but its not very precise... they eventually go out of sync and don't rotate perfectly 45 degrees to one side then 45 to the other side.
plz help! this is one challenge that is kicking my behind. I swear i'm laying in bed trying to figure this out and my wife thinks i'm thinking of other women lol
what is the specification of the motor, e.g. voltage, current, etc
recommend you use hall-effect-switches to detect the limits - this removes the possibility of switch bounce
draw up a description of the sequence of events using pseudo-code - this will help when you finally implement code
this the exact egg turnerhttps://www.amazon.ca/Digital-Automatic-Plastic-Universal-Incubator/dp/B0BX5GD75Y/ref=sr_1_5?crid=2ZW9V36CLMW9E&dib=eyJ2IjoiMSJ9._2DMEfvUFaKeQrmk3ob5t5u5Ye-L-moOdSj4vpHTUZI9fV7iSMxkHy_XhoN7SiO42qyQWVdJ70La_y0ttAHVDR-FtxfMZDSEwrqBp9Bmp8pRPpaeV4Y3eViPMhMICAgjypAnm6wxNDgmIvBisH8-vaXcchsfQtZ9fI-M_CUys1Ga_pT7kBW8KP5eJbQHCzk-TULNOvUWhhTI5RI3Vyy2476oje9kE8Ignmx7PhnNlD_wQyjdPlQy1uElOytzwmeeQiz7aSVtcrj4vfo7E-7yqJn1ZhUn-fqyEqlFR55mcBUbpVnGqB4mFuID4DwY3qbVfQGvC66hVAdv0jFlzXNQ0vktKJvVGZSDshhlWxZaB46PYwMKWiYtLcfbBi847-FfLF57OspTrw1whyA0slU4k3rEH3d3GaRlE4FaQRtvjjwVd7ug2S13v2VQVpCYKr36.GGJ5lmXS11RtdMq6xHtuy_n606wj5P_FKvf4JN0FsGg&dib_tag=se&keywords=egg+turner+incubator+12v&qid=1743143072&sprefix=egg+turner+incubator+12v%2Caps%2C174&sr=8-5
I have a 110v to 12v power supply to power them via relay and now i'm gonna go look into this hall- effect switches. thank u
I just realized the link has a 110v motor but mine is identical but the motor is 12v , I also have some that are 110v. but I do have power supplies for them, and I control from Arduino with relays.
sounds like you have already been experimenting with controlling the motors using an Arduino
post your code indicating what it does and what you would like it to do
use code tags </>, e.g. select “Edit>Copy for forum” then select < CODE/ > and paste the code or text where it says “type or paste code here”
Is it a half/180° turn with pauses between?...or does just 'rock' back, pauzes..., 'rock' forth,..etc?
Never used them but seem to me they could do the job (simple scematic).
To controle the motor just use a optocoupler 5V/mosfet 12V circuit (lots examples on the internet and copilot can help to). You can buy these on a small pcd, ready to use.
Easy peasy.
Rather than the relay use a MOSFET module to control the motor, it will last for ever.
You can still use the relay if you wish. I can show you how to wire the components.
You can find this module in different places like amazon, ebay etc.
To learn to code, put some time in it. There are a lot of tutorials that are good. The ones with video (youtube or other) take; it seems; the most time but you'll get it faster.
In the Arduino IDE there a lots of examples and these examples are elaborated on the Arduino website. The same goes for, for example, the Elegoo Arduino tutorials that go with the super starter kit (link on the same page).
I've just started watching on youtube this one/channel to get some details straight in my current knowledge (because i'm a semi beginner myself). Sometimes he is letting out some details but if that happens and you want to know more, just type it in your search bar.
Your project should be easy for me. Especially the code. But i'm not going to create it for you. No one will on this forum.
I'm working on my own project and before that i tried a few small things to get somewhat the hang of it like recreating the first tutorials and 'tweaking' them.
Hopefully after trying out some tutorials you'll be triggered to try some other stuff on your own.
should work
I tend to attach a small powerful magnet to the moving component and the hall effect switch to the fixed component
connect switch to a microcontroller GPIO input and loop waiting to detect 0/1 change when appropriate action is taken
No. That's not how the forum works. The forum knows that if you are simply given working code, you won't learn much. If you write the code, with help and assistance from the forum, you will learn far more.
If you want to pay for someone to write the code for you, we can move your topic to a special section of the forum so you can discuss payment. (I am not recommending this, I personally would not trust those that offer to help for payment. Some may be dishonest. Others may be sincere but over-estimate their own skills and abilities.)
This description makes no sense to me. If the motor is at a limit, and is not reversed, how can it resume? How can the other limit switch ever be activated?
EDIT: ok, I think I may have got it. It's not clear from the product description you linked, but I think that motor must have a high-ratio gearbox so that it turns very slowly, and turns a rotating arm with a spike that fits into the vertical slot that can be seen on a plastic bar in the images. So your limit switches would be at the ends of the bar?
If so, I think one limit switch should be enough. The other extreme can be done with timing.
The "egg turner" linked by the OP actually rocks the eggs +/- 45 degrees or so, but has the same effect as turning the eggs. Other egg turners do actually rotate the egg completely. It seems that the motor continuously rocks the eggs, I guess if you were running from a battery this may seem unnecessary.
I don't really see there is a need for any switch; just run the motor for 30 seconds or so to get a couple of rocking cycles, then wait for an hour or whatever. I doubt it matters whether the egg is pointing exactly straight down or at an angle while at rest.
It should be marking time, that is to say waiting for one hour to pass.
This is easy enough to do easily and would also be fun to take a bit more sophisticated approach.
loop
trundle left until the left limit switch is hit
do nothing for one hour
trundle right until the right limit switch is hit
do nothing for one hour
You've said the motor turns one way only, so it's even simpler
loop
trundle until either limit switch is hit
do nothing for one hour
The key is being able to see when the switch becomes pressed, not when it is being pressed.
This is a basic concept it will be worth getting your head around. It is referred to as "edge detection" or "state change detection". There is a demonstration of this in the IDE examlkes and it links to a competent article on the subject.
Fortunately there are also several many other people who have covered the same idea. Multiple perspectives can be helpful; one explanation may land better than another for you.
And if it would be easier to just let the motor spin in both directions (if the egg turner allows it): Arduino/H-bridge IC tutorial
I was intrigued and went searching and found a H-bridge to let the DC motor spin in both directions (reversing polarity at the two dc motor wires). After figuring the H-bridge out (and even leaning what a flip flop is!) i thought 'hmm would there be a IC version of this H-bridge?'. And yes!
Even found an Arduino tutorial with this chip!
So by trying to make a contribution here i have learned something to!
The only thing i need to figure out is to use only one GPIO pin to control the motor (&change the spinning direction). Maybe that's not so safe for the h-bridge when changing polarity super fast. I the youtube example they use a delaytime between reversing direction.
and it never stops (i'm deeeeep in the rabbit hole). While i was ordering some pieces and components for myself. ==>How to connect a ready-to-use mini board with optocoupler and mosfet:
No not at all, i'm trying to help and i'm stumbling on some to-the-point info that is also interesting for me. If i had someone, helping me like this for my project i would be very happy. Especially with some ready to use stuff to experiment with (without handing over the complete solution with schematic and code)
I was happy to finally be able to make a contribution to equalize the 'balance' a bit (and to show off & looking like a experienced one).
did that al lot...and still doing...and here we go, three non relevant posts...
Still thx for all the contributions you have already delivered on my topics! Your the master, i'm the apprentice.
the motor keeps turning in one direction with a lever attached to a rocker arm so it will rock the eggtrays back and forth like a baby in a crib. i just wanna add limit switches at each end so once it rocks one way and reaches to point before it starts going the other way, it'll hit the limit switch and tell it to pause the rocking for 1 hour, then resume to motor till it rocks the other way and hit the limit switch on the other side and pause for an hour.
is there a way to upload video on here?