This is the revision A of the Midimotor1e module.

Midimotor1e Module (Revision A)

Table of Contents

1. Introduction

The Midimotor1e module is designed to drive a medium (aka midi) sized motor with a maximum current of 3.5 Amperes per motor. The logic circuitry is separated from the motor H-bridges via optoisolators. There is an additional 5-pin connector that can be connected to a quadrature encoder or potentiometer. Also, there is a 2-pin connector that can be used to connect to one or more normally open limit switches.

2. Programming

This module is controlled via two registers files -- a 24-bit signed integer register file and an 8-bit register file.

The 24-bit register file is described in the table below:

`
Index Name Read/WriteDefault Description
0 Position Read Only* 0 The current position of the system
1 Target Read/Write 0 The desired position of the system
2 D Read/Write -1 [D]enominator (shared) for PID feedback constants
3 Np Read/Write 1 [N]umerator for [p]roportoional feedback
4 Ni Read/Write 0 [N]umerator for [i]ntegeral feedback
5 Nd Read/Write 0 [N]umerator for [d]erivative feedback
*In quadrature mode, the Position register can be written, but increments and decrements will still happen as quadrature wheel turns.
The PID algorithms has three constants, Kp,, Ki, and Kd. These three constants are computed from D, Np, Ni, and Nd as follows: With the exception of the position value, the values in the 24-bit register file only change when a command is sent to change a value. The position value is continuously updated via the values read from either the quadrature disk or the position potentiometer.

The 8-bit register file is described in the table below:

Index Name Read/Write Default Description
0 Configure Read/Write 0 Configuration for motor direction, quadrature vs. potentiometer, position direction control, etc.
1 Status Read Only 0 Status of what is going on inside the module: Seeking to a target, limit switch trip, etc.
2 Speed Read/Write 0 Actual motor speed
3 Errors Read/Write 0 Number of errors detected.
4 Deadband Read/Write 4 Distance to target at which to stop seeking
5 Idle Read/Write 0 Number of times the position was in the deadband
6 Limit Read/Write 20 The maximum number of times position is in the deadband before seeking is stopped.
7 Index24 Read/Write 0 Index into 24-bit register
The Configuration register is used to specify motor driection, position direction, and whether quadrature or a potentiometer is used for position measurement. The Status register specifies what is going on inside of the module. Speed is the current speed. The Speed register is a signed 8-bit quantity that ranges from -128 to +127, where +127 corresponds to a 100% pulse width modulation ration and 0 corresponds to motor off. If the module is not seeking a position, the motor will go that speed. The Errors register counts how many quadrature state transition errors have occured. The Deadband, Idle, and Limit registers are used to control when position seeking turns off.

The module is operated by writing values into the two register files. To set up the module, the following is done:

In order to seek to a position, the Target register is loaded, this register can be updated even if a position seek is in progress. Indeed, the Target register can even be pointed to a location that will cause the motor to immediately reverse directions. The Position register can be read to see where the current position is.

The programming table lists all of the commands.

3. Hardware

The hardware consists of a circuit schematic and a printed circuit board.

3.1 Circuit Schematic

There is a separate parts list file.

3.1.1 Logic Schematic

The logic section of the Midimotor1e module is shown below:

Midimotor1e Logi Schematic
The logic power and CAN signals come in from N4 pins 3 through 8. The CAN signals are connected to the MCP2551 CAN physical layer IC, U5. The transmit and receive pins of the microctroller, (U4 pins 5 and 6) are connected to the other side of U5. Lastly, the RC0 through RC3 are used to drive the quad optoislator, U3, through current limiting resistors R5 through R7.

3.1.2 Power Schematic

Please note that U3 optoisolator shows up in both schematics. There is only one optoisolator, it is just easier to understand what is going on if the optoisolator is present in both schematics. There is no shared ground between the two sides of the optoisolator.

The power section of the Midimotor1e module is shown below:

Midimotor1e Power Schematic
Each L298 (U1 and U2) is a dual H-bridge in a Multiwatt-15 package. As per recommended practice, the two H-bridges are ganged together to form a single H-bridge with 3.5 Amp capacity. Power comes in on N3. The dedicated regulator VR1 provides 5 volts for the logic ciruitry. The H-bridge circuitry is always enabled. The Schottky diodes (D1-D8) are used to clamp out unwanted voltage spikes that occur as a result of switching. Each H-bridge is connected to two optoisolators in U3 to allow independent switching of the H-bridge.

3.2 Printed Circuit Board

The printed circuit board files are listed below:

midimotor1e_back.png
The solder side layer.
midimotor1e_front.png
The component side layer.
midimotor1e_artwork.png
The artwork layer.
midimotor1e.gbl
The RS-274X "Gerber" back (solder side) layer.
midimotor1e.gtl
The RS-274X "Gerber" top (component side) layer.
midimotor1e.gal
The RS-274X "Gerber" artwork layer.
midimotor1e.gml
The RS-274X "Gerber" mask layer.
midimotor1e.drl
The "Excellon" NC drill file.
midimotor1e.tol
The "Excellon" tool rack file.

4. Software

The following files are available:

midimotor1e.ucl
The Midimotor1e µCL source code. There is not much actual code here, since most code is implemented in libraries.
midimotor1e.asm
The Midimotor1e assembly code listing
midimotor1e.lst
The Midimotor1e assmbley listing file.
midimotor1e.hex
The µCL Midimotor1e Intel® Hex file.

5. Issues

The following issues came up:


Copyright © 2009 by Wayne C. Gramlich. All rights reserved.