yes:
1) connect the input to output;
2) run the following code in the mcu:
while (1) {
}
input_output:17: error: 'Serial' does not name a type
Serial.print(outputPin, value);
^
input_output:18: error: expected constructor, destructor, or type conversion before '(' token
analogWrite(outputPin);
^
exit status 1
'Serial' does not name a type
pinMode(outputPin, PWM); // instead of OUTPUT
...
Serial.print(value);
analogWrite(outputPin, value);
input_output:26: error: expected constructor, destructor, or type conversion before ‘(‘ token
analogWrite(outputPin);
^
exit status 1
expected constructor, destructor, or type conversion before ‘(‘ token
/*pinMode(outputPin, PWM); // instead of OUTPUT
...
Serial.print(value);
analogWrite(outputPin, value);*/
//analogWrite(outputpin); analogRead(inputpin));
int inputPin = PA6; // analog input pin, inputPin = PB0;
int outputPin = PA7; //output pin
int analogOut;
void setup() {
Serial.begin(115200);
pinMode(inputPin, INPUT_ANALOG);
// pinMode(outputPin, OUTPUT);
pinMode(outputPin, PWM);
int8_t value = analogRead(inputPin);
}
void loop() {
while (1) {
}
}
//Serial.print(outputPin, value);
analogWrite(outputPin);
New code and new error.
input_output:3: error: ‘Serial’ does not name a type
Serial.print(value);
^
input_output:4: error: expected constructor, destructor, or type conversion before ‘(‘ token
analogWrite(outputPin, value);
^
exit status 1
‘Serial’ does not name a type
/*pinMode(outputPin, PWM); // instead of OUTPUT
...*/
Serial.print(value);
analogWrite(outputPin, value);
//analogWrite(outputpin); analogRead(inputpin));
int inputPin = PA6; // analog input pin, inputPin = PB0;
int outputPin = PA7; //output pin
int analogOut;
void setup() {
Serial.begin(115200);
pinMode(inputPin, INPUT_ANALOG);
// pinMode(outputPin, OUTPUT);
pinMode(outputPin, PWM);
int8_t value = analogRead(inputPin);
}
void loop() {
while (1) {
}
}
//Serial.print(outputPin, value);
//analogWrite(outputPin);
It must be inside either setup() or loop() …
input_output:3: error: ‘Serial’ does not name a type
Serial.print(value);
^
input_output:4: error: expected constructor, destructor, or type conversion before ‘(‘ token
analogWrite(outputPin, value);
^
C:\Users\OWNER\Documents\Arduino\input_output\input_output.ino: In function ‘void setup()’:
input_output:14: error: ‘outputpin’ was not declared in this scope
analogWrite(outputpin);
^
exit status 1
‘Serial’ does not name a type
/*pinMode(outputPin, PWM); // instead of OUTPUT
...*/
Serial.print(value);
analogWrite(outputPin, value);
//analogWrite(outputpin); analogRead(inputpin));
int inputPin = PA6; // analog input pin, inputPin = PB0;
int outputPin = PA7; //output pin
int analogOut;
void setup() {
Serial.begin(115200);
pinMode(inputPin, INPUT_ANALOG);
analogWrite(outputpin);
// pinMode(outputPin, OUTPUT);
pinMode(outputPin, PWM);
int8_t value = analogRead(inputPin);
}
void loop() {
while (1) {
}
}
//Serial.print(outputPin, value);
//analogWrite(outputPin);
[ted – 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.

I found this example of doing a similar thing with just one Google search:
https://www.arduino.cc/en/Tutorial/AnalogInOutSerial
void loop() {
while (1) {
}
}
probably not.
here are two examples of an empty loop doing wonderful things relevant to this very topic: https://dannyelectronics.wordpress.com/ … eneration/
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..
[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/
Yes, Danny, when put into context it all makes sense
Ray
[Pito – 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
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.
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.
The second link – I’m familiar
The last – I’m studying it
original poster == ted
srp
[ted – Sun Jan 07, 2018 4:49 pm] –
(it is not “PWM basic”) = it is in analog field
<…>
I’m doing this with curiosity to see the advantages of digital technology.
I suspect that every reader here has a certain curiosity that drives their learnings in the computer field, be it big data warehouse servers or tiny microcontrollers. I can certainly appreciate the desire to learn. But, learning analog technologies and digital technologies often requires one to learn to walk before we run. In my life, I have found that a solid understanding of basic concepts is absolutely mandatory and that foundation serves well for the next layer of learning. But, just like school, we all need a few lab sessions to pull together concepts into working methods.
I would not want to impede your creativity or learning. I champion your desire to learn. I think that the stm32duino forum can assist, but our assistance must be assisted by you and that means you must study and experiment and be specific with your forum questions. Rather than asking “How would I…” it is far better to research and ask, “I have read <url> and I am have this code (attached) which I developed for prototyping, however I am having an issue…”
Of course, the forum will attempt to guide you to an answer.
I cannot remember in recent years not being able to find information on programming concerns/issues/errors/style from an Internet search. Sometimes (often) I had to download a PDF document from a manufacturer and read for hours. Sometimes I had to breadboard a digital or analog circuit to continue an experiment relating to programming or understanding a filter technique. Yes, it is hard work to acquire knowledge and to understand how to apply that knowledge to a specific problem needing to be solved.
I hope these links help you:
For the world around us and for an understanding of how everything relates/reacts:
http://hyperphysics.phy-astr.gsu.edu/hbase/hframe.html
For creating and understanding how basic electronics works:
http://www.falstad.com/circuit/
Goodluck,
Ray
The first link = many years of experience in it.
The second one also is not a new one for me.
Regarding filters I think no one on forum attempted something similar
[ted – Sun Jan 07, 2018 8:49 pm] –
Thanks.
The first link = many years of experience in it.
The second one also is not a new one for me.
Regarding filters I think no one on forum attempted something similar
You are probably incorrect – my guess is a number of members have PWM to analog filtering experience. The Internet overflows with knowledge. But, your diagram showed a black-box design with analog in and analog out and absolutely no code, so the implied state is you have not attempted to program a solution. Rather, you ask for a solution.
For the output side, PWM to analog is a very common thing to do. Even this old TI PDF explains the basics:
https://www.google.com/url?sa=t&source= … hF_Y8DY8Ch
Analog input to a number representing relative value to PWM was shown in the Arduino example I linked to previously. You should build that potentiometer to LED brightness circuit. Essentially, you only have the input filter to design, the output filter to design and glue it all together with an enhancement of the Arduino code.
You have the circuit simulator link to work out the RC values.
But, unless you write the code and prototype the design, where is the learning? If you know physics, know electronics, and can understand the example code then you should be able to program something to get close to a decent solution.
Therefore I am going to lock this post. ted, please do your research, write some code to read AD, manipulate the AD value, and output the PWM, You will need to calculate the correct input and output filter values. Then if you have a specific issue that the forum can assist, post a new thread and ask your question.
THIS THREAD IS LOCKED FOR FURTHER POSTS
Ray
