Skip to main content
Three farmer's cows eating hay through bars.
Automated milking systems are being developed to do much more than just milk cows. Newer systems can test the milk’s quality, monitor health and fertility, and feed in to a centralised computer system for the whole farm ©

The automation of dairy farms

Robotic milking is not a new innovation, but the systems are increasingly being adopted by UK dairy farms. Science writer and broadcaster Geoff Watts learned from John Baines, Technical Director at Fullwood, how these systems are being engineered to do more than just milk cows.

There is something faintly incongruous about the sight of a dairy cow ambling through a farmyard, entering a barn and, at its own volition and at a time of its own choosing, stepping into a robotic milking machine. Cows are herd animals that mostly follow the actions of the group or, more often, their human herder. The agricultural engineers who first dreamed up the idea of robotic milking machines seem, quite unintentionally, to have given cows an autonomy that allows each one to make decisions for itself.

Robotic milking is still relatively uncommon in the UK, where only around 10% of farms already use the systems and they constitute around 30% of all new milking systems being purchased. However, robotic milking is a proven technology and it has become a core element in a more recent and still expanding web of technologies that are bringing a new rigour to the business of dairy farming. Instruments that can be bolted on to the milking robot, or otherwise used in conjunction with it, are now offering farmers a more complete picture of their livestock: their animals’ health, fitness and fertility, and the quality of the milk they produce.

A greyscale image of a cow milking facility, where cows were herded into machines.

While early milking parlours were mechanised, dairy farmers still had to herd the animals into the machines and attach teats. Cows can enter the automated systems at their own volition and the teats are typically attached by a robotic arm © Royal Association of British Dairy Farmers

As a recent report on the state of the dairy industry pointed out, farming is not noted for the speed or enthusiasm with which it has embraced technology. Mechanisation has brought larger tractors and replaced muscle power with machine power, but it has only been near the forefront in one area – the use of GPS to guide unmanned tractors. The industry has now started to adopt automation and begun assembling networks of machines that are able to talk to one another; the internet of things seems set to bring radical changes to the business of dairy farming.

Early attempts at robotic milking

🥛 The early hurdles with robotic milking technology and how they were overcome

The engineers who originally set out to automate milking faced several challenges. The first was simply to get the cows’ cooperation. This proved relatively straightforward as with most animals, food is a powerful inducement. A second, and more demanding hurdle, was to devise a means by which the robot could identify the position of the cow’s teats and bring its four suction cups into correct alignment with them. The 1990s saw a variety of attempts, some that never left the drawing board and others that began to overcome the obstacles step by step.

For example, a report issued by the Silsoe Research Institute in 1993 outlined the technology used by one prototype milking robot to tackle the attachment problem. The robot relied on three sources of information. First there was ‘stored knowledge’ that was derived by initially guiding the robotic arm bearing the teats manually into place, and having the machine memorise the relevant coordinates. Added to this was ‘inferred knowledge’ of the teat position, which was obtained from knowing the body position of the cow as assessed by “linear potentiometers, which are fitted to the stall and connected to links held in contact with the cow by pneumatic cylinders”. There were two sets of this equipment: one to detect any longitudinal movement of the animal and the other to detect lateral movement.

The robot’s third source of information came from a matrix of light beams generated by infra-red light-emitting diodes that crossed the interior of the machine’s teat-cup holder to impinge on an array of detectors. “A teat entering the matrix obstructs one or more of the beams causing the robot to move until the teat is centred over the teat-cup holder, which the robot then raises for attachment.”

The performance of this system was not altogether impressive. In one test of 10 cows involving 1,440 attempted teat-cup attachments, almost a fifth were unsuccessful. A different approach relying on ultrasound guidance of the robotic arm was also found wanting. It was the introduction of more sophisticated optical tracking, especially with lasers, that made robotic milking the practicable and effective technology it has since become.

A sketch of a hand-operated vacuum milker with handles (left). A sketch of cows in a building eating from a trough and being milked by the murchland milking machine (right).

Although not robotic, innovative engineering was employed in the Colvin hand-operated vacuum milker in 1860 (left) and the first commercial milking machine developed by Murchland in 1889 (right) © Fullwood

Automated milking

