Shop OBEX P1 Docs P2 Docs Learn Events
iOS to Propeller programming proof-of-concept — Parallax Forums

iOS to Propeller programming proof-of-concept

dgatelydgately Posts: 1,630
edited 2014-03-20 15:58 in Propeller 1
There are several discussion threads in response to Ken's original post asking for possible iPad-to-Propeller solutions for programming and controlling robots and other Propeller-based devices. There are some great projects being developed based on that thread...

This thread is more a direct response to the original post and discusses a native iPad/iPhone app solution.

I'm developing an iOS app (iPhone and iPad compatible) that runs a version of openspin. At this point, my project is just a proof of concept for editing, compiling and loading of .spin-based projects.

The current status is that the app can:
  • create new .spin files and edit them
  • upload previously created .spin files as well as .spin libraries (from eMail, websites, other apps, etc.)
  • compile .spin sources and included libraries
  • display compiled results data (binary or eeprom type, file size, etc...)
  • send all file types (.spin, .eeprom, .binary) to other apps (such as eMail) for transport to other devices
  • communicates via Bluetooth LE to a modified Bluetooth Xbee (upgraded with a Bluetooth LE HM-10 module), attached to an Activity Board
  • compiled projects have been tested, though loading took place from a MacBook Pro

Current work "in-progress":
  • working on transport of compiled binary to RAM
  • working on transport of compiled eeprom to EEPROM

Future work:
  • provide other transport support (XBee WiFi type devices)
  • provide a terminal for display of running program output/input
  • port application to Bluetooth LE enabled Android devices

I'm looking for help in the loader aspect of this project. Since the HM-10 device that I am using does NOT currently support a binary transport mode, I'm developing a simple text-based solution for this. See further posts for progress on that front. Suggestions and comments are welcome.


Looking for other discussions on cross-platform propeller development? see these threads:

http://forums.parallax.com/showthread.php/153214-Open-Propeller-Project-1-iPad-to-ActivityBot

http://forums.parallax.com/showthread.php/152711-A-Propeller-WebTool-Framework-for-Compiled-Languages

dgately

