BLDC Motor Control

I’m doing my final year project on closed loop control of a BLDC motor. I’ve started off writing some code that will switch three-phase inverter circuit that will commutate the motor at a speed set by a 10k pot. (I’m trying to establish a working open loop controller before moving onto closed loop). I’ve attacehd my circuit diagram and code aswell as screenshots of the issue im facing.

The MOSFETs on the inverter are switching in the correct sequence, and the speed control section of the code is working, as the switching speed of the inverter is changing when I slide the pot up and down. However, only a small current seems to be going towards the motor itself. As you can see I’ve added ammeters in my circuit. The current reads a maximum of around 0.5A. The motor is not spinning which makes me think that this maybe isnt enough current?

I’ve tried upping the voltage supply and I can’t figure out any other way to increase the current going into the motor, or why it won’t spin.

Does anyone have any idea what I could potentially be missing? It’s starting to severely stress me out.

int led1 = 2;
int led2 = 7;
int led3 = 4;
int led4 = 3;
int led5 = 6;
int led6 = 5;

int potpin = A0;
int potval;

void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
}

void loop() {
  potval = analogRead(potpin);

  digitalWrite(led5, LOW);
  digitalWrite(led1, HIGH);
  delay(potval);
  digitalWrite(led6, LOW);
  digitalWrite(led2, HIGH);
  delay(potval);
  digitalWrite(led1, LOW);
  digitalWrite(led3, HIGH);
  delay(potval);
  digitalWrite(led2, LOW);
  digitalWrite(led4, HIGH);
  delay(potval);
  digitalWrite(led3, LOW);
  digitalWrite(led5, HIGH);
  delay(potval);
  digitalWrite(led4, LOW);
  digitalWrite(led6, HIGH);
  delay(potval);
}

Screen Shot 2018-03-28 at 17.43.47.png

check the Id vs Vds datasheet for IFR520. what's the current with Vgs @ 5V? see the problem now?

sherzaad:
check the Id vs Vds datasheet for IFR520. what's the current with Vgs @ 5V? see the problem now?

yeah update, im now using IRF3205s on my simulation and i also changed some of the parameters of the motor. here they are:

inductance : 0.1mh
resistance: 1
torque constant: 100
rotor inertia: 5

the motor now atleast moves. but it jerks back and forth and doesnt go smoothly in one direction at all. any ideas why?