Тёмный

How to use a microcontroller's analog to digital converter 

FriendlyWire
Подписаться 15 тыс.
Просмотров 20 тыс.
50% 1

Analog to digital converters (ADCs) are very useful tools for converting voltages into numbers.
In this tutorial we will learn how to use the 10-bit ADC module of the PIC16F1455 microcontroller: we will connect it to a potentiometer and use it to control the brightness of an LED. Check out the companion article on my website for more details and an up-to-date list of all components: www.friendlywire.com/tutorials...
Thanks for tuning in, and let me know in the comments if you have any questions!
Website: www.friendlywire.com
Twitter: / friendlywire
Reddit: / friendlywire
Facebook: / friendlywire
Instagram: / friendlywire
Timestamps:
0:00 Introduction
0:56 Part 1: The main idea
2:23 Part 2: Programming and flashing the PIC16F1455
7:44 Part 3: Schematic and building the circuit

Опубликовано:

 

7 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@Akos_V
@Akos_V Год назад
Thank you so much, these videos got me started with microcontrollers. It is a massive help
@FriendlyWire
@FriendlyWire Год назад
Thank you, and I am so happy to hear that! :)
@FriendlyWire
@FriendlyWire 4 года назад
Here is the overview: Part 1, The main idea: 0:57 Part 2, Programming and flashing the PIC16F1455: 2:24 Part 3, Schematic and building the circuit: 7:45
@mikko-mattikurppa4779
@mikko-mattikurppa4779 Год назад
Thank you for this awesome tutorial video. You are great teacher. I'd like to hear why you prefer using IPE for programming, instead of using make and program device button. I mean maybe there are some benefits that i do not know of? You can also enable power target circuit from pickit3 in MPLAB X ide. Right-click active project folder and select properties: make sure that pickit 3 is connected hardware tool. Select pickit 3 (left), option categories --> power. Enable and select voltage. Ipe is much clearer though and propably the best way to teach. I'm addicted to your professional and well-made videos. And what's best i think is your website. This is just pure gold. Hope this channel grows ALOT.
@FriendlyWire
@FriendlyWire Год назад
Thank you so much for your kind words, Mikko-Matti! For some reason the IDE's interface with the PICkit3 would not work reliably for me and my setup, whereas for the IPE it always works fine. I will be sure to give it another try some time, I hope it's not too confusing for beginners. Thank you again, and have a fantastic week!
@anokhautomation4453
@anokhautomation4453 2 года назад
Very very useful tutorial 👍 thanks for your detailed demonstration 🙏
@FriendlyWire
@FriendlyWire 2 года назад
Thank you so much, glad you like the video! :)
@VintageProjectDE
@VintageProjectDE 4 года назад
A really neat little project for an intro to ADC! One hint towards those breadboard PSUs: It's worth checking polarity before plugging them into the breadboard. It's very convenient to have them matched + to red and - to blue. The other way round, not so much. (Yes, happened to me. Didn't find it at first.)
@FriendlyWire
@FriendlyWire 4 года назад
Thanks! I have never seen a breadboard PSU with inverted polarity, but I will make sure to mention it in a future video! Thankfully the polarity is printed on the PCB and you can see it at 8:35 so it is hopefully not too confusing :)
@science.20246
@science.20246 Год назад
@@FriendlyWire ١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١١111
@mqi7269
@mqi7269 3 года назад
Very good Present, Thank you
@FriendlyWire
@FriendlyWire 3 года назад
Thank you so much, I am happy you like it! Is there anything about microcontrollers you want to see next here on the channel? I am always looking for new ideas :)
@mrengtop
@mrengtop 6 месяцев назад
This is realy good & clear explanation... Thank you..👏👏👏
@FriendlyWire
@FriendlyWire 6 месяцев назад
Thank you, I am glad you found it helpful! :)
@Mr_Motor
@Mr_Motor 2 года назад
your premium content deserve more views
@FriendlyWire
@FriendlyWire 2 года назад
Thank you so much :)
@lcohen2981
@lcohen2981 4 года назад
Thank you for these videos, they are so helpful! Particularly to someone like myself who has no previous experience. I was wondering what programming languages you can use to write the code for pic microcontrollers. Any suggestions?
@FriendlyWire
@FriendlyWire 4 года назад
Thank you for tour nice words, I am happy that the videos are helpful to you, it means a lot! I only use C to program PIC microcontrollers, and the compiler is called XC8 (and, with certain optimizations switched off, it is free to use). You can check out my PIC introduction video and my website www.friendlywire.com for more information on this. It is of course also possible to program directly in machine language (assembler), but for simple projects that are not time critical it is hardly necessary. Not sure if there are other dialects you could program PIC microcontrollers with, for me C has always been the language of choice :)
@anithasshenoy6662
@anithasshenoy6662 5 месяцев назад
MPLAB has an online facility called MPLAB xPress. we can do the programming on it. However it doesn't show PICKIT3 or 2. I tried this code on it. It did well and produced the hex file too. One thing I noticed is, when choosing the type of file, it shows only C. There is no assembly. Any idea on this ?
@FriendlyWire
@FriendlyWire 5 месяцев назад
PICkit2 and 3 are deprecated and no longer officially supported by MicroChip, this is probably why they don't show. It's a bit of a shame since the PICkit3 is all you really need for basic hobby electronics. I was not aware of the online tool, interesting. I use the MPLAB X software on my computer, so that it does not require an internet connection. At what point do you choose a file type? The source code on my websites is written in C.
@anithasshenoy6662
@anithasshenoy6662 5 месяцев назад
@@FriendlyWire It is sad that they deprecated Pickit 2 & 3. Pickit4 is damn costly here. Can't buy it at this point. There is one disadvantage with the online facility. Once can do only one project at a time. Looks like it holds the files in a folder called sandbox. I suspect it holds the files only for three days. Some thing like that flashed on the screen. When I tried to open a new project, It deleted the already created one. But for beginners, it is a not a bad option. When I tried to create a new file it displayed three types - Header, c main , source file. So I believe it allows only C language. need to explore more.
@Rafea_alshehry
@Rafea_alshehry Год назад
Can I use PIC16F628A? I need a piece other than PIC16F1544, can I exchange it for any other item? I hope you mention an alternative to it
@FriendlyWire
@FriendlyWire Год назад
This tutorial is specifically for the PIC16F1455. The PIC16F627A and PIC16F628A do not have built-in ADC modules, unfortunately, so you cannot use them for this purpose. Do you have other chips available? The PIC16F1459 may be a good choice, too. Let me know, and I am happy to help :)
@anokhautomation4453
@anokhautomation4453 Год назад
Nice tutorial 👍. shall we do it with pic 16f627A also??
@FriendlyWire
@FriendlyWire Год назад
Sadly, the PIC16F627A does not have an ADC module built in, so it does not work in that case.
@anithasshenoy6662
@anithasshenoy6662 5 месяцев назад
Thank you very much for presenting this in a simple and practical manner. I love it. Pic16F1455 is not available here. Can I use pic12f510 instead. It too have ADC.
@FriendlyWire
@FriendlyWire 5 месяцев назад
The PIC12F510 can also be programmed with the same tools as presented in this video. But the code will be different, unfortunately, this is the disadvantage of there being so many different PICs :( Where are you located?
@anithasshenoy6662
@anithasshenoy6662 5 месяцев назад
@@FriendlyWire India. Unless there is a huge demand, the vendors will not import the components. Once the stock is sold out, it may not be easy to get the same item again. There are international vendors like elements14. But they sell only to tax registration holders. pic16f1455 is 10 bit , while 12f510 is 8 bit. Hence the code will need to adjusted for 8 bit . right ? is there anything else I need to look out? thks
@FriendlyWire
@FriendlyWire 5 месяцев назад
@@anithasshenoy6662 The problem with PIC controllers is that they all have a slightly different architecture (different register names etc) which makes it difficult to re-use code from one controller (like the PIC16F1455) and use it directly for another one, like the PIC12F510. More likely, we would have to re-write this from scratch. Do you have experience with PIC controllers? If not---which is totally OK---then I would suggest we start with making an LED blink first, and then move on to the ADC question. Let me know! We can chat on Instagram/Twitter or via email (address is at the bottom of www.friendywire.com).
@anithasshenoy6662
@anithasshenoy6662 5 месяцев назад
@@FriendlyWire Thank you very much. I understand. I have been into electronics since my school days 50 years back and into software programming since 1985. This is not my profession now. I had stopped doing electronics some 30 years back. However , now that I have lots of free time , I started looking into it. I found that there is whole new world in MC. I am gathering the required equipments for the programming. I hope to get it by next week or so. Though I live in a big city, the local stores do not have the PICKIT3 or 3.5 and even the MC's. I wanted to order some of these MC's online , hence wanted to know a bit about them. I shall write to you , once I get those items and try my hand. Your video's are of great help. Thanks once again for your kind efforts.
@FriendlyWire
@FriendlyWire 5 месяцев назад
@@anithasshenoy6662 Thank you for sharing, and I think you will have a lot of fun with microcontrollers, especially if you already have a background in coding. Regardless of whether you will use PICs or not, I am sure it will be a great experience. Yes, please get in touch when the items arrive, or if you want to chat about projects, I am always happy to help. :-)
@soumeya772
@soumeya772 2 года назад
Hello, first I wanna say this video was great and u did explain it very well, keep going! Now I have a question: can we create a ramp or triangular waveform using an ADC? and if this signal can do the job of the potentiometer like increasing the glowing and decreasing it ? ( I m using a pic32mk in my project )
@FriendlyWire
@FriendlyWire 2 года назад
Thank you! You are thinking of a DAC, a digital to analog converter, basically the opposite :) An ADC takes an analog voltage and turns it into a number. A DAC takes a number and outputs and analog voltage. If you want to dim an LED I would recommend using pulse width modulation (PWM) instead; you can check out my electronic candle video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pCvCan2yGZg.html If you are interested in generating specific waveforms, then the DAC is your tool of choice, but the built-in ones typically have a slightly lower resolution.
@soumeya772
@soumeya772 2 года назад
@@FriendlyWire thanks for explaining!
@FriendlyWire
@FriendlyWire 2 года назад
@@soumeya772 Of course, and let me know if you have other questions :) I may do a video on DAC's in the future.
@soumeya772
@soumeya772 2 года назад
@@FriendlyWire your video is gonna be so helpful! Thank u again for helping ^^)!
@FriendlyWire
@FriendlyWire 2 года назад
@@soumeya772 Thank you for your kind words, it means a lot :)
@mariakitchen4182
@mariakitchen4182 Год назад
Please can you do it using assemble code and lcd
@mariakitchen4182
@mariakitchen4182 Год назад
Using atmega328p and output x axis and y axis
@FriendlyWire
@FriendlyWire Год назад
@@mariakitchen4182 That's a nice idea for a project. I don't work with assembler, though, for now. I will do an LCD tutorial very soon, stay tuned!
@cying6614
@cying6614 2 года назад
Do you guys have any ideas on how to save the digital values into a text file? Thanks
@FriendlyWire
@FriendlyWire 2 года назад
Good question! The easiest way I can think of, with the content I have online, is to use the RS232 tutorial to sent it to a computer. Then you need a program running on the computer that manages the incoming data. You can learn more about RS232 and how to use it on a microcontroller here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-2T9ca53KMrM.html
@cying6614
@cying6614 2 года назад
@@FriendlyWire Thank you for your quick response. I appreciate it greatly. How about if this is a chip in an independent instrument which should save the data like temperature readings as text file in itself and when the computer is connected to the instrument via USB it then can read the data like from a regular USB fresh memory? Thank you
@FriendlyWire
@FriendlyWire 2 года назад
@@cying6614 Then you need a means of storage on the chip. Many PICs have an EEPROM memory that you can use, but that memory is limited. You could use an external EEPROM as well. Another alternative is to use an SD card adapter. These are fairly easy to write to, but managing the file system is a bit complicated if you want the data to be readable on a computer.
@cying6614
@cying6614 2 года назад
@@FriendlyWire Thank you very much
@FriendlyWire
@FriendlyWire 2 года назад
@@cying6614 Happy to help!
@swatcat7928
@swatcat7928 2 года назад
Good bless Arduino...
@FriendlyWire
@FriendlyWire 2 года назад
Ha, how so? I always believe that people should use the microcontroller that works best for them :)
@swatcat7928
@swatcat7928 2 года назад
@@FriendlyWire for been easy to learn..
@FriendlyWire
@FriendlyWire 2 года назад
@@swatcat7928 I know what you mean :) I find working with PICs very interesting, because we need to look at registers in the controller and have to try to program everything ourselves, and I like the challenge. Also, once you have bought the PICkit3 programmer for around $25, a PIC only costs $3 or so, so they can also be a bit cheaper than Arduinos in the long run. But to each their own :)
@jadidfekih
@jadidfekih 3 года назад
Good 8-bits joke LOL
@FriendlyWire
@FriendlyWire 3 года назад
Ha, you're the first one to comment on that! :)
@jadidfekih
@jadidfekih 3 года назад
​@@FriendlyWire You both (you and 8-bit guy) are doing a great job, keep it up.
@FriendlyWire
@FriendlyWire 3 года назад
@@jadidfekih Thank you for your kinds words, I am glad you enjoy the videos! :)
Далее
CD4026 decimal counter tutorial
7:59
Просмотров 22 тыс.
D3 Ваз 2107 Не умри от зависти!
18:57
Electronic Basics #36: SPI and how to use it
10:31
Просмотров 333 тыс.
How to use an ADC (embedded example in C)
14:56
Просмотров 29 тыс.
How to get source code onto a PIC microcontroller
11:21
Building an analog clock with a microcontroller
24:55
Before you buy a Digital to Analog Converter (DAC)
6:38
Analog-to-Digital Converters (ADC) - Basics
18:01
Просмотров 119 тыс.
How Do ADCs Work? - The Learning Circuit
10:13
Просмотров 124 тыс.
D3 Ваз 2107 Не умри от зависти!
18:57