As well as allowing robots to quickly respond to potential damage to their systems, it could also protect humans who are increasingly working alongside them.
The scientists plan to base the system on "insights from human pain research".
To test it, they fitted a robotic arm with a fingertip sensor that could detect pressure and temperature.
The researchers, from Leibniz University in Hannover, are developing a system that would allow a robot to "be able to detect and classify unforeseen physical states and disturbances, rate the potential damage they may cause to it and initiate appropriate countermeasures, ie reflexes", they explained.
Just as human neurons transmit pain, the artificial ones will pass on information that can be classified by the robot as either light, moderate or severe pain.
Researcher Johannes Kuehn told IEEE Spectrum: "Pain is a system that protects us. When we move away from the source of pain, it helps us not get hurt."
Teaching robots about a range of stimulus is important, robotics expert from Cambridge University Prof Fumiya Iida told the BBC.
"Getting robots to learn is one of the most challenging things but is fundamental because it will make them more intelligent," he said.
"Learning is all about trial and error. When a child learns that falling over causes pain, it then learns to do it with more skill."

Experts have found dog intelligence works similarly to human intelligence.
Recent studies have also shown brighter people tend to live longer.
Scientists think if they can prove the same is true in dogs they can use them to study health issues such as dementia.
Dr Rosalind Arden, a research associate at the London School of Economics, which carried out the study with Edinburgh University, said the discovery could have "far reaching implications for understanding human health and disease and canine health and disease".
She said: "We asked the question, if a dog is good at one test does it tend to be better than average at the other test? And we found that yes that's true.
"This is the first step in trying to develop a really snappy, reliable dog IQ test, and that has got implications that aren't obvious at first."
Scientists put the intelligence of 68 working border collies to the test by devising a series of cognitive tasks for them to carry out.
One involved finding their way to a food reward they could see but was behind a barrier - meaning they had to work out to go around the barrier rather than try to dig under it.
Another involved offering two plates of food and assessing if the dogs learnt to go to the one with the bigger portion, while a third task examined how many times a dogs followed a human pointing gesture.
Those that performed well in one of these tasks tended to be above average in the others too.
Dr Arden said scientists have known for some time that brighter people tend to live longer.
However, this can be notoriously tricky to investigate because our lifestyle choices - whether we smoke, and how much we eat, drink and exercise - have a major impact on our health.
Dogs offer a good insight because they are "basically teetotal", Dr Arden said.
They also have another important trait - like humans, they naturally acquire dementia. This causes their behaviour and brain structure to change, Dr Arden said.
She added: "You'll find a dog that changes its social habits, it doesn't want to be petted any more, it becomes introverted and alone. They reproduce lots of the disturbances found in human dementia."
Researchers stressed they have only established that dog intelligence is measurable, as it is in humans, but have yet to establish if this is linked to health.
Dr Mark Adams, research fellow at Edinburgh University, said: "This is only a first step, but we are aiming to create a dog IQ test that is reliable, valid and can be administered quickly.
"Such a test could rapidly improve our understanding of the connection between dog intelligence, health, even lifespan, and be the foundation of 'dognitive epidemiology'.
"Dogs are excellent for this kind of work because they are willing to participate and seem to enjoy taking part."
The research is published in the journal Intelligence.
Researchers from Germany are developing an artificial nervous system aimed at teaching robots how to feel pain.
[NEXT_CONCEPT]
A dog IQ test has been developed by scientists who said it could pave the way for breakthroughs in the understanding of the link between intelligence and health.