# Raspberry Pi Motor control HAT

**URL:** <https://forum.core-electronics.com.au/t/raspberry-pi-motor-control-hat/14577>\
**Category:** Projects\
**Created:** [12 July 2022 05:11 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-motor-control-hat/14577 "2022-07-12T05:11:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [12 July 2022 05:11 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-motor-control-hat/14577/1 "2022-07-12T05:11:42Z")

</div>

**DC Motor Control HAT**

Using a Raspberry Pi to control DC motors needs additional hardware and I wanted to create a minimal sized HAT to cover a lot of requirements as listed below.

[![](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/f/fafdc8e9700b4b06df2d5e03c192c65c989d4b2a.jpeg) ](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/f/fafdc8e9700b4b06df2d5e03c192c65c989d4b2a.jpeg)

**Specifications**

- 3 channel DC Motor control using [SN754410ne](https://core-electronics.com.au/sn754410ne-stepper-motor-drive-ic.html) drivers using the [DFRobot motors](https://core-electronics.com.au/n20-dc-motor-with-magnetic-encoder-6v-with-1-298-gear-ratio.html).
- 3 channel encoder [ls7184n](https://www.usdigital.com/products/accessories/interfaces/ics/ls7184n/?q=LS7184N) processing (processed before it gets to the Pi so that you just get a direction and steps # flag)
- 2 channel MOSFET FQP30N06 switching for external devices
- SPI breakout
- RF24 wireless breakout
- 5v input for Pi
- specific motor input so that you can run different voltage motor types
- Piezo buzzer
- Raspberry Pi GPIO header
- 3 x RJ45 headers for connection to the motors to have motor control and pass back the encoder data.

**Board**

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/7/7c9752375a0eb6731db57ca3ce7d88372ec3cc4b.png)

**Schematic**

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/f/fc63346b70c698efc4d9dbc39bc5447c198c30a8.png)

This add on HAT uses just about every single GPIO pin to achieve motion control of 3 axis of DC motors.  
The encoder IC provides a direction and utilises the A and B channels from the Motor encoder to give an accurate position.

---

<div class="post-metadata">

**Author:** ![Liam120347](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/liam120347/32/5003_2.png) [@Liam120347](https://forum.core-electronics.com.au/u/Liam120347)\
**Post date:** [12 July 2022 07:06 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-motor-control-hat/14577/2 "2022-07-12T07:06:12Z")

</div>

Sick write-up Andrew!

> [@AndrewBG](#):
>
> 3 channel encoder [ls7184n](https://www.usdigital.com/products/accessories/interfaces/ics/ls7184n/?q=LS7184N) processing (processed before it gets to the Pi so that you just get a direction and steps # flag)

Thats a sick IC, if I ever need to read an encoder on a Pi I’ll be sure to jump on this!

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [12 July 2022 21:35 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-motor-control-hat/14577/3 "2022-07-12T21:35:08Z")

</div>

It is an awesome IC, pity that it is difficult to get. I had to order 50 from the USA and all the associated costs that go along with that, however now that I am using it, the timing issues that I was having when reading the A and B channels went away.

The Encoder IC coupled with the DFRobot mini DC Encoder motors is a very sweet combination, the only component that I would like to change over time is the motor driver, purely because I cant get the braking function to work.  
If the motors would stop faster it would be ideal, currently getting about 4-5 encoder rotations after commanding it to stop.  
The other driver issue is that the motors really wont drive at any other speed than 100% via PWM, the torque is simply reduced too much.  
That was the first test in replacing braking, slow down the motor when coming up to the set-point, but it would always end up stalling, unfortunately.
