How can I make Sparki go faster?

It’s way too slow.

Mine had decent speed at first, but now it positively crawls along. I think it just chews up battery way to fast. After only one day of use, the speed has dropped dramatically

Salut,

the reason why the robot is crawling so slow is due to a hard-coded speed limit in the library. Additionally, the speed of the motors depends on the voltage and batteries that wear out drop that voltage. But the coding error is the first one to change.

Ciao, Mathias

Sparki can be made to go faster.

In the Sparki.cpp file, each move command is defined.
The code below is for moving forward. The speed is controlled by the number. The default is 100. Below, I’ve changed to 200 (obviously this doubles the speed).
(Note:-> The upper limit would be 255 as far as I know).

***Do this at your own risk. May have an effect on life of motors, ect.***

void SparkiClass::moveForward()
{
motorRotate(MOTOR_LEFT, DIR_CCW, 200);
motorRotate(MOTOR_RIGHT, DIR_CW, 200);

}

[quote=“Trevor”]Sparki can be made to go faster.

In the Sparki.cpp file, each move command is defined.

[/quote]

Where is Sparki.cpp? I couldn’t find it. Also, when I make the change, will the SparkiDuino IDE automatically recompile it when I run a sketch (e.g. Wall Avoidance)?

Yes it will recompile it once you’ve saved the .cpp file first.

On a mac it’s at: SparkiDuino.app/Contents/Resources/Java/hardware/arduino/cores/arduino. Not sure for windows.

[quote=“Trevor”]Yes it will recompile it once you’ve saved the .cpp file first.

On a mac it’s at: SparkiDuino.app/Contents/Resources/Java/hardware/arduino/cores/arduino. Not sure for windows.[/quote]

Ahh, thanks. Man, that thing is really buried. I didn’t know you could find folders in SparkiDuino.app. For other OS X users who might be reading this and can’t find the SparkiDuino.app/Contents folder, this is what I did:

Go to the Applications folder
Right-click the SparkiDuino.app icon
Choose "Show Package Contents"
Find Sparki.cpp in the folder Trevor mentions above

Trevor, I am using standard AA alkaline batteries (instead of rechargeable), does that mean my Sparki will run longer if I increase the speed a bit (vs. rechargeables)? The rechargeables I have are listed as 1.2V rather than 1.5V on alkalines.

Anyone know how to up the speed using windows?

@vladarino, Will get longer out of non-rechargables alright.

Just made a code update to increase the speed 2x. That’s as fast as it will go before it stops working.

Just a note: battery level and voltage don’t change Sparki’s motor speed. Steppers work differently than regular motors, and changing the voltage won’t affect the speed. The only case where it might is if the voltage is so low the motors start to ‘slip’ their steps, but Sparki shouldn’t even be turning on at that point.

That’s great! I look forward to downloading the update.

Is there any way you can make the speed setting its own API call? It’d be great to be able to customize it.

Thanks so much.