Dual Sensors On Production Line Question

Hello and thank you for your time and help,

First, I'm completely new to programming Arduino, but I have worked through a few projects with the help of these forums and Google... my code is usually an ugly, slightly buggy, Frankenstein mix of what I can piece together from others.

I have tried searching for a solution to my latest project, but nothing has worked out so far. I'm hoping someone can help me get started and then I can learn/expand from there.

  1. I have a tube that will be filled with ball bearings.
  2. Two line break sensors will detect the presence of ball bearings in the tube.
  3. When Sensor #1 does NOT detect a ball bearing, a stepper motor is activated to start filling the tube with ball bearings.
  4. Stepper motor stays on while the tube is filled and until Sensor #2 detects ball bearings.
  5. when Sensors #1 & Sensor #2 both detect ball bearings the stepper motor is shut off.
  6. The procedure restarts and waits until the ball bearings are emptied from the tube.

The problem I foresee is that while the tube is filling, the ball bearings fall past Sensor #2 in order to fill the tube. Soooo, the code needs to verify that the ball bearing is blocking Sensor #2 because the tube is filled and NOT because a ball bearing has simply fallen past the sensor.

Any help would be appreciated!!!

Thanks,
Mike

Hello usarpa

Post a timing or state diagram to see what should happens and a picture of the hardware setup.

A picture is always worth a thousand words.

1 Like

Do you have experience with any other type(s) of programming?

So it needs to distinguish between being briefly blocked by a passing ball, and being permanently blocked by a static ball ...

Make a pause in filling to prevent falling bearing interact with sensor and read the sensor again.

Indeed.

@usarpa and drawing a picture (such as a state diagram) is a very good way for you to clarify your own understanding of the problem - very often, it will lead you to answer your own question!

Thank you for the fast reply,

I will work on a state diagram and picture when I get back to the shop.

Thanks again for the help!

Thank you for the fast reply,

Firstly, I have very little programming experience. (the way I worded it makes it sound otherwise, my apologies for that)... I have "coded" multiple solutions in the past, but always with the help of others and Google. Most of my projects require simple code and I can usually make it work" from existing code or suggestions

Second, Yes, that is correct, I need to distinguish between a brief line break as opposed the a sustained line break.

Thanks again,
Mike

Another possibility is to fill unconditionally: When sensor one doesn't see bearings, run the stepper for three seconds (or whatever you decide by experiment). Wait five seconds and check sensor two. Repeat as necessary.

You may want to look at a state machine to control this.

Yes, I'm working on creating a diagram that will show the logic and also a picture to help clarify.

Thanks so much,
Mike

That may be a good workaround...

So... When sensor #1 does not detect an object, run the stepper for a set amount of time (stop the stepper to avoid false positives).
Then enter into a conditional statement that checks Sensor #2,

IF blocked, THEN stop stepper, ELSE run stepper for set amount of time again?

Do I understand that the way you suggest?

Mike

Yes. Be careful though if your code needs to do other things - such as stop perhaps. Don't get locked into waiting for the bearings if your program has additional responsibilities.

Also, keep count of how many filling cycles you have done since you noticed you were low. A large number may be an indication that something is wrong.

1 Like

Make a pause in filling to prevent falling bearing interact with sensor and read the sensor again

I've had to solve this problem before and this is the simplest approach. If it doesn't work (e.g., you need to fill at high speed), there are other methods, but I'd try this first.

1 Like

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