Comments

  • dgatelydgately Posts: 1,630
    edited 2014-01-16 12:22
    In response to several questions in another thread...

    What kind of project is this?

    The iPad app uses the Apple's Core Bluetooth framework, which allows communication to a Bluetooth LE (HM-10) module that I've shoe-horned onto a Bluetooth XBee board after removing the Bluetooth 2.0 module (HC-06). The pinouts of these two modules are similar, though not exactly the same. That board is plugged into the Activity Board's XBee socket and wired like any XBee device. (http://www.jnhuamao.cn/bluetooth.asp?ID=1)
    The BTLE device I am using is built by Jinan Huamao technology Co,. Ltd. The onboard firmware, labelled HMSoft version 5.21 and greater handles the BTLE connection as a peripheral device, responding to Core Bluetooth API on an iOS device. The company provides sources for an example application that runs on iOS devices. They have Android examples as well!


    What approach you plan for the loader?

    It appears that a method very similar to previous XBee loader methods is needed. Right now, my issue is sending binary data rather than textual data.
    Here's one example (Soft Loading an Application Image into the Propeller P8X32A via XBee Transceivers): http://www.parallaxsemiconductor.com/an007 Discussion thread at: http://forums.parallax.com/showthread.php/127780-Upload-Prop-programs-via-XBee?highlight=XBee


    How much space does the Bluetooth code take? Can it run entirely in a COG so you can have the loader fill all of hub memory with the user program?

    On the Propeller side, the Bluetooth device is just another UART connection. The HMSoft firmware responds to AT+ type commands to set up the UUIDs and modes needed to communicate to a "central" Bluetooth device, such as an iPhone, iPad or Android device. There is so far, very little code on the Propeller side. I send about 8 commands to the device to create an LE server (peripheral).


    Also, how will you provide a console link back to the iPad after the user's program starts? Can you share your approach with Bluetooth?

    Gee, great question... That's on my list of things to think about once I have a basic communication link between the iOS device and the prop.


    Where I bought the Bluetooth LE module: http://www.ebay.com/itm/wireless-MBT...item3f2efbc862

    More answers in the next post...

    dgately
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-16 12:28
    dgately wrote: »
    I'm looking for help in the loader aspect of this project. Since the HM-10 device that I am using does NOT currently support a binary transport mode, I'm developing a simple text-based solution for this. See further posts for progress on that front. Suggestions and comments are welcome.
    I got my ActivityBoard communicating with my Xbee Wi-Fi module using the Xbee's API frame mode and have been able to talk locally to the Xbee using API frames. So far I haven't been able to receive IPv4 frames from another network node attempting to connect to the Xbee but I'm going to work on that more tonight. The Xbee frame driver is written in PASM and runs in a COG and handles both sending and receiving Xbee frames. The rest of the code will initially be written in C using the CMM memory model running from hub memory. That's how my test program works now. If I can start getting IPv4 packets into the Propeller I think I'll be a long way towards getting a loader working. After that, I need to figure out how to handle console I/O that normallly goes through P31/P30. If this gets done before you find another solution, you're welcome to use it.
  • dgatelydgately Posts: 1,630
    edited 2014-01-16 12:37
    Dave Betz asked: You mention that your Bluetooth module responds to AT commands. Does it also support the Xbee "API mode" where you can send/receive binary frames?

    There is a limited set of AT ''type' commands that the module responds to. URL to the datasheet which provides the command set: http://www.jnhuamao.cn/Bluetooth40_en.zip. No API mode, currently! I do know that the developer is actively working on Firmware updates and recently updated the version to 5.21 and added commands to support iBeacon advertisement, which makes the module easy to find from iOS and Android devices.

    Since the module currently appears to support text modes only, there is a definite need for a transmit/receive layer on both sides of the load method. That's why I need help from folks like you!


    tdlivings commented: Instead of sending binary data send text like in the olden days using Motorola S Records or something similar. This way you are just using the serial connection you already have to send the text. On the Prop side the loader becomes a parser in front of the present Prop loader that can parse the SRec data back to binary.

    Yes, good suggestion as the device does appear to be text-only for current firmware versions. Thanks for your suggestions!


    This would also require OpenSpin and PropGCC to output SRec's files to be sent wireless.

    Not necessarily... openspin returns a binary file that iOS can open and read into an NSData object. That object will get broken down into small byte streams that will be sent as characters (C chars) and then re-constituted (like grape juice from concentrate :innocent:) on the propeller side.


    Just a suggestion to think about http://en.wikipedia.org/wiki/SREC_(file_format)

    Yes, reading that now. Thanks!


    dgately
  • tdlivingstdlivings Posts: 437
    edited 2014-01-16 13:24
    Here is another link on S-Records
    In the early days of micros 6800 etc S-Records were the way to save the assembler output and to load
    the output into RAM or the EEPROM burner.
    Intel had their Intel HEX format. Same concept
    Still used but we now have elf files to describe the compiler image to be loaded.

    Sending text is the way to go as trying to send raw binary. if you try and send binary 0x10 it looks like a line feed so send "10" two ASCII chars

    http://www.x-ways.net/winhex/kb/ff/Motorola-S2.txt

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-16 13:27
    tdlivings wrote: »
    Here is another link on S-Records
    In the early days of micros 6800 etc S-Records were the way to save the assembler output and to load
    the output into RAM or the EEPROM burner.
    Intel had their Intel HEX format. Same concept
    Still used but we now have elf files to describe the compiler image to be loaded.

    Sending text is the way to go as trying to send raw binary. if you try and send binary 0x10 it looks like a line feed so send "10" two ASCII chars

    http://www.x-ways.net/winhex/kb/ff/Motorola-S2.txt

    Tom
    If you want to use S-Records, a trivial binary to S-Record translater could be written in short order. I'm pretty sure they already exist though. In fact, it looks llike the GCC linker can output S-Records based on a command line option.
  • tdlivingstdlivings Posts: 437
    edited 2014-01-17 15:08
    Dave
    Thank's for the info.
    If the GCC linker can output S Records would there be an option that could be entered into SimpleIDE
    to dump the S Records out.

    My brainstorming is thinking if we can send over the air by some means the S-Records for program and the
    receiver can then read them and wiggle pins 30 and 31 just like the PropTool or SimpleIDE the Prop development
    board i.e. Activity Board does not even know it is not a direct serial connection.

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 15:12
    tdlivings wrote: »
    Dave
    Thank's for the info.
    If the GCC linker can output S Records would there be an option that could be entered into SimpleIDE
    to dump the S Records out.

    My brainstorming is thinking if we can send over the air by some means the S-Records for program and the
    receiver can then read them and wiggle pins 30 and 31 just like the PropTool or SimpleIDE the Prop development
    board i.e. Activity Board does not even know it is not a direct serial connection.

    Tom
    I'm not sure I follow. Who is "the receiver" in your model? I thought you had the Xbee module plugged directly into the ActivityBoard. In that case, the receiver is the ActivityBoard and it doesn't need to wiggle pins 30/31 to effect a download. Or do you have another Propeller or some other processor connected to the Xbee module?
  • tdlivingstdlivings Posts: 437
    edited 2014-01-17 15:34
    Dave
    Yes the Activity board with an XBEE is the receiver.
    I was not revering to physical hardware serial connection when I said wiggle the pins bu
    instead can we create or already have software to take the S-Record description of a program
    and send it into the serial port on 30,31 to load it just as if it came from the PropTool or SimpleIDE

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 16:11
    tdlivings wrote: »
    Dave
    Yes the Activity board with an XBEE is the receiver.
    I was not revering to physical hardware serial connection when I said wiggle the pins bu
    instead can we create or already have software to take the S-Record description of a program
    and send it into the serial port on 30,31 to load it just as if it came from the PropTool or SimpleIDE

    Tom
    I still don't understand. If the Xbee is plugged into an ActivityBoard and it is running a program that is receiving an S-Record file from some other machine over a TCP/IP or Bluetooth connection, then it can't send it to pins 30/31 since the ROM loader is not running and so the data sent to those pins would have no effect. This would only work if you have two ActivityBoards, one running this S-Record listener and sending the resulting data to another ActivityBoard that is running the ROM loader. My idea was to have only one ActivityBoard that boots into a loader program on reset. That loader program loads code into a COG that listens for connections from the Xbee and loads hub memory with any data received. If for some reason a binary link is not possible, that COG would also have to convert S-Records to binary before loading data into hub memory. When it was done loading it would start the Spin interpreter from ROM to get the program running. Pins 30/31 would not be involved at all unless they happen to be the pins used to communicate with the Xbee.

    Am I completely misunderstanding what you're trying to do?
  • tdlivingstdlivings Posts: 437
    edited 2014-01-17 20:02
    Dave
    No way to miss understand as I was thinking out loud but do not have a complete concept
    yet. Just thinking of various pieces.

    After reading your last post it hit me that what I was really visioning was a separate box
    which received S-Records over the air and had a serial port on the
    output that connected to the serial port on the Prop development board and downloaded the program
    to the board the same as the PropTool. The Activity Board would not know it was not actually connected
    to a PC USB serial port but instead to this separate box acting as a PC USB serial port.

    Maybe it can even receive an email from Tech Basic containing the S-Records and download the code.

    As I said thinking of the various pieces
    Thank's for the info on your thoughts

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 20:46
    tdlivings wrote: »
    Dave
    No way to miss understand as I was thinking out loud but do not have a complete concept
    yet. Just thinking of various pieces.

    After reading your last post it hit me that what I was really visioning was a separate box
    which received S-Records over the air and had a serial port on the
    output that connected to the serial port on the Prop development board and downloaded the program
    to the board the same as the PropTool. The Activity Board would not know it was not actually connected
    to a PC USB serial port but instead to this separate box acting as a PC USB serial port.

    Maybe it can even receive an email from Tech Basic containing the S-Records and download the code.

    As I said thinking of the various pieces
    Thank's for the info on your thoughts

    Tom
    Okay, now I understand. If you're talking about a separate box between the PC and the ActivityBoard then what you're suggesting makes sense. I was trying to do the Wi-Fi handling on the ActivityBoard itself.
  • dgatelydgately Posts: 1,630
    edited 2014-01-26 09:58
    Some progress on 2 iOS apps...

    First, an app I've named "spinTab" (as in: Spin Tablet), an iPhone/iPad app that uses the openspin compiler to compile & edit Spin code. It's in an XCode project that at this time is based on a Bluetooth LE communications link. I'm using an HM-10 module, that has been soldered to a Bluetooth XBee adapter (details below). Current status: App can compile spin code, transfer compiled data to the ActivityBot. Not sure if Bluetooth LE provides an efficient means for transfer of compiled code (small packet size of 20 bytes, total)...



    Second, a robot controller, similar to the techBASIC controller demonstrated in the other forum thread. This is a native iOS app, that communicates view Bluetooth LE (commands are small packages < 20 bytes). The UI provides for speed, direction, rotation of an ActivityBot as well as switches/buttons for I/O control. Right now, I'm working on parsing commands from the serial stream. I've ported Jonny Mac's spin-based Human Friendly Control Protocol (jm_hfcp.spin) to C and am getting that to handle the commands.



    Bluetooth LE:

    Since there are currently no Bluetooth LE modules in XBee form that I've found for sale, I've modified a non-LE HC-06 Bluetooth XBee adapter. The HM-10 pinout is fairly close to the pinout of an HC-06 module. I de-soldered the HC-06 from the XBee adapter, soldered the HM-10 in its place. Pin 23 of the HM-10 likes to be pulled-up to 3.3 volts, so I soldered a 4.7K ohm resistor between pin 23 and 3.3 volts. I was informed by this article on the Lets Make Robots website @: http://letsmakerobots.com/node/38009

    Links:



    Issues:

    At this time, Bluetooth LE module configuration methods are not standardized. Module developers provide their own firmware. The AT command (in firmware) set for the modules I am using is developed by HMSoft, which is the software side of JNHuamao, a company in China. HMSoft provides iOS and Android sample code, for the tablet/phone side. Any code written for the prop side of the coin, would need to be modified for different Bluetooth LE modules. And, LE packet size on iOS and Android is limited to 20 bytes per transfer. As a means to transfer binary code, you can pass about 16 bytes per packet, which is NOT efficient. Moving spinTab to support WiFi Xbee type devices seems to be the better solution.


    That's my update for now...


    dgately
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-01-26 20:32
    Following this with interest.

    There one in XBee footprint, the BLEBee from Seeedstudio, currently out of stock but word is it will be back "soon".

    Here is developer Micheal Kroll's github, and forum. Don't know if he is still looking for beta testers!
  • Don MDon M Posts: 1,652
    edited 2014-01-27 04:00
    dgately wrote: »
    Some progress on 2 iOS apps...

    First, an app I've named "spinTab" (as in: Spin Tablet), an iPhone/iPad app that uses the openspin compiler to compile & edit Spin code. It's in an XCode project that at this time is based on a Bluetooth LE communications link. I'm using an HM-10 module, that has been soldered to a Bluetooth XBee adapter (details below). Current status: App can compile spin code, transfer compiled data to the ActivityBot. Not sure if Bluetooth LE provides an efficient means for transfer of compiled code (small packet size of 20 bytes, total)...



    Second, a robot controller, similar to the techBASIC controller demonstrated in the other forum thread. This is a native iOS app, that communicates view Bluetooth LE (commands are small packages < 20 bytes). The UI provides for speed, direction, rotation of an ActivityBot as well as switches/buttons for I/O control. Right now, I'm working on parsing commands from the serial stream. I've ported Jonny Mac's spin-based Human Friendly Control Protocol (jm_hfcp.spin) to C and am getting that to handle the commands.



    Bluetooth LE:

    Since there are currently no Bluetooth LE modules in XBee form that I've found for sale, I've modified a non-LE HC-06 Bluetooth XBee adapter. The HM-10 pinout is fairly close to the pinout of an HC-06 module. I de-soldered the HC-06 from the XBee adapter, soldered the HM-10 in its place. Pin 23 of the HM-10 likes to be pulled-up to 3.3 volts, so I soldered a 4.7K ohm resistor between pin 23 and 3.3 volts. I was informed by this article on the Lets Make Robots website @: http://letsmakerobots.com/node/38009

    Links:



    Issues:

    At this time, Bluetooth LE module configuration methods are not standardized. Module developers provide their own firmware. The AT command (in firmware) set for the modules I am using is developed by HMSoft, which is the software side of JNHuamao, a company in China. HMSoft provides iOS and Android sample code, for the tablet/phone side. Any code written for the prop side of the coin, would need to be modified for different Bluetooth LE modules. And, LE packet size on iOS and Android is limited to 20 bytes per transfer. As a means to transfer binary code, you can pass about 16 bytes per packet, which is NOT efficient. Moving spinTab to support WiFi Xbee type devices seems to be the better solution.


    That's my update for now...


    dgately

    Where do you buy the HM-10 modules?
  • dgatelydgately Posts: 1,630
    edited 2014-01-27 09:00
    Don M wrote: »
    Where do you buy the HM-10 modules?

    That's a good question! I bought 2 HM-10 modules off of eBay (around $16.00 U.S.) from seller: http://www.ebay.com/usr/nuannuan0411

    Now, I only see this very oddly-priced item: http://www.ebay.com/itm/wireless-MBTV4-bluetooth-4-0-module-Low-Energy-BLE-module-Serial-port-module-ios-/271371192418?pt=LH_DefaultDomain_0&hash=item3f2efbc862. Either it's a mistake or the pricing is for 10 of these modules... Hmm!

    Here are two websites where the modules can be purchased ($6.50 U.S.):



    dgately
  • dgatelydgately Posts: 1,630
    edited 2014-01-27 09:07
    Following this with interest.

    There one in XBee footprint, the BLEBee from Seeedstudio, currently out of stock but word is it will be back "soon".

    Here is developer Micheal Kroll's github, and forum. Don't know if he is still looking for beta testers!

    Yes, those have been out-of-stock for a while... Of course, firmware will be different so AT commands will most likely be different, as well. I picked the jnhuamao modules because of the Let's Make Robots article which explained how to use them and jnhuamao seems to be actively developing firmware and has produced several (4) updates since I've purchased. The updates were in support of iBeacon advertisement, which iOS uses to find the modules. I'll take a look at the other modules and the software at github. Thanks Tracey!


    dgately
  • dgatelydgately Posts: 1,630
    edited 2014-01-29 16:39
    A bit of an update...

    The Robot Control iPhone/iPad app can now send a few primitive commands to the ActivityBot. P26 & P27 LEDs can be turned on & off. The speed UI control now sends data that makes the ActivityBot move forward, though it's still a bit sketchy as to its actual movement (goes forward, turns right, goes a bit more forward, makes a u-turn; all this when the command was just forward movement). It appears that the commands are reaching the bot far faster than it is able to consume them.

    My question is, "How often should I allow the sending of commands that move the bot (as opposed to commands that turn LEDs non & off)?" What's a typical time between events for RC controllers (for RS planes & copters) as they send them via radio? As the user slides the control up & down, to increase forward speed, reduce speed or even reverse the bot, how often should I send speed values to the bot?

    I've been working from the idea of sending raw data as fast as I can send it from the iPad, then timing the execution of movement type events on the prop side. Of course, I would probably need to throw out some commands as they fill up a queue, in order to keep the bot in sync with more recent commands. I would not throw out important commands like stopping the bot, reversing its movement, etc... Though, this tact will be problematic if the bot is to do anything precisely, right?

    Any ideas are quite welcome!


    dgately
  • photomankcphotomankc Posts: 943
    edited 2014-01-30 06:36
    Can you change it to something where you only send commands when something changes but otherwise just send "I'm still here" messages so the bot knows it's still under control?

    So:

    Turn Right at speed X
    Still Here
    Still Here
    Forward at speed X
    Still Here
    Still Here
    Still Here
    Still Here
    Stop
    Still Here
    Still Here



    That would seem to make it possible not to need to process commands nearly as fast and if you can short-circuit the rest of the command parse for "Still Here" then you can react quickly and stop if the controller stops communicating for a couple of check periods. You would stay responsive to commands that make the bot change it's motion, and not need to discard commands or stream them constantly.
  • Stephen MoracoStephen Moraco Posts: 316
    edited 2014-03-19 23:16
    dgately,

    One thought... while we won't for now get a compiler into the app store, we could still team up on the app if it were in GitHub and those of us who are iOS developers could download it, build it and run it on our own iPads/iPhones.

    Is this something you'd consider? (posting it to GitHub and letting some of us contribute to it and letting all of us benefit from its existing?) If you've already posted to GitHub or here, forgive my enthusiasm, I'm just catching up on posts! (But let me know where ;-)

    I'd be a great tester and contributor, for example ;-) I would also consider working on a propeller download BLE service spec as well as a Bi-directional propeller debug service. which we could implement in our BLE hardware making the app work for all who built in these services.... Just some thoughts.... ;-)

    -Stephen, KZ0Q
  • dgatelydgately Posts: 1,630
    edited 2014-03-20 11:15
    dgately,

    One thought... while we won't for now get a compiler into the app store, we could still team up on the app if it were in GitHub and those of us who are iOS developers could download it, build it and run it on our own iPads/iPhones.

    Is this something you'd consider? (posting it to GitHub and letting some of us contribute to it and letting all of us benefit from its existing?) If you've already posted to GitHub or here, forgive my enthusiasm, I'm just catching up on posts! (But let me know where ;-)

    I'd be a great tester and contributor, for example ;-) I would also consider working on a propeller download BLE service spec as well as a Bi-directional propeller debug service. which we could implement in our BLE hardware making the app work for all who built in these services.... Just some thoughts.... ;-)

    -Stephen, KZ0Q

    Stephen,

    Yes, I'm good with all of this. I'm a little out of time for the next week as I've got a webpage to build for another project. Let me look at the sources and see what I can do about posting to github. One thing I need to update is in bringing-in the latest openspin source to compile inside the app project. I'll update this thread when I've had time for that.

    Thanks,
    dgately (Dennis)
  • Stephen MoracoStephen Moraco Posts: 316
    edited 2014-03-20 15:58
    dgately wrote: »
    Let me look at the sources and see what I can do about posting to github. One thing I need to update is in bringing-in the latest openspin source to compile inside the app project. I'll update this thread when I've had time for that.

    Dennis, I'll be watching for news... Thanks!

    Stephen- KZ0Q
Sign In or Register to comment.