This question is a follow up for this question. I have a classic servo motor (Vin, PWM, Ground), and a short program to work with it. The code is:

import RPi.GPIO as GPIO
import time

GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)

def update(angle):
    duty = float(angle) / 10.0 + 2.5
    output = pwm.ChangeDutyCycle(duty)
    print output

def loop():

def main():
        while i<3:
        return 0

if __name__=="__main__":

My goal is to detect if the servo motor is actually connected and working. The program works well disregarding the servo status (connected/disconnected). As the answer suggests - implementing the circuit to check if the signal is coming. There's an idea to implement the switch circuits (as stated in the answer to a previous question). However I was wondering if someone can provide another solution. The priority is cheap as possible.

I use the external power source for servo - 4 AAA batteries in sequence. I've tried connecting LED in sequence between Vout of battery and Vin of servo - LED lit, but servo didn't move. Same happened when I connected LED in between PWM GPIO and PWM of servo - LED blinked but servo didn't move.

  • This looks to be no so much a followup, but a duplicate of the previous question. What are you looking for that's different this time round? – goobering Jun 8 '16 at 10:10
  • I'm looking for more circuit solutions in this question - in previous question I asked about software solution. – Constantine Samoilenko Jun 8 '16 at 10:12
  • Why? Surely the user knows if they have a servo connected or not? If the user doesn't know then what does it matter? Also software timed PWM is not really suitable for servos unless your application is pretty noddy. – joan Jun 8 '16 at 10:18
  • Also that is why I use different title and different tags - to give the questions clearer distinction. I may as well erase all the code and servo reference and just leave inputs and outputs, however I left those parts because they might be crucial in providing the answer. – Constantine Samoilenko Jun 8 '16 at 10:18
  • 1
    There is no magic here. You will have to design a test bed which exercises the components in a known way, e.g, the servo will have to sweep between two end points fitted with micro-switches. This is not a Pi question. – joan Jun 8 '16 at 10:42

I will perform periodic diagnostics on the devices remotely and I want to know which parts are not functioning.

By definition there is a simple logical reason this is not possible for anything. It is not possible for your car. It is not possible for the International Space Station, you, your cat, your house, or a Raspberry Pi.

I'll explain this by analogy to the car. Let's say a car manufacturer decides to develop a phone app which allows you to remotely check "which parts are not functioning". Obviously this is possible to an extent. For some things (e.g., proper compression) this may require the car's engine be started remotely. It also obviously requires a complex array of sensors be deployed throughout the car. Depending to what "an extent" we want to go, it may also require the car drive around remotely.

Doing this very thoroughly could add tens of thousands of dollars of cost to the car. What's more, as you add complexity for the remote sensing of non-functioning parts, you increase the potential for the remote diagnostic system itself to malfunction. Having a car drive itself around remotely in order to check if it works properly is not sane.

If sanity is not a concern, you could then set out to spend an infinite amount of time integrating an infinite arrangement of redundant sensors to check the sensors that check the sensors that check the equipment, etc. The further you go down this path, the more absurd it gets, and the less interested consumers are going to be in your car. People do not want a car where millions of R&D dollars have been wasted on a system to check whether or not the car works. They want a car where effort is focused on making sure the car works.

Going back to your actual situation, in comments you have made it clear that what you want to check is not really just a servo, it is, more generally, the state of anything connected to an output that does not have a corresponding input. The answer to this question is:

No, you cannot verify an output is connected to anything without a corresponding input.

However, you can make sure you use appropriate quality components, attach them properly, and do testing and quality assurance on site, before they are shipped out. This may mean hiring skilled staff, etc. There is no magic bullet by which you can overlook poor practices and insufficient resources. If you aren't sure whether something is going to work or not, then you should be honest with the people you are selling it to, or else admit you simply cannot provide what is required.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.