create two PWM pulses with 10kHz difference

Thread Starter

jalil92

Joined Jun 7, 2019
7
hello
I want to produce two PWM pulses with lpc1768 module. The frequency of PWM should be in the range of 3000kHz to 3500kHz and the difference of frequencies should be 10 kHz (for example 3100kHz and 3110kHz). How do I do this?

Please help me.

Thank you
 

JohnInTX

Joined Jun 26, 2012
4,787
Do you mean the LPC1768 ARM microcontroller? If so, here's a datasheet so that others can take a look at it. I'm not familiar with the chip myself but it looks like it has a dedicated motor control PWM and another general purpose PWM. How are you using them?

Do you have a schematic and code listing to post?

Good luck!
 

Attachments

djsfantasi

Joined Apr 11, 2010
9,237
First, your value for the analogWrite() function will go out of bounds. If val is 1023, val/3 is going to be 341... 255-341 is a negative value. analogWrite() won’t like that.

You could calculate appropriate values yourself, but Arduino C has a function for you!

Check out the map() function. It maps one range of values into another range. It can even invert the results. So as Val increases, the input to analogWrite() decrease..

Read the description at the link I provided and post any questions here.
 

djsfantasi

Joined Apr 11, 2010
9,237
You’ve defined analogpin equal to 0. That likely isn’t an analog pin. I’m not familiar with the LPC1768 ARM microcontroller. Is pin 0 an analog input pin?
 

danadak

Joined Mar 10, 2018
4,057
Do you want the PWMs to track each other over that range of 3000 -
3500 KHz ? If so one master and one slave or reciprocal tracking ?
Both masters ?

What resolution do you want, 8, 16, 24, 32 bit ?


Regards, Dana.
 
Top