A surgical instrument system comprising a surgical instrument and a housing is disclosed. The housing comprises a handle assembly, at least one motor, and a drive shaft. The surgical instrument system comprises a shaft assembly configured to be attached to the housing. The shaft assembly comprises a control circuit and a locking mechanism. The locking mechanism prevents movement of the drive shaft if the shaft assembly is not attached to the surgical instrument in an orientation which enables the operation of the surgical instrument. The locking mechanism comprises sensing means for determining whether the locking mechanism is actively engaged.