View previous topic :: View next topic |
Author |
Message |
m7md007
Joined: 23 Sep 2011 Posts: 10
|
serial communication and lcd problem |
Posted: Mon Oct 10, 2011 9:44 am |
|
|
dears,
i am currently on a project that have a variable such that let us assume that the variable
conv=0b01011101
1- i want display the value of conv on the lcd
(so that to be in the lcd 01011101 )
i tried to write
lcd_putc(conv);
but it didn't work
how can i do that
2- my second problem that i want to send the value of variable conv serially to another pic
(so that to transmit the bits 01011101 serially to the other pic )
can any one help me
can any show me a simple ex how to do that?
good luck |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon Oct 10, 2011 1:55 pm |
|
|
while I'm waiting for the bird to be burned....
1) if you want to display the data in BINARY, search this forum, as someone wrote a small progrm to do that....
2) to send it to say another PIC or PC, either look at the examples int he examples folder or read the FAQ section of the onscreen help file( press F11 when project is open).
You should have what you need in less than 1/2 hours of reading....
... time to uncover the bird. |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Tue Oct 11, 2011 9:53 am |
|
|
Dear temtronic i really appreciate your sarcasm.
But i am new to ccs c for pic.
If you can be more specific in your answer and show me how do it in a real beginner level and show me the steps
i will be grateful.
Thank you in advance. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Oct 11, 2011 10:22 am |
|
|
You need to write a loop that rolls through the bits of the variable testing each bit and then sending the proper char.
You can use if() { } else {}
you can use the CCS bit_test() function
you can use ()? : ;
What you want is pretty easy... but like all the others might say, it would not be in your best interest for me to write the code for you as you wouldn't learn yourself for it.
We're happy to guide though.
-Ben
p.s. you don't need to PM us to help, I was already looking at this thread. Cheers. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Tue Oct 11, 2011 10:29 am |
|
|
first of all
thank very much for your reply
your advise was on my mind but i thought that there is a dirct way to show the binary bits for the variable on the lcd
second what about sending the bits serially to another pic
good luck |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Oct 11, 2011 11:17 am |
|
|
m7md007 wrote: |
your advise was on my mind but i thought that there is a dirct way to show the binary bits for the variable on the lcd
|
Not by default. I do not believe there is a printf parm that "prints binary" at all. Need to make one.. But it's so easy, that might be why it doesn't exist for CCS PIC-C.
Quote: |
second what about sending the bits serially to another pic
|
Via SPI/I2C/RS232? Is this a separate need for the same project? Is the other PIC the same? Which PIC are you using? You haven't given us enough info.
RS232 is the easy/quick way unless you need more speed. just use putc/fputc to transmit your char to another host -- be mindful of the need for RS232 level conversion hardware (like a MAX232 or MAX221). If you're connecting to another PIC, not needed unless far away -- then it's a good idea. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Tue Oct 11, 2011 11:36 am |
|
|
thank u for your reply
i will try to write the code for print the binary printing in the lcd
i am programming a pic 16f877a in ccs pcwhd 4.057
for my project i take an input from the keypad and depending on the input i make simple calculation and the result saved in a 8 bit variable called conv
then i want to send the 8 bit variable serially to another pic that display conv in the lcd in the binary form
that is the brief summery of my project |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Oct 11, 2011 11:46 am |
|
|
Why are you using 2 pics?
Doesn't an 877 have enough pins to do the LCD and the other stuff?
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Tue Oct 11, 2011 11:57 am |
|
|
the two pic's are connected to each other through an rf wireless module so this module take the data serially from one pic and trasmit it wireless and the rx module receive the data and gave it serially to the second pic
for that to happen i must first let the pic communicate with each other serially and then i will instal the rf module
in a brief word the two pic far from each other |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Oct 11, 2011 12:12 pm |
|
|
then for your cabled version, consider using MAX221 (or equivalent) RS232 level translators over your long cable...
and then remove them when going wireless.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Tue Oct 11, 2011 12:17 pm |
|
|
Can you be more detailed?
I am still a beginner.
note: please be patient with me. |
|
|
m7md007
Joined: 23 Sep 2011 Posts: 10
|
|
Posted: Thu Oct 13, 2011 9:40 am |
|
|
Thank you bkaman
I solved my problem.
I did the code to display the binary.
and for the serial I defined a char called it conv_a
and then
Code: |
while (TRUE)
{
conv=conv_a;
putc (conv_a);
}
|
|
|
|
|