Wallacoloo / printipi

3d printing directly through the Raspberry Pi's GPIO pins
MIT License
141 stars 43 forks source link

IoDriver for L298N ? #90

Closed hsh001 closed 8 years ago

hsh001 commented 8 years ago

Hi Does anyboby works on minimalist cnc using L298N as driver for bipolar stepper motors ? With this 'dual full bridge' motor direction is handling by a simple step inversion... It will be nice to use printipi for a very simple cnc... Thanks for your job

Wallacoloo commented 8 years ago

Hi @hsh001. There is currently no built-in support for L298N drivers. However, if you wish to add support for it, you can create a new file, src/iodrivers/L298N.h, implement the same interface as in src/iodrivers/stepdirstepperdriver.h and then use the L298N type in place of A4988 in your machine configuration file.

The getEventOutputSequence function is called every time the motion planner plans a step. It is (naively) expected to be 'const', but any dual full-bridge implementation will likely have to be stateful, since the signals needed to move a stepper by +/- 1 step are dependent upon the current step number (mod 4, I believe). This isn't a problem - just declare the necessary state info as mutable, and keep the method const.

You can also change the return type to (e.g.) std::array<OutputEvent, 2>, since I believe advancing one step using a dual full-bridge should only require toggling two outputs.