Wireless problem


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    7

    Default Wireless problem

    Hello everybody.

    I've been looking a lot your forum which gave me a lot of help without the need of ask questions... all my problems where solved using 'Search'...

    Now I think I need some guru help to solve my little problem.

    I am trying to build a remote trasmitter wich will send SHT11 sensor data to my wireless station.

    The modules I am using are this(TX):http://elmarpeters123.googlepages.com/TM1000-1.pdf
    and this for RX (RM1SGS):http://e-madeincn.com/Product/Product-RXModule.htm

    I've found them on ebay. They are very cheap. I paid 12€ for 3 pairs of them, shipping included!

    I am writing some simple code to test them. The transmitter is a 12F683. Power pin is used to power up the transmitter via a transistor, will send data and then will be powered off for a minute to save battery.Here is the TX section:
    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
        serout txpin,n2400,[$55,$55,$66,#i]
        high led
        pause 30
        low led
        pause 1000
        low power
        pause 1000
        next i
    goto loop 
    Then there is the RX section, the pic used is a 16F876:

    Code:
    
    INCLUDE "modedefs.bas"
    
    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
    
    'LCD Lines constants
    row4        con	$d4
    row3	    con	$94
    row2	    con	$c0
    row1	    con $80
    rxpin   var portb.0
    rx_data var byte
    
    TRISC=255
    intcon=0
    
    pause 500
    lcdout $fe,1
    lcdout $fe, row1, "** RX TEST **"
    pause 300
    
    loop:
          serin rxpin,n2400,1000,loop,[$66],#rx_data
          lcdout $fe, row3,dec1 rx_data
    goto loop
    
    The TX/RX modules work fine, If I monitor the rx pin of the receiver I get exactly what I send, with no garbage at all.

    Still on the rxpin set on the pic I get the same clean data.

    Can somebody explain me why the PIC does not always print the correct data?
    The amount of correct numbers recieved is about 60%.
    I've tried with and without preambles, serin, serin2,hserin, but I always get the same results.
    I repeat, connecting the rxpin to an rs232 everyhing's perfect. It seems the pic is not fast enough the get data! It has a 20Mhz clock with proper capacitors.
    One more thing: The pic has all the sensors(18b20, SHT11, pressure, RTC) soldered around.
    I'am trying to expand the initial project, adding a receiver.
    Anyway, the code uses just the rxpin to catch data.
    Thank you for your attention
    Francesco
    Last edited by supersonic; - 17th December 2007 at 14:51.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by supersonic View Post
    all my problems where solved using 'Search'...
    You're in the minority...good for you...

    Looks to me like you're using the internal oscillator on the 12F683 (i.e. GPIO4 & GPIO 5 are used). The internal clock is probably off the nominal 4MHZ by a bit on one side of the other (i.e. might be 4.1mhz, might be 3.9mhz, whatever). Jist of the story, you're 2400 baud is based off the oscillator...if the oscillator's off, the 2400 baud is off.
    Write yourself a quicky program to generate a square wave of a known frequency, use a 'scope or freq. counter to count that square wave, and tweak the OSCTUNE to get 4mhz exactly.
    Or try slowing down to 300 baud and see what happens. Slower baud rates are generally more tolerant of being out of tolerance.

  3. #3
    Join Date
    Dec 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Looks to me like you're using the internal oscillator on the 12F683 (i.e. GPIO4 & GPIO 5 are used). The internal clock is probably off the nominal 4MHZ by a bit on one side of the other (i.e. might be 4.1mhz, might be 3.9mhz, whatever). Jist of the story, you're 2400 baud is based off the oscillator...if the oscillator's off, the 2400 baud is off.
    Yes, I am using the internal oscillator at 4Mhz.

    Write yourself a quicky program to generate a square wave of a known frequency, use a 'scope or freq. counter to count that square wave, and tweak the OSCTUNE to get 4mhz exactly.
    Or try slowing down to 300 baud and see what happens. Slower baud rates are generally more tolerant of being out of tolerance.
    Unfortunately I have no scope.... but the problem is that attaching the rxpin on a pc and monitoring with a serial port monitor, the receiver gets exactly what I send. So I guess the problem is somewhere in the PIC code, maybe some registers to be correctly configured or wrong code somewhere.
    Is 2400 8N1 too fast for a 20Mhz powered PIC? I will try to slow down to 1200...

    Thanks skimask

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


    Did you find this post helpful? Yes | No

    Default

    Another way to teak the internal OSC is to program your PIC with _INTRC_OSC_CLKOUT set. The just grab the signal of the internal OSC.

    Problem could be because of the latency SERIN/LCDOUT combination... well i know it's a slow baudrate... but on the other side there's that Timeout thingy that may timeout somewhere in a middle of a byte.... I would suggest to remove the Timeout... and my obvious suggestion... use HSERIN.. yeah a real USART + it's nice input buffer

    HEY You have it for free on your 16F876... why not using it?
    Steve

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

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    How does it at if you just continuously send that '$55-$55-$66-#data' string without any pauses at the transmitter? And get rid of that timeout in the RX code like mister_e said?

    Also, if you plan on powering this thing up just once a minute, I wouldn't send the data just once. I'd send it 3, 4, 5, maybe more times in a row and do some comparison checking at the RX end.
    You get 3 data in a row that are the same, you got good data, otherwise you throw it out. Or you receive 5 data chunks, 3 match, the other 2 don't, the 3 that match are what you take from it.
    Whatever works...in the end, it turns out to be 'Supersonic Protocol version 1.0'.

    As far as tuning your OSC...a far out idea that worked for me once a few years ago...(and I was bored and I was thinking back to a lesson my physics teacher taught many many moons ago with a water tank and two egg beaters)...
    I generated a 1khz tone with my PC and put it on speaker... I set up the PIC to generate a 1khz tone thru another speaker... Then I listened to both of them at the same time.
    If the tones are both at 1khz, they 'beat', and what I hear is constant...
    If the tones are 1hz off from each other, I hear an increase/decrease about once per second as they beat and unbeat on each other.
    If they're out in the weeds somewhere, it just sounds wierd.
    Tweak the OSCTUNE and retried it until they were dead on...took a few days, but I got it...
    Then I bought an o'scope...

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


    Did you find this post helpful? Yes | No

    Default

    mmm, or use a Guitar tuner
    Steve

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

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Hi Steve. I don't think that the timout of the Serin could be of a problem since it gets reset as long as data are arriving. It times out only if there is more than the t defined idle input.

    If the connection is made directly from the serial output of txer to the serial input of rxer, is the communication 100% succesful?

    If it is, then I am guessing that the problem is caused by the modules. Maybe they loose sync when data that is not encoded properly are transmitted. Try to encode data like manchester or similar.

    You are using a good preamble of $55, which is the best to stabilize the data slicer but your payload is not. And follows $66 that is pulling the data slicer a little.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    I based my assumption on the previous statement...
    but the problem is that attaching the rxpin on a pc and monitoring with a serial port monitor, the receiver gets exactly what I send. So I guess the problem is somewhere in the PIC code,
    now, what happen if you receive a sucessful $66 + 1 byte, you show it on the LCD, if the next byte is delayed enough, there shouldn't be much of a problem... but let's say it's sent in middle of LCDOUT or Timeout goto loop(which is barely possible.. slow baudrate, preamble sent, and wait for a synch.... ), there's still no input buffer, and maybe this could be part of the problem.... but yeah, i admit... chances are really slim seeing the TX Code.

    No config fuses at all, no schematic... hard to tell what's wrong. Could be the usual noisy PSU...
    Steve

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

  9. #9
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    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.

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    The next bunch of data will come 2 seconds (at least) after. So I doubt that LCD stuf is a problem. It should work. Of course it could loose the data the moment that timout occurs, so it will grab the next data arriving. Is this happening Francesco?

    How is the PC part connected? PC RS232 pin is connected to the Receivers output?

    Ioannis
    Last edited by Ioannis; - 17th December 2007 at 17:40.

  11. #11
    cdmiwa's Avatar
    cdmiwa Guest


    Did you find this post helpful? Yes | No

    Default

    Supersonic,

    I got a couple of the same wireless boards you got (Great price), except I got the RM1SGS2. I got some at at 433mhz and some at 315mhz. I can get the 433 to work, mostly, but I haven't been able to get the 315 to work (They seem plug compatible). Do you have a reference layout or anything I can try to get them to work?

    Right now I've got them hooked up directly to the pic.

    Thanks,

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