Inputting 16 bit numbers into a 16 series pic

Status
Not open for further replies.

bryan1

Well-Known Member
Hiya Guy's,
Well I finally found some time for my projects so I'm making up a small cnc machine. The first task is to make 1 axis and get the software all figured out. Tomorrow I'll be hooking up a bipolar (5 volts @ 1amp current) to the shaft via gearing to give me a higher resoultion and more torque. Now the shaft I made is an acme thread 1/2" x 10 TPI so one revoultion will be .1" or 2.54mm. I've spent nearly a week making everything up to an accuracy of 0.001" and when I install the thrust bearings on the threaded shaft I won't have any backlash as the nut and shaft I made is bloody accurate :twisted:.

Now for the question I plan on using a 16f877a or a 16f777 as the main microcontroller and in my square one book 'easy steppin' is a nice routine for ramping up, rapid traverse and ramping down to the destination but it can only input an 8 bit number as the code is designed around a 16f84. I need to input a 16 bit number as my slide has 360mm of travel. I've looked around the piclist and tried google but I couldn't find anything so I was hoping someone could provide a link or explain how I can accomplish my task of inputting a number bigger than 8 bits.

Cheers Bryan
 

PIC's (like most micro-controllers) are 8 bit devices, for 16 bit routines you simply use more than one GPR, and write your routines accordingly. Just as with counting on your fingers, you need to check for carries and overflows - so if you increment the lower byte, you need to test if it overflows, and if it does?, then increment the upper byte as well. It's quite simple to do, and there's plenty of data on the PICList.

BTW, if you check my LCD tutorials, one of those uses a 16 bit counter to display an increasing number on the LCD.
 
Hiya Guy's
Eh Nigel thanks for the advise I'll certainly check out the pic list again and I have all your tutorials saved as I always reference them and I'm not always on the net. Anyway I got the basics finished today so below is a pic of the latest progress. I'm going to have to increase the ratio on the gearbox as the resoultion is about .002" each step. As the total travel of the axis is 295mm I reckon I can get away inputting 8 bit numbers for the start and worry about bigger numbers later.

I hope the moderators don't mind me putting this in this forum but I'll be putting some of the code I write on this thread but if it needs moving to another section feel free to do so.

Cheers Bryan
 

Attachments

  • cnc_photo_2.gif
    185 KB · Views: 384
bryan1 said:
I hope the moderators don't mind me putting this in this forum but I'll be putting some of the code I write on this thread but if it needs moving to another section feel free to do so.
Cheers Bryan

No, this fits Microcontrollers just well. Maybe after it's finnished we can move it to the Projects section.

BTW: This looks like a sweet project...
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…