Shop OBEX P1 Docs P2 Docs Learn Events
Wireless joystick — Parallax Forums

Wireless joystick

P!-RoP!-Ro Posts: 1,189
edited 2009-03-26 20:09 in General Discussion
I am thinking of using the sx to make a joystick wireless using IR. I know little about sx's so before I jumped into this project head first I wanted to find out if doing this is actually feasible. I need to relay the data of 3 pots and 4 buttons, but my current worry is the sx won't be fast enough to transmit this data at a quick enough pace (a min. of 1/20 of a second, but even that is slow). Think this is a plausible use·for the sx?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PG

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-18 06:07
    The SX is plenty fast enough for this -- the "slow" part is going to be using IR to send serial data. The reason is that you need to modulate the IR at 38-40kHz for reliable operation in ambient light, and most of the IR detectors are setup to demodulate. Your serial speed is going to depend on the IR demodulator.

    I've been doing IR transmission lately for DVD and camera control so I reorganized some of those code snippets along with an ADC subroutine that I use -- attached you'll find a program that I'm fairly confident will work "out of the box." I checked the modulation, serial data to LED, and the 50ms burst flag with a scope -- all looks good. Even at 2400 baud you can transmit four bytes in about 17 milliseconds, so your desired throughput is there. There are constants for higher baud rates; start low and work your way up.

    Note: Be sure to put a 100-ohm resistor between RA.0 and the IR LED anode.
  • P!-RoP!-Ro Posts: 1,189
    edited 2009-03-18 22:39
    Thanks JonnyMac, I'll try it as soon as I can this weekend. If it can't transmit the data fast enough, I might be able to try shortening the amount of data sent, but again I will have to wait until the weekend to work that out.

    I'll see what I can do and I'll post what I come up with.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-18 23:37
    Four bytes at 2400 baud takes 17 milliseconds -- if you need to send data faster you could easily adjust the (transmit) burst timer down to 25.
  • P!-RoP!-Ro Posts: 1,189
    edited 2009-03-25 22:33
    I've been working through the Programming the SX Microcontroller text so I could better understand your code, however it's been slow and about the only thing I know how to do right now is blink an led and increment a variable. I would hate to be too dependent on you, however I'll need a little more help in understanding your code before I can use it.

    From what I understand, all I need to do is connect the pots and buttons to the correct pins and it will run, right? If so, than my only question is how exactly the data is transmitted. I need this so I can code my prop to read the output.

    Again, thanks for all the help, Jon.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-25 22:42
    The data is transmitted serially using a 38.4kHz-modulated IR LED. I've got a couple projects that use the IR modulation/control strategy to send Sony SIRCS code so I know the essentials work; all I've done is connected that to standard UART code.

    None of us learn this stuff overnight -- spend some more time and it will come together. I'm on the road and am really not one to give long-winded explanations of working code ( unless it's in my Nuts & Volts column! tongue.gif )
  • P!-RoP!-Ro Posts: 1,189
    edited 2009-03-26 19:42
    I'm sure I'll figure it out eventually. Thanks for the code Jon.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-26 20:09
    I'm on the road right now with my own SX-based products being launched this weekend (one through EFX-TEK, two other designs I did for other companies). When I get back I'll setup a test to prove the viability of the scheme. I hope I didn't sound short or not wanting to help, with three products needing to launch this weekend I'm WAY behind on sleep and nutrition....
Sign In or Register to comment.