Hi all.
I built a small desktop CNC machine. I am making the controller for it now. I have a Nanocore12MAX microcontroller that I want to run it. I have the FETs on separate chips. I have run the motor it both directions using the microcontroller to make sure I can run the motor using it. I can get it to run the motor in one direct when I want it to but I need to control it with the computer. I am using CodeWarrior to program the chip in C code. I have 9 outputs from the computer. 3 for each motor 1 enable, 1 cw/ccw and 1 step. Those nine outputs make 512 states that the micro controller must know what to do when each state is given and feed the correct instructions to the machine. I can set the output by sending the correct binary number to the outputs to make the motor move.
I have spent several hours looking around on CNCZone and the internet and not found any C code that could be used for what I need.
I see no reason to reinvent the wheel or in this case C code. If someone has C code that would work I would use that if the owner did not mind. This would be the best solution if someone was generous enough to share code with me.
I see 2 ways to do it. Have 512 if then statements and have the micro controller go through all of them and step as the motor as output of the computer is read. In other words brute force it. I can do it but it would not be the best solution.
The second I was told about but have not idea how to do it have the micro controller pole the inputs and when it get an instruction it will shift a binary byte left or right to step the motor the desired directions. Then there is the worry about the carry bit. I have not idea how to do this but it would be a better solution than the above one.
Unless someone has better advice I am going to brute force it.
Thanks for your help.
Stan