Adapting a sketch - dairy automation

Hi All,

I've been looking through a lot of projects and examples trying to find something that i can modify (in most cases dumb down) to take over an automation task in a friends Dairy. The more I look, the more confused I get.

We need to control the monitoring of milk flow and subsequent removal of the cups, note that at this stage we don't really need to know how much milk has flowed, rather just when it stops, or, slows to a preset minimum level. There is a very complicated and heavily integrated system already there, but it would be extremely expensive to get repaired

The code needs to run a countdown timer at three different stages (or scenarios) in the milking process, to ensure that the removal doesn't occur prematurely, and switch 2 solenoids that control vacuum flow. This is the part I was looking to add to a sketch already out there.

I've looked at water flow, water level and continuity projects so far and am not sure which would be the best path.
We need to work with milk 'flow' meters that monitor flow based on continuity that operate at either 12 or 24v.

The operator needs to be able to start the process manually, be able to cancel at any time (if something went wrong) and override the process in the case of milking the cow into a bucket (so no milk flow - but still activate solenoids) or override to clean the milking system.

Like many people who post here, I am inexperienced in coding, hence would prefer to modify existing sketches, rather than attempt something from scratch.
The ability to add volume counting and lcd display in the future would be a benefit.
I can be more specific about the scenarios if someone needs more info, just haven't put them here yet in fear of boring people to death...

Any suggestions would be gratefully received,

Cheers
Chris

This sounds like something that could be done by an Arduino in the hands of someone with suitable knowledege and experience. For someone without knowledge of electrics, electronics and programming it sounds like it would be the equivalent of learning to swim as your boat sinks in the middle of the Atlantic.

Another important thing to consider - even if you do get it to work who will be able to maintain it if you are not available due to vacation or illness?

These are some of the reasons why commercial systems appear expensive at first sight.

My main recommendation is "pay for a professional repair or replacement system"

IMHO there is zero chance of getting your system to work by modifying existing programs - even if you could find some code that provides a starting point - unless you (and preferrably a colleague working with you) acquire sufficient programming skills so that you would not really need any code to start from. There are just so many small ways in which your system will be different that you will get tied up in knots.

If you do want to pursue this project my suggestion is to start by identifying small features within your project and learning how to do each of them on its own. There is a wide range of examples with the Arduino IDE and I suspect most parts of your project will be covered by them. This will likely take several weeks of part time study.

You will also need to learn how to interface your real-world equipment to the Arduino.

Sorry if this is not what you wanted to hear.

...R
Planning and Implementing a Program

Thanks for your reply.
Repairing the existing system is out of the question, with quotes of up to $40k.

I do have an understanding of the electronics involved, just not a lot of coding experience, so a learning curve is inevitable.

I don't believe it will be as complicated as you imagine. It appears initially at least, that it is an extension of something like a water level sketch. Detecting when no liquid is present, allowing for a delay before acting and then setting two output pins, one to high and one to low, as well as pushbutton reading.
I may be underestimating the complexity of the code involved, but as an alternative to spending large amounts of cash, the cheapest option still at least $20k for a completely new system, ignoring everything else there, we have to try. Both the $20 and $40 k options are out of the question.

If you have an opinion of specific starting points, I'd be glad to hear them.

Cheers
Chris

Start with the sensors. If you have working sensors then try to get one working with an Arduino on your bench.

If you don't yet have sensors then I imagine that will be a long-lead-time item. Something that is hygenic and approved by your health authority and your milk buyer will take a bit of searching.

If you can, get the datasheet for the sensor and share it here.

Boulton:
Both the $20 and $40 k options are out of the question.

If you have an opinion of specific starting points, I'd be glad to hear them.

I have already made a suggestion in Reply #1 which is essentially the same as that of @MorganS.

However I remain doubtful that an amateur DIY system is appropriate in a business situation as the business might find itself with a failed system and no technical support. If you are not the senior manager for the business please be sure to discuss this aspect with the senior manager before deciding to proceed.

...R

In every project, there is a simple (or complicated) work flow.

