Keith wrote: > I'm the software developer for a little company called Corvette > Engineering. I'm a C++ /windows / Unix programmer by trade, though I > did do some 68HC11 development back in the latter part of last century. > Boy it's cramped in these PIC devices! It takes a different mindset to program small resource-limited systems. It's not for everyone. > OK, pretty new to the PIC world, so I'm wondering if the above pic is > going to make me suffer in the following application...or if I should > get a fancier PIC with a built in PWM or even one O them thar motor > controller PICs? I like the 8 pin package... It depends you your tradeoffs. If this is a high volume product then you're probably going down the right path. If not, then development cost will outweight the saving so of a buck or two per PIC. You'll probably find it easier to use a PIC with more hardware support, like PWM. However if you really need it to be only 8 pins then I don't think you get PWM hardware. > This is an extremely simple project, The goal is to measure the > frequency of the input signal and use it to vary the PWM which will > drive a FET that controlls a 12v solenoid. > > I have a PWM running using timer0, so that wasn't too bad. > > I plan on using interrupts on a GPIO pin to measure the period of the > incomming signal. > > Outputs > 250hz PWM > > Inputs > 0 to ~5khz TTL square wave signal > 2 push buttons, used to modify the PWM vs frequency slope, min and max. I think this is doable but I wouldn't promise it without some investigation due to the 5KHz input frequency. I'm a bit uncomfortable with multiple interrupts going on possibly messing up the PWM, at least until I can analyse it further and decide it's not an issue. This part has an internal 4MHz oscillator, so your instruction rate will be 1MHz. At 250Hz PWM you have 4000 instructions per PWM period. Let's say you make your PWM slice time 100 instructions, that gets you 41 different output values. That's probably enough to control your solenoid, but you need to be sure. I haven't looked at this in detail so this is just a knee jerk reaction, but I would look into using timer 1 to accumulate input pulses and check the value at regular intervals instead of trying to capture individual input pulses at 5KHz. You're going to have a fairly fast regular interrupt for the PWM anyway, and I would look into having this do the frequency measurement also. Now that I'm thinking about this more, it sounds more doable but I think is not a trivial or beginner project. If this is for a real commercial application, it may be more cost effective to have some like me who does this for a living take care of the PIC part. ****************************************************************** Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC consultant in 2004 program year. http://www.embedinc.com/products -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist