Quick basic questions about microcontrolers/microprocessor 8/16/32 bits

Thread Starter

Xenon02

Joined Feb 24, 2021
504
Question #2
Connecting a loudspeaker to the DAC does not work, unless…?

I've seen a couple of circuits in which DAC is connected to OP Amp and from OP Amp is connected to Speaker. Op Amp there is pobably there to increse the output analoge sygnal.

Question #3
What is the voltage output of the DAC?

As I've read it depends on from the reference voltage VCC and how many bits is the resolution. There is formula for this : Vout= (Reference voltave)*(Digital number Input)/(2^N - 1)

Question #4
How much current can the DAC deliver?

I couldn't find info for this. Maybe it now acts like voltage source and give as much current as it's needed for example let's say the speaker has 8 Ohm so when I know the output voltage and the resistance there is the current. Which gave me another question but for now I leave it here.

Question #5
What is the output impedance of the DAC?

No clue.

Question #6
What is the impedance of the loudspeaker? For example for YD36 is like 8 Ohm.

Question #7
How much current can the loudspeaker handle?

The speaker I mentioned has 0.5W power so if I know the output voltage and the resistance then I can know what is the output current that can be maximal on the output. Thus what is the sound then the Voltage or the current ?

Question #8
How loud do you want the sound to be?

It depends, if we want louder sound we need to "boost" the output, the bigger the amplitude the louder.

After this I still would like to know if my thoughts are correct now with the screen stuff I said.


(Observe, I have taken one single question and tried to break it down into minute details in order to solve the problem. I have not deviated from the problem by going off with a different question. This is the art of problem solving which you need to learn. You also need to learn how to analyze and answer these questions on your own otherwise you are going nowhere.)
Yes, you are right.
My problem is that when I want to ask one question, while writing it another question borns related to this question and it's hard for me to leave it because either I will forget about it or my post will be left or my english will be to sloppy enough that the answer doesn't asnwer my question rather makes it more complex. So at the end asking one questions end with multiple. And I have problem asking exact questions like you did because I lack a lot of knowladge about practical part, I'm now at theory step ;>, because I have a feeling that I will break something if I didn't know something beforehand.
 

BobTPH

Joined Jun 5, 2013
11,516
You need to slow down and study the basics. You are trying to understand complex things without understanding any of things needed even to describe it. Stop making assumptions about about how things work. You need to be an expert before you can do that with any chance of being right. Pretty much all of your assumptions here have been wrong.
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
Then I don't know what I was supposed to say here then or where to start from.
I only knew something about UART (only basic terms from wikipedia or so), if questions are the assumptions then welp, I am wrong and I didn't expect much more from me.
But going back to what I also tried to say before, I started from asking question on how bytes works (taking free space) because bytes stuff was mixing all over my head imagining how it could work, then it went to UART and at that point I was lost with how the space is reserved for UART and then came up with different problems like how do I know how long I can make strings or what if there is not enough strings to fill the whole screen etc, or with the screens that can change the size of letters the same problem with imagining it. Usually external device problems how it worked etc.
My questions were wrongly asked but I felt lost at that point and still went on with the questions I asked not knowing what basics I lacked or where to start again then.
Basically I am usually confused with how to configure sending or receving bytes/bits the way it will work, or what happens if I didn't predict something for that external device. Like if the string is to long or to short or if I can change the size of letters then how can I predict how much strings and how long they are or for speaker or for other devices.
 

BobTPH

Joined Jun 5, 2013
11,516
how can I predict how much strings and how long they are or for speaker or for other devices.
This is exactly what I am talking about. Speakers do not take strings of bytes, they take a varying voltage. Where did you get the idea that they need a string of bytes? There is no digital data involved in driving a speaker. So the question is nonsense.
 

MrChips

Joined Oct 2, 2009
34,817
You need to take one topic at a time and understand it fully (or as much as is applicable to the topic at hand) before moving on. If multiple questions arise, as will always happen and more so in your case, write them down and ask them at another time so as not to confuscate the present problem.

One of the seemingly simple concepts that newcomers fail to master is Ohm's Law.

Concisely stated, Ohm's Law states that the current I through a resistor is directly proportional to the applied voltage V and inversely proportional to the resistance R.

Mathematically, we express this as,

I = V / R

There are two corollaries of Ohm's Law.

V = I x R
R = V / I

Ok, so you think you have mastered this? Not so fast!

Here are some examples where newcomers get into trouble very quickly.
How do you measure current and voltage in a simple circuit?

1696853996894.png

We recently saw a case here on AAC where someone got measurements that were inconsistent with the mathematics.

Examine both drawings A and B. First impression says that the voltmeter V should give the same reading as battery source Vb.
Under what circumstances is this not true?