In the short history of robotics, there are few instances of successful interactions between a robot and a living creature. There are fewer still where engineers have designed a machine that is able to take account of biological and behavioural variability in establishing contact between the two parties, which is what milking robots have achieved. The goal was not reached overnight, and today’s robots are the product of developments that began several decades ago. Their exact form and method of operation depends on the manufacturer, but the similarities are greater than the differences.

The machines have to be animal friendly: robust enough to withstand the occasional kick, but gentle to the animal

Cows in a dairy farm walking into an automated milking stall through a gate.

Cows are encouraged into the automated milking stall by a feeding trough at one end. The rear gate closes when the animal’s presence is detected by a photocell, which also records the cow’s identity via an electronic tag © Fullwood

Besides the design problems familiar in the development of any new machine, engineers who devise robots for use with agricultural livestock have to bear in mind that it will operate in an exceptionally mucky environment. The machines have to be animal friendly: robust enough to withstand the occasional kick, but gentle to the animal. The pneumatic or electrical drives that power the sections of the robot that have direct contact with the animals have to be sensitive to any opposing force. The chosen parameters will vary from one function to another but, generally speaking, the rule is to push firmly but lightly, and to back off when experiencing sustained resistance.

The equipment usually comprises a tough stainless steel stall that is slightly wider and longer than the animal, and has gates at both ends. The cow enters the empty stall, lured by a feeding trough mounted on the closed head-end gate, while a photocell detects the animal’s presence and the rear gate closes. The cow’s identity is established by an electronic ankle, neck or ear tag.

The cow enters the empty stall, lured by a feeding trough mounted on the closed head-end gate, while a photocell detects the animal’s presence and the rear gate closes

A robot arm machine milking a cow's udders.

A robotic arm in the milking stall uses stored coordinates to locate the position of the cow’s teats, which are then washed by soft brushes on the arm. A laser tracking system is then also employed to improve more accurate positioning of the suction cups © Fullwood

The robot’s arm is mounted outside the stall and below udder level, where it can swing horizontally into the stall, beneath the animal’s belly, and move unhindered between the front and back legs. Using stored xyz coordinates to locate itself in roughly the required position, the arm first cleans the cow’s teats using a water spray and pair of soft rotating brushes that can help trigger the release of the hormone oxytocin into the cow’s circulation, which produces the milk.

Alignment of the robotic arm’s four suction cups below the cow’s teats calls for more accuracy than the cleaning that preceded it. This extra precision is achieved by a laser or similar optical tracking system directed to the teats. It has to cope with a target that is anatomically variable and prone to move as the cow breathes or shifts the position of its body within the stall. The tracking system guides one of the cups to its correct location and then pushes it up on to the teat. Suction pulls it firmly into place and holds it there. The same procedure is repeated for each of the other three cups.

A vacuum sensor located in the tube carrying milk away from the robot signals that the cup is attached. However, the cup might be hanging on to the skin of the udder and not to the teat itself. If this happens, a liquid flow sensor that is electrochemically activated by the presence of milk will fail to send the expected signal and the cup will be detached for a second attempt. The milk sensors also respond when the flow from each teat has ceased. One by one the cups are pulled off, the teats are sprayed with disinfectant, the robotic arm retracts, the front gate of the stall opens, and the cow is free to go.

Milk quality

Besides collecting milk, the robot’s inbuilt instrumentation can run a series of checks on its quantity and quality, the latter including its fat, protein and carbohydrate content. Optical scanning reveals the presence of any blood that might render it unfit and therefore to be rejected. Data on all aspects of every milking for every cow is collected by the robot and transmitted to the farm computer. Farmers can scrutinise them as and when convenient, and in as much detail as necessary to understand the performance of each cow in the herd.

Analysis of the milk may point to particular nutritional deficiencies in some animals and this can alert the farmer to take remedial action when feeding the cow during milking

Analysis of the milk may point to particular nutritional deficiencies in some animals and this can alert the farmer to take remedial action when feeding the cow during milking. The robot could even act on its own initiative if given appropriate instructions. The robot can also make choices about the path to be taken by the cow as it leaves the milking stall. With appropriate gating technology, each cow can be allowed to return to the barn or the field, or be automatically diverted to a pen for a particular purpose, such as a veterinary inspection.

A close-up of a cow's back legs and it being milked by a machine.

A liquid flow sensor in the system that is electrochemically activated by milk can tell whether the cup is attached incorrectly and when the milk production has ceased, automatically allowing the suction cups to be removed. Inbuilt instrumentation can also run checks on the milk’s quality and quantity © Royal Association of British Dairy Farmers

