Converting PWM to Analog signal

Hi guys..

I have been trying to send a 50Hz square wave pulse (almost square wave) from 1 uno to another uno. Been using Lora 1276 for this purpose. I used the analog map function for sending the continuous pulse. Issue that I face is, at the receiving end, the signal that I obtain is of 490Hz (PWM frequency). How do I get back my 50Hz pulse? Its a sync pulse, used for synchronisation of tx and rx stations. Therefore, the pulse generated should be precisely obtained at the receiver. Will a DAC do the job ? Received signal can be 49, 50 or 51 Hz.. Looking for a solid solution.

When words don't convey meaning, maybe it is time to post code

In code tags.

Drones transmit PWM by converting to PPM. PPM is then transmitted where the receiver can convert it back to PWM.

PWM and PPM Difference and Conversion - Oscar Liang

Search on words like "arduino convert pwm to ppm".

ammaradam/ppm-encoder: PWM TO PPM CONVERTER FOR 2.4GHZ RECEIVER USING ARDUINO (github.com)

Hi,

What do you mean by "almost"?
Is "almost" very important or if a pure square wave was used would it make a difference to the synchronization?

If not a pure squarewave with 50% duty, can you please post a diagram of the waveform.

If a pure squarewave, then you do not need to use PWM, you just transmit and receive a HIGH or a LOW for the parts of the squarewave.

Can you please tell us the actual application that your project involves?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

If you are receiving 490Hz maybe you could sync on every 10th pulse edge, that would be 49Hz. Based on the nebulous description given.

int val = map(analogRead(pot),0,1024,0,255);
I mean mapping read values within range of 0-255. Is the point clear now? or still something cooking?

that's a new info for me. let me have a deep look on it and come back to you..

will look into it buddy, and come back.. thanks for the valuable info..

No.
If you then apply the value val to an analogWrite function you will get

You never had one to begin with.

Perhaps you meant

int val = analogRead(pot) / 4;

hi TOM,

first of all, let me give you a brief idea about the application. its hard to describe it in a write up, that's why i didn't go very deep into that subject.. anyways, listen....

its for synchronising two independent devices, which operate at 230V, 50Hz, AC. there are situations when these devices go out of phase and make unwanted results. to keep all the devices in phase and work in a synchronised manner, I'm planning to share/feed this synch pulse to all the independent devices within a range of 50m.
It's not a pure square wave. For testing purpose , I'm using a 50 duty cycle pure square wave. but in actual case, the duty cycle of the synch pulse is something like 15% or 20%.

let me see what you have to say..

dear grumpy mike, whatever you said, i have already mentioned them in the topic description.

no, above was what i meant bro

That's unusual, but if you say so.

hmm

I just wondered why you want to exclude the value 255 from your mapping.
(and why you want to do such a simple operation is such an expensive way)

And what ever I said must have flown over your head. You describe what you have. What you have is what you should expect to have if you do the process you describe. Where is the mystery?

Maybe you want something different, if so you have to do something different, but you have to tell what it is. You speak of getting back to a 50Hz signal. But you never had one in the first place so how can you get back it it? I would change the translation program you are using, it is not serving you well.

Hi, @ADD12
Is this the same problem, just expressed differently?

Why don't you sync them to the mains 50Hz, and just send one start pulse to make them all start at the same time?
Have you factored in latency?

What are the devices that get out of phase/timing?

Please draw a block diagram of your system?

Tom... :smiley: :+1: :coffee: :australia:

hi @TomGeorge , the devices are located (for eg: like in different shops / stalls). therefore, there is a chance for phase difference in the supplies used(different people use different phases like R or Y or B. Thats what makes this complex..