Virtually all code I have written has been paid for by the customer, so never protect it, I have protected code for OEM's at their request & given them the passwords etc. (they paid for it, these were standard machines they sell).
TBH, why bother, PLC code is just applications of the PLC manufacturers functions, I have never passworded any of my code, I have often been involved in replacing systems that have been protected, even if you do get the code more often than not it is just as quick to re-write it from scratch rather than try & decipher someone elses code.
I can understand why some protect their code i.e. stop unscrupulous people cloning machines/plant that some company have spent a lot of time & money on.
As for producing functions & trying to sell them you would probably find not many people would buy, but good luck if you can make a bit of money out of it.
TBH, any decent PLC engineer could produce similar code. Like Peter has said, be prepared to support it.
On another note: (not knocking intelectual rights) A plant supplied by a company was designed to our specification, we paid for the development of the complete system hardware design & software, the supplier had slightly under estimated on the controls side & locked the applications, it was noted that this supplier was known for it, the control was to say the least very poor, they charged us considerable sums to get it right or if we needed any enhancements doing we were being held to ransom. In the end, I re-wrote the code for the 8 PLC's, we had another systems house to do the Scada & recipe control (I spent the whole time at the suppliers helping them with the code on the scada & getting it right). We estimated the cost of this to be less than the continuing costs of having the original supplier keep making changes & messing it up. In the end I believe that their attitude to ripping the customer off actually cost them future work worth a lot of money.