Pick and Place automatic feeders controller

See this post by me first to get some background on this project: Designing motherboard for PNP auto feeders? - Page 1

I am new to Arduino so I am wondering how feasible is this and can it be done with just Arduino code or do I need C/C++? I was thinking of using Arduino Mega 2560 as explained in that post due to the large number of pins and have it communicate with OpenPNP software: openpnp.org using Gcode to activate individual #Z feeder to advance X distance at Y speed.

Where should I get started? My coding skills are beginner, but at the same time, if I am learning Arduino, I would prefer to know the direction or topics I should focus on so I don’t try and cover too much territory at once, but rather learn with examples that relate to this application.

Any suggestions on how I should go about making/programming this?

Arduino code is C++.

Do you have a good design for the hardware already?

Don't expect people to try to follow two different conversations on different websites. Please put all the info here that is relevant to any advice you want from this Forum.

You have not told us what you want your Arduino Mega to control - without knowing that it is hard to see how we can help.

And you have not told us what the OpenPNP software will do and what are the relative roles of it and of the Mega.

...R

My apologies for linking an external thread. I can explain.

OpenPNP uses Gcode to drive the feeders. The motherboard of the feeders would need to receive the Gcode, parse it and activate a specific feeder # to pull the cover tape off until the tape advances x mm distance. Distance feedback is provided via an encoder that has two springs, which short themselves when they touch a pad to signal the motherboard that the tape has advanced x pitch. See pic.

Any help on how I can go about programming this or direction would be greatly appreciated.

Thanks!

shai:
OpenPNP uses Gcode to drive the feeders. The motherboard of the feeders would need to receive the Gcode, parse it and activate a specific feeder # to pull the cover tape off until the tape advances x mm distance.