Fertility and health

Automated milking offers the opportunity for monitoring each cow’s health and fertility. It is a feature that already exists in most systems and seems set to grow. Farmers need to know which cows are ready to breed and when because milk production, which starts when a cow calves, ceases after 10 to 12 months, so the cow must breed again to restart the flow. Cows are also only receptive to insemination for a brief period every 21 days, so timing is important. When cows are ready to breed, they become more active and their step count may increase by around ten times. The ankle or neck tag can be combined with a three-dimensional accelerometer to monitor the cow’s activity. This is also critical to monitoring the animal’s health as, for example, a cow that repeatedly gets up and lies down may be suffering some kind of discomfort.

The accelerometer can monitor and broadcast this movement continuously and in real time. However, if for some reason the cow has been beyond the range of the system, information stored in the tag can be downloaded when the cow makes its way back to the milking robot. Indeed, the milking robot offers a clutch of opportunities for health assessment. Further measures of the milk flow can flag up disease in the milk glands, such as the bacterial inflammation known as mastitis.

Online cell counting in milk has also been introduced to detect signs of mastitis. Some of the cells in question are shed from the cow’s milk-producing tissues, but most are white blood cells that appear in increasing numbers in the milk when the animal has acquired one of the pathogenic microbes that cause mastitis. Cells are detected by the withdrawal of a small sample of milk from the stream, which is mixed with a dye to stain any cells present that allows a digital camera to count their number per unit volume of the milk.

The cell counts, for every cow at every milking, are also made available through the farm computer so that infected milk can be automatically diverted away from the main collection tank.

The cell counts, for every cow at every milking, are also made available through the farm computer so that infected milk can be automatically diverted away from the main collection tank. The manufacturers claim that this system helps earlier detection, and earlier treatment, of even sub-clinical mastitis, and for the effectiveness of that treatment to be monitored.

Feeding has so far proved a less popular candidate for automation, but a minority of larger farms are already using it. Autonomous feed robots can be programmed to make their way along a preset route to a farm depot where the separate ingredients of the feed are loaded into them in the appropriate proportions. Having mixed them within its hopper while making its way back to the cows, the robot then moves along each row of animals dispensing feed in a predetermined amount. This allows the animals to be fed day and night.

Lameness: A further opportunity for new technology

🐄 Automating the detection of lameness in cattle

Bioengineers at the Royal Veterinary College (RVC) are among several groups to have experimented with automating the early detection of lameness in cattle. Affecting up to a third of dairy cows each year, lameness is not only a cause of pain but of reduced milk yield and lower fertility.

While early detection is self-evidently desirable, it is also time consuming and labour intensive because it relies on observation of the cows’ movements and patterns of behaviour. Survey evidence suggests that many stockmen fail to notice what may be subtle indictors of the earliest signs that something is amiss.

Lameness alters a cow’s normal pattern of walking, and the RVC team set out to exploit this in a machine designed to identifying such changes. Over a period of two years, they collected data on half a million foot strikes recorded from the sensors fitted to a series of force plates set at the exit from a milking parlour. This provided them with measurements of foot location, the vertical and horizontal forces involved, and other relevant features of every cow and the manner of its movements. Skilled observers also scored each cow for lameness using visual rating, and the team then compared their findings with those of the machine.

The researchers are confident that force plate analysis can pick up the early signs of lameness without human inspection. Their particular system has yet to be commercialised, but at least one other has recently come to market.

The farm computer

The farm computer controls all of these devices and analyses the data that many of them collect. It is a focal point for all the accumulated information about each cow’s health and wellbeing, and the milk that it is producing. Depending on the sophistication of the system, the computer can be programmed to act for itself in respect of individual animals.

Farmers new to this arrangement may fear being overwhelmed by the information that they can summon up on their screen, perhaps missing important insights amid a flood of data that will mostly be telling them that things are progressing satisfactorily. In practice, this overload can be avoided by prior selection of a normal range of values, with pre-determined alerts if those values are exceeded.

The most obvious benefits to the farmer of an automated system are the liberation it offers from the twice daily constraint of milking time and the need for close scrutiny of every animal for signs of disease. However, this latter advantage can also be seen as a drawback; good farmers know their cattle extremely well and may become aware of something that is not apparent to a machine. It is an argument that is already familiar in medicine, which has long since adopted vast amounts of diagnostic and monitoring technology. Doctors have found a middle way in which the use of technology stops short of total reliance on it and farming will surely learn similar lessons.

