hi
i need to send two bytes(Address and the instructions) from the serial port when i click a command button in VB6 interface.how can i do that? lets say i have a text box to give the address. when i click the command button first the value in the text box should go through the serial port and after few seconds the instruction byte should be transmitted. anyone please help me
after sending these two bytes should be stored in two variables in the microcontroller. here is my code for microcontroller
do {
if (Usart_Data_Ready())
{
k=Usart_read();
i = Usart_Read();
portd=i;
porta=k;
}
} while (1);
but this is not working properly. every time i send this the pic read them but not as intended.the variables are showing 160 and 170 changingly. its like a synchronization error. can anyone help me please
You are probably missing bytes when you are processing the previous pair. Try adding a sync byte at the start (or end) of your message. If you send 13, 160, 170 then your pic can wait until it receives a 13 before getting the two variables. If you still have problems then reduce your baud rate or use an interrupt driven fifo.
I'm only guessing how the library functions work but I think this should work.
Code:
char GetByte(){
while(!Usart_Data_Ready());
return(Usart_Read());
}
do {
while (GetByte!=255);
k=GetByte();
i = GetByte();
portd=i;
porta=k;
}
} while (1);
this code is not taking the incoming 4 bytes from the serial port to variable j. instead it only takes the first incoming byte to the variable j. is there anyway of getting incoming 4 bytes to a long variable in microc?
please help me
hi
i need to edit MS access data from VB6. Lets say i have a table in access name 'table1'.and it has some data. i need to enter more data to the table from VB. there is a text box in vb to add data called name.txt.i m using ADODC can anyone please help me. if u can please send me a sample code.
hi
i have a program to get a byte from a microcontroller to a VB6 interface. i need to store them in the MS access table.i linked VB and access using ADODC.through that i can read data in the table from VB. Say i have the table1 in access. i need to store the incoming byte in the "address" field of the table.please anyone help me.if you can send me a sample code
hi
i need to send 5 bytes through serial port when i click the command button in VB 6 and assign those bytes to a microcontroller.
but i can send only the first two bytes when click the button. the other 3 bytes are not sending.. is there any sending buffer to increase the size? following is my code
PLS ANYONE CAN HELP ME. if my code is wrong pls send me a correct code
Private Sub cmdtx_Click()
MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(123)
MSComm1.Output = Chr$(233)
MSComm1.Output = Chr$(234)
MSComm1.Output = Chr$(134)
End Sub
The size of the output buffer doesn't matter as it is the micro controller that is crashing. You either have to fix the micro controller code or use a (VB) timer to send 1 character every 10mS or so.
if (Usart_Data_Ready()) {
one = USART_Read();
}
if (Usart_Data_Ready()) {
two = USART_Read();
}
if (Usart_Data_Ready()) {
three = USART_Read();
}
if (Usart_Data_Ready()) {
four = USART_Read();
}
}while (1);
anything wrong? im using 16f877a. how can i alter input buffer size of the micro contraller?
Dim OutString As String
Private Sub Form_Load()
MSComm1.PortOpen = True
Timer1.Interval = 10
OutString = "Hello World"
End Sub
Private Sub Timer1_Timer()
If Len(OutString) > 0 Then
MSComm1.output = Left(OutString, 1)
OutString = Mid(OutString, 2)
End If
End Sub
Actually, that receive code is completely wrong. You need to wait for a byte to be ready. Something like the code I posted on the previous page.
Mike.
Edit, you could try something like,
Code:
do {
one=0;
while(one!=255){ //wait for start of packet
while(!Usart_Data_Ready()); //wait for byte to be received
one = USART_Read(); //read it
}
while(!Usart_Data_Ready());
one = USART_Read(); //should contain 123
while(!Usart_Data_Ready());
two = USART_Read();
while(!Usart_Data_Ready());
three = USART_Read();
while(!Usart_Data_Ready());
four = USART_Read();
}while (1);
receiver reads the first two byts successfully. problem is with the third byte and the know how to change the input buffer of the microcontroller?
thanx