Тёмный

PIC MCU TUTORIALS #18 - Using LCDs & LCD library (Absolute Beginner) 

Microesque
Подписаться 1,8 тыс.
Просмотров 4,4 тыс.
50% 1

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

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 59   
@Microesque
@Microesque Год назад
I have included a single-file version of the library in the download link, which contains only one ".c" file. If you don't plan to inspect or modify the functions, I recommend you use the single-file version instead. The procedure to load the library is the exact same, just with one ".c" file instead of 21 separate files. This version doesn't clutter the project tree with a bunch of files. It also doesn't make you include unnecessary functions or definitions (the ones that you're not supposed to change anyway). The original idea was to make each function separate in their own files to make viewing and modifying them easier for beginners, but I see now that it made things complicated for no reason. Use the single-file version; it's just better... ¯\_(ツ)_/¯
@emiliomaalouf5101
@emiliomaalouf5101 6 месяцев назад
Does this library work for 16x4 lcds ?
@Microesque
@Microesque 6 месяцев назад
@@emiliomaalouf5101 It should, as long as it uses the "HD44780U" controller.
@ngtony5428
@ngtony5428 7 месяцев назад
In learning , I like separate 21 file . I watched more than 10 youtube about PIC LED , YOU ARE THE BEST. THANK.
@RajinderSingh-bx3cz
@RajinderSingh-bx3cz 3 месяца назад
Thank you so much for this video. If possible please continue to make more videos.
@Microesque
@Microesque 3 месяца назад
Thanks 👍 I want to, believe me, but it doesn't seem like it'll be possible for a while still...
@sapient_design
@sapient_design 7 месяцев назад
FYI! If using a PIC16F74 MCU then during the "Configuring the library for your connections" section, Change LATAbits.LATA0 to PORTAbits.RA0 and so on for 1,2,3,4,5 This had me stumped for awhile. After consulting the datasheet I was able to identify the issue. Thanks for the awesome video!
@Microesque
@Microesque 7 месяцев назад
Yeah, PIC16 microcontrollers are ancient and don't have LAT bits; they use their PORT bits to change their outputs. Ideally, no one should use them in this day and age. If you have any questions you can just mail me btw, I usually check it every day 👍
@suntzu1409
@suntzu1409 8 месяцев назад
This by far the best series on programming PIC that i have come across. To anyone watching this, make sure to check out various resources in the video descriptions
@Microesque
@Microesque 8 месяцев назад
Appreciate the compliment 👍
@SanelKeys
@SanelKeys 8 месяцев назад
My second comment on this video, after while: I use your code as reference for making my own libraries. I use CCS PIC C. I've made my own headers for every PIC I use, just like headers in XC8. So, every register has bit names like those in XC8, just like every register has same or similar names, and is used in very similar fashion (dereferencing appropriate union).
@Microesque
@Microesque 8 месяцев назад
I'm assuming it worked out then 👍 Normally, ordering of the bit-fields is implementation defined in C; XC8 compiler strictly states that it orders them by their definition order, I guess that's also how CCS compiler is too.
@SanelKeys
@SanelKeys 8 месяцев назад
@@Microesque CCS has hidden bit definitions, that I was unable to find. It's part of so called built in code of compiler. One of reasons I've made my structures/unions was an exercise for working with unions and structures, emulating CMSIS and bare metal programming for the STM32 MCUs.
@mohammed_2212
@mohammed_2212 2 года назад
Thank you Mr. ,You are professional man ,thanks for this Library, I am very interested, I am checked the library and work well.💯💯👌👌
@anokhautomation4453
@anokhautomation4453 2 года назад
Very very useful tutorial 👍 thanks for sharing 🙏
@prasanthchigurupatii
@prasanthchigurupatii 9 месяцев назад
Awesome explanation, Kind request to Explain for I2C+PCF8574A +LCD
@SanelKeys
@SanelKeys Год назад
Awsome video and library.👌👍
@Microesque
@Microesque Год назад
Thanks 👍
@abdulbarirawan5694
@abdulbarirawan5694 9 месяцев назад
❤❤❤
@pietmatsobane6790
@pietmatsobane6790 2 года назад
Very Professional
@karthid2557
@karthid2557 Год назад
Thanks you sir 🥰
@adedejikehinde5875
@adedejikehinde5875 Год назад
Thanks you so much, this video is very insightful. Do you have any lesson videos on CCS C compiler too?
@Microesque
@Microesque Год назад
Thanks 👍 Unfortunately I've never used the CCS compiler so I can't help you with that😕
@filipp7611
@filipp7611 4 дня назад
Can you share please the project configured for PIC16F887, no matter what Im doing I have a blank screen :( Ive configured ADCON1, switched RA4 to RB4 (also tried RA4 with resistor), all headers has correct oscillator value (im using 20mhz), but nothing works :( PIC works for sure because in parallel im blinking LED and reading time from RTC3231, all works fine. P.S FINALLY !! was able to make it work! Just used another LCD + switched to RD pins, maybe first LCD is broken or something with soldering.
@Microesque
@Microesque 3 дня назад
Glad you got it to work 👍
@filipp7611
@filipp7611 2 дня назад
​@@Microesque Can you answer on one question please, for some reason my LCD blinking every ±2-3s, can't understand it is a text or backlight, blinking I mean the text becomes more darker for about 0.2s and get back to normal, I update only last line every 1s, but blinking happens every ±2-3s. Im using good power supply, added all "filter" capacitors.
@Microesque
@Microesque 2 дня назад
​@@filipp7611 I couldn't quite understand the problem. Is it the text or the backlight blinking? Either way, something like that will be the result of a power supply issue. If your text is blinking or resetting, make sure to check if the LCD is actually receiving 5V. These LCDs have a very tight operating voltage range. Getting even close to 4.5V may cause it to reset. If you have relatively high power components in the same circuit, or if you have long/thin power lines, your supply rail might be sagging just long enough to reset your LCD, but not long enough to be picked up by your multimeter. If the backlight is blinking periodically every couple of seconds, and you're switching something in your circuit every couple of seconds as well, there's likely a short circuit in your setup shunting the power rail to ground. The backlight is just an LED, it's not connected to anything else on the LCD. Unless there was a short, it wouldn't just turn off like that.
@thatoprince8518
@thatoprince8518 Год назад
I follewed step every you did but my LCD is not displying information. What could be the problem?
@Microesque
@Microesque Год назад
I just tested the library and you're right, my LCD was unstable. I increased the delays in the library and it is working fine now. I also re-uploaded the library files with the new delay values. Try the new library I've uploaded and hopefully your problem will be fixed. If you still have problems make sure you have everything connected properly and that your definitions in the header file are correct. I don't know how I never had issues while developing the library or using it while making these videos, and now I started having them after your comment... what the...🤔
@filipp7611
@filipp7611 20 дней назад
Can't compile this for PIC16F877, is it possible at all? The main error is "use of undeclared identifier 'LATAbits'".
@Microesque
@Microesque 19 дней назад
PIC16 microcontrollers are very old and use a different architecture; you shouldn't use them even for learning purposes, unless you have to. You can check the comment from "@joshuvajohnvarghese2372" below, where I explained the issue further. Basically you can make it work by: 1 - Changing the LAT... definitions in the header file to their PORT... equivalent. 2 - Making sure the pins you're using are properly set to digital (use PCFG bits in ADCON1). 3 - Making sure to not use an open-drain only pin.
@filipp7611
@filipp7611 19 дней назад
@@Microesque Thank you a lot for the quick answer, I just have 6 units of 16f877 and don't want to buy new ones until I use those, next time will buy something new.
@syaffiqriyaacob9800
@syaffiqriyaacob9800 6 месяцев назад
Sorry sir i just want to ask do you have adc.h library tutorials
@Microesque
@Microesque 6 месяцев назад
Unfortunately, not yet. That's supposed to be the next video on the list, but I haven't had the chance to work on it for a long time.
@lunarrr2476
@lunarrr2476 Год назад
Please post new videos in your excellent series. If you could explain the schematics of the MCU it would be great, this way we can learn to code in assembly or C without any abstraction. With the purpose of coding our own library for any sensor based on the datasheets.
@Microesque
@Microesque Год назад
Thanks 👍 I've been having difficulties finding the time to make more videos, but rest assured, I haven't given up on the channel, and neither will I ever. ----------------- As for the schematics, I've explained more than a beginner needs to ever know when using C, so I assume you're talking about instructions and assembly. That would need its own series, and almost no one uses assembly anymore since it's family-specific, hard to learn, time consuming, and impossible to do anything complicated with. Including such information in this "absolute beginner" series doesn't really make sense unfortunately. ----------------- Also, I'll admit that I'm not that good with assembly, I only know what I had to use. I'm by no means an expert, and teaching that topic would require me to do a lot of research, so I don't misinform people. But if you have any specific problems or questions, you can ask me here or through e-mail, and I'll try to help. 👍
@lunarrr2476
@lunarrr2476 Год назад
@@Microesque it's very hard to find your series on youtube, I had to scroll a lot and was lucky to find your channel. I have no idea how youtube works, but you should consider putting tags on your video/channel, like programming PIC, PIC C, Bare metal C, debugger, programmer, microcontroller architecture, datasheet, etc...this way your series shows up on the search results. You have the best series.
@Microesque
@Microesque Год назад
​@@lunarrr2476 Thanks for the compliment👍When I first started the channel, I remember reading that tags didn't affect the search results, so I didn't bother. But maybe I should put some of the generic ones... Not like I'll lose anything.
@udayshetty5947
@udayshetty5947 Год назад
Make video on i2c using LCD
@Microesque
@Microesque Год назад
I'll probably update the library to allow for I2C connection in the future but it'll be a while from now. Like I said in the video, I2C boards are just I2C to parallel converters and you can easily change the source code to make it work(I put comments for every single code). I didn't bother with I2C because it adds a lot of overhead and it of course requires an I2C(MSSP) module to work, so I just preferred 4 more wires over all of that.
@ememeable
@ememeable Год назад
Dear friend i thank you very much however do not if you will receive this message to reply i am currently learning assembly language having switched from arduino i am thus wondering if the lcd file is compatible i am also struggling with __delays on mplax asm language just to blink an led your advise will be appreciated
@Microesque
@Microesque Год назад
You can mix C and assembly code. This is usually done by writing your assembly code as a routine (function) and calling it in your C code, or by writing inline assembly (writing assembly directly in C). Read the XC8 Compiler User's Guide (pages 216 and after): ww1.microchip.com/downloads/en/devicedoc/50002053g.pdf --------------- For the delays, it's very easy to write your own delay routines. It's usually done by loading a value to a general purpose register, and constantly decrementing it and checking if it's zero. You can nest multiple of these for exponentially longer delays. The values you put in the register will determine how long the delay will be. You can watch Ben Eater's video for a better understanding. It's for the 6502 microprocessor, but the same idea applies to any assembly. Video (watch until 4:40): ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-g_koa00MBLg.html You can see how delays are implemented for your architecture by making an empty function in C and using the built-in delay functions. Then, you can inspect the code generated by the compiler using the disassembler. For how to do that, you can watch my delays and disassembly videos. Delays video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-1hkHIIbCeN4.html Disassembly video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-N6k7jgPHrKM.html --------------- I don't know if you're a beginner, but I suggest not bothering to learn assembler if you are (unless you're very interested and it makes you happy 😄). Assembly is rarely used these days except for time-critical applications, and even then, most of the time they are used as inline to otherwise C based projects.
@mustafashaikh6742
@mustafashaikh6742 2 месяца назад
Can make a video in adc conversation in pic microntroller
@Microesque
@Microesque 2 месяца назад
That is supposed to be the next video on the list, but I haven't had the time to make videos for a while now😟
@tanerdincler753
@tanerdincler753 Год назад
The screen you are using is 4x20. I am using 2x16. How will I do this ?
@Microesque
@Microesque Год назад
Just do everything in the video as if you had a 4x20 LCD, they both use the same chip. The 2x16 just has those 2 lines and 4 columns off screen but otherwise they're the same. The "cursor_set()" command should also work the same, though stuff you try to write to 3rd and 4th lines won't show since again they're off screen.
@tanerdincler753
@tanerdincler753 Год назад
@@Microesque Thank you for your answer. It really works for 16x2 as you said. But I noticed that, for Mplabx 6.05 version, the screen does not open at optimization level 0. Works at Optimization Level 1 and above. What is the reason for this? Also, LCD_add_character() function addresses work between 1-8, not 0-7.
@Microesque
@Microesque Год назад
@@tanerdincler753 I just tested with the latest compiler and 2x16 LCDs work without a problem for all optimizations. To be honest this isn't the type of code that would break from compiler versions or optimization. Try doubling the delays in the "LCD.h" file("LCD_BUSY_DELAY" -> 80 and "LCD_BUSY_DELAY_EXTENDED" -> 3200), and see if that helps. Other than that, I can't think of anything, check your connections maybe?-----I also tested "LCD_add_character()" and it definitely works with addresses 0-7, it breaks if you add a character to address 8 and so on, I don't really know how it's broken for you.
@joshuvajohnvarghese2372
@joshuvajohnvarghese2372 Год назад
will this work for all mcu under 16F? cause im using 16f72. and its not displaying anything
@Microesque
@Microesque Год назад
That microcontroller is ancient... Old PIC16 MCUs don't have LAT registers; they write to their PORT registers to update the I/O pins. If you wrote the LAT bits in the definitions part of the header file like I said in the video, it won't work. If you did that, you're probably getting errors when building the project. You'll have to replace those with the corresponding PORT bits, though it's been a while since I wrote the library, so I'm not exactly sure if it'll work with that change only.
@joshuvajohnvarghese2372
@joshuvajohnvarghese2372 Год назад
@@Microesque yah I replaced it with port bits and I was able to build successfully by nothing got printed on display.
@Microesque
@Microesque Год назад
​@@joshuvajohnvarghese2372 Hmm... I just tested the library, and it definitely works. But when I try it with a PIC16F877 I had lying around, you're right, it doesn't work. The library just manipulates the I/O, so I assumed it would work. Don't know why it doesn't. I'll have to look into it...
@joshuvajohnvarghese2372
@joshuvajohnvarghese2372 Год назад
@@Microesque thank you would be soo great if you could fix it
@Microesque
@Microesque Год назад
​@@joshuvajohnvarghese2372 I seem to have found the issue. These old PIC16 devices seem to have their RA4 pins turn into open-drain when configured as output. If you have any pins connected there, add a pull-up resistor or use a different pin. If you're using any pin that has analog capability, configure them as digital using the "PCFG" bits in the "ADCON1" register. The datasheet clearly shows (page 23) that configuring pins as analog or digital shouldn't have any effect on pins configured as output; however, if I don't configure them as digital (for PIC18F877), they don't work as outputs... I don't know why. Maybe I'm missing something... The architecture for your microcontroller and my PIC16F877 should be the same, so make sure to configure the pins you're using as digital using the "PCFG" bits. If that also doesn't work, I don't know what to do, as I don't have the microcontroller you're using. I did get the library to work on PIC18F877 I had on hand using the methods above. Make sure your connections and definitions are correct, and the cables are making proper connection.
@shalukaindunil5567
@shalukaindunil5567 Год назад
Can not commented
Далее
Китайка и Зеленый Слайм😂😆
00:20
Decompress small game, have time to play it!
00:35
How to interface an LCD with PIC18 Microcontroller
18:50
Explaining RISC-V: An x86 & ARM Alternative
14:24
Просмотров 452 тыс.
Китайка и Зеленый Слайм😂😆
00:20