problem with communication with PPC and microcontroller using serial

icefairy333

Active Member
Licensed User
Longtime User
I am working with a project that need control a microcontroller that based 51 kennel。
I use the BT-serial to transmit data between them,and now I can send data between them。
But the question is that the data receive in the microcontroller is not what I sent。What I wan to transmit is the hex byte like 0x1A,but no matter what I transmit,the microcontroller receive is 0x78,0x80 and 0Xf8,nothing else。
I had used output2 outputbyte and other way in serialEX lib 。but none of them work。
How can I transmit a hex data like 0x0c。???
THANK U ALL!!
 

icefairy333

Active Member
Licensed User
Longtime User
0x1A is just a example.
NO matter what i sent ,what the microcontroller receive is 0x78,0x80 and 0Xf8 .nothing else。



eg:
Dim Byt(1) As byte


Sub Button1_Click

Byt(0)=09 '0= first elemenet of array, 129 is the value to send

If serial.PortOpen = True Then
Serial.OutputBytes (dj(),0,1) 'Send the single Byte Array
End If

End Sub
 

mjcoon

Well-Known Member
Licensed User
If serial.PortOpen = True Then
Serial.OutputBytes (dj(),0,1) 'Send the single Byte Array
End If

1) "dj()"?

2) It would be good to have an "Else", e.g. to show a message if the port is not open

3) How about attaching the complete .sbp of a minimal program that shows the problem so we can see what serial settings you have chosen

4) What serial settings do you believe you have established in the microcontroller?

N.B. I have no experience with BT-serial, so I do not know if there are any contraints and how handshaking/flow-control might work, if at all!

Mike.
 

icefairy333

Active Member
Licensed User
Longtime User
(1).it's Byt() indeed.
(2). thanks for your advice.
(3).here's the demo code.and the ccommunication between the mobile phone and the microcontroller had been established correctly.
(4).i use the on-line debug and the IDE to monitor the microcontroller at the real time,and i added a breakpoint at the interruption when a serial data is received.and when i press the send button in the mobile phone ,the break take place as my designed.but the data i received are just like 0x78,0x80 and 0Xf8.not waht i sent.that's the question. really Helpless.
thank you all the same
 

mjcoon

Well-Known Member
Licensed User
You can't send an Array via Serial using BT or any other method.
Serial is one Byte at a time.

So why does Andrew Graham offer
Output2(bytearray As Byte()) : Sends the bytes from bytearray to the port without any encoding. The actual bytes output will be those from the array.
in his SerialEx.dll?

Perhaps you are making a (rather rarefied!) joke? Who said that the bytes all go together? The point of having a transmit speed is to clock the successive bits of the bytes; the bits go one at a "time".

icefairy333's problem still needs a solution...

Mike.
 

taximania

Well-Known Member
Licensed User
Longtime User
So why does Andrew Graham offer

in his SerialEx.dll?

Perhaps you are making a (rather rarefied!) joke? Who said that the bytes all go together? The point of having a transmit speed is to clock the successive bits of the bytes; the bits go one at a "time".

icefairy333's problem still needs a solution...

Mike.
I don't post random jokes :)
I just tried to point out serial goes 1 byte at a time, which you agreed with.
@icefairy are you sure your microcontroller is set to receive correctly.
Is this page of 'my website' any use to you ?

BlueSmirf Bluetooth RS232 from microchip Pic to Pocket PC
 

icefairy333

Active Member
Licensed User
Longtime User
taximania ,thanks for your great work .
what i want to do is some thing like you had done.
and i used a microcontroller based 51 kennel. and i purchase a BT-serial module for the connection between the phone and the microcontroller,and the matching between the phone and the module is work .
I am interesting in your PIC side,what do you receive at the serial interruption?
 

hdtvirl

Active Member
Licensed User
Longtime User
This is just a suggestion, but have you tried using your PC to send a serial byte form the serial port of your PC using Hyperterm for instance to both your Phone and your Microcontroller, this will help you where to focus your attention.


Having designed with the original 8051 from Intel I used the tried and trusted max232, Capacitor/Resistor circuit. to implement a full rs232 interface to the 8051.



Regards

BOB
 

taximania

Well-Known Member
Licensed User
Longtime User
taximania ,thanks for your great work .
I am interesting in your PIC side,what do you receive at the serial interruption?

I didn't use the pic's 'rs232 built in features'.
I just used basic rs232 pic code. That way I can control the flow of data.
Timing is the problem.
The pic must know what is being sent to it, read it, then act on it.

It's no good sending 4 bytes to a microcontroller if it hasn't got, or using a buffer. You will lose data.
I used a loop in my pic, to wait for a byte. Sent from my phone. Then react on it's content.
Ascii 'A' might mean read 3 more bytes etc
Again, all down to timing, in both the pic and the phone.

Give me a day or two. I've got more examples of transfer between my phone and graphic LCD modules. These never got posted on here or my website.
 
Top