Skip to the content
2 layers100 × 60 mmMotordrivershield, the printed circuit board in 3D

Motordrivershield

wuehr1999/lois_ecu2

General purpose ECU for robotics applications

Size
100 × 60 mm
Copper layers
2
Thickness
1.6 mm
Parts
163
Nets
103
Pads
507
Tracks, vias
1,357, 544
Pours
38
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
25 Dec 2022
Updated
16 Feb 2023

Overview

Motordrivershield is an open-source printed circuit board by wuehr1999, from the wuehr1999/lois_ecu repository on GitHub, published under the MIT licence. It is a 2-layer board of 100 × 60 mm with 163 parts on 103 nets, routed with 1,357 tracks and 544 vias.

It is built around the MAX3232ID, SN65HVD232D and IFX007T, with the LM358, TPS54335ADDA and BNO055 among its other parts. Its parts include 62 capacitors, 57 resistors, 14 connectors, 13 ICs and 5 diodes. It belongs with the STM32 boards of this library.

Main components

7

README

README.md

lois_ecu

This repository contains the hardware, firmware and tooling for a general purpose control unit for differential drive based wheeled robotics platforms. An image of the real hardware and a component diagram are shown below.

Firmware

The firmware comes as a STM32 CubeIDE project and currently implements the following features:

  • Closed single loop RPM-control for two DC-motors with encoders
  • Realtime calculation of differential drive odometry
  • Servo sweep for the ball distribution device
  • NMEA parser on RS232_1 (used for UBLOX GPS)
  • NMEA parser on RS232_2 (used for KVH-C100 fluxgate compass)
  • Host communication via UART
  • 2048 Byte reealtime reord buffer ( recording of RPM, torque and compass heading over a given time )
  • Easy human readable and debuggable ASCII communication leaned on modbus protocol with optional checksum

Host communication protocol

The communication protocol is ASCII-based and the messages have the following format:

:<8-bit command><32-bit payload><8-bit crc><\n>

All values are written in hexadecimal, so that every message has a fixed length of 14 characters. There is also a ROS2 driver, which uses the given protocol to make the functionalities available via ROS.

The table below shows the currently implemented messages. There are also some periodic messages from the ECU to the Host. By writing the commands of this messages to the ECU, the period can be changed. The payload is then interpreted as an uint16 containing the period time in milliseconds. 0xfffe then means requesting a periodic message once and 0xffff turns the message off completely.

CommandFunctionTo ECU (E)/ To Host (H)Payload interpretationPeriodic
0x01Dutycycle of left and right motor, RPM controller gets disabledE2 x int16 ( -100 % - 100 %)
0x02RPM of left and right motor, RPM controller gets enabledE2 x int16
0x03Turn board LED on or offEbool
0x04Record a given amount of RPM samplesE / H2 x uint16 ( m samples left and n right ) to ECU or sequential max(m, n) 2 x uint16 ( tick timestamps in 100 ns followed by 0x00000000 ) to Host
0x05Emergency stop button pressedHbool
0x06Kp left controllerEfloat32
0x07Tn left controllerEfloat32
0x08Td left controllerEfloat32
0x09Kp right controllerEfloat32
0x0aTn right controllerEfloat32
0x0bTd right controllerEfloat32
0x0cRecord a given amount of compass heading samplesEuint32 n samples to ECU or sequential n + 1 2 x int16 ( heading data in degrees ) followed by 0x016A016A to Host
0x0dGPS positionE / H3 sequential uint32, 2 x float32 ( 0xffffffff, latitude, longitude )x
0x0eGPS timeE / H3 x uint8 ( hours, minutes, seconds )x
0x0fGPS dateE / H3 x uint8 ( year, month, day )x
0x10Compass headingE / H1 x int16 ( degrees to north )x
0x11Terminal mode ( forward serial sensor Rx input on this interface )Euint8 ( Host protocol, GPS sensor, compass sensor )
0x12Encoder overall ticksE / H4 sequential 4 x uint32 ( 0xffffffff, timestamp in nanoseconds, left encoder, right encoder )x
0x13Left encoder short level time correctionEfloat32
0x14Left encoder long level time correctionEfloat32
0x15Right encoder short level time correctionEfloat32
0x16Right encoder long level time correctionEfloat32
0x17Record a given amount of Torque samplesE / H2 x uint16 ( m samples left and n right ) to ECU or sequential max(m, n) 2 x uint16 ( torque 12-bit ADC values followed by 0x00000000 ) to Host
0x18Reset all controllers, interfaces and countersE-
0x19Use ball distribution device onceE-
0x20Odometry calculated on robotE / Hsequential 7 started with 0xffffffff followed by 6 x float32 ( x, y, phi, dx, dy, dphi )x

Encoder and RPM controller tuning

There is tooling in Scilab provided, that can be used to find the parameters for the implemented RPM controller. The first step is recording a step response with full torque/ dutycycle and data of free spinning wheels at a constant dutycycle and saving the data as *.csv files. This can for instance be done by using the ROS ecosystem of lois. There are also some examples in the controller tuning folder.

Encoder correction

The ECU determines the RPM values of the robot by measuring the time of high and low levels of the encoder signals. With this implementation, also encoders with fewer steps ( usually mounted directly on the wheel ) can be used with a sufficient resolution. The problem is, that some encoders have inequal high and low times. Therefore correction factors can be calculated and entered at runtime ( commands 0x13 - 0x16 ) from the free spinning record.

Finding the controller parameters

The controller is updated in the ECU with a frequency of 5 Hz. It is only a single loop RPM controller without a cascade for torque control, as it is not necessary for most differential drivetrain applications.

There is one band limited PI controller for each motor with the transfer function G(s) = Kp * ( 1 + s * Tn ) / ( s * Tn * ( 1 + s * Td )).

The Scilab tooling helps to approximate the plant from the step response as 1st or 2nd order system and find sufficient controller settings. The tuning paradigm is the compensation of the most critical pole of the plant followed by gain optimization. The following goal parameters that can be selected:

  • Encoder steps per revolution
  • Controller frequency in Hz
  • Don't optimize for phase margin with gain optimum ( Td = 0 )
  • Maximum overshoot inpercent
  • Step response destination in % for optimization ( average RPM value during operation )
  • Stabilization time in seconds
  • Tolerance band in %

PCB toplayer

PCB bottomlayer

Parts

163
QtyValueFootprintReferences
28100nFcapacitors:C_0603C1, C2, C3, C4, C16, C18, C22, C23, C28, C29, C30, C31, C37, C38, C43, C44 +12
1810kresistors:R_0603R10, R11, R14, R15, R24, R26, R28, R29, R31, R32, R42, R44, R48, R49, R51, R52 +2
8220nFcapacitors:C_0603C24, C25, C26, C27, C39, C40, C41, C42
622kresistors:R_0603R36, R39, R40, R41, R43, R45
5100kresistors:R_0603R1, R3, R4, R5, R21
41nFcapacitors:C_0603C35, C36, C48, C49
4510resistors:R_0603R30, R33, R50, R53
456kresistors:R_0603R34, R35, R37, R38
4DNIcapacitors:c_elec_8x6.7C33, C34, C46, C47
4IFX007TSOT_TO:TO-263-7LeadU6, U7, U9, U10
4MHP_3.2_5.0MECH_mounting_holes:MHP_3.2_5.0MECH1, MECH2, MECH3, MECH4
31kresistors:R_0603R46, R47, R58
322uFcapacitors:C_1206C14, C19, C20
3Led_SmallLEDs:LED_0603D1, D2, D8
3WR-TBL_691313710002mechanical-connectors:WR-TBL_691313710002P5, P6, P8
20R0resistors:R_0603R12, R13
220resistors:R_0603R7, R8
220pFcapacitors:C_0603C52, C53
2220resistors:R_0603R20, R23
24.7uF 50Vcapacitors:C_1206C8, C9
247uFcapacitors:c_elec_8x6.7C17, C21
25.6kresistors:R_0603R25, R27
2CONN_01X04Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalP3, P13
2CONN_02X03Connector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_HorizontalP10, P11
2DNIcapacitors:c_elec_4x4.5C32, C45
2LM358SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mmU5, U8
1100nFcapacitors:C_1206C12
110uFcapacitors:C_1210C55
110uFcapacitors:C_1206C7
1120resistors:R_0603R9
1120pFcapacitors:C_0603C10
112nFcapacitors:C_0603C11
1143kresistors:R_0603R18
1150kresistors:R_0603R55
115Afuse_holders_and_fuses:Fuseholder_ATO_Blade_littlefuse_8_PinF1
116Mcrystals:Crystal_SMD_0603_4PadsY1
119.1kresistors:R_0603R22
11Mresistors:R_0603R2
1220kresistors:R_0603R16
13.74kresistors:R_0603R19
143.2kresistors:R_0603R17
147uFcapacitors:TantalC_SizeD_EIA-7343_WaveC15
147uF capacitors:TantalC_SizeD_EIA-7343_WaveC13
14k7resistors:R_0603R6
174437324150L_power:WE-LHMI40xxL1
174xx32SOIC:SOIC-14_3.9x8.7mm_Pitch1.27mmU11
1BAT46Wdiodes:SOD-123D3
1BNO055LGA:LGA-28-5832U2
1CONN_01X02CON_wuerth:WR-TBL_691322310002P7
1CONN_01X03Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_HorizontalP1
1CONN_01X03CON_wuerth:WR-TBL_691322310003P2
1CONN_01X04connectors_JST_SH:Connectors_JST_SM04B-SRSS-TBP12
1CONN_01X06Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_VerticalP9
1D_Smalldiodes:DO-214ABD4
1Jumper_NC_Smallwire_pads:SolderJumper_2mmJP1
1LT1117SOT_TO:SOT-223U3
1Labellabels:BotL4
1Labellabels:jecc_logoL2
1Labellabels:TopL3
1MAX3232SOIC:SOIC-16_3.9x9.9mm_Pitch1.27mmU13
1QWIICconnectors_JST_SH:Connectors_JST_SM04B-SRSS-TBCN1
1SN65HVD232SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mmU12
1STM32F103C8TxQFP:LQFP-48_7x7mm_Pitch0.5mmU1
1SW_PUSHmechanical-switches:smd_pushSW1
1TPS54335ASOIC:SOIC-8-1EP_3.9x4.9mm_Pitch1.27mmU4
1USB_Bmechanical-connectors:USB_BP4

Similar boards

  • 2 layers86 × 80 mmStromwaechter, the printed circuit board in 3D

    Stromwaechter

    generationmake/Stromwaechter_PCB

    PCB with current sensors for 12 V battery systems

    132 parts
  • 4 layers135 × 75 mmCorevus g, the printed circuit board in 3D

    Corevus g

    calithameridi/corevus

    High-flexibility, low-cost mechatronics controller for 3D printers

    444 parts25
  • 2 layers35.6 × 38.1 mmBrake Controller, the printed circuit board in 3D

    Brake Controller

    Autonomous-Motorsports-Purdue/AMP_PCB_Brake-Controller

    PCB with brake motor controller files and documentation

    28 parts
  • 2 layers101.6 × 63.5 mmDccpp pcb, the printed circuit board in 3D

    Dccpp pcb

    trainman419/dccpp_pcb

    This is the DCC++ board project. It's a relatively simple printed circuit board which integrates all of the components that are necessary for a DCC++ base station onto a single PCB, with all of the things you need, and…

    70 parts
  • 2 layers75 × 86 mmTriforce control, the printed circuit board in 3D

    Triforce control

    TeamTriforceUK/triforce-control-pcb

    An open source KiCAD PCB design for the Triforce Fight Controller.

    20 parts
  • 4 layers40 × 40 mmOpenWave, the printed circuit board in 3D

    OpenWave

    wattnotions/OpenWave

    Open Source Ocean Wave Sensor

    51 parts8

Questions

How big is the Motordrivershield PCB?

It measures 100 × 60 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Motordrivershield use?

163 parts, built around the MAX3232ID, SN65HVD232D, IFX007T and LM358. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Motordrivershield KiCad files?

From the wuehr1999/lois_ecu repository on GitHub, at the commit this page was made from: the board is hw/motordrivershield.kicad_pcb and its schematic hw/interfaces.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Motordrivershield design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).