1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

TX RX HC-12 radio module

Discussion in 'Oshonsoft' started by camerart, Apr 16, 2018.

  1. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    385
    Likes:
    18
    Location:
    Helsinki, Finland
    Maybe I don't understand what you want to do with the leds,
    but you have no code in rx to set rled = 0
     
  2. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    As long as we get there in the end, that's fine.
    C.
     
  3. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi J,
    I've used rled = 0 yled = 1 and rled = 1 yled = 0 in the past, I'll add it back in, but the problem is: they are OFFing, but not ONing. Although if they come ON, they don't switch off till TX SENDs a '0' is and RX is reset.

    I think it's something to do with timing of the HSERGET.

    I have an ASCII table, but probably only need 0 to 9, for playing with.
    C.
     
  4. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Failed! I can only get the RX to switch, if I reset the PIC. Here's what I used:
    There is a more complex version on AAC, which I'm gouing to try now. I've used similar before, and it is very versatile.
    C.
    TX'--------------------------------------------------------------------------------------------
    main:
    If button = 1 Then 'BUTTON NOT PRESSED
    rled = 0
    yled = 1
    Hserout "0", CrLf
    Endif
    WaitMs 500

    If button = 0 Then 'BUTTON PRESSED
    rled = 1
    yled = 0
    Hserout "1", CrLf
    Endif
    WaitMs 500

    Goto main
    RX------------------------------------------------------------------------------------------------
    main:
    Hserget i
    WaitMs 500
    If i = Asc("0") Then '< --- -- 48 is number 0
    Hserout "Number: ", i, CrLf
    rled = 0
    yled = 1
    WaitMs 500
    Endif

    If i = Asc("1") Then '< --- -- 49 is number 1
    Hserout "Number: ", i, CrLf
    rled = 1
    yled = 0
    WaitMs 500
    Endif
    Goto main
     
  6. Ian Rogers

    Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,741
    Likes:
    954
    Location:
    Rochdale UK
    ONLINE
    I am struggling here C...

    If you press ( And keep it pressed ) red should light and yellow should go out and when you let go ,the leds should reverse..???

    Why are you sending ("number: " i,CrLf ) back to the transmitter.. If you don't deal with the reception in the transmitter the serial port will overun!!
     
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    Why are you sending ("number: " i,CrLf ) back to the transmitter? Only so I can see it in the computer terminal as a check. It's not necessary really.

    PORT overruning! How do I stop this?
    C.
     
  8. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10
  9. Ian Rogers

    Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,741
    Likes:
    954
    Location:
    Rochdale UK
    ONLINE
    If you use that code on your Tx board and not the PC, the serial port in the pic will receive the string but the port will not be read, This will cause the OERR flag to be set and the port will need a reboot! The terminal program on the PC will do it automatically..
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    Aha!
    As the computer terminal is just for monitoring, it can be ignored.
    Is there a way to reset the OERR flag, so the TX can keep READing?
    C.
     
  11. Ian Rogers

    Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,741
    Likes:
    954
    Location:
    Rochdale UK
    ONLINE
    If OERR = 1 then
    CREN = 0
    CREN = 1​
    ENDIF

    Im not sure if this will fix the problem, but try this in the main loop..
     
  12. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    See image.
    C
     

    Attached Files:

  13. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    385
    Likes:
    18
    Location:
    Helsinki, Finland
    OERR is a bit in some USART register.
    I don't have the d/s here now, but use something like
    IF someregistername. OERR=1
     
  14. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    385
    Likes:
    18
    Location:
    Helsinki, Finland
    The register is RCSTA, so try

    If RCSTA. OERR=1 Then
    RCSTA. CREN=0 ...
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi All,
    I chose to use a more complex but versatile program, from another forum ETO, from Eric Gibbs
    Here are both TX and RX:
    Thanks to everyone who helped.
    C.
     

    Attached Files:

    Last edited: Apr 20, 2018
  16. Ian Rogers

    Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,741
    Likes:
    954
    Location:
    Rochdale UK
    ONLINE
    Yeah! I know... I've been watching!! As long as you get there, That's all that matters..
     
  17. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I and J,
    If you would like me to carry on getting this simpler program to work for your satisfaction, I'll carry on, but for my purposes, the #33 programs are better.
    C.
     
  18. Ian Rogers

    Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,741
    Likes:
    954
    Location:
    Rochdale UK
    ONLINE
    Eric's programs normally work, so They would be the ones to build on... As you know, I use C so any basic program we develop would only be for others on this forum!!
     
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    Very true. I've been playing with them, and they're working ok, apart from changing frequency. I'm just about to start a post regarding this.
    C.
     
  20. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,789
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Here are a couple of programs, that I've modified, to be TX with RX ECHO, for use to test antennas.
    They aren't perfect, and need to TX to be RESET for a result.

    Switch on RX and TX, then move the TX away from the RX, while RESETTING the TX with either the BUTTON pressed or not. If pressed and they are in range, then a signal goes to the RX and it sends asignal back to the TX, which switches a LED on.
    Hope it's useful.
    C.
     

    Attached Files:

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice