Pulsing motor controller

Hi! I'm probably missing something obvious but bear with me, as I'm new to the Arduino and to this forum.

I've got an Arduino Diecimila. Up to now I've used the delay functions to pulse things (speed controllers, speakers). But I can't really rely on that when I've got to pulse two speed controllers and a speaker all at different rates, because the code gets messy and the delay is blocking. So I wrote some code to basically get the change in time (microseconds) and use it to avoid having to use the delay function altogether.

The thing is, when it at first didn't work, I checked what the change in time actually was with the following code:

unsigned long lasttime=0, currenttime=0, dt=0;
//dt is delta t or change in time
void setup()
{
Serial.begin(9600);
}
void loop()
{
lasttime = currenttime;
currenttime = micros();
dt = currenttime - lasttime;
Serial.print(dt);
Serial.print("\n");
}

And what I got was about 5200 microseconds. If that's right, according to my calculations, that is about 192 Hz....aren't I supposed to be getting something closer to 16 MHz? Even if Serial.print() is slowing it down somewhat? I'm using the Victor 884 speed controllers from IFI so I need to pulse them for a interval time of anywhere from 856 microseconds to 2120 microseconds, approximately.

I'm pretty sure the Arduino is capable of a faster refresh rate and something in my code or hardware setup is wrong. Any ideas?

856 microseconds to 2120 microseconds

Try the servo libraries.

Oddly enough, 5 characters ("5200\n") takes almost exactly 1/192 of a second to transmit at 9600bps.

Thanks! Didn't really make that connection (I guess I wasn't sure what units a baud rate is in exactly, or how many bytes for that value I was sending).

Anyhow, I'll have to look over that later (it is almost 4 in the morning here...) but my best guess is that the code had a different error that was causing it not to work right, separate from the fact that inserting the print statement was slowing down the rate that drastically.

9600 bps is one bit every 1/9600th of a second.
A transmitted character is usually 10 or 11 bits long (1 start, 8 data, 1 stop, possibly plus 1 parity bit).
So, you can transmit at most 960 characters per second.
5 / 960 = 1 / 192.

Looks like your speed controllers are designed to work with standard R/C gear, so you should really look at the servo libraries.
I think MegaServo allows most flexibility.
http://www.arduino.cc/playground/Code/MegaServo

Hm. So I've got what I need working alright, but I still have some questions as to theory and whatnot. I just learned the basics of timers and interrupts today and I'm still trying to figure out what exactly I can/should do with them.

My code right now works but depends on a reasonably fast refresh rate. If the time for a loop goes above, say, 100 microseconds I will probably start getting visibly erratic behavior from my speed controllers, and if it goes above the value I'd like my pulse interval to be, they won't work at all. Putting in a Serial.print statement appears to slow down the loop that much.

I imagine that some kind of hardware solution would involve something that would pulse the motor controller for me at varying pulse widths. I would just sent it a signal whenever I wanted the pulse width to change and I wouldn't have to constantly speak to it to keep it working. That way, if the loop speed for the arduino slows down a lot, the only thing that will be affected is my robot's reaction time to stuff, which isn't a very big problem to me (so long as it keeps moving).

So, uh, am I missing the obvious? Is this something standard, or something I can easily do with interrupts and timers and so on? Or will I always have to worry about keeping my loop times low if I want PWM devices attached to it to keep working?

So, uh, am I missing the obvious

Yes - use the servo libraries.