Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Serial Port


Serial Port

Author
Message
Keithuk
Keithuk
Forum God
Forum God (298K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K
mvPradeepemb (11/24/2008)
Option Explicit

Private Sub Command1_Click()
  
End Sub

I maybe jumping the gun but.

A tip, you really shouldn't use the default names for controls, apart from a quick try of something. If the command button does something specific please use a specific prefix to that control name. This makes the code easier to follow.

cmdOpen_Click(), txtUser.Text, lblValue.Caption etc

All these control prefixes can be found in the VB6 Help. If you don't have MSDN help then you must be using an illegal copy of VB6 from a friend. Ask you friend if he has the MSDN help disks, perhaps his is illegal. No you can't download it for free. I'll post a copy of the prefixes if you're stuck.

Its nice to see your using Option Explicit though. Wink

Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Yes Keith, that's good advice. The only reason that I use default names is so my code can be copied & pasted by the recipient without having to edit the control names in the properties window. Wink

Now as far as his problem is concerned I'm going to have to dwell on it as I don't have an answer at the moment.

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
mvPradeepemb (11/24/2008)

   Loopback test works perfect as i click the command button. But when i interfaced with controller i receive the data as 0 56 0 56 0 56 where my transmitted value is 5 

OK, somewhere in this thread I think I posted a link to MS Portmon.exe. Find it, run it and see what it receives. Portmon is a powerful tool for MSComm debugging.

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

Wilksey
Wilksey
Forum God
Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)

Group: Forum Members
Posts: 14, Visits: 18
Could you post your uC code please?



Sounds like the port in the uC isn't set up correctly.



Have you set the MAX232 chip up correctly?



Cheers

~Wilksey~
CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
FYI, Zero (0) is CharCode "Null" and Six (6) is CharCode "Acknowledge". Since I know nothing of your Microcontroller only you would know if these characters are part of that chips protocol.

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

Keithuk
Keithuk
Forum God
Forum God (298K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K
Bye gum this topics going on a bit. 55 posts and 6 pages later and its still going that must be a forum record.  BigGrin  w00t  Wink

Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Wilksey
Wilksey
Forum God
Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)

Group: Forum Members
Posts: 14, Visits: 18
56 is the code for "8".



0 is the code for Null as CDRIVE said.



Please provide as well as the uC code a simple drawing of the circuit you have used to interface the uC to the Max232 IC.



I have had a similar problem with biasing resistors.



Regards.

~Wilksey~
CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Keithuk (11/24/2008)
Bye gum this topics going on a bit. 55 posts and 6 pages later and its still going that must be a forum record.  BigGrin  w00t  Wink

Keith, I was going to ask you if this post was breaking any records! BigGrin If I had his chip in front of me this would have been over way, way back!!w00t

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
Wilksey, here is my uc code,

#include <avr/io.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
void init(void);
void usart_init(void);
void usart_transmit(unsigned int data);
unsigned int usart_receiver(void);

int main(void)  
{
init();
SREG |= _BV(SREG_I);
usart_init();
while(1)
{
usart_transmit(0x03);

}

}

void init(void)
{
DDRA &=~_BV(PINA6);
PORTA |=_BV(PINA6);

DDRB=0xFF;
PORTB=0xFF;
}

void usart_init()
{
//UCSRA=(1<<U2X);

UBRRL=BAUD_PRESCALE;
UBRRH=(BAUD_PRESCALE>>8);
UCSRB=(1<<RXEN)|(1<<TXEN);
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
}

void usart_transmit(unsigned int data)
{
while(!(UCSRA & (1<<UDRE)));
UDR=data;
}


unsigned int usart_receiver(void)
{
while(!(UCSRA &(1<<RXC)));
rec=UDR;
return rec;
}

void USART_Flush( void )
{
unsigned char dummy;
while ( UCSRA & (1<<RXC) ) dummy = UDR;
}


mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
Circuit Diagram:


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search