PDA

View Full Version : I need to measure alot of different frequencies at the same time (up to 48) How?



Tobias
- 18th June 2014, 04:31
I have been working around the PIC chips for quite some time. Built many different products. This one though I am not sure how to do or where to start.

I can have up to 48 frequencies I need to measure. The rising edges will pretty much never be at the same time.

I can't find a chip that has that many CCP/Input captures, so I would guess I will have slave chips measuring and then reporting to the master chip.

So with that in mind, assume I pick a slave chip that has four CCP pins so I end up with 12 slaves. Can I really measure effectively four different frequencies that don't have the leading edges in line? Or Do I end up with 48 slaves talking to one master?

HenrikOlsson
- 18th June 2014, 06:15
Hi,
I'm not suggesting that I've got a solution but several questions pops up while reading your post....
What frequencies are we talking about, to what kind of resolution do you need to measure and how often does it have to update the measurement for each input?

If the frequencies are low(ish) and you can live with fairly low update rate you might be able to use pulsin or count and measure one input at the time. Although I've never personally used the CCP module in capture mode to measure frequency I see no reason for it not work on multiple channels - even though the signals aren't in sync. However, a chip with many CCP modules will usually be big so you may be pissing away alot of space and features by picking that instead of the smallest device with one (or more CCP modules).

But again, what kind of frequemcy, resolution and update rate are we talking about?

/Henrik.

Tobias
- 18th June 2014, 23:58
This is an agriculture application. I am going to measure seed population. The seed rate (population) is dictated by two variables; seed plate count and rpm. Seed plate count is how many seeds are dropped per revolution. This can vary from 12 to 120 seeds revolution and the rpm can vary from 12 to 80 rpm.

So a minimum frequency is 2.4hz and maximum is 160hz.

There are a couple things to keep in mind. Sometimes there is a 'skip' this is when a seed doesn't get into the seed plate and consequently not dropped into the ground. I need to detect the skips. I also need to be able to report population atleast every tenth of a second when the population frequency allows it.

There are a couple of ag manufacturers that already do this. I just need to figure out how. The one 'Seed monitor' I have on my test bench is completely potted so I can't take it apart and learn anything.

I am thinking I use smaller slave chips with a DtoA and CCP pin. The CCP measures the frequency and then I give an analogue out. The master then measures the 0-5v signal to record the population.

Another thought is using a PIC with many CCP pins but I just don't know how that will work due to the leading edge of each input not being aligned.

HenrikOlsson
- 19th June 2014, 06:31
Hi,
Hmm, OK, so at the lowest frequency, how wide is the pulse comming from the "seed slot sensor"? Ie, what's the dutycycle ratio and are the slots equally wide on a 12 slot disc as they are on a 160 slot disc? (I suspect they aren't...)

I mean, you're obviously not going to measure frequency since the gate time would have to be long to get the resolution. You're going to have to measure pulsewidth and convert that to frequency, which I suspect is what intended anyway, but if the seed slots in the discs are different you're going to have to either cater for that or measure both the slot and the "space". Ie a full period.

I'm not sure why you're worried about the leading edges not being aligned. I don't see the problem.

Another aproach could be to use a timer and the interrupt on change feature. When ever an input changes state grab the timer value and calculate the difference from last state change for the pin in question.

Just thinking out loud....

/Henrik.

EarlyBird2
- 19th June 2014, 09:53
I thought that on a seed drill all of the disks rotated at the same speed and the spread rate was a simple calculation involving the number of slots and rpm. This would mean that only one disk needs to be monitored to calculate the spread rate. The complication is detecting missed seeds for which each disk has to have a detector. So the question is what form does the existing detector take does it count seeds or missed seeds? I would have thought the latter and if that is the case then the application becomes easier.

Tobias
- 19th June 2014, 14:28
You can do it that way if you don't want accurate information. When a bag of corn seed costs over $300 (that is a 50 lb bag) you can't take anything for granted and every row is monitored. Plus with my electric planter drives I vary population on a row by row basis so it gets pretty important then too.

www.electricplanter.com

The sensor detects each seed passing through the seed tube after is falls from the seed plate on its way to the ground.


I thought that on a seed drill all of the disks rotated at the same speed and the spread rate was a simple calculation involving the number of slots and rpm. This would mean that only one disk needs to be monitored to calculate the spread rate. The complication is detecting missed seeds for which each disk has to have a detector. So the question is what form does the existing detector take does it count seeds or missed seeds? I would have thought the latter and if that is the case then the application becomes easier.

EarlyBird2
- 20th June 2014, 06:10
That is impressive!

It not only counts the seeds on each row it also controls the rate of each row automatically.

Tobias
- 20th June 2014, 13:36
Thank you.

It started out as something Dad and I wanted to do on his corn planter six years ago. Now I have sold over 4000 units in the US, UK, AUS, SA, and Ukraine over the last five years. This next year I bet I sell 4000 more.

Its taken on a life of its own.

EarlyBird2
- 21st June 2014, 06:52
You have a working system that counts each seed, works out the spread rate and adjusts the rate to meet a set value.

