RAMPS is mainly just an interface boards for stepper controllers, with Megatronics being that same board with an Arduino Mega on board. They also provide a few inputs (thermistors and end-stop), and a few outputs (FETs to control stuff), and in some cases generic I/O (servo pins, expansion headers, etc). You still need a number of Pololu A4988/DRV8825 (or compatible) stepper driver boards. Both have sockets on them for these boards (depending where you buy, they may be included or not).
The advantage of these boards is simply that it does all the hard connection work for you. You can easily drive them with your own code. You just need to set the right pins and toggle them appropriately. I know somene who is using 3 steppers on a RAMPS board with some simple code to control a loom.
Most of the firmwares are complicated so reading them as an example is not going to help you with getting to know how it all hangs together. There is some test firmware somewhere that simply drives the motors in certain predictable patterns. I can't remember the link and couldn't find it just now, so someone else might help on that front.
Basically you need to set the enable pin appropriately (depending on the board, it may not have one, or it might be common between a few pins, or each stepper may have it's own - always check), then you set the direction pin (direction always depends on the motor wiring which can be inconsistent, so experiment) then you pulse the step pin the number of steps you want it to move. Note that the "steps" are actually depend on the microstepping jumpers - so 1 step pulse will get you 1/16th of a step if the jumpers are set for 1/16th step. You just send a train of multiple pulses to get the number of steps you want.
Notes:
There is no feedback loop, so you don't know if your step succeeded. You could put an encoder on it, but none of the 3D printer electronics really do that - they rely on you tuning the stepper drive appropriately.
The "pulse" needs a reasonable duration. I don't know what the minimum is (check the spec sheets for the Pololu A4988 or DRV8825 boards), but things like 1-2 microseconds is usually way too small.
The advantage of these boards is simply that it does all the hard connection work for you. You can easily drive them with your own code. You just need to set the right pins and toggle them appropriately. I know somene who is using 3 steppers on a RAMPS board with some simple code to control a loom.
Most of the firmwares are complicated so reading them as an example is not going to help you with getting to know how it all hangs together. There is some test firmware somewhere that simply drives the motors in certain predictable patterns. I can't remember the link and couldn't find it just now, so someone else might help on that front.
Basically you need to set the enable pin appropriately (depending on the board, it may not have one, or it might be common between a few pins, or each stepper may have it's own - always check), then you set the direction pin (direction always depends on the motor wiring which can be inconsistent, so experiment) then you pulse the step pin the number of steps you want it to move. Note that the "steps" are actually depend on the microstepping jumpers - so 1 step pulse will get you 1/16th of a step if the jumpers are set for 1/16th step. You just send a train of multiple pulses to get the number of steps you want.
Notes:
There is no feedback loop, so you don't know if your step succeeded. You could put an encoder on it, but none of the 3D printer electronics really do that - they rely on you tuning the stepper drive appropriately.
The "pulse" needs a reasonable duration. I don't know what the minimum is (check the spec sheets for the Pololu A4988 or DRV8825 boards), but things like 1-2 microseconds is usually way too small.