I'm having trouble with math in picbasic pro. I'll give you an over view of what I'm trying to do. I've been automating a few machines that feed out cardboard and cut it off. The feeding is done by a stepper motor directly connected to a roller. I've been using CNC control software to handle this up till now. I'd like to reduce my cost and have a smaller control.
The roller that the stepper motor is connected to is 1.987” in diameter. So to figure out how much stock is fed out each turn I need the circumference. Which is 1.987 * PI = 6.2423. So with every turn of the stepper motor it feeds out 6.2423 inches of stock.
I have a 2000 step per revolution stepper motor. So then we take the circumference 6.2423 / 2000 which gives us .003121”. This is how much stock is fed out with every step.
This is easy in normal computer programming. But working with pic's is totally new to me.
So far in this project I have a 4X4 keypad working it will store “123A 567B 789C *0#D” in a variable. I also have LCD out put working.
So basically what I need working is for the user to be able to enter the amount of stock they want. Lets say they enter 60.25” inches. With the “*” as the decimal point on the keypad.
So with the above equations all I really need to have in my program is a variable is the (steps per inch = .003121) and then you just take 60.25/.003121 = 19304 Then I would just send out 19304 pulses to a pin on the pic to step the drive.
So my question is how do I work with decimals in 16bit math?
My other question that goes with this is how do I store multiple keys typed in on the keypad so that if the user types in 60.25 I can work with it?
I've attached a picture of the stepper motor (bottom left) attached to the machine with the rollers and cardboard feeding though so you can have a better idea of what I'm doing. Thanks.
Bookmarks