What sensor are you using to detect the seeds being dropped? I have used pulse counter chips as counters combine this with a clock timing of 100 ms will give spread rate seeds/second presumably tractor speed is also needed to give seed/metre.

From calculating spread rate the drill has to adjust the rate too the set rate. Will the PIC do this or is there some other control on board the tractor to do this?

I am thinking along the lines of 48 slave counters with serial connection to master controller. I can visualise what the slaves will do but can only guess at how the master will adjust the spread rate.

Tobias
- 21st June 2014, 09:23
I don't know true seed count as of now. My electric drives work two ways; with a hydraulic rate controller or a rate controller I make based on an Adroid tablet.

For the first example, I have an Interface board that connects to the PWM output of a standard rate controller. It measures the PWM signal and makes the rate controller think a hydraulic drive is connected. By measuring the PWM and providing a feedback signal to the rate controller I am able to figure out how the rate controller is trying to spin a hydraulic drive. Normally a hydraulic drive spins the seed plates. So once I calculate the desired rpm needed by the rate controller based on row spacing, seed plate count, ground speed and needed population, I send the rpm number to the Control board. The Control board handles four rows individually. The slick thing is I send this data wirelessly from the Interface board to the Control board so the only connection I need between tractor and planter is power and ground.

The Interface board also connects to the 'section control' outputs. On a hydraulically driven planter farmers can use electric clutches on each row to engage/disengage the drives to minimize seed waste. I connect to these outputs to know which rows need to be on/off.

Each electric drive has an encoder that I use to measure rpm and adjust accordingly with a PID routine.

At current time, with a rate controller from another manufacturer or using my Android based rate controller, there is a 'Seed Monitor' It is connected to a seed sensor on each row of the planter. It is basically an optic sensor on the seed tube between the seed plate and the ground. It pulls low when the seed is in front of the seed sensor. Its not even close to being a 50% duty cycle.

If a farmer uses my rate controller, he is stuck with another display in his tractor that is the seed monitor. I want to integrate seed monitoring into my rate controller. I do display on my rate controller UI a population number but that is based purely from the encoder, not the seed being dropped into the ground.

The big thing in planting corn is being able to detect skips...when a seed is supposed to be dropped yet not. This is usually due to the vacuum pulling a seed against the seed plate not being correct. So I really need to be able to measure population based on seed drop from the seed sensor, display it on my Android UI and also throw up a flag on the UI when a skip is detected also.

I have started to work on the PIC32 chips but I am still running into the amount of available CCP/Input Capture pins not going up to 48 on a single processor. A 48 row planter is pretty rare but I need to be able to handle it. The majority of my customers are in the 12-16 row range.


You have a working system that counts each seed, works out the spread rate and adjusts the rate to meet a set value.

What sensor are you using to detect the seeds being dropped? I have used pulse counter chips as counters combine this with a clock timing of 100 ms will give spread rate seeds/second presumably tractor speed is also needed to give seed/metre.

From calculating spread rate the drill has to adjust the rate too the set rate. Will the PIC do this or is there some other control on board the tractor to do this?

I am thinking along the lines of 48 slave counters with serial connection to master controller. I can visualise what the slaves will do but can only guess at how the master will adjust the spread rate.

EarlyBird2
- 21st June 2014, 09:41
The big thing in planting corn is being able to detect skips...when a seed is supposed to be dropped yet not. This is usually due to the vacuum pulling a seed against the seed plate not being correct. So I really need to be able to measure population based on seed drop from the seed sensor, display it on my Android UI and also throw up a flag on the UI when a skip is detected also.


Pulse counter connected to PIC for serial communication looks the way forward. Have one pulse counter and PIC for each row. Just need to test a pulse counter that works with the seed drop pulse. I have used this for example CD4520BEE4 it counts in the background and outputs the count to four pins on the PIC. The count is simply read by sampling the port. They are cascade able so can be connected to give 8, 12, 16 ... bit counts. The PIC will read the port and send to the UI, which you have already sorted out.

I presume that as there is a PIC on each row it could also be used to control the motor.

AvionicsMaster1
- 24th June 2014, 13:58
You know some of things you think are pretty simple like a farmer planting seeds are indeed quite technical and wireless to boot. Awesome integration of technology with one of the most basic requirements of society. Very interesting project that will make me look at using PICs in different ways. Thanks. I hope you find an answer to your desire.

pedja089
- 24th June 2014, 16:31
I was working on similar project, only difference is that my device monitor 4 seed plates on mechanical planter.
I used 1 IR LED 5mm, and 3 IR photo diode 3mm side by side connected in series, to detect falling seed from seed plate. If there is no detection for 3-5S then alarm will sound. Additional function is to count seed on each row, and total count.
Another idea was to monitor holes on plate and to check if there is seed on every hole.
I didn't use interrupts or counters, just detect falling edge from sensor, count them, and reset alarm timer...
For edge detection I used
IF PinOldState>Pin THEN DETECTED
PinOldState=Pin
That is all.
On my setup time frame for detecting each seed is about 5mS. So just put that in loop, or use timer and interrupt on overflow, set interrupt frequency about 1KHz, and you are done...