====MegaPi==== {{boards:megapi.jpg?200}} \\ \\ {{boards:megapitb6612.jpg?100}} {{boards:megapidrv8825.jpg?100}} This board contains an ATmega2560 and is compatible with [[:boards:mega2560|Arduino]]. It can connect directly to a Raspberry Pi or work standalone. Power applied to the DC input jack may be between 6V and 12V and feeds up to four motor controllers and the TI regulator which outputs 5V at up to 3A for logic. When using the DC jack, 5V is delivered to the Pi header to power the Raspberry Pi (reliability unknown). A USB cable is used to program via the bootloader on the MegaPi. WARNING: Various issues have been observed with the board causing any connected scope to reboot and other devices on the same power circuit behave erratically. Something to consider when powered by a random 12V PSU which may have an earth at a different potential to the earth of other devices. ===Motor controllers=== At least two are known to exist, the TB6612 and DRV8825. == TB5512== The TB6612 refers to two pins NE1/NE2 which are nowhere to be found on the data-sheet so no idea what they are without reverse engineering the layout. It also has its own dedicated output connector ==DRV8825== The DRV8825 is a stepper motor driver and uses the pinout on the board and also utilises the regular motor outputs. For a NEMA17 motor rated at 400mA per phase the trimmer should be adjusted to 0.2V to limit the current into the motor. ===Setup=== [[:tools:gccavr|gcc-avr]] ===Pinout=== CH340 Tx -> Rx0 PE0 CH340 Rx <- Tx0 PE1 RPi Tx -> Rx2 PH0 RPi Rx <- Tx2 PH1 BT Tx -> Rx3 PJ0 BT Rx <- Tx3 PJ1 LED PB7 Rx1 PD2 Tx1 PD3 NB Disable system login console on Pi to enable AVR UART2 comms. == Motor I/O == __GPIO__ 1 2 3 4 ENABLE PC2 PC1 PL7 PF5 MS1 PC3 PC0 PL6 PF4 MS2 PC4 PG1 PL2 PF3 MS3 PC5 PG0 PL1 PF2 RESET PC6 PD7 PL0 PF1 SLEEP PD3 PD2 PE5 PE4 STEP PB6 PH5 PH6 PE3 DIR PB5 PH4 PH3 PG5 __TIMER__ MOTOR TIMER STEP 1 OC1B PB6 2 OC4C PH5 3 OC2B PH6 4 OC3A PE3 === Motor wiring === __NEMA__ Left to right (socket pointing upward) This may actually be reversed or just wrong. 1 PHASE 2 START GREEN/WHITE B+ B2 2 3 PHASE 2 FINISH GREEN B- B1 4 PHASE 1 FINISH RED/WHITE A- A1 5 6 PHASE 1 START RED A+ A2 __MOTOR__ A `generic' cable from eBay (these vary) A+ RED A- GREEN B- BLUE B+ BLACK My generic cable has the two centre pins twisted. __PORT__ Left to right (from above) B+ B- A- A+ Wiring as per above will result in correct shaft direction. Reverse wiring or swap one pair of wires to rectify incorrect direction. ===Resources=== {{boards:megapischematic1.pdf|Schematic 1}} {{boards:megapischematic2.pdf|Schematic 2}} {{boards:17hs13-0404s.pdf|17HS13-0404S stepper motor}} [[https://www.haydonkerkpittman.com/-/media/ametekhaydonkerk/downloads/linear-hybrid-actuator/integrated-connectors-hybrid-linear-actuators.pdf|NEMA17 integrated connectors]] [[https://www.ti.com/lit/ds/symlink/tps54331.pdf|TI TPS54331 data-sheet]] [[https://toshiba.semicon-storage.com/info/TB6612FNG_datasheet_en_20141001.pdf?did=10660&prodName=TB6612FNG|Toshiba TB6612 data-sheet]] [[https://www.ti.com/lit/ds/symlink/drv8825.pdf|TI DRV8825 data-sheet]] [[http://www.ti.com/lit/an/slyt482/slyt482.pdf|Acceleraton and deceleration profiles for stepper motors]] [[https://iopscience.iop.org/article/10.1088/1757-899X/294/1/012055/pdf|Stepper motor profile in real-time]]