Shop OBEX P1 Docs P2 Docs Learn Events
HELP - HomeMade Remote Control - Why won't this code work — Parallax Forums

HELP - HomeMade Remote Control - Why won't this code work

jmevansjmevans Posts: 22
edited 2007-06-25 15:19 in General Discussion
I put TX_TEST on one SX28 and Rx_TEST on another SX28
then connected the two RA.0's together.

I can't figure out why this code will just not work
When i push Button RA.1 or RA.2 the receiver blinks RB.4 (LED)
but nothing else seams to work.

Help

Comments

  • BeanBean Posts: 8,129
    edited 2007-06-10 02:15
    Most likely because you cannot use the internal oscillator for serial communications it's not accurate enough.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • jmevansjmevans Posts: 22
    edited 2007-06-10 04:42
    Great, I will give that a try.

    Do you have any recomendations?
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-06-10 18:49
    Bean's right, you need to use an external clock source for serial. You can use a 4 MHz resonator since your baud rate is slow.

    On the receiver side you may want to allow for upper- and lowercase letters in your command header; here's how we do it at EFX-TEK with our serial accessories:

    ' Use: theByte = RX_BYTE { ConvertToUppercase }
    ' -- converts "a".."z" to "A".."Z" if "ConvertToUppercase" bit 0 is 1
    
    FUNC RX_BYTE
      IF __PARAMCNT = 1 THEN                        ' option specified
        tmpB2 = __PARAM1                            ' yes, save it
      ELSE
        tmpB2 = 0                                   ' no, set to default
      ENDIF
      IF BaudRate = BR2400 THEN
        SERIN Sio, BaudSlow, tmpB1                  ' for Prop-1/BS1
      ELSE
        SERIN Sio, BaudFast, tmpB1                  ' for Prop-2/BS2
      ENDIF
      IF tmpB2.0 = Uppercase THEN                   ' convert to uppercase?
        IF tmpB1 >= "a" THEN                        ' lowercase?
          IF tmpB1 <= "z" THEN
            tmpB1.5 = 0                             ' ...yes, make uppercase
          ENDIF
        ENDIF
      ENDIF
      RETURN tmpB1
      ENDFUNC
    



    If you're expecting a character to be a letter then the function above can convert it to uppercase by using this call:

    char = RX_BYTE 1
    



    In my programs I use a constant called "Uppercase" so the listing is more readable:

    char = RX_BYTE Uppercase
    



    If a non-letter character is received it is not changed by the function. Note, too, that the function above checks the baud rate jumper on our boards; you can remove this check for a fixed baud system.

    Post Edited (JonnyMac) : 6/10/2007 6:54:19 PM GMT
  • jmevansjmevans Posts: 22
    edited 2007-06-10 23:39
    Thank You.

    I am ordering some 4Mhz's today.

    Mark
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-06-11 01:23
    The SX has provision to calibrate the internal oscillator in the confguration bits. I think there are about 3 bits which will nudge the frequency. You would need to measure the output though with a frequency counter. It's a lot of hassle versus an external source which would be rated for 100ppm precision for the cheaper ones.

    I don't know if you looked at all your IR receiver modules, Digikey carries the Sharp line at low cost and high performance.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-06-13 01:27
    Try putting a slight pause in your TX_BYTE subroutine. You want to make sure that the receiver is ready before you send each byte.

    - Sparks
  • jmevansjmevans Posts: 22
    edited 2007-06-14 05:12
    Did I forget to mention that I am using RF?
  • jmevansjmevans Posts: 22
    edited 2007-06-21 14:18
    I have tried the above mentiond and i can get it to work going RA.0 of SX#1 to RA.0 of SX#2 with·one pulled up wire·between them,· but I cannot for the life of me seem to get it to work with the RF tranceivers.

    Could I need to do something with the Highbit and Lowbit? or with a sync pulse? (Please see attached code in previous post)

    I can see that people have used·the RF·transmitter and·RF receiver·with the BS1, BS2 and then Javelin, but has anyone ever used them with the SX chips?

    I have tested·the RF tranceiver package that I have and they work great with the CIP-8E and CIP-8D from·www.Rentron.com·but I can't get them to work with the SX.

    Mark

    P.S. I am now using·50MHz

    Post Edited (jmevans) : 6/21/2007 5:06:32 PM GMT
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-06-21 21:09
    I tried to look at the data sheets for the two chips that you mentioned but I was unable to get them to display on my computer.

    I hope you will not mind my asking this but if the encoder chips work, why not use them instead of SX's?

    It seems like you have only connection and signal generation issues to resolve. I was unable to open the documents that should describe these. If you can post that information or point to working code for another processor surely someone will help you figure out what settings you need and what sync pulses to send.

    I am sorry I am not able to help further.

    - Sparks
  • DosManDanDosManDan Posts: 179
    edited 2007-06-22 07:47
    I have sucessfully built several transmitter and receiver circuits using the SX-28. I'm not using the Parallax ones, so my situation might be different from yours. I also have them talking to a BS/2 without any problems either.

    What transmitters/receivers are you using?

    Dan

    Post Edited (DosManDan) : 6/22/2007 7:59:07 AM GMT
  • jmevansjmevans Posts: 22
    edited 2007-06-22 13:26
    DosManDan,

    I am trying to use a couple pair of these: http://www.sparkfun.com/commerce/product_info.php?products_id=7813#


    I have used them with these : CIP-8E 8-Bit Encoder IC· and· CIP-8D 8-Bit Decoder IC from: http://www.rentron.com/remote_control/Holtek.htm
    and they work great.

    I have tried to transmit from one SX to another SX and a BS2 at the same time.· The DEBUG on the BS2 shows data, just not the data that i am trying to send. The SX shows data also but there again its not the data that I am trying to send.

    Thanks
    Mark
  • DosManDanDosManDan Posts: 179
    edited 2007-06-22 18:09
    I think I can solve this one for you pretty quick...

    The two data lines you have are different, use the second data line and everything should be fine. So, from the outside edge of the board, connect to the second DATA pin, not the first one.

    The reason it worked with the decoders is that they are able to use the digital signal. The second pin is analog, so you can just read it and not have to do anything weird. Interstingly enough, sometimes that second pin is called the TEST line, and the first one is called the DATA line.

    I have diagrams, prototype boards·and complete code written for these, I just need to find time to draw up a schematic and post it. Maybe I'll get to it this weekend if I can find a moment.

    Let me know how it works out for you,
    Dan

    Post Edited (DosManDan) : 6/22/2007 6:15:17 PM GMT
  • jmevansjmevans Posts: 22
    edited 2007-06-22 19:05
    Thanks DosManDan,

    I will try that as soon as i get home tonight.· I would also be interested in your code and wireing diag. when you get them finished.

    Thanks

    Mark
  • DosManDanDosManDan Posts: 179
    edited 2007-06-22 20:41
    Mark,
    I don't know how far you are looking to send a signal, but I've found these to be pretty effective in the 60-90 ft range. After that, stay signals start to mess things up. To get the full range, you need to invest a few dollars in an antenna made for the 433.92 frequency. There are two models I've looked at, one is about $3 and the other one is about $9. The cheap one looks like the metal antenna you would find on a radio, the other is a rubberized mini whip. If you are going for range, it think a small investment like this is worth it.

    Dan
  • jmevansjmevans Posts: 22
    edited 2007-06-22 20:53
    Dan,

    Are you using 12v on the transmitter?

    Mark
  • DosManDanDosManDan Posts: 179
    edited 2007-06-22 22:49
    I run them both at 5V. That way I don't need to deal with shifting voltage up or down.

    Dan
  • jmevansjmevans Posts: 22
    edited 2007-06-23 05:04
    Dan,

    I am getting my data through, but their is a problem, the first char. sent·is not always the first char. received.

    do you have any code for something that you have working? Both TX and RX?

    Mark


    Post Edited (jmevans) : 6/23/2007 6:16:03 AM GMT
  • DosManDanDosManDan Posts: 179
    edited 2007-06-23 08:15
    I was really hoping to clean the code up first. This was just my proof of concept code, so it isn't as clean as it should be.

    My SX-28 is hooked up to a keypad and an LCD screen. So depending on where you are looking at the code, you might want to remove some of the extra stuff. It should work fine as is, but you probably want to use debug statements where you see things that mention an LCD. This is literally straight off my drive, so you might also have to UNCOMMENT some lines, depending on what I was testing last. Basically make sure one chip is sending a message and the other is waiting to receive it. I don't remember what I was testing last, but this code works and was tested up to 60ft through walls in my house. I have about an 8" wire as an antenna. I can post a pic of my prototype if you think that might help.

    My prototype has a Receiver AND a Transmitter on it. It talks to other boards that have the same configuration. I'll put the BS/2 code here too, since you mentioned needing that.

    So, here is what the SX-28 files do:

    Receiver - Reads the incoming data, displays it to an LCD panel, then sends an acknowledge "!"

    Transmitter - Old code I used to send a test pattern. I included it in case you needed one.

    RF Console - This is the one I use now for the prototype. The SX-28 scans a 3 x 4 keypad waiting for a·code. The code is packaged up with other info and transmitted. The program waits for a reply. The information is displayed on an LCD panel. This program works with the BS/2 transmit/receive code.

    The BS/2 code waits for a message, checks it, then sends back a reply character.

    I implemented a very crude checksum method, so you might need something a little more robust for your app.

    I was going to post this as a finished project when I got it all cleaned up....so I hope people aren't to critical of it right now.

    Dan

    Post Edited (DosManDan) : 6/23/2007 8:43:20 AM GMT
  • DosManDanDosManDan Posts: 179
    edited 2007-06-24 03:17
    Did this help you solve your problem?

    Just checking up,
    Dan
  • jmevansjmevans Posts: 22
    edited 2007-06-25 13:32
    Dan,

    Thanks that did help. I am still experimenting with some timing issues, for some reason if I add a new debug on the BS2 it troughs off the first incoming char. again.·confused.gif··

    But now I can get coding on the rest of my project.·smilewinkgrin.gif
    .

    Mark
  • DosManDanDosManDan Posts: 179
    edited 2007-06-25 15:19
    Glad to hear you got past that problem, it sure can be frustrating. As for the debug statement, make sure you aren't putting it in the middle of your receive routine. For instance, if your transmitter is sending 3 characters, and you put a debug line in your receive routine (so you can watch the incoming characters), you might miss one. I usually load up all the incoming data, then look at it.

    Have fun, best of luck with your project,
    Dan
Sign In or Register to comment.