Hello! OK, so I have carefully tested the small controller, and watched the results on the oscilloscope. Finally, the software appears to be without any errors, and is much simpler and easier to read now. I think I'll run the bike controller at 4kHz. It may irritate dogs in the neighborhood, but it will keep switching losses down, and it's just a first draft. Well, second draft if you count the 5v 0.01amp one.
To compile this program, download the FREE Atmel AVR Studio!
Atmel AVR Studio
To compile the program, change the file name to end with .c instead of .txt
It wouldn't let me upload it here unless it was in ".txt" format.
There are a lot of page references in PWMAndInputTest.txt. They refer to the PDF of the documentation for the ATMega8. It can be found
HERE!
Also, the code assumes you are using the PDIP version of the chip (28 pin version).