Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Nothing on the last column of the display

Status
Not open for further replies.

Mimuwhen

Junior Member level 3
Junior Member level 3
Joined
Oct 7, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
284
Hi everyone;

I was finally able to get mplab to compile this code and I've been playing around with it. It's a bar graph that displays audio on an LCD after displaying a brief intro text. This is my first project that isn't just a blinking LED or a "Hello world" type of deal so forgive any silly questions.

The problem I'm having is that for some reason I can't get anything to show on the 16th column of the screen, this is on both top and bottom rows. This happens in both the simulator and in the physical build and in both the intro text part of the code as well as the bargraph part of the code. I modified the intro text to fill the entire screen with the letter O and sure enough there's nothing on the 16th column. You'll notice this uses a costum library for the 4 bit display which kinda makes it trickier, I haven't been able to get a hold of the author so I was hoping you guys might be able to help me.

My second problem goes as follows, I plan on displaying a menu on screen in place of the intro text of this code and for this I'll need to display the value of a variable. The costum library of this code doesn't allow me to do that it seems, either that or I just cant figure out how. Can someone tell me if it's possible to use this library to print the value of a variable on screen? The plan is to toggle between the menu and the bar graph with a button, this part I've already accomplished. The menu will show a counter where the number corresponds to a sound effect on a sound chip. The MCU will not be controlling the sound chip, it will just keep track of the number of times the sound chips up and down buttons are pressed to show the corresponding number on screen.

Follow this link and the first post has the code in it's original form attached. I'd upload it here but I'm having issues with the uploader.

https://www.edaboard.com/threads/327751/

schematic

**broken link removed**

Your help is much appreciated!
 
Last edited:

Your circuit is fine. I will check the code and update.


I think this is causing the problem. I guess it should loop from i = 0 to i < 16. The lcdbuf1[0] and lcdbuf2[0] doesn't contain anything and hence 1st coloum of LCD will be always blank but the 16th column will be filled.


If you have Proteus file then Zip and post it here.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
goto_lcd(0x00);             //LCD Top row
        for(i=1;i<16;i++)
        {
        if (lcd_buf1old[i]<lcd_buf1[i]) lcd_buf1[i]--;
        if (lcd_buf1old[i]>=lcd_buf1[i]) lcd_buf1old[i]=lcd_buf1[i];
        write_lcd_char(lcd_buf1[i]);
        }
 
        goto_lcd(0x40);             //LCD Bottom row
        for(i=1;i<16;i++)
        {
        
        if (lcd_buf2old[i]<lcd_buf2[i]) lcd_buf2[i]--;
        if (lcd_buf2old[i]>=lcd_buf2[i]) lcd_buf2old[i]=lcd_buf2[i];
        write_lcd_char(lcd_buf2[i]);
        }

 
Last edited:
Hmmm, I re-downloaded the original file that the author sent me and tried again. For some reason now it works perfectly. I modified the intro text with all 0s again and they're all there this time. I have no idea why. For some reason it doesn't show the bar graph in my simulator even with the unmodified code and since I broke my display I will have to wait til I get a new one to see if the bar graph is actually working properly. Again though, before it wouldn't display anything on the last column and now it does. Really weird.

I have encased what used to be the old intro text into an if statement and the while(1) loop immediately following it, which makes up the bargraph, is now an else. I am using RB7 as an input and it toggles between if and else. This is so that when I push the button the screen goes from the menu to the bar graph. I figured out how to display variables and I've set up "soundno" as the variable representing the sound number to be played.

The additions/changes look something like this, obviously trimmed down for simplicity.


Code:
void main(){

unsigned int soundno=0;

if(RB7=1){
write_lcd_string("SOUND:");
goto_lcd(0x06);
write_lcd_number(soundno,10,2,0);
}

else {

               //bargraph code

}              //end of bargraph code

}              //end of main

When I do this in the simulator the screen does indeed change depending on the state of RB7 but as I said earlier, even with the original unmodified code the simulator doesn't show the bargraph so whether or not this actually displays the bargraph when RB7 goes low will be seen once I get my new display.

For now I am trying to figure out how to increment variable soundno using RB6. I tried using an if statement within the first if statement but I guess that's a dumb idea,

Code:
If(RB7=1){
if(RB6=0)                             //lame attempt at incrementing soundno when RB6 goes low
{++soundno;
__delay_ms(30);}                 //lame attempt at debouncing
write_lcd_string("SOUND:");
goto_lcd(0x06);
write_lcd_number(soundno,10,2,0);
}

When I power the circuit soundno is already displayed as 1 even though the initial value is 0 and when I press the button to make RB6 go low it makes soundno go to 0 and once I release the button it makes it go back to 1.

On the display it looks like this

Power on the circuit
SOUND:1
Press button
SOUND:0
Release button
SOUND:1

I'm obviously doing something hilariously wrong, I could use your advice.

Thanks.
 
Last edited:

Zip and post both versions of the project, the one which doesn't display on 18th column and the one which you got from the author.

The attached file displays the spectrum but 1st and 16th column remains blank.
 

Attachments

  • 16F877a DFT rev1.rar
    212.1 KB · Views: 108
Last edited:

Alright,

So I got my simulator to display the graph. The issue was that the sine wave generator feeding it wasn't wired correctly. With this I can now fully test using only the simulator.

Indeed one of the columns of the graph is still missing although the intro text/Menu works just fine. This happens in both the code directly from the author and the one I modified.

This file contains both the original code I got from the author and the one I modified where it can be toggled between the main screen and the graph.

**broken link removed**

The only change I made to the original code included here is that I replaced all the intro text with 0s to fill the entire screen, here you can see all the columns work. It's only the bargraph that is missing a column. Again, this bug is present even in the original by the author.

For some reason I can't open the file that you attached in your last post, it makes MPLAB crash. I assume that's just another copy of the original. Are you sure it's missing both the 1st and 16th line when you try it? For me it's only missing the 16th line.
 

Here you go. The first image shows the intro text which has been replaced with 0s filling the entire screen to make it more noticeable that all columns are working. Other than that change, the code is completley original.

The second image shows that the graph is missing the 16th column.

24b673b.png

8yaqv8.jpg
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top