Convert PWM Input

Hello.
I have read many posts but can't find an answer to the following problem.
I have a PWM input (digital pin 6) that is of the right frequency but the duty cycle is too short, ie, marks to space ratio the mark is too short. Is there a way I can take the PWM input, determine the start of the mark, the end of the mark and expand the mark/space ratio so that the mark is virtually full on when the input mark is largest. To output on Digital pin 12.
I hope someone can understand this as I have found it difficult to explain.

To do what you are asking, the repetition rate of the output signal has to be increased and I suspect that is not what you want. Perhaps if you explained the problem there may be other solutions.

From what is the signal coming?


![DSCI0669|666x500](upload://iP8LH1ZVWAIVnSIeIMDj
ZBpvXdY.jpeg)

I have tried to upload a couple of photos of input. maybe got the posting a bit wrong. What I would like from the output is the mark to be 100% at maximum input width and negligible at minimum input.

Hello
Post your current sketch to see how we can help.

I'm trying to understand the question... Are you saying that in my very crude pic below, you have the top waveform as input, and want the bottom one as output?

Hello sionaggutraidh
Yes that is exactly what I want at full output, reducing to very little mark at lower end. So that in the first picture it is virtually unaltered, but as input rises the output is like your lower drawing. The PWM drive I have at the moment doesn't have sufficient mark width to drive my L298N across the range of little drive to full drive
Many thanks

I'd be very inclined to ditch that for something less steam-age :wink:

Again, where is the input coming from? It sounds like you have something like a servo output from an RC receiver which only varies from about 5% to 10% mark/space and you want to convert it to real PWM 0-100%. But that's as much guessing as I'm going to attempt without some answers.

Steve

Hi Both,
First to sionaggutraidh the problem: I need to be able to control a motor at 24v 3 amps. Do you suggest a newer type.
Secondly to slipstick, Exactly right.
Many thanks for replies, appreciated

L298 is 2A per channel, so presumably you're doubling up?

Have a look at Pololu, they have a huge range.

It's proportional isn't it.... can't you use map?

There are thousands of pages on reading RC receiver (servo) signals with an Arduino on the internet. Do a search for "Arduino read rc receiver".

Once you have the pulse width you can use the map function mentioned by @sionaggutraidh to scale to your output.

Are you using an Arduino UNO where Pin 12 is not a PWM pin? If you use a PWM pin then this line will do the conversion from RC Servo Control to PWM:

    analogWrite(PWMpin, 
        constrain(
            map(pulseIn(8, HIGH), 1000, 2000, 0, 255)
        , 0, 255)
    );

Though you might need to change the 1000, 2000 because many servo outputs use a wider range than that. 600,2400 is not uncommon.

Steve

Thankyou very much slipstick. Did exactly as you said it would. I am very grateful for the time taken to help me and give a clear answer.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.