Newbie radio link issue


Closed Thread
Results 1 to 32 of 32
  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default Newbie radio link issue

    I'm new to serial comms and never tried a radio link before and am having troubles. I have an "easy radio" ER400TS and ER400RS chips, and am trying to link two PIC16F678 together with them. Have tried most things but gotten stuck - it does say in the datasheet for the easy radio chips that it defaults to 19200bps and gives the instruction to set data rate to 2400 as ER_CMD#U1

    Many thanks to anyone who can give me some clue as to what I'm doing

    Here's my receiver code:
    @ DEVICE PIC16F676, INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF


    'Define OSCCAL_1K 1
    DEFINE OSC 4

    TRISA = %001000
    TRISC = %000000


    ANSEL = 0 'disable analog
    T1CON = %00000100
    VRCON = 0 ' A/D Voltage reference disabled
    CMCON = 7 'Disable comparitor

    timesw var PortA.5
    gosw var PortA.3
    stopsw var PortA.4
    timeset var byte
    display var byte
    time var word
    b0 var byte
    b1 var bit

    clear
    timeset = 1
    PortA = 0
    PortC = 0
    serout PORTA.4,0,["ER_CMD#U1"] 'change receiver to 2400bps

    Begin:

    display = (1 << b0) - 1
    PORTC = display
    pause 100
    if b0 < 7 then
    b0 = b0 + 1
    goto begin
    Else
    Pause 1000
    b0 = 0
    portC = b0
    Endif

    Start:

    serin PORTA.0,0,["A"],timeset,b1 'Read receiver

    disply:

    display = (1 << timeset) - 1 'Set display to be bar type
    PORTC = display 'output LEDs
    goto Start


    AND HERE'S MY TRANSMITTER CODE:

    @ DEVICE PIC16F676, INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF

    'DEFINE ADC_BITS 10
    'DEFINE ADC_CLOCK 3
    'DEFINE ADC_SAMPLEUS 50
    'Define OSCCAL_1K 1
    DEFINE OSC 4

    TRISA = %111000
    TRISC = %000000

    'ADCON0 = %10000000
    'ADCON1 = %000
    ANSEL = 0 'disable analog
    T1CON = %00000100
    VRCON = 0 ' A/D Voltage reference disabled
    CMCON = 7 'Disable comparitor

    timesw var PortA.5
    gosw var PortA.3
    stopsw var PortA.4
    timeset var byte
    display var byte
    time var word
    b0 var byte
    b1 var word

    clear
    timeset = 1
    PortA = 0
    PortC = 0

    Begin:

    display = (1 << b1) - 1
    PORTC = display
    pause 100
    if b1 < 7 then
    b1 = b1 + 1
    goto Begin
    Else
    Pause 1000
    b1 = 0
    portC = b1
    Endif

    Start:

    if timesw = 1 then settime 'jump to setime if triggered
    if gosw = 1 then go
    if stopsw = 1 then trnsstop
    gosub disply
    goto start

    settime:

    if timeset > 6 then timeset = 0 'if greater than max then reset
    time = 0
    pause 100
    if timesw = 1 then settime 'wait till switch open
    timeset = timeset + 1

    goto start

    disply:

    display = (1 << timeset)' - 1
    PORTC = display

    return

    go:

    PORTC = 0
    PORTC.5 = 1
    pause 1000
    for b0 = 0 to 5
    toggle PORTC.5
    SEROUT PortA.0,0,["A",timeset,1]
    pause 100
    next b0

    goto start

    trnsstop:

    PORTC = 0
    PORTC.0 = 1
    Pause 1000
    for b1 = 0 to 5
    toggle PORTC.0
    serout PortA.0,0,["A",timeset,0]
    pause 50
    next b1

    goto start

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George View Post
    I'm new to serial comms and never tried a radio link before and am having troubles. I have an "easy radio" ER400TS and ER400RS chips, and am trying to link two PIC16F678 together with them. Have tried most things but gotten stuck - it does say in the datasheet for the easy radio chips that it defaults to 19200bps and gives the instruction to set data rate to 2400 as ER_CMD#U1

    Many thanks to anyone who can give me some clue as to what I'm doing
    PBP manual, page 130 and page 137.
    There's something on each of those pages that you've forgotten. Hopefully after you add that certain thing, all should be well. The rest of the code, at first glance, looks like it should be ok.

    Another thing...make sure the whole thing works without the RF modules first, direct connect between the two PICs. That seems to be a common theme in most RF projects. People don't build up to the RF link, they just expect it to work on the first try (or the 100th ), and come to find out that the basic code was flawed in the first place.
    Last edited by skimask; - 20th February 2007 at 00:00.

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    PBP manual, page 130 and page 137.
    There's something on each of those pages that you've forgotten. Hopefully after you add that certain thing, all should be well. The rest of the code, at first glance, looks like it should be ok.
    I presume you are meaning the mode names? If so i used the code instead - ie. 0 = T2400

    I'll try the direct connection now - I was thinking about it, but put it off

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George View Post
    I presume you are meaning the mode names? If so i used the code instead - ie. 0 = T2400

    I'll try the direct connection now - I was thinking about it, but put it off
    I just looked at the PBP manual again. If you're using numbers, you don't need to include the file. My bad...
    Also, the datasheet says to use inverted data, i.e. N2400 instead of T2400.
    I'm just having a quick look at the datasheet now...so bear with me...

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    I pulled the radio modules off and did a direct connect - and it didn't work! All it was was making sure the internal oscillators were calibrated. Then it worked so my hopes were high for connecting the radio modules again - but alas, it was not to be. just doesn't work for some reason - I think it has something to do with the internal setup of the radio chips - for some reason (maybe their brand name) I thought it would be easy! And would just transmit data as it came into it's pin - but apparently u have to set baud into the receiver and there r a few other options which make it a bit complicated for a beginner.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,809


    Did you find this post helpful? Yes | No

    Default

    If direct connection works and RF link does not (considering that the radios are communicating) then I would suggest to try sending only the bytes AAh repeatedly and see if the receiver gets the data.

    If you have success then consider to use bi-phase or manchester encoding of the bytes to be transmited (forum has solution for this).

    Ioannis

  7. #7
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    What's the command line to make it just send the AAh bytes repeatedly? As I said before I'm totally new to serial comms - are you meaning simply as:
    SEROUT PortA.0,0,["AAh"]?

    Does anyone have any recommendations as to a good radio set to use - like one where you hook it up and it works? No internal settings that are adjustable etc - just goes

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


    Did you find this post helpful? Yes | No

    Default

    AAh : AA is the value, h represent Hexadecimal.

    SEROUT pin, baud, [$AA,$AA,$AA,$AA,$AA, YouDataVariable]
    OR
    SEROUT2 pin,baud,[REP $AA\5,YourDataVariable]

    Anything from Linx, Laipac, RFSolution, Maxstream will work without too much adjustment, but the manchester protocol have to be use in most case.

    Sometimes just by sending some $AA, a header, your variables may work good. If you don't have many data to sent, i don't think Manchester is really needed.

    Transmitter
    SEROUT2 ...[REP $AA\5,"READY", YourVariable]

    Receiver
    SERIN2 ...[WAIT("READY),YourVariable]
    Steve

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

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,809


    Did you find this post helpful? Yes | No

    Default

    Just for testing try to send repeatedly:

    loop:
    SEROUT pin, baud, [$AA]
    goto loop

    This will send endless AA to the receiver.

    If you read them then you need to encode your data.

    If you don't then you need to check the design back from zero.

    For modules contact me private if you need many. We build our own.

    Ioannis

  10. #10
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Have found the problem, wrote to the manufacturer and they replied with this:

    The ER modules are pre-set to 19200 baud. If you cannot talk to them at this speed then you cannot use them. One of the best ways to get around this is to purchase the eval kit for 55 pounds. This has two pcb boards, leads, antennas etc. which enable you to connect the module to a PC that can communicate at 19200 baud. Then you can send the ER command to change the board rate to PIC baud rate you need for example 2400 etc.

    So I was thinking about building another board with a 20MHz crystal and try send it the commands to change down to 2400. If I do this - am not really sure of the syntax - it says in the datasheet the comm settings is ER_CMD#U1 so do I send it like this SEROUT pin,baud,["ER_CMD#U1"] ???

    Thanks again for all your guys input so far

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


    Did you find this post helpful? Yes | No

    Default

    any link to the datasheet?
    Steve

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

  12. #12
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Have found the problem, wrote to the manufacturer and they replied with this:

    The ER modules are pre-set to 19200 baud. If you cannot talk to them at this speed then you cannot use them. One of the best ways to get around this is to purchase the eval kit for 55 pounds. This has two pcb boards, leads, antennas etc. which enable you to connect the module to a PC that can communicate at 19200 baud. Then you can send the ER command to change the board rate to PIC baud rate you need for example 2400 etc.

    So I was thinking about building another board with a 20MHz crystal and try send it the commands to change down to 2400. If I do this - am not really sure of the syntax - it says in the datasheet the comm settings is ER_CMD#U1 so do I send it like this SEROUT pin,baud,["ER_CMD#U1"] ???

    Thanks again for all your guys input so far

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


    Did you find this post helpful? Yes | No

    Default

    O.K. i heard you but any link to the datasheet?
    Steve

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

  14. #14
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Sorry - here it is: http://www.lprs.co.uk/pdf_directory/....3-sept-05.pdf
    BTW - if I make a 20MHz board - what size caps do I use with my crystal? I use to use 22pF with 4MHz - does that mean I use 5pF with 20MHz?
    cheers
    Last edited by George; - 21st February 2007 at 19:54.

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


    Did you find this post helpful? Yes | No

    Default

    the recommended cap are listed in your datasheet. usually 22pF is a nice choice.

    In theory your SEROUT is good. BUT, to me, you still have to transmit it with the default baudrate.. so it doesn't solve the problem unless you buy the suggested module to reprogram them first.. waste of time and money to me.

    BTW @19200 baud, for ANY reliable serial comm, i'll suggest you to use the PIC USART with HSERIN/HSEROUT instead.
    Steve

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

  16. #16
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    You don't think SEROUT2 running 20MHz could send enough data to change the default setting in the radio module? Is my syntax correct in how I'd send it? If you think that the serout won't do 19200 then I think I'll just cut my losses and try find another module that just works, the manufacturer did say that I could send it back and they would change it in the factory and send it back to me - however they r on the opposite side of the planet!

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


    Did you find this post helpful? Yes | No

    Default

    Try with DEBUG first. it's probably better. BUT both of them worth a try for sure.
    Steve

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

  18. #18
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    sweet - will try with debug - is my syntax correct?

    SEROUT pin,baud,["ER_CMD#U1"]

    sorry - i mean:

    DEBUG "ER_CMD#U1"

    ???
    Thanks
    Last edited by George; - 21st February 2007 at 20:28.

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


    Did you find this post helpful? Yes | No

    Default

    should be good. Don't forget to set the according DEFINEs listed in the manual.

    Good luck!
    Steve

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

  20. #20
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George View Post
    You don't think SEROUT2 running 20MHz could send enough data to change the default setting in the radio module? Is my syntax correct in how I'd send it? If you think that the serout won't do 19200 then I think I'll just cut my losses and try find another module that just works, the manufacturer did say that I could send it back and they would change it in the factory and send it back to me - however they r on the opposite side of the planet!
    If you've got a few extra crystals handy (and assume that you just happen to have the right values ), how about tell the compiler you're using 2400 baud with 4mhz, but actually use a 32mhz. The compiler won't know the difference and you'll be running at 19,200.
    But since you're running a 16F series, you're probably limited to 20mhz (depending), so maybe, tell the compiler you're running 4mhz with 9600 baud, and actually use 8mhz, to which you'll get 19,200 baud...
    But there I go thinking again...gotta stop that...

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


    Did you find this post helpful? Yes | No

    Default

    yes, tricking the way you said should work... but i don't see any advantage here.
    Last edited by mister_e; - 22nd February 2007 at 00:34.
    Steve

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

  22. #22
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    yes, tricking the way you said should work... but i don't see any advantage here.
    According to the manual, when using SERIN/SEROUT, 4mhz only get you 2400 baud reliably. Tricking the compiler, a person should be able to get 4800 on 8mhz, 9600 on 16mhz, etc. without too much worry...that's all.
    I'm using this sort of thing to work my comm's at 38,400 with a bit more accuracy (I think). My program, running at 40mhz, didn't seem to want to run when compiled with DEFINE OSC 40 and SEROUT2...6 to get 38,400 comm's. But, if I defined 4mhz and SEROUT2...254, and just pretended to be using 3,840bps, it worked like a champ. I dunno, maybe the timing was just off that one or two extra microseconds or something...

  23. #23
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    How do I know if I transmit the data inverted or true? What's most likely? Cheers

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


    Did you find this post helpful? Yes | No

    Default

    Probe your serial PIN at the end of the transmission. If this pin is HIGH, you're in the TRUE mode, unless you're in INVERTED mode.
    Steve

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

  25. #25
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Have ordered a couple of linx TXM-418-LR modules - hopefully they will work better for my application - anyone had success with these? They actually look like really good bit's of kit, cheap, small and overpowered! The only downside to prototyping with them is they r SMD.

  26. #26
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    George, I recently purchased a 2 pair of LINX RXM-433-LR-S and TXM-433-LR-S modules from parallax. They come with antennas and have interface circuitry for level shifting to 5 volt levels. I have used them with manchester coding and a sync pulse and have gotten distances of a few hundred feet. However the baud rate is quite slow as they tend to delay the received signal above about 2 milliseconds per bit. I am currently running them at about 500 baud manchester. Much above and they are unreliable. Don't beleive the claims of 10k baud..... However if you are set on purchasing them I would get them from Parallax, as I said they are fully assembled and ready to be pluged into your circuit. Best of luck....

    Dave Purola,

    George, Here is the link....
    http://www.parallax.com/detail.asp?product_id=28180
    Last edited by Dave; - 27th February 2007 at 00:58.

  27. #27
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    I have used them with manchester coding and a sync pulse and have gotten distances of a few hundred feet. However the baud rate is quite slow as they tend to delay the received signal above about 2 milliseconds per bit. I am currently running them at about 500 baud manchester. Much above and they are unreliable. Don't beleive the claims of 10k baud.....
    I've got a pair of those on a temp sensor/logger/thingy out inside my garage. Distance from garage to house is about 275ft, TX inside garage, RX inside house. I'm running 19.2K w/ manchester coding (9600 baud effective rate). And they work great, not using anything for error detection or correction...

    But as the site says, the range is 'based on environmental conditions', 'your mileage may vary', 'do not take with alcoholic beverages', 'the check is in the mail', 'see a doctor before using', etc...

  28. #28
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    skimask, I bet your sending data continously. As I ran these tx/rx modules on the bench I noticed that the more data they sent continously the better the receiver alligned to the transmitted signal. I send 1 packet of 32 bits (64 manchester bits) with a sync pulse once every minute and the best reliable baudrate I can get is 500 baud manchester. I suppose if I sent a couple thousand bits I might pick up 1 or more packets at 380 ft.. Are you using the stock antennas or have an external antenna?

    Dave Purola,
    N8NTA

  29. #29
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I use the Linx LR series in a ton of various applications, and have no problem at all with 9600bps up to 2000'.
    If you're using the Parallax modules, your range may be limited by the antennas they use on the modules.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  30. #30
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    skimask, I bet your sending data continously. As I ran these tx/rx modules on the bench I noticed that the more data they sent continously the better the receiver alligned to the transmitted signal. I send 1 packet of 32 bits (64 manchester bits) with a sync pulse once every minute and the best reliable baudrate I can get is 500 baud manchester. I suppose if I sent a couple thousand bits I might pick up 1 or more packets at 380 ft.. Are you using the stock antennas or have an external antenna?

    Dave Purola,
    N8NTA
    Stock antenna's that came with the modules (the little whips), not really placed up high or anything, eye level on the TX, waist level on the RX. Not continuous data, however, I 'preload' the TX with a decent amount of sync (64 x $AA, I read somewhere once that these types of TX's want about 5ms of preamble before they really work well), then 2 $55's, then send the temp data word, repeated 4 times.
    The RX won't take the data unless it first sees 32 x $AA, then the 2 $55's, and it really won't take the new data unless it sees 3 out of the 4 data words equal each other. I set it up so the TX PIC only wakes up once a minute and it only sends data if the temperature changes more than 1 degree F. The RX has an RTC on it and keeps track of time (incidentally, the RX also powers down for 55 seconds after receiving the data because I know it'll never get another packet before that, every last bit of power at both ends, even though the RX is wall-powered).

    And for the physical impediments to RF transmission:
    TX antenna -> concrete block wall -> open air for 275ft (give or take 10ft) -> house siding -> stud wall with insulation -> sheet rock wall x2 -> RX antenna.
    But that's just my happy story my good transmission. I suppose if I would've got the next module down the manufacturing line, I could just as easily be running 1200 baud for 50ft at most.

  31. #31
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Sounds hopeful anyrate, I had a look at the paralax website and am wondering what the other components on the board do - the Linx website say there r no external components required and show schematics of it hooked directly to a PIC - any ideas?

  32. #32
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George View Post
    Sounds hopeful anyrate, I had a look at the paralax website and am wondering what the other components on the board do - the Linx website say there r no external components required and show schematics of it hooked directly to a PIC - any ideas?
    I couldn't tell you what they are...power supply filters, antenna matching type stuff, who knows... What the website means by 'no external components required' probably means that nothing is needed outside of the pins that connect it to the board...which is correct. I connect directly to the PIC and the power/ground rails.

Similar Threads

  1. Car radio (Car radio and electronics support forum)
    By freewillover in forum Forum Requests
    Replies: 1
    Last Post: - 1st July 2009, 19:41
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  3. Replies: 5
    Last Post: - 6th September 2007, 04:59
  4. quickBlue™ Link
    By lester in forum Bluetooth
    Replies: 4
    Last Post: - 20th March 2007, 13:23
  5. 18F1320 ... Strange Memory
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 9th April 2006, 09:55

Members who have read this thread : 1

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