One way to do it is to use an output with a pulse/pattern, connected through the sensing device (switch, photo sensor...) connecting it back to the input. If the switch is closed the pulse/pattern should be available on the input. If the pulse/pattern isn't on the input you know that the switch isn't closed, isn't working or that the circuit isn't working, which should be a safe state (not dangerous state - motors or relays off). To improve safety, the sensing device should invert the signal (photo sensor) so that a simple short circuit on the input and output wires also can be detected. To improve safety even more, the input should be doubled (two sensors) and both should be working in parallell to be able to set the device in the dangerous state. What kind of device is it for? Ruben > Hi, > > I am writing a safety-related software and need to detect if an input > pin gets stuck at 1 (or 0). Could any one tell me how to do it in the > software? > > Thanks alot! > > Tony > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > ============================== Ruben Jvnsson AB Liros Electronic Box 9124, 200 39 Malmv, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se ============================== -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.