Jump to content

Firmware


jayjay23

Recommended Posts

I am moving home so on next week I think I will not be able to try. Anyway, I already tried to change the P I and D values. The P value, I could not make it work well. Anyway, I now think that PID as used on balance bots is not OK for EUC.

What I want try next: at a 1ms, put a positive and after a negative duty-dycle. I want to be on the case where the wheel is on balance and need the less energy to keep it. The PID would end with this situation and so I want to try it and understand how much energy/ duty-cycle this motor needs to keep the balance while I hold the EUC with my hand.

Link to comment
Share on other sites

Yes, the motor never moves if P is 0 because the duty_cycle calc will be 0.

I were able to try this code (trying cycles of 1ms up to 50ms and diferente duty_cycle values):

if (duty == 1)
{
    motor_set_duty_cycle (150);
    duty = 0;
}
else if (duty == 0)
{
    motor_set_duty_cycle (-150);
    duty = 1;
}

and the motor vibrates to much and don't stay "blocked" as on the original firmware. I think I need to work more on the motor driver.

Link to comment
Share on other sites

1 hour ago, electric_vehicle_lover said:

Yes, the motor never moves if P is 0 because the duty_cycle calc will be 0.

I were able to try this code (trying cycles of 1ms up to 50ms and diferente duty_cycle values):

if (duty == 1)
{
    motor_set_duty_cycle (150);
    duty = 0;
}
else if (duty == 0)
{
    motor_set_duty_cycle (-150);
    duty = 1;
}

and the motor vibrates to much and don't stay "blocked" as on the original firmware. I think I need to work more on the motor driver.

The order of the hall sensors cables are correct? In case there's a different pinout.
Only to make sure it's a software/ config error and not wrong connected sensors.

Link to comment
Share on other sites

10 minutes ago, OliverH said:

The order of the hall sensors cables are correct? In case there's a different pinout.
Only to make sure it's a software/ config error and not wrong connected sensors.

The motor runs with this connections so they should be ok. The question may be that the motor firmware driver is no ok yet for this application (similar to original firmware).

Link to comment
Share on other sites

@vezu4iy, thanks for the video!! I decided to make my latest test after seeing the video you shared and after I remembered my own unicycle. And yes, I also think duty-cycle and speed are minimal on the equilibrium.

Thanks for this link, I will really appreciate to read it: http://rspa.royalsocietypublishing.org/content/early/2010/01/18/rspa.2009.0559#sec-8

  • Upvote 1
Link to comment
Share on other sites

If you now change that P value to .5 you should be able to acheive a very "floppy" balance with a wide margin of error. 

 

The larger you make that number, the smaller the error will be. 

 

At some point you will over compensate(what you had with a multiplier of 10) and you will need to back off again. 

I have built no less than 3 balancing robots. I promise this is the answer. (Unless it's the motor driver)

 

Again the speed at which you reach the balance is meaningless if you never achieve balance. 

 

Get it to work first, then make it fancy. 

Edited by chriscalandro
  • Upvote 1
Link to comment
Share on other sites

@chriscalandro I appreciate your availability for o skype. This project uses brushless motors that are more difficult to control. On top of that, we do not have documentation for this motors and their control on the original firmwares are really different from usual methods. I need to work more on the motor controller before the PID and balance.

Please keep connected to this thread and we will discuss later your help.

Link to comment
Share on other sites

Alright, I think I have some time to poke through the motor control today...

 

Here is the first thing I notice

With this code, if there are 6 sectors, you never actually get to sector 6 while incrementing, and you never get to sector 1 while decrementing, because while incrementing, if the sector = 6, then the sector  = 1

 

you have this

unsigned int increment_sector (unsigned int sector)
  {
  if (sector < 6)
  {
  sector++;
  }
  else // sector = 6
  {
  sector = 1;
  }
   
  return sector;
  }
   
  unsigned int decrement_sector (unsigned int sector)
  {
  if (sector > 1)
  {
  sector--;
  }
  else // sector = 1
  {
  sector = 6;
  }
   
  return sector;
 

}

 

 

I believe you should have something like this

  {
  if (sector < 7)
  {
  sector++;
  }
  if (sector == 7) // sector = 7
  {
  sector = 1;
  }
   
  return sector;
  }
   
  unsigned int decrement_sector (unsigned int sector)
  {
  if (sector > )
  {
  sector--;
  }
  if (sector == 0) // sector = 0
  {
  sector = 6;
  }
   
  return sector;
 

}

 

 

Edited by chriscalandro
  • Upvote 1
Link to comment
Share on other sites

I edited my earlier response.  Check it out.  This would probably solve the terrible noise and the sync issue it sounds like you have as well!

 

You were doing 

1 - 2 - 3 - 4 -5 - 1 - 2 - 3 - 4 - 5 

and

6 - 5 - 4 - 3 - 2 - 6 - 5 - 4 - 3 - 2 

Edited by chriscalandro
  • Upvote 1
Link to comment
Share on other sites

I really appreciate your effort. It made me think again on that code and I am pretty sure it is correct. I remember to see it running using the debugger.

Can you please review that code again? 

What I do is to verify if variable is lower than 6 and increment. Else, then the variable is set to 1.

I did the motor code myself but taking as reference many other OpenSource codes and application notes.

I believe the number of windings have no effect on the code, at least I didn't saw any example code for it!!!

Edited by electric_vehicle_lover
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...