It is claimed that milk yield tends to increase following the adoption of robotic milking, which can be an indication of contentment

How the cows themselves feel about automation can only be inferred. It is claimed that milk yield tends to increase following the adoption of robotic milking, which can be an indication of contentment. Machinery that operates quietly, does not shout or wield a stick, and makes no unpredictable demands is certainly calculated to suit a cow’s temperament.

Measuring body condition

🐮 Software that creates a 3D image of a cow’s hindquarters

The appearance of the hindquarters of a cow is a useful indicator of the adequacy or otherwise of its diet, which is a major influence on milk production. Farmers usually assess cows by eye, noting how their skin is either stretched tightly over the spine and pelvic girdle, or cushioned and rounded by an underlying layer of fat. Using a standardised five-point body condition scale they can score each cow, which can be more revealing than an animal’s body weight alone.

Another recent addition to the health checks that can now be slotted into the pathway to or from the milking robot is the automated assessment of a cow’s body condition.

At least one manufacturer has introduced new camera technology that aims to improve the accuracy and consistency of visual inspection. These systems rely on a short video sequence of the cow’s hindquarters recorded by a camera mounted above a location that each animal must pass daily, such as the exit of an automatic milking machine. An infrared source on the camera directs a beam of light at the cow and technology in the camera’s detector records how long it takes for reflections to reach it. The image-capturing process takes only seconds, and can be completed without the cow needing to stand still.

Software on the farm computer creates a 3D image of the cow’s hind quarters from the data, and compares the contours of several areas with a set of standard surface contours seen on animals in conditions ranging from skinny and malnourished to overfed. The final result is presented by the computer as a score on the familiar five-point scale. A daily score for each animal’s body condition allows its progress to be checked over time, and action to be taken if it falls outside pre-set limits. Such changes might be caused by a problem with the cow’s health or the farmer might need to adjust feeding to take account of its position in the lactation cycle. Either way, the computer will automatically issue an alert.

The technological failure

Where technology of this kind will go next is uncertain. Likely candidates for the future of automated milk testing are various reproductive and stress hormones and other yet to be identified biological markers of health and metabolic wellbeing. Less predictable is the role of novel gadgetry that exploits new observations about animals. For example, it seems that when sheep are suffering pain their eyes narrow, their cheeks tighten, their ears fold forward, their lips pull down and back, and the shape of their nostrils changes.

University of Cambridge scientists recently rigged up a camera linked to a computer running artificial intelligence software that can identify and distinguish between these and more normal facial expressions. Their thought was to fit drinking troughs with the cameras, so that farmers would be alerted to any of their flock suffering distress that might otherwise have gone unnoticed. Whether cows display comparable changes of expression is a question for biologists, farmers and vets rather than engineers.

Agricultural data analysis will become increasingly important in boosting the efficiency of the industry, and in planning its future

Even with another decade’s worth of engineering advances, an image of a self-governing agricultural internet of things could be seen as fanciful. Although engineering ingenuity will continue to foster change, and not only in dairy farming. Current projects listed by the University of Lincoln’s newly created Institute for Agri-food Technology include: an automated selective broccoli harvester; three-dimensional vision-based crop-weed discrimination for automated weeding; the autonomous control of agricultural sprayers; and the quantitative estimation of blemishes in potatoes using machine vision.

A recent survey described agriculture as among the world’s least digitised industries, but the use of robots that collect data on the scale now growing apparent in the dairy industry is changing everything. Agricultural data analysis will become increasingly important in boosting the efficiency of the industry, and in planning its future. The popular notion of agricultural engineering as concerned largely with building bigger and better tractors is already out of date, and becoming more so.

This article has been adapted from "The automation of dairy farms", which originally appeared in the print edition of Ingenia 72 (September 2017)


John Baines is the owner of JRB (Dairy) Consulting Ltd. At the time of publication, he was been Technical Director of Fullwood, between 2003 and 2018 and he has been involved in the agricultural industry since graduating from the University of Aberdeen in 1977. John has been at the forefront of many projects including improving milking technology and introducing automation to the industry, as well as supporting milking system installations across the world.

Keep up-to-date with Ingenia for free