what you are asking is to integrate multiple devices into a cohesive whole that meets both health needs for the animal and the health needs for those consuming the product.

Of course you CAN do it, Noah built an Arc and saved all the animals from the Great Flood. I think he lived for over 900 years, not sure how many hundred years it took to build the thing.

but, as you said, there are multiple paths of controls, we do not work with that, we work with one at a time.

pick the main one, the reason for it to exist.

lay out that is a simple flow chart type diagram and make sure that your bits and pieces can work together.

make that work.

Once you have that working, all the other features you ask will be much easier to comprehend and implement.

What you are really asking for is an industrial control process that rivals many manufacturing plants, but in one package.

Let's say it only takes you a year to get it fully operational, and you spend only $5,000 for the parts needed.

AND you are allowed by law and code and such to use such a device.

Not sure of where you live, but what pay would you expect to receive if this was your full time job for a year ?

Let's just say that you are an entrepreneur and want to make this a product. You have to either add more features than the existing devices, or sell it for less, then convince a farmer to spend $$ on a product that has no history and no one to service the unit if if has the slightest problem.

I am not saying to not try, but just trying to give you some perspective to your project.

I would offer that the best way to start is to get one milking machine and add your sensors and make that work
then copy that project onto a second machine, the get a dozen working for enough time to have total reliability without problems.

While that is getting a track record of 100% operation, add features.

Boulton:
Repairing the existing system is out of the question, with quotes of up to $40k.

And your cows can really wait for a year for you to hopefully cobble together a replacement?

I also hope you get a decent pay for all that work.

The hardest part that I see is the sensor - reliable, can handle the fat in the milk, fully certified for food use, etc. Then there's the control panel, where the operator controls the thing. That's gotta withstand quite some abuse, on top of all the hygiene issues. The controls to the solenoids - not that hard to build, but much harder to make really reliable.

The code comes after that, and is probably one of the easier parts of the whole job as the number of inputs is very limited and they are well defined.

I don't believe it will be as complicated as you imagine. It appears initially at least, that it is an extension of something like a water level sketch. Detecting when no liquid is present, allowing for a delay before acting and then setting two output pins, one to high and one to low, as well as pushbutton reading.
I may be underestimating the complexity of the code involved,

This feels like one of those projects that begins with "All you have to do is...."

Many of us have been there, done that, and bear the scars to show for it.

That's why you are being advised to proceed cautiously, if at all.

Can't address the usefulness of it but, there's this: AUTOMATIC-MILK-COLLECTION-SYSTEM.

Gigs & collaborations might be another way to go.

If you are being quoted $20-40k for a replacement, do you think it likely you can do it with $100 of arduino bits and a couple of hours programming?

Allan

You seem to be intent on using some of the existing system components, but you have not told us exactly what is wrong with the system.

If you are going to use existing components and there are no data sheets available for each piece, then you must identify all the operating parameters of each in order to incorporate them in your new system.

And as you do this, begin to write a flowchart of the logic used by the operators to run the system. This will be used in writing you code.

I assume the existing system has a controller somewhere. What is it and does it have an operating system? What does it use for input and for output and document both. Are there peripheral devices connected to the controller?

Paul

allanhurst:
If you are being quoted $20-40k for a replacement, do you think it likely you can do it with $100 of arduino bits and a couple of hours programming?

Allan

+1

...R

Hi everyone,

thanks for all your input whilst I was asleep!

So I'll just put in the detail...

The entire dairy was computer controlled.
Each cow had a collar with her rf id in it. As she walked into the milking shed, an rf reader read her collar and 'remembered' her position in the parlour.
Her data file was then sent to the sub controller in the milking pit to the relevant position. That controller measured out her feed amount. You then started milking.
You hit the start button, the controller opened the vacuum solenoid to the milking claw and shut the solenoid to the cup removing ram (so you can pull the claw over to the cow).
The cows data file had parameters in it that told the controller the expected milk volume from that particular cow, her cell count (udder health) and the minimum flow point at which time it should shut the milking vacuum and open the withdrawal ram solenoid which then pulled the cups back off.

