I AM A NOOB TO THE ARDUINO.
I know a little about using other MCU boards, and similar, though the Arduino is a new realm for me.
This is part of:
This is my first Arduino project, just getting my feet wet. This is part of the third version of my 3D-Printer firmware, for my third 3D printer design, and the first that I am getting ready to release under a BSD license on Thingiverse. The HW is mostly printable (no screws, no bolts, no nuts, etc), and is designed to be highly extensible along the Z-Axis (that is it can be easily extended in the height of printing).
My user-name here takes from the fact I am playing with 3D printers (the 3D part), and the goal of printing an object that is 8192 mm in height on a version of the printer I am getting ready to release.
The 3D printer works well with earlier versions of my firmware (running on AVR in AVR asm, and Raspberry Pi under RISC OS), though part of the design goal is to use an Arduino for the controller, with completely new firmware.
What I want to do:
I would like to directly bitbang a few steppers attached through ULN2803's to an Arduino Mega2560, in a timer interrupt routine. Something along the lines of (do not know if the following can work, though it is an outline):
//Move the steppers as needed, called from a timer interrupt every
// 0.1 milliseconds.
StepperMv(){
++StpTimer;
if (StpTimer >= XTime && XDist){
XDist--; XTime += XDelay;
XDelay = (XDlyMin < XDelay) ? (XDelay - (XDelay >> 2)) : (XDlyMin);
YStep = (XStep + XDir) & 7 & !(abs(XDir)-1);
PORTB = (PORTB & 0xF0) | Steps[XStep];
}
if (StpTimer >= YTime && YDist){
YDist--; YTime += YDelay;
YDelay = (YDlyMin < YDelay) ? (YDelay - (YDelay >> 2)) : (YDlyMin);
YStep = (YStep + YDir) & 7 & !(abs(YDir)-1);
PORTB = (PORTB & 0x0F) | Steps[YStep] << 4;
}
if (StpTimer >= ZTime && ZDist){
ZDist--; ZTime += ZDelay;
ZDelay = (ZDlyMin < ZDelay) ? (ZDelay - (ZDelay >> 2)) : (ZDlyMin);
ZStep = (ZStep + ZDir) & 7 & !(abs(ZDir)-1);
PORTC = (PORTC & 0x0F) | Steps[ZStep];
}
if (StpTimer >= ETime && EDist){
EDist--; ETime += EDelay;
EDelay = (EDlyMin < EDelay) ? (EDelay - (EDelay >> 2)) : (EDlyMin);
EStep = (EStep + EDir) & 7 & !(abs(EDir)-1);
PORTC = (PORTC & 0xF0) | Steps[EStep] << 4;
}
}
So bitbanging the ports directly.
The Problems:
1 : I can not find the Arduino way to set up a timer interrupt.
2 : I can not find how the ports of the AVR Mega2560 map to the pins of the Arduino Mega2560.
A plea
Can someone please help with this issue? At least point me in the correct direction, please?
