Help please, this is my first project

Hello, I’m still new at this. This stuff is pretty cool. I asked about this project a while back, but I’ve changed the way I want to do it.

I have an 8vdc led/photo sensor that product is passing by it at 100 to 200 times a second. I want to use an Arduino uno to receive the analog signal (voltage) into and analog pin. The Arduino will count the number times product passes the sensor per second and send it to a computer. Where I will then use the information.

My plan is to send the sensor voltage( 0v to 8v) into a voltage divider, so that the max voltage going to the Arduino is not higher than 5V. Then the Arduino will monitor the voltage a few thousand times a second, and as soon as the voltage goes above a threshold that I set in my code, the program will count it as item passing the sensor. The product will take a few milliseconds to pass the sensor. Once I know how long that is, I’m planning to have some kind of delay after one item passes so that the program isn’t counting the same one several times.

Will this work? Is there anything I need to worry about?
Once I have it working for one sensor I want to add 5 more.

Any thoughts or tips would be greatly appreciated.

Thanks for time.
Matt

How many analog pins does you Arduino have?

Paul

6, I believe. Arduino Uno R3

Sounds like a reasonable plan to me.

cool thanks. There will 20ft to 40 ft of wire between the sensor and the arduino. I don't know much about this, do I have to worry about noise in the voltage or any weird stuff.
Thanks
Matt

Yes, noise is extremely likely to be a problem with long wires, especially in a machine environment. And the solution, to use shielded cable, could impact the signal response time.

Get it working with short wires before trying to extend them.

Seems to me that at a rate pf "a few thousand times a second" that a digital signal from the sensor and using an interrupt would be better. But that's just me :slight_smile:

mattmgame:
6, I believe. Arduino Uno R3

OK, and how many A/D conversions can be done simultaneously? Remember your sensors can give data randomly, so quickly all will need the conversion at the same time.

Paul

bluejets:
Seems to me that at a rate pf "a few thousand times a second" that a digital signal from the sensor and using an interrupt would be better. But that's just me :slight_smile:

Sorry I'm a newbie, what do you mean by an interrupt?

Paul_KD7HB:
OK, and how many A/D conversions can be done simultaneously? Remember your sensors can give data randomly, so quickly all will need the conversion at the same time.

Paul

Hi thanks, I don't know how many conversions can be done simultaneously.
I made a quick little breadboard with a POT, I would turn the knob back and forth as fast as I can(obviously no where close to what I need, and only one) If the voltage went above my threshold, it counted each loop that it was above and display it each second. The program displayed the average voltage over the past second. I also had a counter that showed the number of loops per second. Between 6000 and 7000 per second.

I think the product should take at least a few milliseconds to pass the sensor. So even if the program/arduino is busy converting another sensors voltage and checking it, on the next loop it should catch this sensor.

I might be totally wrong, this is all new to me. Am I misunderstanding what you are saying?

Thanks
Matt

Hi,
How many analog inputs will you be using?

The UNO only has one AtoD and multiplexes the 6 inputs, so simultaneous readings of all 6 are not possible.

Tom... :slight_smile:

TomGeorge:
Hi,
How many analog inputs will you be using?

The UNO only has one AtoD and multiplexes the 6 inputs, so simultaneous readings of all 6 are not possible.

Tom... :slight_smile:

Hi thanks, I need to have analog 6 inputs. for now. Would it work to, have it read pin 1, check voltage and note what it is, then pin 2... and so on?

Is there a better way to read 6 or more voltages at once. I was at one point going to use a comparator and have my threshold set on my board. But then I can't adjust it. I would like to have my program monitor the actual voltages because I want to be able fine tune things and see if I can determine when product other than the normal product is passing by.

Hi,

mattmgame:
Hi thanks, I need to have analog 6 inputs. for now. Would it work to, have it read pin 1, check voltage and note what it is, then pin 2... and so on?

Is there a better way to read 6 or more voltages at once. I was at one point going to use a comparator and have my threshold set on my board. But then I can't adjust it. I would like to have my program monitor the actual voltages because I want to be able fine tune things and see if I can determine when product other than the normal product is passing by.