That sounds like a job that could be done by the GRBL program which is designed for CNC projects.[

Distance feedback is provided via an encoder that has two springs, which short themselves when they touch a pad to signal the motherboard that the tape has advanced x pitch.

That sounds more like a limit switch than an encoder. An encoder produces pulses as something moves and the Arduino would need to count the pulses to know how far the something has moved. A limit switch is much easier to deal with.

But you still have not described the project in any useful way -
How many feeders?
From the Arduino's perspective what is a feeder? If it is a stepper motor then exactly what stepper motor and stepper motor driver?
What level of precision is required?

Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Upload Guide

...R

Hi robin,

Thanks again for offering to help. Seems you're a star on this forum!

You are correct that it acts more as a mechanical switch rather than encoder. Each click should be pre-programmed to equal a certain distance. There is no stepper motor being used here, just a regular N20 DC motor that isn't capable of any steps (hence the need for an "encoder").

Feeder number may change, but let's say 20 to begin with just for the sake of the entire thing working. I understand there's a limit depending on processor, etc.

The level of precision would be as follows:
If there's for example 36 pads on the sprocket, then that would mean 10 degrees between each pad (or "limit switch click"). The 10 degrees would have to be set in config as equaling a certain distance or rather pitch. This way when OpenPNP sends Gcode to move the tape a certain distance, it's converted to amount of clicks. So perhaps degree isn't necessary here, just distance = # of clicks.

If you still need something cleared, please let me know. I would love some guidance on how I can go about writing this program to control the feeders.

shai:
Feeder number may change, but let's say 20 to begin with just for the sake of the entire thing working. I understand there's a limit depending on processor, etc.

Start with a single feeder. Don't even think of more until you can get one working reliably.

The level of precision would be as follows:
If there's for example 36 pads on the sprocket, then that would mean 10 degrees between each pad (or "limit switch click"). The 10 degrees would have to be set in config as equaling a certain distance or rather pitch. This way when OpenPNP sends Gcode to move the tape a certain distance, it's converted to amount of clicks. So perhaps degree isn't necessary here, just distance = # of clicks.

This is still unclear to me. What is the significance of the 36 pads. Does it mean that there is one SMD part for every segment on the sprocket? (If not, how does it work).

Have you an example of a GCode message that will be received and the action that it should give rise to? That seems to me essential at this design stage.

...R

Some SMT tapes have components every hole. See pic below. Some SMT tapes have 2 components every hole. See pic below. The more pads, the more accurate the movement. Just like a regular encoder.

Here's a very good example of M-Codes used to control the feeder: M-Code-Commands List [mgrl]

That person wrote their code on top of Arduino Mega 2560, but his feeders function slightly differently and I am not experienced enough to understand his code. His Arduino code is here: GitHub - mgrl/0816-feeder-firmware: Firmware for the 0816 automatic 3d printed smt feeder for OpenPnP.

My feeder I believe is much simpler than his. Is there any way you can help me to getting at least one feeder working? Perhaps some step, by step instructions? That would help me tremendously.

shai:
Is there any way you can help me to getting at least one feeder working? Perhaps some step, by step instructions? That would help me tremendously.

That would require far too much of my time. Maybe someone else will have the time to help.

Or you could ask in the Gigs and Collaborations section if you are prepared to pay for help. (I don't do paid help)

...R

Ok, so all this detailed explanation for nothing?

You are supposed to do the work. We can only advise when you have problems.

Since we don't have your hardware we can't test anything and rely on your description of the problem.

shai:
Ok, so all this detailed explanation for nothing?

Up to the point where you said "Is there any way you can help me to getting at least one feeder working? Perhaps some step, by step instructions?" I had been assuming that all you needed was help with some small element of your program.

...R

WELCOME TO THE FORUM !

your project is rather large and as the old Chinese fortuine cookie said

every journey begins with the first step.

as I see this, you posed a motor and a gear train and a feeder roller.

you need some optics to see the holes in the paper
you need to drive the motor

so, step #1 is to put together a single motor
and the drive mechanisim
and the sprocket
install the optics to see the holes.

I see a DC motor and an encoder.

get that one unit running
I would offer that the placement of the parts would be something you would need to program separately for each part but I would also assume that there would only be a limited number of placement distances. (parts on the tape)

This first one should be a great learning task and we will certainly help you as you stumble and also help guide you to avoid mistakes.

As a comment on the forum, we will help easier when the information is clear and things are not left out. you seem to be the former on that, so that will make all of our lives easier.

since I have a production/manufacturing/field service background, I tend to like a module that is plug and play, so I would tend to have one Arduino on a drive. but, that is not always the case.
it is easier to have one unit fail and 20 others working, and be able to swap one in or out.....
but, much more often, one micro can run all 20 things....

So, as Robin2 said in post#6 start with a single feeder.

break that into modules
motor,
encoder
tape hole sensor

take a minute and look at every sensor you can imagine you need to run one motor.
list every digital input then every output, and every analog input.
since step one really is to get one line running, your first device needs to be able to handle every I/O

once you have all those listed, add some room for additional lines, then chose between an UNO pin count board and a MEGA pin count board.

Seems like one UNO could handle one motor. An UNO, a NANO and a Mini use the same processor. different packages.
I would suggest you get an official board for your first unit so you have one that you know is made well and proper and it also helps contribute to the operation of this forum.

I also suspect that your first unit will never see your final device and will always be your test unit.
once you get that running, you will know if you will need a single UNO for every motor or if one MEGA will be able to run 20 of them.

as for the X/Y part, there is a lot of tutorials about X/Y tables.
that part is really for a whole different thread.

shai:
Some SMT tapes have components every hole. See pic below. Some SMT tapes have 2 components every hole. See pic below. The more pads, the more accurate the movement. Just like a regular encoder.

Here's a very good example of M-Codes used to control the feeder: M-Code-Commands List [mgrl]

That person wrote their code on top of Arduino Mega 2560, but his feeders function slightly differently and I am not experienced enough to understand his code. His Arduino code is here: GitHub - mgrl/0816-feeder-firmware: Firmware for the 0816 automatic 3d printed smt feeder for OpenPnP.

My feeder I believe is much simpler than his. Is there any way you can help me to getting at least one feeder working? Perhaps some step, by step instructions? That would help me tremendously.

code is rather simple in the beginning.
it starts with the step by step process in your head.
move to position, hole in tape is sensed.
look at pre-noted part count for this tape (1 every hole, 2, 3...)
move one part. (encoder increments)
that sounds pretty simple.
it should present the part in the place where it will be picked.
write that out and add every sensor type. a switch opening to sense or a switch closing to sense
and every output, move the motor, cut the paper ? whatever.
really once you get the hang of one, the code will make more sense.
Also, once you write code for one, the code you linked to will also make more sense to you.

You write: Some SMT tapes have components every hole. See pic below. Some SMT tapes have 2 components every hole. See pic below. The more pads, the more accurate the movement. Just like a regular encoder.".

In my 19 years of owning an electronic assembly service, I have never seen an SMT tape with more than one component per hole. If that occurred, then someone made a mistake. How would the pickup head ever be able to find the first one to be picked up, or even the second one when it could be anywhere in the tape hole?

Paul

Sprocket holes, not component pockets?

So I started simple, to see if I can get one feeder to work. I used Tinkercad Circuits to test my code, but it’s not working. The push button is supposed to resemble the clicking of the encoder against the springs as posted earlier. Any help on what I’m doing wrong here in my code?

It’s supposed to stop the motor after the button is pressed 5 times, but the motor keeps spinning.

int encoderCounter = 0;
int buttonState = 0;

void setup()
{
  pinMode(A3, INPUT);
  pinMode(4, OUTPUT);
}

void loop() {
  while (encoderCounter < 5) {
		digitalWrite(4, HIGH); // Turn on Mosfet
  }
  if(buttonState = digitalRead(A3), HIGH){ // Read the state of the pushbutton value
      encoderCounter++; //If high, add +1
  }
}

A test with an IF or a WHILE needs ==

Don't complicate things with compound statements. When you do that you can't check the intermediate values.

Keep It Simple

buttonState = digitalRead(A3);
if (buttonState == HIGH) {

And it is much better to give meaningful names to I/O pins - for example

byte buttonPin = A3;

buttonState = digitalRead(buttonPin);

...R

Thank you for clarifying that, but I still can't wrap my head around what's wrong with my code. I simply want the motor to run until button is pressed X times.

Figured it out! https://www.arduino.cc/en/Tutorial/StateChangeDetection
Simply swapped the LED pin for the Mosfet pin and voila. Would've been nice if someone could've pointed me to that tutorial by Arduino :slight_smile:

So what would be the next step so that I can send Mcode commands to activate 1 out of 30 feeders so the motor turns until Mcode (x distance) is reached?