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."
Researchers from Germany are developing an artificial nervous system aimed at teaching robots how to feel pain.