Here is another simple circuit called a voltage divider.

1696854328515.png

We can determine the theoretical equation for Vout as a function of Vin. We can verify the theory by taking a measurement with a voltmeter.
Under what circumstances does the equation fail to give the correct answer?

Connect a loudspeaker to the output of a DAC.
Under what circumstances do the theoretical calculations fail to give proper results?

My point of this exercise is: Don't jump to quick conclusions without first studying all possibilities.
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
Here are some examples where newcomers get into trouble very quickly.
How do you measure current and voltage in a simple circuit?

1696853996894.png
Here A is correct.
About the current, if the R is known and V is known then I = V/R. But if we want to use also another device then ammeter (I think I said it correctly).


Take drawing B as an example. First impression says that the voltmeter V should give the same reading as battery source Vb.
Under what circumstances is this not true?
When the voltmeter is not ideal (it has it's own parallel resistance). Usually the resistance is really big.


We can determine the theoretical equation for Vout as a function of Vin. We can verify the theory by taking a measurement with a voltmeter.
Under what circumstances does the equation fail to give the correct answer?
If the input voltage is also non ideal there is possibility that it;s resistance can also change the output voltage also the non ideal voltmeter can also have a resistance that can be significant at measuring.


Connect a loudspeaker to the output of a DAC.
Under what circumstances the theoretical calculations fail to give proper results?
I think the same as above.
If the DAC has a significant resistance let's say it is not very small (ohm, mili ohms) but bigger then it can't be ignored and it will create a voltage divider which in result will change the voltage at the end. Which means that output of DAC can't be treated as typical voltage output that usually ignores output resistance.
 

Ian0

Joined Aug 7, 2020
13,132
This is exactly what I am talking about. Speakers do not take strings of bytes, they take a varying voltage. Where did you get the idea that they need a string of bytes? There is no digital data involved in driving a speaker. So the question is nonsense.
. .. and from .wav file to loudspeaker, my data will have gone nowhere near a UART!
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
I have a bit lost the track.
Are those questions related to my concerns ? Because I was concerned on how the bytes are stored and how to get knowladge to program it correctly like the screen strings I asked and what happens if I didn;t predict something like with the screen or with the speaker (something doesn't mean string for speaker ... I mean that I didn't predict something). I don't know what I should ask though or where to start getting this knowladge.
 

BobTPH

Joined Jun 5, 2013
11,516
You start by writing programs for simple things. As you learn, you move to more complex things. The questions you have are all based of misconceptions because you have apparently not done any programming at all. Once you start, you will find that the things you are puzzling over now are not issues. Think controlling LEDs, not LCD displays or digital audio.
 

Ian0

Joined Aug 7, 2020
13,132
You mention the UART, audio and displaying characters on a screen. If you are anything like I am, I don't actually learn unless I have a problem to solve or a task to achieve. I can read endless answers to abstract questions and learn nothing.
What are you actually trying to achieve? You will learn by doing it and asking for help on specific questions as you get there.
1. Get started
2. Work on the problem until you are stuck,
3. Look it up or Ask.
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
You start by writing programs for simple things. As you learn, you move to more complex things. The questions you have are all based of misconceptions because you have apparently not done any programming at all. Once you start, you will find that the things you are puzzling over now are not issues. Think controlling LEDs, not LCD displays or digital audio.
I've done some LEDs controlling at MCS-51 using assembler and using C. That's why I was having problem understanding how te memory is alocated for more complex stuff when I was introduced to UARF and how external devices function in all, not knowing what will be the consequence of missing something like I mentioned many times with LCDdisplay or other stuff.

So I thought that after LEDs I could go forward so I asked questions beforehand to understand the concept in how it works or how the processor works with the external devices so I could understand the error that could occure while working on it. At the end I got to twisted that I don't know anymore what I know and what not, and where to start again ;> But doing LEDs is working with single bytes but I wanted to advance a bit further understanding how other thing works. It puzzles me alot ;>
And my sloppy english as well sometimes gets misinterpreted because I wrote it poorly.

I basically think of micro or other digital devices as a precise machine that if I miss something it won't even flinch to work or do wierd stuff with it (I was once scolded for changing the interrupt activation speed like the timer interruption was happening faster for 8 segment display). Oh yes while writing it I remember working with 8 segment display on MCS-51, I had to know how to switch from one segment to another segment and what type of information was it supposed to be. Also the switching had to be very fast.
 
Last edited:

Thread Starter

Xenon02

Joined Feb 24, 2021
504
Pick a simple thing to do with a UART, then try to write a program for it.
I wonder which when I heard there isn't much to do with UART ;>


You mention the UART, audio and displaying characters on a screen. If you are anything like I am, I don't actually learn unless I have a problem to solve or a task to achieve. I can read endless answers to abstract questions and learn nothing.
What are you actually trying to achieve? You will learn by doing it and asking for help on specific questions as you get there.
1. Get started
2. Work on the problem until you are stuck,
3. Look it up or Ask.

I also get stuck on how it theoretically works.
Like UART I know it send/receive 8 bit data but how it works in real life ? With display or with speakers or with other devices. That's why I was asking at the beggining and asked many different questions, because I didn't understand the concept how this thing worked with more complex devices. Or how to predict some of that stuff. Like I am stuck with what happens if I don't give enough strings for display will the rest of the display just won't work or if I give to much of strings what happens. These questions are just things that I can;t figure out when I worked with 8 segment display I had to pick specific display then send specific letter. I also know there are displays that can change the size of letters so what happens then with strings and stuff ? I know it is stupid to ask not starting with it at the beggining but the problem was understanding how to use UART for these devices then it went to where the data is stored and how devices uses it and what happens if I did to much or to less of something.
 

Ian0

Joined Aug 7, 2020
13,132
I can't think of many applications that actually use a UART these days. Certainly, anything to do with displays and audio wouldn't use the UART. If you can think of a valid application then it will be easier to explain.
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
I can't think of many applications that actually use a UART these days. Certainly, anything to do with displays and audio wouldn't use the UART. If you can think of a valid application then it will be easier to explain.
So screen and speakers aren't the best I guess. I don't know any more better application for it.

At the same time I would also want know the display question I asked before, theoretically of course because I have only 2x16 display. What happens if I give to much strings or to less for the clasical displays and with displays that can change the size of letters ?

This is only a question to ease my curiosity because I don't know what happens with the screen when it has defined characters in line and with changable size (reducing the pixels to make smaller letters or adding pixels to make letters bigger).
 

Ian0

Joined Aug 7, 2020
13,132
So screen and speakers aren't the best I guess. I don't know any more better application for it.

At the same time I would also want know the display question I asked before, theoretically of course because I have only 2x16 display. What happens if I give to much strings or to less for the clasical displays and with displays that can change the size of letters ?

This is only a question to ease my curiosity because I don't know what happens with the screen when it has defined characters in line and with changable size (reducing the pixels to make smaller letters or adding pixels to make letters bigger).
The screen I use has commands to set the font size, and separate commands to send text. The text is sent in ASCII regardless of its size (but it is interfaced by SPI).
If you send strings that are too long to the display, what happens depends on the size of the display and the characteristics of its driver IC. The common LCD displays tend touse the same chip for 2x16 and 2x20, so that the 2x16 is the same thing as the 2x20 but with four characters missing at the end. So if you send 17 characters then the 17th disappears, but if you send 21 then 17, 18, 19 and 20 disappear but 21 appears in the first position of the 2nd line.
That might not apply to all displays.
So it's important to know exactly where you are going to put every message, otherwise it might not be readable or it might look untidy.

You might need a UART to interface to MODBUS, DMX-512, or perhaps a GSM modem. I can't think of any other applications.
 

Thread Starter

Xenon02

Joined Feb 24, 2021
504
The screen I use has commands to set the font size, and separate commands to send text. The text is sent in ASCII regardless of its size (but it is interfaced by SPI).
How is it that it is regardless of the size.When you change the font size then you can have more characters or is it like with other displays that it ignores or overwrites to much characters ?

Also when I don't smaller string then just the rest of the screen is not used I guess ?

You might need a UART to interface to MODBUS, DMX-512, or perhaps a GSM modem. I can't think of any other applications.
I will consider looking at them.
 

Ian0

Joined Aug 7, 2020
13,132
How is it that it is regardless of the size.When you change the font size then you can have more characters or is it like with other displays that it ignores or overwrites to much characters ?
Also when I don't smaller string then just the rest of the screen is not used I guess ?
It will keep on printing characters until it either runs out of room to put them in or overlaps onto the next line.
 

MrChips

Joined Oct 2, 2009
34,817
I can't think of many applications that actually use a UART these days. Certainly, anything to do with displays and audio wouldn't use the UART. If you can think of a valid application then it will be easier to explain.
I am using UART protocol over Bluetooth.
 

BobTPH

Joined Jun 5, 2013
11,516
Well, I am going to guess that debug output the most common use of UART on microcontrollers.

For X’s sake, just write a friggin’ program that sends the text “Hello”. And don’t use any libraries in writing it, talk directly to the hardware registers. We can help if you get stuck.

For bonus points, set up a USB to serial port board on your PC and get a terminal program so you can see the output.

Then you will know far more about using UARTs than spending days in the forum and reading will ever get you.
 
Top