Yes it would, but you will have to check the speed.
The AtoD has a small quirk in that if you are reading different inputs quickly you may need to read each input twice and discard the first reading.
The AtoD has a capacitor on its input, it takes time for the charge to change from one sample input to the next.
So double sampling makes sure that the second reading will be valid.
Tom... :slight_smile:

mattmgame:
Sorry I'm a newbie, what do you mean by an interrupt?

. Look it up . Details are in the web site with explanations better than I could ever hope to achieve here.

You're basically saying that you want to do this in the analogue domain. Is there a reason for that?

And you don't need a calculated delay; you can detect when a sensor is blocked and next detect when it's no longer blocked; that way your code will not block and you can do e.g. detections on different sensors.

Hi, I’m still waiting for my supplies to come in the mail so that I can start playing around with stuff. I’ve dabbled in the code world a fair bit, but I’m no expert. I have very little to no electronic background but I’m learning.

This is what I'm working on. I have a 4 light led across from a photo sensor. I have seed falling passed it 100 to 200 times a second.
From what I understand the voltage will change as the light received is lowered. There is a good chance that dust and other debris could also pass through. I wanted to check the voltage a few thousand times a second to…

Get the average voltage of one seed passing and how long it takes to pass. Then if something smaller than one seed passes like dust or debris which will dim the light but not as much as a seed, I don’t count it. If something larger than 1 seed passes ie. 2 seeds passing so close that they’re shadow is either wider or longer than the average, I would note it or count it as 2 seeds. I just want the Arduino to monitor the voltage and send the data to my computer where my program will figure everything out. Once I have one working I what to make it work for 6 sensors.

If there is a better way I’m all ears.

Thanks for your time

Matt

I think the whole mechanical application needs working out first.
For example what happens if 3 or 4 or more seeds pass one behind the other.
Or if 3 or 4 or more seeds pass in series. i.e. no gap between each.

bluejets:
I think the whole mechanical application needs working out first.
For example what happens if 3 or 4 or more seeds pass one behind the other.
Or if 3 or 4 or more seeds pass in series. i.e. no gap between each.

Another problem to contemplate is static electricity. Many, many years ago I operated a grass seed cleaning mill at night. If static charges on machines and seeds and dirt, etc. were not neutralized during the operation, soon every thing would clog up.

All parts of your operation need to be carefully and thoroughly grounded so charges can be directed to ground, and not the seeds. But, you probably already know this and have it well in hand.

Thanks for the replies guys. I'm a farmer, this in on my corn and soybean planter. Each row has a pretty accurate metering system which when set properly should only allow 1 seed to fall at a time. This happens very fast when planting soybeans, 1 seed every 3/4inch per row going 5.5 mph. There is a monitor/computer already counting the seeds. Basically there is a system already doing what I want to do. But components of the monitor are starting to break. To buy a new monitor(computer) from the company is like $2500 to $4000. And it's a crappy interface, not customizable. I want to build my own using the sensors already on the machine, tie into the system already there and make it how I want it to work. The % of times more than 1 seed falling should be low. And 0% or almost 0% of more than 2 seeds falling(in each row at a time). I don't know exactly how the current monitor works inside but it takes the 0v - 8V signal from the led/photo sensor when the seed passes.
I can see static being more of an issue with grass or cereal grains but I can't say that I can remember noticing a lot of it with this planter, it's always in contact with the ground so maybe that helps.

My plan to deal with one seed falling after another is to... have an average amount of time it takes for 1 seed to fall. Then if it is a certain % longer than that, I will count it as 2. I'm not too concerned with the programing, I know it could get fairly involved and will take some trial and error. I'm trying to figure out a good way to get each sensors information into my computer.

I've been in contact with another farmer that did something very close to this, but he set his threshold on a shield and used a comparator. Then when the output of the comparator goes high he went into an optocoupler(to deal with difference in voltage) and then into his ardunio. So his arduino wasn't monitoring the voltages, just counting the optocoupler changes .He didn't change anything on the planter. I want to do the same, but be able to adjust the settings and have my program learn when the average seed is falling, then tell me when something other than that is happening.
Thanks for your time and help
Matt

Not being critical at all, but if you had explained this in your first post, by now someone would have been able to offer a real solution.

Paul