The ships schoolmaster is a Civilian Officer, like the Surgeon, Chaplain or the Purser. This position became official towards the end of the 18th century. Until this point a few conscientious captains supplied someone to teach the boys and younger midshipmen.
He was appointed by the Captain and was rated "Midshipman" but he rarely rose above this rate. He would have been considered a "Petty" officer since he was appointed by the Captain. He was no considered a normal midshipman and would not find himself on the normal watches that midshipman stood.
His had to be able to read, do mathematics and be "well skilled in the theory and practice of navigation". He had to get a certificate from the Trinity House of Deptford Stround to show his qualification.
He did not rate a cabin and took his meals in the gunroom with the midshipman. While his pay is that of the midshipman, after 1812 he was also given a bonus of £20 per year. He was also paid £5 per year from each of his Officer/students.
Needless to say, this position was not one easily filled by qualified teachers. Some who filled it were from the lower decks such as some one from the Master's or Purser's department. Other's were scholars who were escaping from something on shore, a drinking problem, women or debt.
The Chaplain could also act as the Schoolmaster, but receiving on the £5 tuition from the Officer/student as additional income.
In later years, this position became a Naval Instructor and by 1861 they became a commissioned officer.