Pololu Corporation M2H24v14 User Manual Download Page 11

2. Contacting Pololu

We would be delighted to hear from you about any of your projects and about your experience with
the Motoron. If you need technical support or have any feedback you would like to share, you can

contact us

[https://www.pololu.com/contact]

directly or post on our

forum

[https://forum.pololu.com/c/support/

pololu-motor-controllers-drivers-and-motors]

. Tell us what we did well, what we could improve, what you

would like to see in the future, or anything else you would like to say!

Pololu Motoron Motor Controller User’s Guide

© 2001–2022 Pololu Corporation

2. Contacting Pololu

Page 11 of 67

Summary of Contents for M2H24v14

Page 1: ...ry Pi 16 3 4 Setting I C addresses with a Raspberry Pi 17 3 5 Setting I C addresses with an Arduino 18 3 6 Writing code 20 4 Motoron M3S256 pinout 24 5 Motoron M3H256 pinout 26 6 LED feedback 28 7 I C interface 30 8 Variable reference 32 9 Command reference 51 10 Cyclic redundancy check CRC 66 11 Reset pin 67 Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation https www polol...

Page 2: ...troller Shield for Arduino Connectors Soldered The Motoron M3S256 Triple Motor Controller Shield for Arduino shown above can control three motors and is designed to plug into an Arduino https www pololu com product 2191 or compatible board such as the A Star 32U4 Prime https www pololu com category 165 a star 32u4 prime The Motoron M3S256 can operate from 4 5 V to 48 V and has reverse voltage prot...

Page 3: ...ifications Logic voltage range 2 8 V to 5 5 V Control interface I C I C clock speed up to 400 kHz Optional cyclic redundancy checking CRC Configurable motion parameters Max acceleration deceleration forward reverse Starting speed forward reverse Direction change delay forward reverse PWM frequency eight options available from 1 kHz to 80 kHz Command timeout feature stops motors if the Arduino stop...

Page 4: ...through hole connectors Motoron M3S256 with soldered stackable headers and terminal blocks https www pololu com product 5030 Motoron M3S256 with headers and terminal blocks included but not soldered in https www pololu com product 5031 Motoron M3S256 without any headers or terminal blocks included https www pololu com product 5032 Motoron M3H256 with soldered stackable headers soldered terminal bl...

Page 5: ...minal blocks installed This version allows you to use all the main features of the board without additional soldering as the motor and power leads can be connected to the board via terminal blocks and the logic connections are made by simply plugging the shield into an Arduino M3S256 kit version Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 1 Overview Page 5 of 67 ...

Page 6: ...t 2444 Four 2 pin 5mm screw terminal blocks https www pololu com product 2440 One 1 25 male header https www pololu com product 965 There are more parts included than can be soldered to the board providing different assembly options to suit a variety of applications Additional connector https www pololu com category 19 connectors options are available separately and wires can also be soldered dire...

Page 7: ...ldered to the larger through holes for the power and motor connections and the blue ones should get locked together prior to installation see our short video on terminal block installation https www youtube com watch v 6pDyTLRZ2Eg M3S256 with no connectors Motoron M3S256 Triple Motor Controller Shield for Arduino No Connectors The no connectors version https www pololu com product 5032 is just the...

Page 8: ...1952 two screws https www pololu com product 1968 and two hex nuts https www pololu com product 1967 This version allows you to use all the main features of the board without additional soldering as the motor and power leads can be connected to the board via terminal blocks and the logic connections are made by simply plugging the shield into a Raspberry Pi M3H256 kit version Pololu Motoron Motor ...

Page 9: ... One 1 25 male header https www pololu com product 965 Two standoffs https www pololu com product 1952 Two screws https www pololu com product 1968 Two hex nuts https www pololu com product 1967 There are more parts included than can be soldered to the board providing different assembly options to suit a variety of applications Additional connector https www pololu com category 19 connectors optio...

Page 10: ...ger through holes for the power and motor connections and the blue ones should get locked together prior to installation see our short video on terminal block installation https www youtube com watch v 6pDyTLRZ2Eg M3H256 with no connectors Motoron M3H256 Triple Motor Controller for Raspberry Pi No Connectors or Standoffs The no connectors version https www pololu com product 5035 is just the PCB a...

Page 11: ...o share you can contact us https www pololu com contact directly or post on our forum https forum pololu com c support pololu motor controllers drivers and motors Tell us what we did well what we could improve what you would like to see in the future or anything else you would like to say Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 2 Contacting Pololu Page 11 of 67 ...

Page 12: ...t there is a limit to how much current the power supply can provide The operating voltage range of a Motoron is the range of voltages that can be supplied to the Motoron s VIN and GND pins which power the motors The operating voltage range of the Motoron M3S256 and M3H256 is 4 5 V to 48 V The Motoron requires a DC power supply The continuous current per motor of a Motoron is the maximum amount of ...

Page 13: ...xample when they are accelerating or encountering extra resistance 3 2 Connecting everything This section explains how to connect motor power motors and a microcontroller to a Motoron motor controller Connecting terminal blocks We generally recommend using green 3 5mm pitch terminal blocks https www pololu com product 2444 for the motor power and motor connections If you have an assembled version ...

Page 14: ... not the connect their GND pins in a way that is meant to carry the large currents involved in motor control Note that connecting power to VIN does not power the Motoron s microcontroller and does not cause any LEDs to turn on Each motor should have one lead connected to an MxA pin M1A M2A or M3A and the other lead connected to the MxB pin with the matching motor number The Motoron s concept of fo...

Page 15: ...e Raspberry Pi s 3V3 pin to the Motoron s logic voltage The Motoron does not need to be connected directly to the controller it can be connected through another board including other Motoron boards as long as those boards pass the GND SCL SDA and logic voltage connections through You can also connect the Motoron to a controller board that has a different shape as long as you make the same connecti...

Page 16: ... 3 3 Enabling I C on the Raspberry Pi This section explains how to enable the correct I C bus on your Raspberry Pi make sure that your user has permission to access it and test your setup The Motoron is designed to connect to the I2C1 bus on the Raspberry Pi which uses GPIO pin 2 for SDA and GPIO pin 3 for SCL If you are using Raspberry Pi OS this bus is represented by dev i2c 1 that is the name o...

Page 17: ...need to change the I C addresses of one or more Motorons Warning If you have devices on your I C bus that are not Motorons the procedure below could cause undesired behavior when it sends commands to them that are intended for the Motorons The recommended procedure for setting the I C address of one or more Motorons that are connected to the I C bus of your Raspberry Pi is 1 Ensure that the JMP1 p...

Page 18: ...rved for other uses by the I C specification For example type a17 to set the address of the Motoron to 17 Alternatively you can just send a by itself in order to have the program automatically pick an address for you starting at 17 and skipping addresses that are already in use on the bus This sends a Write EEPROM command to all of the Motorons using address 0 but the command will only have an eff...

Page 19: ... looks something like this Scanning for I2C devices Found device at address 0 Found device at address 16 Done The scan detects that a device on the bus is responding to address 16 because that is the Motoron s default address It also detects a device on address 0 because that is the I C general call address and all Motorons respond to it by default in addition to the normal address We will use add...

Page 20: ...commands to it and receive responses from it The commands are sequences of bytes 8 bit numbers from 0 to 255 and the responses are also sequences of bytes The details of how the I C interface works are documented in Section 7 The details of what commands are supported and how to encode them in bytes are documented in Section 3 6 Numbers prefixed with 0x here are written in hexadecimal notation bas...

Page 21: ... possible Each of these examples just controls one Motoron If you are using multiple Motorons you can create an additional MotoronI2C object for each controller and pass the I C address of each Motoron to the constructor for each object using the address parameter This can be done for any of the examples listed above and the library comes with an example named simple_multi_example py which is base...

Page 22: ...r reset flag Bytes 0xA9 0x00 0x04 This command clears sets to 0 a bit in the Motoron called the Reset flag This flag gets set to 1 after the Motoron powers on or experiences a reset and with the default configuration it is considered to be an error so it prevents the motors from running This is an example of the more general Clear latched status flags command and there is no CRC byte appended beca...

Page 23: ...ommand and all other commands are documented in Section 9 Motion parameters You can send a Set variable command documented in Section 9 to configure how the motors move In particular you can set acceleration and deceleration limits for each motor and each direction of motion which helps to reduce sudden current spikes or jerky motions The only Motoron setting that is stored in non volatile memory ...

Page 24: ... a microcontroller to the Motoron The motor power supply should be connected to the VIN pin and adjacent GND pin and a motor can be connected to each pair of MxA and MxB pins e g M1A and M1B For more information on choosing a power supply and motors see Section 3 1 The Motoron s logic is powered from the Arduino by the IOREF pin and it is controlled via I C through the SCL and SDA pins see Section...

Page 25: ...n s AVIN pin to the nearby VM pin Doing this supplies power to Arduino s VIN pin AVIN from the reverse protected motor supply voltage VM Alternatively you can power the Arduino through a voltage regulator https www pololu com category 136 voltage regulators The Motoron M3S256 has VM GND and AVIN pins next to each other which are designed to be connected to a regulator The regulator should be conne...

Page 26: ...3 1 The Motoron s logic is powered from the 3V3 pin which connects to the pin of the same name on the Raspberry Pi The Motoron is controlled via I C through the SCL and SDA pins see Section 7 Additional GND pins provide a common ground reference between the Motoron and the Raspberry Pi The JMP1 pin can be shorted to the adjacent GND pin to allow the Motoron s I C address to be changed as detailed ...

Page 27: ...ator must also be able to supply enough current for the Raspberry Pi e g 3 A for a Raspberry Pi 4 An ideal diode circuit on the Motoron prevents reverse current from flowing from the Raspberry Pi to the VREG pin if the Raspberry Pi is separately powered for example through its USB power receptacle However we do not recommend connecting external USB power to the Raspberry Pi while it is powered thr...

Page 28: ...t prevent the motors from running The red LED will be on solid if a motor fault is happening motor power has been lost or if there is a firmware level error stopping the motors from running More specifically the red LED will be on if any of the Motor faulting No power or Error active flags documented in Section 8 are 1 Otherwise the red LED will be off If the red LED is off it does not necessarily...

Page 29: ...supply VIN increases Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 6 LED feedback Page 29 of 67 ...

Page 30: ...ata when bytes are written faster than it can handle or if a read transfer is started before data is available If your I C controller does not support clock stretching properly you can avoid clock stretching by limiting your write transfers to be at most 31 bytes long and delaying for 1 millisecond after each write transfer to give the Motoron time to process it I C address By default the Motoron ...

Page 31: ...whether those bytes actually form valid commands Some Motoron commands generate responses To read the response to a command you can start a read transfer after writing the last byte of a command before you have written any other bytes To ensure that responses do not get mixed up the Motoron clears its stored response every time a new byte is written It is OK to skip reading a response if you do no...

Page 32: ...ed in bytes The Type specifies how many bits the variable occupies and says whether it is signed or unsigned The Range specifies what values the variable can have The Default specifies the value that the variable has when the controller starts up before it has been modified The Units specify the relationship between values of the variable and real world quantities The Data indicates how to interpr...

Page 33: ...fered speed Max acceleration forward Max acceleration reverse Max deceleration forward Max deceleration reverse Starting speed forward Starting speed reverse Direction change delay forward Direction change delay reverse Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 8 Variable reference Page 33 of 67 ...

Page 34: ...disableCrcForCommands void enableCrcForResponses void disableCrcForResponses void enabeI2cGeneralCall void disableI2cGeneralCall This variable holds bits specifying which features of the Motoron s command protocol are enabled A bit value of 1 indicates that the corresponding feature is enabled For more information about these features see the documentation of the Set protocol options command in Se...

Page 35: ...ed status flags Set latched status flags Arduino library uint16_t getStatusFlags bool getProtocolErrorFlag bool getCrcErrorFlag bool getCommandTimeoutLatchedFlag bool getMotorFaultLatchedFlag bool getNoPowerLatchedFlag bool getResetFlag bool getMotorFaultingFlag bool getNoPowerFlag bool getErrorActiveFlag bool getMotorOutputEnabledFlag bool getMotorDrivingFlag void clearLatchedStatusFlags uint16_t...

Page 36: ...wer flag documented below is 1 so see the documentation of that flag for more details The Reset flag gets set to 1 when the Motoron powers on or its processor is reset or it receives a Reinitialize command There are several non latched status flags which cannot be directly set or cleared The Command timeout flag indicates that the Motoron s command timeout feature is active because too much time h...

Page 37: ...or outputs are disabled meaning that the motors are coasting If this is 1 some of the outputs might be enabled but others might be disabled if there is inadequate VIN power or a motor fault is happening The Motor driving flag is 1 if the Motoron is currently trying to drive any of its motors at a non zero speed This bit can only be 1 if the Motor output enabled flag is also 1 VIN voltage Category ...

Page 38: ...n or equal to the time specified by the Command timeout variable and the Command timeout variable is non zero then the Motoron will set two flags in the Status flags variable Command timeout and Command timeout latched When a valid command is received the Command timeout flag gets cleared and the Command timeout latched flag can be cleared with the Clear latched status flags command By default the...

Page 39: ...imits are set this is also equivalent to the Coast now error response Brake means that the Motoron will make all of its motors brake while obeying deceleration limits This is equivalent to sending a Set braking command with a brake amount of 800 to each motor If no deceleration limits are set this is also equivalent to the Brake now error response Coast now means that the Motoron will make all of ...

Page 40: ...gs that must be explicitly cleared before they will change to 0 and the Command timeout flag If you try to set any other bits in the error mask to 1 those bits will be changed to 0 Jumper state Category general Offset 10 Type unsigned 8 bit Data Bit 0 JMP1 to GND jumper installed Bit 1 JMP1 to GND jumper not installed Bits 2 to 7 are reserved and should each have a value of 1 Arduino library void ...

Page 41: ... 80 kHz Bits 4 to 7 are reserved and should be set to 0 Default 0 Command Set variable Arduino library void setPwmMode uint8_t motor uint8_t mode uint8_t getPwmMode uint8_t motor The lower 4 bits of this byte specify the PWM frequency to use for this motor You can set this variable with a Set variable command which takes a 14 bit argument The upper 6 bits are ignored while the lower 8 bits get cop...

Page 42: ...setAllSpeeds int16_t speed1 void setAllSpeedsNow int16_t speed1 void setAllSpeedsUsingBuffers void setAllSpeedsNowUsingBuffers void getTargetSpeed uint8_t motor This is the speed at which the motor has been commanded to move The Current speed documented below will move towards this over time limited by the acceleration and deceleration limits if enabled Pololu Motoron Motor Controller User s Guide...

Page 43: ...king might not necessarily be applied when the current speed of the motor reaches zero For the Motoron M3S256 and M3H256 this type of Motoron is only capable of full coasting and full braking and it can only use coasting if it coasts all the motors at once Therefore if the current speed of any of the motors is non zero or any of the motors has a non zero target brake amount the M3S256 M3H256 will ...

Page 44: ...g low coasting both outputs disabled or something in between as determined by the target brake amount variable and the hardware limitations of the controller A value of 800 corresponds to the MxA output driving high VIN and the MxB output driving low GND This direction is called forward and causes the green motor indicator LED to turn on A value of 800 corresponds to the MxA output driving low 0 V...

Page 45: ...eed uint8_t motor int16_t speed void setAllBufferedSpeeds int16_t speed1 void setAllSpeedsUsingBuffers void setAllSpeedsNowUsingBuffers void getCurrentSpeed uint8_t motor This is a speed that can be set ahead of time with the Set speed or Set all speeds commands When you are ready to use the buffered speeds you can use the Set all speeds using buffers command to make it actually take effect If you...

Page 46: ... increase by the specified value divided by 8 The Motoron keeps track of any fractional parts of the speed internally Another way to think about this variable is that it is how much the current speed can change in 80 ms For example if you set the max acceleration forward to 124 then the current speed can only increase by 15 5 speed units every 10 ms or 124 speed units every 80 ms This means it wou...

Page 47: ...ult 0 Command Set variable Arduino library void setMaxDecelerationForward uint8_t motor uint16_t decel void setMaxDeceleration uint8_t motor uint16_t decel uint16_t getMaxDecelerationForward uint8_t motor This variable specifies how quickly the motor s current speed is allowed to decrease when it is greater than 0 A value of 0 the default disables this deceleration limit so the current speed can d...

Page 48: ...o 800 Default 0 Command Set variable Arduino library void setStartingSpeedForward uint8_t motor uint16_t speed void setStartingSpeed uint8_t motor uint16_t speed uint16_t getStartingSpeedForward uint8_t motor The Motoron allows the speed of the motor to accelerate instantly from 0 to the value of this variable ignoring the max acceleration forward This can be useful if you want your motor to accel...

Page 49: ...e unsigned 8 bit Range 0 to 250 2500 ms Default 0 Units 10 ms Command Set variable Arduino library void setDirectionChangeDelayForward uint8_t motor uint8_t duration void setDirectionChangeDelay uint8_t motor uint8_t duration uint8_t getDirectionChangeDelayForward uint8_t motor This variable specifies how long the Motoron should wait with the motor at speed 0 while switching directions from forwar...

Page 50: ...nits 10 ms Command Set variable Arduino library void setDirectionChangeDelayReverse uint8_t motor uint8_t duration void setDirectionChangeDelay uint8_t motor uint8_t duration uint8_t getDirectionChangeDelayReverse uint8_t motor This is like Direction change delay forward but for the reverse direction Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 8 Variable reference Pag...

Page 51: ...s a CRC byte at the end by default and each response contains a CRC byte at the end by default Numbers prefixed with 0x are written in hexadecimal notation base 16 and numbers prefixed with 0b are written in binary notation Numbers with these prefixes are written with their most significant digits first just like regular decimal numbers The term bit 0 refers to the least significant bit of a varia...

Page 52: ...This command generates a 4 byte response with identifying information about the firmware running on the device The first two bytes of the response are the low and high bytes of the product ID The product ID 0x00CC corresponds to both the M3S256 and M3H256 these models use the same firmware and is encoded as 0xCC 0x00 The last two bytes of the response are the firmware minor and major version numbe...

Page 53: ...ed by default and documented in Section 10 Bit 1 This bit should be 1 to enable CRC for responses and 0 to disable it This feature is enabled by default and documented in Section 10 Bit 2 This bit should be 1 to enable the I C general call address and 0 to disable it This feature is enabled by default and documented in Section 7 The other bits are reserved and should be set to 0 The effect of this...

Page 54: ...27 Length the number of bytes to read from 1 to 32 Response The requested bytes Arduino library void readEeprom uint8_t offset uint8_t length uint8_t buffer uint8_t readEepromDeviceNumber Command encoding 0x93 offset length Description This command reads the specified bytes from the Motoron s EEPROM memory which is a 128 byte non volatile memory that is used to store settings that persist through ...

Page 55: ...op The EEPROM memory of the Motoron s microcontroller is only rated for 100 000 erase write cycles The only setting currently stored in the EEPROM memory is the EEPROM device number a number between 0 and 127 that is stored at offset 1 The Motoron uses this number as its I C address if it detects that JMP1 is not shorted to GND when it starts up The default EEPROM device number is 16 Although this...

Page 56: ...n limits and then coast This process can be interrupted by subsequent motor control commands Coast Set speed Set all speeds Set all speeds using buffers The target speed target brake amount buffered speed acceleration limits deceleration limits starting speeds and direction change delays for each motor are reset to 0 It is OK to provide a CRC byte at the end of this command even if CRC for command...

Page 57: ...ctions with names starting with get Command encoding 0x9A motor offset length Description This command fetches a range of bytes from the Motoron s variables which are stored in the Motoron s RAM and represent the current state of the Motoron To fetch variables specific to a particular motor set the motor argument to the motor number between 1 and the number of motors supported by the Motoron To fe...

Page 58: ... to set These arguments are equivalent to the motor and offset arguments of the Get variable command However this command can only set certain variables and the offset argument must point to the first byte of the variable The Motoron will report a protocol error if the motor or offset arguments are invalid The value argument specifies the 14 bit number to set the variable to The Motoron looks at a...

Page 59: ...MotorFaultUnconditional Command encoding 0xA6 Bit 0 unconditional Description If any of the Motoron s motors are currently experiencing a fault error or the unconditional argument is true this command attempts to recover from the faults For the Motoron M3S256 and M3H256 this command does not disrupt the operation of any motors that are operating normally 1 2 3 4 5 command 0 0x9C Set Variable comma...

Page 60: ...it prevents the motors from running Therefore it is necessary to use this command to clear the Reset flag before you can get the motors running or alternatively you can change the error mask We recommend that immediately after you clear the Reset flag you should configure the Motoron s motor settings and error response settings That way if the Motoron experiences an unexpected reset while your sys...

Page 61: ...e motor argument should be between 1 and the number of motors that your Motoron supports If it is invalid the Motoron reports a protocol error The speed argument should be a speed between 800 and 800 If the specified speed is outside this range the Motoron will change it to the closest valid speed between 800 and 800 See the documentation of the Current speed variable in Section 8 for more details...

Page 62: ...mmand encoding 0xE1 for normal mode 0xE2 for now mode 0xE4 for buffered mode lower 7 bits of speed 1 upper 7 bits of speed 1 Description This command is equivalent to the Set speed command but it sets the speed of all the motors at the same time This command takes one speed argument for each motor supported by the controller Each speed argument is encoded as two bytes using the same speed encoding...

Page 63: ...ously set with Set speed or Set all speeds commands in buffered mode The mode specifies how to apply the speed Normal mode Each motor s Target speed is set equal to its buffered speed Each motor s Current speed will start moving towards this value obeying acceleration and deceleration limits Now mode Each motor s Target speed and Current speed are set equal to its buffered speed so the motor outpu...

Page 64: ... while a value of 800 corresponds to full braking However due to hardware limitations the resulting brake amount might be different from what is specified See the documentation of the Target brake amount variable in Section 8 for more details The mode argument specifies when and how to apply the specified brake amount Normal mode The motor s Target speed is set to 0 The Current speed will start mo...

Page 65: ...ives a byte with a most significant bit of 1 while it was expecting a data byte for a command the command is canceled and the Motoron reports a serial protocol error If the Motoron receives a byte with a most significant bit of 1 that is not a recognized command byte it will usually report a protocol error However bytes 0x80 0xFE and 0xFF are ignored and 0xAA is a reserved command byte that should...

Page 66: ...sed as a continuous stream of bits where all you care about is the remainder The Motoron uses CRC 7 which means it uses an 8 bit polynomial and as a result produces a 7 bit remainder This remainder is the lower 7 bits of the CRC byte that is tacked onto the end of a message The C code below shows one way to implement the CRC algorithm Note that the innermost for loop in the example above can be re...

Page 67: ... low resets the Motoron s microcontroller This pin is normally an input but the Motoron does briefly drive it low when it receives a Reset command or if there is any other internal mechanism causing the Motoron to reset Pololu Motoron Motor Controller User s Guide 2001 2022 Pololu Corporation 11 Reset pin Page 67 of 67 ...

Reviews: