I’m trying to run servos, a 16x4 LCD, and hardware serial on a Sanguino board. When there’s no incoming serial, I get an occasional and barely perceptible twitch on the one servo connected. When the Sanguino is receiving serial data, the servo jitters continuously. The same code runs on a Mega2560 without the jitter.

The jitter can be measured with an o-scope when the servo and LCD are removed, so it’s not the hardware, power supply, or grounds. A 1500uS pulse will jump by 50 to 90 uS. Just to make sure it’s not the transmitter end, I even substituted a Duemilanove running a short piece of code.

Since I’ve eliminated all the external hardware, I have to suspect incompatibility between the Sanguino core files and Arduino libraries. Is anyone willing to confirm this, suggest a fix, or find an error in my program?

Just look at digitalWrite() inside wiring_digital.c to see if it's properly disabling interrupts when writing to the port register through the pointer. Copy the fix from issue 146 and your jitters will probably be a thing of the past.

Thanks for the suggestion, Paul. You're correct about the missing lines, and you've also confirmed my suspicion about corrupted interrupts. My servo still jitters, however, so I'm going to install Arduino-0018 and use the modified file.

Okay, Arduino-0018 did no good at all, so I returned to 0022 and started looking through the core files to see if anything looked wrong - not that I'm any good reading someone else's code. On a guess, I deleted all the Sanguino core files, except pins_arduino.c and pins_arduino.h. Then I copied all the other Arduino core files to the Sanguino core directory. Now, I've got a nice, quiet servo!

Although this procedure solved one problem, it may introduce others as my program expands. Still, I'm confident enough to proceed with a circuit board.

Thanks for the suggestion, Bob. I had those files, but didn't try them until this morning. The Duino 644P board gives me about 5 seconds of twitching every 15 seconds, or so. It's not as bad as the Sanguino cores, but not as good as stock Arduino-0022, either.

I have a 1284P with the bootloader installed and want to try it in the board. Any time I try uploading to the chip, I get the error message, 'avrdude: AVR Part "atmega1284p" not found', followed by a list of valid parts. Did you make changes to avrdude.conf?