In your receiver code, how are you determining the entire data string has been sent?
In your receiver code, how are you determining the entire data string has been sent?
Dave Purola,
N8NTA
EN82fn
That's what I don't know.
If I try this on transmitter side:
and on receiver side:Code:main: adcin 7, adval pause 20 hserout [hex adval,13,10] pause 20 goto main
It works, but the result on LCD is unstable, the value sometimes jumping between 0 -255 randomly.Code:main: lcdout $fe,1 hserin 500, main, [hex datain] pause 20 lcdout $fe,$80, dec datain pause 20 goto main
I think this is not the right way how to send and receive serial data via BT .
Can I use hserout [dec adval,13,10] on transmitter side?
What about on receiver side hserin 500, main, [hex datain] not work,
maybe hserin 500, main, [str datain\3] ?
I don't know how to read the sended decimal value in to the datain variable. On receiver side right on output from HC-05 I have correct serial decimal value 0 - 255, verified by serial monitor on PC.
Sending data via an HC bluetooth module is no different to sending it via normal serial, just that there is no physical cable between the two devices (such as a PC and the PIC).
You could try using an FTDI usb to serial module and get the code working via hardwired setup and then use the HC module which should function exactly the same, if it doesn't then this would suggest that there may be a fault with the hardware.
I use these in a couple of my projects to send decimal values from word variables to an application running on a PC
Code:HSEROUT [dec4 CH1_MAX] HSEROUT [dec4 CH2_MAX] etc then HSERIN 1000, RX_Bombed, [dec4 CH1_MAX] to read it back
The RX Bombed is a time out
I then have this bit of code at the start of my comms subroutinesCode:RX_Bombed: TimeoutCount = TimeOutCount + 1 end select Goto main
In the main program loop I have this to check the buffer and jump to the comms subroutineCode:coms: HSERIN [nTest] SELECT CASE nTest CASE "Q" ; if Q then send data to PC Goto Term_TX CASE "S" ; if S then receive data from PC goto Term_RX return
Hope this helpsCode:FOR TempWD = 0 TO 500 IF RCIF=1 THEN GOSUB coms ; Check to see if PC application connected PAUSE 1 next TempWD
Sorry for got to add
Code:RCIF VAR PIR1.5 ' USART receive flag
Last edited by Scampy; - 1st February 2017 at 19:25.
Thank You for answer, maybe I found the problem. If I comment the "lcdout $fe,$80, dec datain" and "lcdout $fe,1" lines in my code the value in datain var come correct an stable.
Then I put the datain value to other variable like:
And it works how I wish, luckily :-)Code:main: hserin 500, main, [dec3 datain] pause 10 let lcd_out = datain lcdout $fe,$80, dec3 lcd_out pause 20 goto main
Bookmarks