Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 14, 2024, 12:23:44 00:23


Login with username, password and session length


Pages: [1]
Print
Author Topic: LED control via USART and VB6 in MikroC  (Read 10628 times)
0 Members and 1 Guest are viewing this topic.
pinoytsikboy
Junior Member
**
Offline Offline

Posts: 66

Thank You
-Given: 68
-Receive: 11


« on: November 02, 2007, 08:15:26 08:15 »

I have this program from one tutorial site which i want to modify to control LED and reset the PIC via USART and VB6. i added some modifcation to allow LED on when it receive any data from USART. The code display text to an LCD. simulated this in proteus and i used virtual serial port driver. I need help to detect command or text output from keyboard to control LED. Here is the code. any help is appreciated.

unsigned short pos, i;
char lcdtext [41];
void main (){
TRISA =0;
PORTA =0;
Usart_Init (9600);
Lcd_Init (&PORTB);
i=0;
while (1)
{
if(Usart_Data_Ready ())
{
lcdtext = Usart_Read ();

i++;
if (i==40)
{PORTA.f0 =1;
PORTA.f1 = 1;
i=0;
Lcd_Cmd (LCD_RETURN_HOME);
for (pos=0;pos<40;pos++ )
{
Lcd_Chr_CP (lcdtext[pos]);

if (pos==16) Lcd_Cmd (LCD_SECOND_ROW);
}
Usart_Write('Y');
}
}
}
}
Logged
Math
Guest
« Reply #1 on: November 04, 2007, 12:19:56 12:19 »

It could be usefull if you would say what do you think the program does..
Logged
pinoytsikboy
Junior Member
**
Offline Offline

Posts: 66

Thank You
-Given: 68
-Receive: 11


« Reply #2 on: November 05, 2007, 06:20:06 06:20 »

as mentioned, the program code simply put text in the VB6 form in the LCD display via USART. What i what to do now is to put in specific text to trigger LED using the USART. I am still new to Mikro C and not familiar on how to compare file data from USART with the text characters. Hope this help clear up things
Logged
boris
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 60
-Receive: 2


« Reply #3 on: November 25, 2007, 10:38:33 22:38 »

Please post the type of PIC you are using. Several PICs have ADCs on PORTA, so try disablind the A/D converters.

for PIC16F88
ANSEL = 0b00000000;  //set all to digital
ADCON0.ADON = 0b0;  //disable A/D
Logged
rod27cn
Junior Member
**
 Warned
Offline Offline

Posts: 51

Thank You
-Given: 43
-Receive: 36


« Reply #4 on: November 26, 2007, 04:21:34 04:21 »

can u post the schematic of the board where u want to run the program? It would be a little better to visualized what you want and how to give some advise if u have the schematic. Smiley
Logged
eYe
Newbie
*
Offline Offline

Posts: 18

Thank You
-Given: 15
-Receive: 3


« Reply #5 on: December 01, 2007, 12:23:37 00:23 »

Is it LED or LCD or MIX.?
also need to see your circuit firsbefore understanf your code..t
Logged
Math
Guest
« Reply #6 on: December 06, 2007, 02:38:56 14:38 »

Please post the type of PIC you are using. Several PICs have ADCs on PORTA, so try disablind the A/D converters.

for PIC16F88
ANSEL = 0b00000000;  //set all to digital
ADCON0.ADON = 0b0;  //disable A/D


A PIC16F88 does't have an USART on board so I think this isn't very usefull ..
Logged
pinoytsikboy
Junior Member
**
Offline Offline

Posts: 66

Thank You
-Given: 68
-Receive: 11


« Reply #7 on: December 22, 2007, 03:40:12 03:40 »

sorr for l8 reply been out for a while. i'm using 16f877a. managed to work it out but it take three tries to functions. needs to modify it to respond immediately. here is the code. trying to upload the proteus schematic, no lucK. how to upload proteus schematic here? need help on that one too, sorry.
char lcdtext [3];
unsigned char lcd [3], buf ;
unsigned char buffer[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} ;
void gets(char lcd[]);
char  *tc1 = "n1";
char *tc2 ="n2";

void main (){
TRISA =0;
PORTA =0;
Usart_Init (9600);
Lcd_Init (&PORTB);

buf=0;
while (1)
{
 if(Usart_Data_Ready ())
 {

   gets (lcd);
   buffer = atoi(lcd);

    if (buffer == tc1)  { portA.f0 = 1;  Lcd_Out(1,1,"on1"); }
   else if (buffer ==tc2){ portA.f1 = 1;  Lcd_Out(1,1,"on2");}
          portA.f0 = ~portA.f0 ;
       Usart_Write('Y');


        }
      }
    }

  void gets(unsigned char lcd[])
{

 char rx_count=0; //counter for character array(string)
 char flag=1; //loop status

 while(flag==1)
 {
  if(Usart_Data_Ready()==1)
  {
   lcd[rx_count]=Usart_Read();
   if(lcd[rx_count]==3) flag=0;
   rx_count++;
  }
 }
}
Logged
rod27cn
Junior Member
**
 Warned
Offline Offline

Posts: 51

Thank You
-Given: 43
-Receive: 36


« Reply #8 on: December 23, 2007, 04:01:56 04:01 »

you can upload it using www.rapidshare.com, then post the link.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC