Full Version: Simplifyng b-robot code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I see b-robot code uses lots of lines of code to WITA and things I will not use.

I just have an arduino nano, 2 stepper motors and 2 A4988 driver and nothing more. I tried simplifying the code of B-ROBOT to just work with these componentes but that is really hard. I spent the last night and this entire morning trying to get this robot to work but it's freaking hard.

Can someone tell me if there is a simplyfied version of this b-robot code with just the essentials?
unfortunately, the code is hard to understand. I am in the process of breaking the code down and putting it together in modules so that one can just play with parts of it and lean something on the way.

The key to the A4988 stepper motors is the use of Interrupts to feed the pulses to the motors. By varying the interrupt timer they change how often a pulse is sent to the motors. The higher the number the faster the motors spin. The motors start at 0 and can go up to 500. This leads to a short pulse of about 86 microseconds in length.

The A4988 can not except a pulse of less than 1 microsecond so in the interrupt routine there is a 1 microsecond delay code because you can not use delay functions in an interrupt routine since they are disabled.

You will also need an accelerometer and gyro if you want it to balance. The code they are using is Quaternions to balance the bot but that is really over kill since Quaternions are used for 3 dimensional objects and the bot only uses one axis to balance, so that can easily be done using a complimentary filter.

Reference URL's