Russ, Do you have the processor and any other IC's bypassed with a capacitor? Also, do you have snubber diodes on the motor leads to clamp counter-emf when the coil denergizes? If not, these could possibly be causing a problem. I built an application sometime ago that drove some stepper motors, and what I done just because I thought it would be good practice is to add a short delay (IIRC, about 50ms) after the processor initialized, but before it started running the motor drive routines. I figured this would allow everything to settle out and stabilize before I started the active part of the program. You might want to try this to see if it helps in your case. In my case, it worked well. I never did take it out though to see if it still ran the same, but it did run well with it in there. My reasoning here is that when you first start up, and the outputs are configured, if even a lillet voltage is present on a winding or windings during startup, when thing finally get switched off to start the program at a known point, this counter emf may be causing noise on the power supply lines or on the high impedance clock circuit, and causing havoc. I believe it's worth a try to either prove or disprove this theory. Anyway, just a thought. Let us know what you finally find the problem is. Regards, Jim P.S. How about posting a schematic and your code for us to peruse to see if we can see anything that way. Strictly up to you though. > My 16f819 project to drive 2 steppers is making me crazy!!! System > boots and runs fine sometimes. ( see below for Environment ) but only > sometimes. > > A slightly longer version of the story: > > I was just about done on this proto board project, building a second > neater proto board. I could not get the new one to work properly, it > would sometimes run correctly sometimes not. Typically rebooting with > power off and then on quickly would get it to run a stepper sequence, > once one sequence worked others would work as well until power off. > > After power on with some programed blinking of led's and response to > pushbuttons ( all correct ) the routine often breaks down when I run a > several hundred motor steps subroutine for the stepper. > > Sometimes some of the ports bits lock up ( steppers all on portb ) > sometimes portA outputs are also affected. MClear and a second try > sometimes will get it to run correctly, sometimes not. As I say once it > runs right it keeps working correctly ( with its minimal user > interface and calls to the stepper subroutine ) until power off. Went > back to old proto board, found same problem, but again, just > sometimes. Problem probably had always been there but I had not paid > great attention. > > Environment > > 16f819 on Prot oboard > > MPLab Assm > > Great Cow Basic compile to asm. > > Running on 5 volts > > Using internal ossc > > Full asm of shortest version of code at > http://home.comcast.net/~russ_hensel/StepBot3asm.txt > > > Things I have tried that have not worked: > > > Improved PS decoupling, in lots of ways. > > Removed stepper loads and even the output darlingtons. > > Shadowed Port B for output, which I had not originally > done. > > Removed pull down resistors on portb outputs. > > In the Great Cow Basic, moved around the routines and did >some inspection of the asm code. > > Reorganize the code in case problem was related to banking or paging. > > Looked carefully for uninitialized variables. > > Slowed clock down to one half mega hertz. > > Turned off brown-out reset > > Looked on Piclist and Google for info. including Gotchas which are > great but do not seem to be the problem. > > Tried a second 16F819 > > Made sure capture compare was off ( any other peripherals on PORTB That > might be causing a problem? ) > > Reset pin is tied to V+ by 10 K and a .1 uF cap to ground as per manual > ( have varied the cap to higher/lower to see if this helped ) > > Used scope to make sure oscillator was running speed was at least > vaguely right > > Made sure low voltage programming is off > > Watch dog timer is off. > > Tried on off switch between power supply and chip for fast rise of > power supply. > > Have power on reset timer on. > > > Pretty much at my wits end, the few next steps that I have are tedious: > > Pure assembler for the 819 > > Try with a 16F871 which I have on hand > > I could supply all code etc to this list, but hope that a detailed > examination like that will not be required. Anyone out there with a > great insight? I feel it is something simple that I have missed. > > A plea for help from Russ. > > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist