• 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.

Pulse Modification

Not open for further replies.


Hi Guys Just wondering if it is possible to take a variable pulse train which is the same voltage but different pulse widths and run from 10 to 60 HZ max and be able to sample it then either widen the pulse width or shorten the pulse width by a certain percentage of the original pulse width with something like a potentiometer on the fly.

I want to be able to do this with a PIC but before I go ahead and buy the picbasic system and try to learn it I would like some expert advise on weather its possible and or realistic to exert all of my energy on.

Does anyone have any suggestions on what this is actually called or any good pic books to buy for a person like me.

I started to read about assembly language but got steered into the picbasic language instead.

Am I doing the right thing? I dont want to learn 1 thing only to discover I wasted my time and effort on something that cant be done..

Thanks alot


Easily done using a PIC?
Hopefully one day I will be able to say that to someone :)
Where do I start? What stuff should I be learning first so i can fastrack to the guts of it.
Anything I can lookup for refference? Is there a technical word for what I want to do?
Ive only just figured out that you dont need an external crystal with the pic16f268a :)


New Member
Basically, you'd program the PIC to:

1. Wait for a the beginning of a pulse (assuming the pulse is "high" and between pulses is "low", wait for the input pin to read as a 1).
2. Start your output pulse by setting your output pin to 1.
3. Start (or reset) a timer, and then wait for the end of the input pulse (for it to return to 0).
4. When the input pulse ends, read the timer value. Calculate the timer value where you want your new, wider pulse to end based on the percentage you specified.
5. Wait for the timer to reach your new calculated pulse width value.
6. End your output pulse by setting your output pin to 0.
7. Start over at 1.

As for "fast tracking"? Check out Nigel's PIC tutorials in the link in his signature, 2 posts above this one.

P.S. If you want to shorten the pulse width, you'll either need to determine the desired narrower pulse width in advance of receiving the pulse, or to narrow it by a percentage you'd have to measure the input pulse to get its width before outputting your pulse, meaning your output pulse would be delayed by the width of the input pulse.
Last edited:

Nigel Goodwin

Super Moderator
Most Helpful Member
As he's using PICBASIC it's even easie rthan that - just read the pulse using PULSEIN, calculate the required changes, and output the pulse using PULSEOUT.


Well-Known Member
Is this for a fuel injection system or something automotive??

The PICBASIC functions to capture the pulse or generate the output pulse may not be accurate enough, they might jitter and change values etc. If this is for a fuel injection controller it's not a task for a beginner. :)


Thanks guys Thanks alot the Ball is rolling.
Its actually for a speedo correction. I drag race my car and drive it on the street so when i change diff ratios I want to be able to calibrate the speedo to suit.
I know there are kits that you can buy for speedo correction but while I am trying to learn PICs I thought I could do projects I need in the real world and also learn from them at the same time.

I have done Nigels tutorials well not all of them but the ones I had parts for and I must say they have helped me heaps. There are a lot of tutorials on the net but his were the best for me.

Thanks for your help I'll study with guidance as above.
Last edited:


New Member
I would think a speedo would use pulse rate as opposed to pulse width. If that's the case, you'll have to program the PIC to output pulses at a rate that is adjusted based on your correction factor from the input pulses. Still easily done.
Not open for further replies.

Latest threads

EE World Online Articles