It is the cup removal component that we need to get working again.
Basic systems (the $20k option) just use one single parameter for every cow, an average minimum flow that the system uses to determine when to pull the cups off. Doesn't matter which cow or what position shes in. The broken system cannot do this. Some use flow meters measuring volume as well, some just use continuity to determine when there is no flow.
We have the dairy continuity sensors. I am currently trying to get the specs on these to determine the output.

I am doing this for a friend, a fellow dairyman. There are no issues with health authorities, animal welfare or employers. Please put all these distractions aside.
The repair cost is so high because multiple parts of the integrated system have to be repaired just so we end up with the minimum expected volume per cow, in a file sent to the right controller.

All we need is a controller to read the sensor and switch the solenoids with some time delays built in. The original controller boxes will house the arduino, the solenoids, sensors and rams are all fine.

I didn't expect this to be a walk in the park and there is obviously learning to do, if it takes a while, so be it.

One person suggested starting with the sensors.. and that is what we're doing. I then propose to sort out the time delays and button reading and finally the switching of the solenoids. From examples I've seen, this should be quite doable. One came to mind, a minimum water level that switched on and off pumps, but had ethernet capability as well which we don't need.
I already have a 'flowchart' (aka list of sequential tasks) needed. If anyone wants to know what they are to help decipher, let me know and I'll put them up..

Thanks once again to all who took time to reply.

Paul, sorry I forgot to answer your question...

What is wrong...
No cow collars to send animal id.
No rf reader working to read the missing collars.
Need to replace the original milk flow meters, 80% of their functionality isn't required, hence the use of just continuity sensors.
Without all this sorted, there is no way to get the relevant data file to the relevant existing controller, of which only one bit of information is needed anyway and that is the minimum flow to determine when to shut off...

It is not that you cannot do this.
I believe that each of us that posted was talking from our personal experiences.
it is our collective experiences that what we think should take a week or a week-end, can take months.

As a way to help you, we try to point out the things to watch our for.

My personal strategy is to put on a sensor and then data-log it to watch what happens so as to better understand what is needed.

One critical question, for me, anyway, Are we talking about milking one cow at a time or multiple? How many at a time? Does the old controller handle multiple cows at the same time?

Paul

Hi Paul,

There is one controller for each cow. The existing system takes data from each of the 18 controllers to a central PC for data retention and info purposes, but we only need to replace each of the controllers.
So, perfect one sketch and install it on 18 arduino boards, all operating independently.

Basically the idea of cup removers is to allow the farmer to keep putting cups on the rest of the cows and prepare for the next side of cows to come in, without having to go up and down monitoring each of the milking cows to see who needs to come off. The system does this and removes the cups for him (or her). It significantly speeds up the milking process and ensures that cows don't get over milked (cups still sucking and squeezing when there's nothing to milk out - causes health problems)

Cheers
Chris

So it sounds like you need a couple of critical bits of information...

The schematic / interconnection details of each ‘cow controller’.
The specs of the sensors and drivers, as suggested above.
What power sources are available.
What compliance do you have to meet.
The addressing mode, and/or electrical interface for connecting each cow back to the host controller.
The comms protocol for that host interface.

Keep in mind a spare host and cow-controllers are a good idea to eliminate single points of failure.

lastchancename:
So it sounds like you need a couple of critical bits of information…

The schematic / interconnection details of each ‘cow controller’.
The specs of the sensors and drivers, as suggested above.
What power sources are available.
What compliance do you have to meet.
The addressing mode, and/or electrical interface for connecting each cow back to the host controller.
The comms protocol for that host interface.

Keep in mind a spare host and cow-controllers are a good idea to eliminate single points of failure.

-Schematic underway
-Sensor specs are being sought
-Power source is currently 24v dc

The other points you raise are not relevant as we wont be doing any of these. Each will operate independently and do no more than remove the cups connected to it.
Possibility in the future we may look at monitoring actual flow and reporting total on an lcd, but for now, just the functionality I mentioned.

I’m that case, you’ll need a button or switch to start / cancel the operating sequence.
I guess what I was implying was
a) requirements doc
b) spec of parameters and other detail not included in reqs.