Wireless problem


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    There are a couple of things I can think of.

    Try increasing the preamble bytes $55. So, you send $55,$55,$55,$55,$55,$66,[data]
    Try flagging the capture of qualifier in receive module to the LCD. So, you know if it is being captured correctly.
    Perhaps the most important to me. Try keeping the transmitter on continuously till you get the receive part working correctly. Maybe the switching on/off of the transmitter is causing the receiver to go crazy.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    all good point, but this doesn't explain why the PC comm always works.

    EDIT: have to be a paste error, but DEFINE OSC have to be in capital letter, unless... well i guess nothing would even works anyways...
    Last edited by mister_e; - 17th December 2007 at 19:21.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jerson View Post
    There are a couple of things I can think of.

    Try increasing the preamble bytes $55. So, you send $55,$55,$55,$55,$55,$66,[data]
    Try flagging the capture of qualifier in receive module to the LCD. So, you know if it is being captured correctly.
    2 more preamble bytes!!!! Now I send $55,$55,$55,$55,$66,data and the amount of correct data received(and displayed on lcd) is more than 90%

    I've also made a few changes: there is now a 5msec pause after the txer is switched on. 2400bps now works fine.

    On the monitoring side I chenaged the hardware/software tools used. At first I tried a software called serial port monitor and the hardware was a max232 ttl<->rs232 transceiver.

    Now I use a 2 resistor based rs232 adapter and the serial communicator software built into MicroCode Studio.
    What I found is that now I can see the noise!!! There is a lot of junk along with correct data. Maybe the other software/hardware configuration were filtering that noise so I could only see correct data...

    So I thought that adding more preamble could be an initial solution... it worked!
    I will try the reliability of the communcation at longer distance to see if I need to add manchester routines...

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default

    That test results clearly show that the turn-on delay is absolutely necessary. Why not give your Txer more time to wake-up?? Say 100ms and test how it goes. Then you can decrease this wake-up time gradually.

    Also if you send a long stream of preamps and only 1 or 2 data bytes, that is OK. No manchester is really necessary. But more than this... don't think whether to or not to. Just add it.

    More, I would suggest for 100% reliable communication to add checksum or even better a CRC check.

    Almost every receiver will output noise that could lead to false data reception when no transmission takes place. There is no mute function available on these cheap devices.

    Ioannis

  5. #5
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Now that I solved(or going to solve...) reliability problems, I find that serin/serout work fine while hserin/hserout seem to have more problem...

    Usart has been configured used pic multicalc.

    I noticed that Mister_E adds the comment "Enable serial port & continuous receive" setting rcsta receiver.
    Does it mean that hserin does not have to be in a loop? maybe something like:
    Code:
    hserin [#txpin]
    
    main:
      lcdout $fe,row1,dec txpin
    goto main
    could work?

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default

    If you use the example you post, then you will display only the first byte and continue to display that exact byte endlessly.

    If you send serial data then the buffer of the 2-byte long USART will overflow and depending on the setup will stop with error flag raised or replace old bytes with the new ones.

    Please refer to your Data sheet of the PIC you are using for more infos about the USART and its associated flags and control bits.

    If serin/serout work then I am sure that USART will work better and without having PIC to deal with the data untill they are available to process. You must have something wrong with your setup.

    As Steve stated without the whole picture we can only guess.

    Here in Greece we had the ancient times the oracle at Delphi and Pythia making guesses and prophecies but nowadays I suppose it is better to see, measure calculate and then conclude. So if you want real help post all you got (schematics, cablings, software, defines etc).

    Ioannis

  7. #7
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    If you use the example you post, then you will display only the first byte and continue to display that exact byte endlessly.
    As the define comment says "continous receive" I guessed it could've be continuos receive in background while pic runs the program, as hpwm.

    Quote Originally Posted by Ioannis View Post
    If you send serial data then the buffer of the 2-byte long USART will overflow and depending on the setup will stop with error flag raised or replace old bytes with the new ones.
    I included DEFINE CLROERR 1 to clear overflow automatically.
    And surely I still have to study a lot....

  8. #8
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Finally!

    At last I've been able to use USART!
    On the tx side I changed serout from N2400 to T2400 and the rx started to display correct data! Data is sent 10ms after powering the txer.

    99% of data is correctly showed on the display.

    Now I have to mount the sensor and send acquired data along with a sort of checksum.

    I could stay hours watching the display:0...1...2...3...4..... to see if some of my numbers gets lost. Watching it for a minute, no problems!
    So here is the working code for the TX:
    Code:
    INCLUDE "modedefs.bas"
    
    ANSEL=0
    CMCON0=%00000111
    
    define osc 4
    txpin   var gpio.4
    led     var gpio.5
    power   var gpio.2
    i       var byte
    
    low power
    
    loop:
        for i=0 to 9
          high power
          pause 10
          serout txpin,t2400,[$55,$55,$55,$55,$66,#i]
          low power
          high led
          pause 30
          low led
          pause 1000
        next i
    goto loop
    And, of course RX:
    Code:
    define  OSC 20
    Define 	LCD_LINES	4			' Settings for a 4x20 LCD
    Define	LCD_DREG	PORTB		'   4bit mode
    Define	LCD_DBIT	4			'
    Define	LCD_RSREG	PORTB		
    Define	LCD_RSBIT	3		 	
    Define	LCD_EREG	PORTB'      
    Define	LCD_EBIT	2
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFine HSER_BAUD 2400
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    'LCD Lines constants
    row4        con	$d4
    row3	    con	$94
    row2	    con	$c0
    row1	    con $80
    hser var byte
    
    intcon=0
    
    pause 500
    lcdout $fe,1
    lcdout $fe, row1, "** RX TEST **"
    
    loop:
          hserin [wait($66),hser]
          hserout [#hser]
          lcdout $fe, row3," hser: ",dec1 hser
    goto loop
    Last edited by supersonic; - 19th December 2007 at 12:29.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem with ASM IRQ using FSR0 on PIC18F252
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th March 2008, 20:48
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. CM02 and RF04 wireless modules problem
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th December 2006, 10:32
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts