See this KB Article:
The 5100 error would point to a problem with the ink carriage being able to move from side to side properly. With that error, you can try opening the front to make sure the ink is seated properly and check the inside for any jammed/torn paper. If the ink is loaded properly and you did not locate any jammed/torn paper, you can also try using the steps in the link HERE to try cleaning the printer's encoder strip. If that does not resolve the issue, the printer would need service. You can use the link HERE to access your My Canon account to check what service options are available.