PWM basic

What are you developing?
User avatar
mrburnette
Posts: 2216
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: PWM basic

Post by mrburnette » Sun Jan 07, 2018 2:14 am

ted wrote:
Fri Jan 05, 2018 9:34 pm
There must be a simple code for this circuit - sine in sine out. Any solution welcome.
ted:

I just reread every one of your posts since you joined the forum. The questions you are asking indicate a lack of understanding of digital and analog processing using microprocessors. We (forum) can fill in only so many holes in your knowledge but in my opinion you need to take a step back and do some Internet study before you ask questions.

For example, in this current thread, you wish to take an analog input and output an analog waveform; unfortunately you have chosen a uC that does not have a DAC. Therefore, PWM (digital signal) must be used with an integration capacitor to convert varying pulse width to a varying (analog) Voltage.

Image


I found this example of doing a similar thing with just one Google search:
https://www.arduino.cc/en/Tutorial/AnalogInOutSerial

Code: Select all

void loop() {
  while (1) {
  }
}
The above suggests you do not understand the loop () implementation in Arduino. Please read this explanation:
https://www.arduino.cc/reference/en/lan ... etch/loop/
(I think dannyf's response was just for fun.)

The Arduino.cc forum is geared to new users of the Arduino paradigm. .. this STM32duino forum was implemented by users with significant experience and there is very little material here to point a beginner. We do try and point all users to solutions, but (the forum) biggest job is working with users that are having complex behavior issues where the STM32DUINO "core" appears to be malfunctioning and in using the STM32Fxxxx internal modules for peripheral connections. Few of us here with experience have sufficient time to assist a member with the full scope of learning. I expect to see the Op post code that compiles and performs some function to represent an issue. I do not expect an Op to ask for (complete) design and coding assistance.

Ray

dannyf
Posts: 228
Joined: Wed May 11, 2016 4:29 pm

Re: PWM basic

Post by dannyf » Sun Jan 07, 2018 12:39 pm

I think dannyf's response was just for fun.
probably not.

here are two examples of an empty loop doing wonderful things relevant to this very topic: https://dannyelectronics.wordpress.com/ ... eneration/

User avatar
Pito
Posts: 1739
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: PWM basic

Post by Pito » Sun Jan 07, 2018 2:04 pm

The OP is looking for a different stuff - most probably (it is not "PWM basic") he wants to process an audio signal.
ADC->DSP->DAC(via PWM).
To process a speech (300-3000Hz) for example, he wants a loop with say 8kHz tick, and during this 125us he wants do provide 12bit ADC, process the signal (ie FIR filter) and pass the result to PWM output (set to 1/32kHz pwm period for example).
Doable with BluePill, it requires some experience, however (or a ready to get code).
I would suggest to OP to start with something easier to master at this stage.. ;)
Pukao Hats Cleaning Services Ltd.

User avatar
mrburnette
Posts: 2216
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: PWM basic

Post by mrburnette » Sun Jan 07, 2018 2:58 pm

dannyf wrote:
Sun Jan 07, 2018 12:39 pm
I think dannyf's response was just for fun.
probably not.

here are two examples of an empty loop doing wonderful things relevant to this very topic: https://dannyelectronics.wordpress.com/ ... eneration/
Yes, Danny, when put into context it all makes sense :lol:

Ray

User avatar
mrburnette
Posts: 2216
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: PWM basic

Post by mrburnette » Sun Jan 07, 2018 3:06 pm

Pito wrote:
Sun Jan 07, 2018 2:04 pm
<...>
To process a speech (300-3000Hz) for example, he wants a loop with say 8kHz tick, and during this 125us he wants do provide 12bit ADC, process the signal (ie FIR filter) and pass the result to PWM output (set to 1/32kHz pwm period for example).
<...>
In his first post, the Op shows a 7kHz sinewave input ... definitely not what I would have taken as speech input processing (which I fully agree could be done on a generic blue pill.) Part of the problem is that only the Op knows what he is thinking and clearly communicating that to the forum in a query is imperative if any of us are going to be able to assist in earnest.


Ray

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: PWM basic

Post by ted » Sun Jan 07, 2018 4:22 pm

English is not my native language, what is meant Op?
I have no problem with DAC , LC filter for PWM is working very good. Internet study are not answer my questions, there is a lot of info but when you are looking for answer for your questions is hard to find it.
For example the filters, always for low frequencies and output always on serial plotter , I have never seen an example for traditional analog ecvivalent: " Filter input on pin - Filter - Filter output on pin".

you do not understand the loop () implementation in Arduino - sometimes I am confused what is belongs to it , I know analog world, digital = sirst steps.

ADC->DSP->DAC(via PWM). = exactly that, for single frequency

I think dannyf's response was just for fun. = I thought the same, but I tried.

It is a great pleasure to talk with experts.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: PWM basic

Post by ted » Sun Jan 07, 2018 4:49 pm

(it is not "PWM basic") = it is in analog field

I expect to see the Op post code that compiles and performs some function to represent an issue.
Please look at post # 23

https://forum.arduino.cc/index.php?topic=520896.15


I'm doing this with curiosity to see the advantages of digital technology.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: PWM basic

Post by ted » Sun Jan 07, 2018 5:06 pm

The first link - I started from it.
The second link - I'm familiar
The last - I'm studying it

zmemw16
Posts: 1684
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: PWM basic

Post by zmemw16 » Sun Jan 07, 2018 5:40 pm

op == original poster

User avatar
Pito
Posts: 1739
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: PWM basic

Post by Pito » Sun Jan 07, 2018 6:08 pm

op == original poster
original poster == ted
Pukao Hats Cleaning Services Ltd.

Locked