Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Freqency scaler

Status
Not open for further replies.

jimbo123

New Member
Hi all,

About to start a new project,... fairly new to PIC and the MICRO scene - but it seems as the way to go to implement what I need. I'm just needing some feedback as to whether I'm approaching this the right way, or anything that may help me.

What I have is an input pulse train, that changes according to the speeed of a vehicle. Range is 0-400Hz.

What I need is to modify the frequency of the pulses, by way of some PIC code, to provide a different rate proportional to the input.

What I was thinking of was a 16F876, using capture to determine the input frequency, do some 'maths' against the value captured and then using PWM to establish an output frequency.

Does this sound the right way to approach the problem?

I think my problem might be the 'maths' bit, as I need to somehow scale it down by values like 3.08/3.45 or 3.08/3.7 or 3.08/3.9 or 3.08/4.11 - depending upon reading the mode set by a couple of dip switches.

Any help, advice, pointers, etc,.. would be much appreciated.

Thanks,

Jim.....
 
You need to rethink the maths part - PIC's don't do floating point well, it's very slow and takes lots of code. With a little thought you can use integer maths - instead of doing 3.08/3.45, use 3080/345, or even 30800/345, and scale the result accordingly.
 
Thanks for the heads up on the maths bit Nigel - I knew that that part of it would need more thinking - initially I was going to just try and get output=input and then go from there.

Does the rest of how I'm thinking of tackling it make sense?

Is it the right appraoch?

I ended up with the 876 because I thought I needed separate inputs for the CCP and PWM parts.

Thanks again,

Jim.....
 
jimbo123 said:
Thanks for the heads up on the maths bit Nigel - I knew that that part of it would need more thinking - initially I was going to just try and get output=input and then go from there.

Does the rest of how I'm thinking of tackling it make sense?

Is it the right appraoch?

I ended up with the 876 because I thought I needed separate inputs for the CCP and PWM parts.

Thanks again,

Jim.....

I would advise looking at what you can get the PWM to do, I've not played about with it much - but I seem to remember it was fairly limited as a frequency generator. There are also restrictions with CCP and PWM (as they share hardware), but again I've not gone in to it deeply, with two on the 876 they might be seperate - a good study of the datasheet should help.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top