Help With Pololu Motor Driver

Hello All
I am New to Embedded programming and control. I am building a balancing robot using STM32Fxx MCU and Dual H bridge Pololu motor driver. The motors can get power on or some times it is only one of the motors at time run, either forward or reverse. any help is appreciated.

my setting
IN1---->direction control
IN2---->direction control
PWM1D2---->PWM, D1 keep low with Jumper setting

the same setting for the other motor
SF----> Unused
FB----> Used for for current sensing
EN----> HIgh
Out1 and Out2 for the motor.
here below copy my code for the motor driver , PLEASE HELP!!

#include <stdlib.h>
#include <stddef.h>

#include "stm32f30x_conf.h"
#include "stm32f30x.h"
#include "stm32f30x_rcc.h"
#include "stm32f30x_tim.h"
#include "stm32f30x_gpio.h"



#include "Clocks.h"
#include "MotorDriver.h"

uint8_t MotorDriver_Drive_Tx1[32];
uint8_t MotorDriver_ReadSensors_Tx1[32];
uint8_t MotorDriver_ReadSensors_Rx1[32];

#define GPIO_DIR			 GPIOD
#define GPIO_Pin_DIR_M1IN1 GPIO_Pin_0
#define GPIO_Pin_DIR_M2IN1 GPIO_Pin_2
#define GPIO_Pin_DIR_M1IN2 GPIO_Pin_1
#define GPIO_Pin_DIR_M2IN2 GPIO_Pin_7

bool MotorDriver_Initialize(void)
{
	TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
	TIM_OCInitTypeDef  TIM_OCInitStructure;

	GPIO_InitTypeDef GPIO_InitStructure;

	// Enable peripherals
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_DIR_M1IN1 | GPIO_Pin_DIR_M2IN1;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIO_DIR, &GPIO_InitStructure);
	
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN1, DIR_L_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN1, DIR_R_FORWARD);
	
	//  pin for the second input
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_DIR_M1IN2 | GPIO_Pin_DIR_M2IN2;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIO_DIR, &GPIO_InitStructure);
	
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN2, DIR_L_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN2, DIR_R_FORWARD);

	
	
	// defining the PWM out put 
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_6;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
	GPIO_Init(GPIOD, &GPIO_InitStructure);

	GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_2);
	GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_2);

	/* Time base configuration */
	TIM_TimeBaseStructInit( &TIM_TimeBaseStructure ); 
	TIM_TimeBaseStructure.TIM_Period = 1500;
	TIM_TimeBaseStructure.TIM_Prescaler = 2;
	TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV4;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

	TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);


	/* PWM1 Mode configuration */
	TIM_OCStructInit( &TIM_OCInitStructure ); 
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCInitStructure.TIM_Pulse = 0;
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

	TIM_OC2Init(TIM2, &TIM_OCInitStructure);

	TIM_OCStructInit( &TIM_OCInitStructure ); 
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCInitStructure.TIM_Pulse = 0;
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

	TIM_OC4Init(TIM2, &TIM_OCInitStructure);

	TIM_ARRPreloadConfig(TIM2, ENABLE);

	/* TIM2 enable counter */
	TIM_Cmd(TIM2, ENABLE);
	
	return true;
}
/**
  * @brief  Send a command to the motor driver to set the motor speed
void SetM1speed(uint8_t Speed_Mleft)
 {
 unsigned char reverse=0;

	if(Speed_Mleft < 0)
	{
		Speed_Mleft=-Speed_Mleft;// full forwared
		reverse=1; // preserve the direction
    }
	if(Speed_Mleft > 255)
	{
		Speed_Mleft=255; 
     
	    TIM2->CCR2=Speed_Mleft;
	   }

	if(reverse)

	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN1, DIR_L_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN2, DIR_L_BACKWARD);
	else
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN1, DIR_R_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M1IN2, DIR_R_BACKWARD);

	}
void SetM2speed(uint8_t Speed_Mright)
     {	
	unsigned char reverse=0;

	if(Speed_Mright < 0)
	  {
		Speed_Mright=-Speed_Mright;// full reverse
		reverse=1;
  		}
	if(Speed_Mright > 255)
	   {
		Speed_Mright=255; 
	
	    TIM2->CCR4=Speed_Mright;
   	   }
    if(reverse)

    GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN1, DIR_L_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN2, DIR_L_BACKWARD);
	else

	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN1, DIR_R_FORWARD);
	GPIO_WriteBit(GPIO_DIR, GPIO_Pin_DIR_M2IN2, DIR_R_BACKWARD);
		  
   }

DIR_R_FORWARD-set to low
DIR_L_FORWARD-set to high
DIR_L_BACKRWARD…set to low
DIR_R_BACKRWARD…set to high

Hello.

Which motor driver are you using? Could tell me more about your setup? What motors are you using? How are you supplying power? Could you also post a schematic and pictures that clearly show your connections?

Your program seems quite complicated. Could you simplify the code to the most basic program that demonstrates the problem (ideally a few lines of code) and post that along with a detailed description of what you expect to happen and what actually happens? Also, please make sure to put code tags ([ code ][ /code] without the spaces) around your program so it is formatted nicely. I have added those to your post.

- Taylor

Hello Taylor
thank you very much for your Concern.i was using pololu Dual MC33926 driver
your Question was the right ones to help me.
But today I manged to solve the problem, it was a simple soldering error on my Controller board cost me more than a week to find out.

thankyou very much
Eyob

I am glad you solved your problem; thanks for letting me know what was wrong!

-Taylor