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.

Beginner Questions 7 Segment and LCD on Mikroc

Status
Not open for further replies.

ahonda55

Newbie level 3
Joined
May 31, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
Hello, I am new to microcontroller world..and I am learning MikroC
And I need help about some points please..
First, about 7 segment multiplexing, if I have two numbers and I need to show on double 7 segment displays, I understand how exactly multiplexing work but what I need is how to extract the numers, tens and ones and so.. what is the theory, please explain it to me with a simple example if you can.

Second question is about LCD, what is the very first needs to make a very simple program to show something on a very standerd LCD?
What about libraries, how to add them (or run them)?? can I use PIC16f84 to work with LCD? what should I do to before I write a program. I have tried many simple codes but I always get "too many actual parameters" and I get also "main function not defined". What is wrong?



Thanks a lot and please be gentle I am still taking the first step..

Greetings
 

if u post your code here it is easy to help...please refer the following link
 

Thanks a lot dear, but for example, from ME examples...

do {
for (i = 0; i<=99; i++) { // Count from 0 to 99
digit = i % 10u;
digit1 = mask(digit); // Prepare mask for displaying ones
digit = (char)(i / 10u) % 10u;
digit10 = mask(digit); // Prepare mask for displaying tens
Delay_ms(1000);
}
} while (1);

How did he extracted the ones and tens here? what is .. "i % 10u" and what is "(char)(i / 10u) % 10u" doing??

Thanks again and greetings
 

% is the modulus operation,
10u is just number 10 but unsigned (weird, a simple 10 will suffice)
so in "i % 10u" you are calculating the modulo of dividing variable "i" by 10
example:
if variable i = 34
i % 10 will result in 4 !
if variable i is 175
i % 10 will result 5!

this is a common way to get one decimal digit from a number in a microcontroller.

in my last example:
if i is 175,
"digit = i % 10u;"
now, digit is 5;
but, how do you get the next digit 7?
easy, divide i by 10, and then apply the modulo again...
so digit = (i / 10) % 10; this time will be 7 !!

in some cases the divide operation of a number gives a result of a decimal number, not an integer number, so dividing i (175) by 10, if variable i is a float number, the result will be 17.5 and not 17 (like in an integer divide operation) this is most an issue if you didn't defined your integer number as 'int', so to make sure, some people "cast" the result, (or convert the result) this is where the (char) 'cast' comes from...

digit = (char)(i / 10) % 10; is just making sure the the i/10 is an 8-bit integer number.
and in case it's a big number, we only need one digit (7 in my example) and not the complete result (17 in my example, as the '1' is another digit)


(why char is an 8bit number??? it comes from ancient C usage and history)

if i is defined as

char i;

or

int i;

i would omit the (char) cast and the 10unsigned (just 10)
 
Thanks a lot mate, really thank you so much, it needs some thinking but I have started to make a picture :)
Thank you so much.

---------- Post added at 20:16 ---------- Previous post was at 20:05 ----------

Thanks a lot mate, really thank you so much, it needs some thinking but I have started to make a picture :)
Thank you so much.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top