Ioannis, I was using batteries at the time originally. here were my stats of that circuit at the time (this has now changed)
18v Drill motor removed from housing and mounted on stand.
1N4001 Diode
180uf Cap @ 25v
FDP8440 Mosfet 30V 277A (theoretical)
12F675 (has been replaced with 12F683 with HPWM @18Khz)
now, when I was using the 12f675 I was using the code from http://www.picbasic.co.uk/forum/showthread.php?t=17550 which I gave up trying to calculate the frequency on, I had about 3 sets of code that went about simulating a PWM and it was accurate but very slow. one of them only ran at 4hz I think, I didnt have my scope so it was all guesswork. I tried calculating it out in my head based on what little info I could get online and from datasheets. my thinking was if the internal OSC ran at 4mhz, somewhere in the docs it said it only used 1/4 of the OSC som that put me at 1mhz, then I had my pwms accuracy, so say i wanted a 255 positions that took the 1mhz / 255 = 4khz, and if I had other code it changed that, before coming up with that code it was even worse. now that I know how to use HPWM its irrelevent.
when I first hooked everything up I didnt use a diode or a cap, it was awful. it was so erratic and forgetting all my electronics knoledge I grabed the first item available a Cap. adding this worked a little better. as from a dead stop it started fine but as I increased the speed it increased but when i tried to decrease it became erratic. going back to my electronics knoledge I realised, oh yea I need a diode in there for the reverse voltage spikes, so that worked great. it was a little troublesome with the non linear actuation but I thought that could be part of the code I came up with or perhaps the instability of the motor/diode/cap settings. a larger cap worked better and after building 5 or 6 boards I tweaked it to where it was working pretty good, I still use those boards in some clip on 12v automotive fans I made for using in my lab. they still work fine, I dont know why. when I tryed removing the cap on my original circuit it became erratic again sometimes going into runnaway mode with no control.
I am not sure what caused the original issues, perhaps it was my code, or a solder break, a clip lead, or that stupid 1N4001 diode, it could have been anything. but without the cap it does work perfect on a new circuit so I will be leaving the caps off from now on. I was just starting to learn PICs back then, when I ordered my programmer it came with a 12F629 chip so thats what I started to learn on. It didnt have a PWM so I was unaware that they even had these. untill much later. Im guilty of trying to keep using old tried but not really true code. Its part of that if it works why change it attitude. Which by the way since joining this forum has woke me up and shook me. I read posts all the time that I remark to myself, hey thats kinda cool I wonder where I can use that bit of code at. And then theres some like, Ok thats way over my head...
So everyone, read these posts, try to understand where code can be used, WATCH for mistakes like mine, listen to those that know. and if you dont get something ask, or breadboard it, dont give up, and if you come up with a great piece of code share it, there might be something you dont notice, or someone may be able to show another way or cut the code down in size.
Thank you everyone again for analysing my circuit, its woke me up and I am going back through several circuits and code, cleaning up.
Bookmarks