Solved: lcd

Go To Last Post
30 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello friends.i write a code to display time and date to LCD and change it with keypad.i am using of atmega32(code vision software) and LCD(16*2).i write my code but when test my code in protous,anyone of  variable appear in LCD.

i know i having problem with {lcd_putsf() and lcd_puts() and lcd_putchar()}

but i dont know how to solve this problem. i even used of itoa(for exapmle itoa(m , buffer_m)for all of needs variable...but with this act lcd show anythhig.

can i can my problem?

i must use what kind variable?or must i use any library?(i use lcd.h)

that is  summary of my code:

 

unsigned char table;
int r,ac;
unsigned int y,M,d,h,minute,s;
void lcd_disp() {

lcd_putchar(h);

lcd_putchar(':');

lcd_putchar(minute);

lcd_putchar(':');

lcd_putchar(s);

lcd_putchar(y);

lcd_putchar('/');

lcd_putchar(M);

lcd_putchar('/');

lcd_putchar(d);
}

 

>

my problem is with variable kind.

lcd_puts can display just special variable...

lcd_putsf can display special variable..

putchar can display special variable...

i cant choose suitable variable

thank of all that partake in discussion

 

Attachment(s): 

This topic has a solution.
Last Edited: Tue. Feb 6, 2018 - 11:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You didn't follow the instructions for posting source code given in your recent thread, then?

 

See: http://www.avrfreaks.net/comment...

 

And, again, what debugging have you done to find the problem(s)?

 

You're using Proteus, so you can step through your code and watch what's happening...

 

 

EDIT

 

SO you edited the OP to apply the code format - but did nothing about the indentation.

 

frown

Last Edited: Thu. Feb 1, 2018 - 02:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In your previous keypad thread awneil already suggested how to use the code tags to post code:

http://www.avrfreaks.net/forum/k...

 

Also:

Make a smaller example with 10 or less lines of code.

Show us you put some effort into helping yourself.

What happens if you just write a single character or a string to your display?

Start with that, and only if that works expand further.

Take baby steps.

 

Is this on a "Real" avr or are you only simulating?

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For starters your circuit is missing ground connection on the AVR.

 

What are you using for a clock source?  Internal RC or external crystal which is missing?

 

Second, Your code.....looks awful....ly hard to understand.

 

Jim

 

Sub-thought - I predict 50+ posts on this one devil

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
Second, Your code.....looks awful....ly hard to understand. Sub-thought - I predict 50+ posts on this one devil
After my post #3 he slapped on a code tag without any identation or shortening the code. I do not feel inclined to help him any further.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i donot know about debuging in protous

but i know my variable kind have problem.

unsigned int y,M,d,h,minute,s;

 

void lcd_disp() {

lcd_putchar(h);

lcd_putchar(':');

lcd_putchar(minute);

lcd_putchar(':');

lcd_putchar(s);

lcd_putchar(y);

lcd_putchar('/');

lcd_putchar(M);

lcd_putchar('/');

lcd_putchar(d);
}

i know if i change kind of variable LCD can show that.but i dont find what is suitable variable..

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it is just simulate

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
In your previous keypad thread awneil already suggested how to use the code tags to post code:

http://www.avrfreaks.net/forum/k...

And clawson explained about the lack of indentation: http://www.avrfreaks.net/comment...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i use internal clock (if my code work i add crystal)

i summary my code

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hadisamani1996 wrote:
i donot know about debuging in protous

So make an effort to learn it, then!

 

What is the point of paying $$$ for a tool like proteus, and then not using its key features?!

 

 

i know if i change kind of variable LCD can show that.but i dont find what is suitable variable..

What does the documentation for the lcd_putchar() function tell you?

 

Hint: the clue is in the name - putchar

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

when you want show character use of this.i realize it

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

certainly read thatsheart

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
What is the point of paying $$$ for a tool like proteus, and then not using its key features?!
I've read this comment in other posts also. It seems a bit naive to think he paid for proteus. It's more likely he "found" it somewhere on the "web" or he's using it at school.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Sun. Feb 4, 2018 - 12:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
After my post #3 he slapped on a code tag without any identation or shortening the code. I do not feel inclined to help him any further.

I edited the OP by posting the code using CODE TAGS, but it appears that the OP has removed all of the code in the OP so I understand you lack of desire to assist any further.

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wrote:

hadisamani1996 wrote:
i donot know about debuging in protous

So make an effort to learn it, then!

You could start here: https://www.labcenter.com/simulation/#debug

 

https://www.labcenter.com/compilers/

 

https://www.labcenter.com/downloads/Tutorials.pdf

 

https://support.labcenter.com/forums/index.php

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

char is 8 bits wide; int is 16 bits wide on avrs;

using putchar with int-s- is likely to be ugly or -incl- weird...

One should first convert them into strings, then display each and every character of the string.... or use a funcrion that displays strings

 

Maybe these utterly basic things are documented? in a course? in wikipedia?in codevison/proteus help?

 

Edited : found again http://www.avrfreaks.net/forum/findpost-your-online-c-books-tools-here

Does codevison typecheck C lines? (seems expensive : they should, IMO)

Last Edited: Thu. Feb 1, 2018 - 03:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please note, putchar just puts a single ASCII character (e.g. 'h' or 'e' or 'l' or 'l' or 'o') on the display.

It does not print strings of characters (e.g. "hello") or numbers (e.g. 1234). It can print the ASCII character for a number (e.g. '1' or '2' or '3' or '4') one at a time.

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the code below you are using putchar in the wrong way.

"putchar" needs an character. not an integer.

A "character" is the ascii number of the representation of numbers, alphabet etc.

https://en.wikipedia.org/wiki/ASCII

void lcd_disp() {
  lcd_putchar(h);       // Does not work as intended.
  lcd_putchar(':');     // This works. Use the single qoutes.
  lcd_putchar(minute);  // Does not work.
  lcd_putchar(':');     // Works.
  lcd_putchar('0' + s); // '0' is ascii for the number zero. and your s var is added.
}

The last putchar with ( '0' + s) should work for single digit numbers.

putchar ( 69 ); // Prints Capital E. 
putchar ( 'E');     // 'E' (single quotes) is the C notation for ascii characters.

You can do the same with the hours, etc.

I'll leave it as a practice up to you how to figure out to print both the "tens" and the "units".

 

@Jim #14 :) He was apparently halfway an edit... He seems to be trying...  Probably also struggling with english...

 

 

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Thu. Feb 1, 2018 - 03:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

very software are free in iran(sorry,iran is embargo country)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

hadisamani1996 wrote: i donot know about debuging in protous

So make an effort to learn it, then!   What is the point of paying $$$ for a tool like proteus, and then not using its key features?!

 

Paulvdh wrote:
I've read this comment in other posts also. It seems a bit naive to think hy paid for proteus. It's more likely he "found" it somewhere on the "web" or he's using it at school.

 

hadisamani1996 wrote:
very software are free in iran

 

Proteus is NOT free LEGALLY in any country!

 

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

Last Edited: Fri. Feb 2, 2018 - 12:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is no need to debug basic c notions;

There is no embargo on (on line ) knowledge (at least 3 people gave hints on how to solve major issues)

 

OTOH:

(embargo - linked ?) domestic difficulies can lead to very old and uncomfortable screens ( new ones can be expensive). Keybeards and mice maybe affected, too.

I bet paper courses (if OP is a student) or brains  do not suffer from embargo.

 

It is difficult to google translate farsi into omericon  or French. Azeri (has enough consonants) is spoken in parts of Iran, and google translates it -along with its consonant deprived variant-  wonderfully (papers without typos) . But I do not know whether bilingual Iranians can spell Azeri....

 

IMO, it is unwise to add a political co notation when one needs some help....

When one does not need help, it is funny (though I often avoid mixing political and technical issues).

Last Edited: Fri. Feb 2, 2018 - 01:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
Proteus is NOT free LEGALLY in any country!
Neither is the CodeVision apparently being used with it.

 

I do hope this thread is not about supporting software piracy!

 

If you want to do "free" AVR development then both AS7 and the avr-gcc it comes with are "free" so there's no real excuse for using pirated tools if that's what is going on here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
there's no real excuse for using pirated tools if that's what is going on here.

I am/was giving the OP the opportunity to explain themselves a little better before locking the thread, but yes I see your point clearly.

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello friends.

i try to repair my code .
i had several problem bout i can solve that.
1)
i must use of int to my for loop.(for example:int h1====>for(h1=0 ; h<20 ; h++)
when i pressed keypad...
and table(in variable that save key pressed code ascii)
i coped table to h1.
now i must displayed h1 to LCD.
if i use of lcd_putchar function....
this function can display one number(number 1 ,2,,,8,)and when h1 grow up of 9...this function show mistake character(according code ascii)
so i cant use of lcd_putchar...
i decide use of lcd_puts
but this function only work with string char..

i must change int h1 to string...
so i use of itoa(int , str) for this convert
and now i can see ideal output in lcd.
thank of all friends

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank of your advance,that help me to find my mistake.thank youheart

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank and thank youyes

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

char can cinvert to int...
my problem was whit string and lcd...
i solve it.
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

* Denis, the moderators have received complaints about this post so its content has been deleted. Please be less offensive. Thanks. *

 

 

 

 

 

Last Edited: Tue. Feb 6, 2018 - 11:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Would everyone please stop making the implication that anyone using Proteus must have stolen it because it is expensive? My understanding is that it is used a LOT in academia where I'm sure the colleges will have some legal agreement with Labcenter. Also folks think nothing of spending $300+ on a scope, why shouldn't some engineers choose to invest the same in a software tool?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, software engineers in Iran get  ca 20,000 US$ a year -is very comfortable w/r average wages-, 3x times less than in London, say: having a simulator is not that useful.

Either OP is a student (has free legal Porteus; but there are Iranian specificities),

an engineer (I doubt his boss will invest, as wages are low enough; but Iranian engineers often write English) or

a hobbyist (but average wages are very low, leading to -likely- PC behaving lousely on the web, and Proteus seen as very expensive overkill)...

Last Edited: Tue. Feb 6, 2018 - 11:01 AM
Topic locked