compass serial port accses in xcode i phone

Discussion in 'iOS Programming' started by timpainter, Mar 20, 2011.

  1. timpainter, Mar 20, 2011
    Last edited: Mar 20, 2011

    timpainter macrumors newbie

    Joined:
    Mar 20, 2011
    Location:
    uk
    #1
    Hi i am new to mac programing
    I want to access the compass and tilt compensation function( object?) using the latest x code ios sdk
    can anyone point me in the right direction ?
    I all so would like to connect to a pic via a serial port?
    is this a problem ?
    Thanks Tim
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    XCode is just an IDE. I suspect where you say XCode you really mean Cocoa Touch.

    Look up Location Services in the API documentation for the compass and accelerometer.

    And there is no serial port access.
     
  3. timpainter thread starter macrumors newbie

    Joined:
    Mar 20, 2011
    Location:
    uk
    #3
    Hi
    Thanks for the reply
    Yes coca's the stuff to use i will persivere and find the relevent objects and methods

    do you know why we are not able to use the serial port? is this apples policy?
    may be i will try audio tone instead as i only need to transmit 3 states to a pic
    ??
    Thanks again
    Tim
    :rolleyes:
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Yes. There is no generic device access at all due to Apple policy. Either via the dock connector or bluetooth. You best/easiest option is WiFi with a discoverable server on the PC/Mac.
     
  5. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #5
    I believe Apple does allow third party access to the port, but you have to qualify your product. Sorry, I don't know the details of how to go about that. Ditto for Bluetooth beyond it's limited restrictions.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    The MFI program exists for peripheral manufacturers yes, but it does not allow generic access for the type the poster is talking about.
     
  7. hayesk macrumors 65816

    Joined:
    May 20, 2003
    #7
    I vote for WiFi - audio tone seems more trouble, and not very usable if you need more types of data. A little TCP server on your PC should be easy to do.
     
  8. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #8
    To use a serial device, such as a pic, you will a wifi to serial converter box, which still seem to be fairly expensive.

    Or you might be able to use another pic or other uP to convert modulated audio from the iPhone's headset jack to/from a serial data stream. (There's a university project which does this.)
     
  9. timpainter thread starter macrumors newbie

    Joined:
    Mar 20, 2011
    Location:
    uk
    #9
    Hi
    Thanks all for the advice I like the idea of using an wired audio tone to control a pic
    as it seems simple to impliment a frequency meaurement and tone generation with most pic microcontrolers
    KIS keep it simple

    Tim
     
  10. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #10
    There are several examples of apps using the serial port for data or analog I/O in the App Store already, so this should be OK. (Most visibly Square: https://squareup.com/)

    It just seems wrong after all these years to have to rely on an analog link at 1200 bps between digital devices that are perfectly capable of talking to each other digitally.

    I had hoped that the news last year that Apple approved a reference design for dock connector to serial ports http://www.ilounge.com/index.php/news/comments/apple-approves-serial-port-to-dock-connector-design/ was an indication of planned openness on the hardware end, but unfortunately not.

    B
     
  11. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #11
    It's possible to get a ton more than 1200 bps out of an iPhone's headset jack. Even fairly ancient modems with 100X slower DSP chips got a lot more bps out of telco quality mono over kilometer long wires.
     
  12. balamw, Mar 20, 2011
    Last edited: Mar 20, 2011

    balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #12
    Link please. I've seen the existence proof of sustained 1200 bps over the headphone jack http://www.perceptdev.com/labs/content/iphone-rs232-1200-baud-no-jailbreak-required-using-20-sdk published in the book but not much beyond that.

    I suspect the path from digital audio to the headphone jack is pretty transparent, but not necessarily the other way around. Is the raw A/D signal (for the mic input in particular) even available or has it already been processed by the time you get it.

    EDIT: What do you know, the reference design I mentioned earlier has actually turned into a real product http://www.redpark.com/news.html but it's tied to this Cisco console app. http://itunes.apple.com/us/app/get-console/id412067943?mt=8

    B
     
  13. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #13
    Also see this thread:
    http://forums.macrumors.com/showthread.php?t=1011028

    Around post #9, find "two IR diodes".

    The circuit is dead simple. The code to drive it, not quite so simple.

    Modular IR receivers are common and inexpensive, e.g.:
    http://www.radioshack.com/product/index.jsp?productId=2049727

    A distributer like Mouser.com or DigiKey.com has many more choices, but with all those options you have to know what to look for.

    For reference, Sony's SIRC protocol:
    http://www.sbprojects.com/knowledge/ir/sirc.htm
     
  14. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #14
    IIRC that's one way comms (from iDevice to IR to Arduino/PIC/etc...) right? and still low bandwidth. Right?

    B
     
  15. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #15
    Yes to both.

    I don't yet see the need for two-way high-speed communication, with the information given so far.
     
  16. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #16
    I don't see a need for high-speed bidirectional links here either, but just wanted to make sure the limitations of that approach were explicit.

    I do prefer to get some sort of ack back (where possible) even if by semaphore flags. So, bidirectionally even if highly asymmetric is desirable.

    B
     
  17. timpainter thread starter macrumors newbie

    Joined:
    Mar 20, 2011
    Location:
    uk
    #17
    Hi yes all very interesting but i only need to drive a couple of relays to control some hardware and recieve a reset signal . i have tryed a microsoftwindows
    version using rs232 dtr rts signal lines this works ok but i would like to use an iphone instead of a p/c

    another idea is pic s support tone dialing protocoll
    and is able to send 0 to 15 control tones any comments??
    Tim
     
  18. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #18
    reset from the PIC to the iPhone app (or vice versa)? relay commands from app to relay? Do you have to be able to query the status of the relays, or is it enough to send commands blind.

    It would seem like your application would work OK with 16 possible commands/responses and there is DTMF code already out there you could build on so why not.

    B
     
  19. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #19
    Much more than 16 if it works on DTMF sequences.

    And DTMF is easier to decode than FFT'ing it:
    http://en.wikipedia.org/wiki/Goertzel_algorithm
     
  20. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #20
    Of course, just keeping it simple, which seems fine for the level of complexity described.

    Even a two digit sequence requires more work to validate the stream so why go there unless you have to.

    B
     
  21. timpainter thread starter macrumors newbie

    Joined:
    Mar 20, 2011
    Location:
    uk
    #21
    reset would be from pic to phone hi/low phone to relays(2) would be blind
    Tim
     

Share This Page