Shop OBEX P1 Docs P2 Docs Learn Events
Bluetooth Programming [Demo] — Parallax Forums

Bluetooth Programming [Demo]

UnsoundcodeUnsoundcode Posts: 1,532
edited 2011-12-30 17:42 in Propeller 1
A few days ago in another thread I discovered that it is possible to program the Propeller over a Bluetooth connection using the Prop tool IDE. The other thread required a method independent of the Prop tool so I thought it worth posting a demo of the method I used in this new thread.

The hardware is nothing special and open to other configurations. The main piece of software revolves around a copy of the Propellers ROM boot loader. Modifications to the boot loader included reassigning serial port pins to match the Bluetooth and reassigning pins to match an additional EEPROM for program storage. My Bluetooth had no way of resetting the Prop so I had to make a couple more modifications that make the new boot loader viable

1. A 15 second (adjustable) time out value while the loader monitors its rx line for activity. Those 15 seconds are the programming window, if it times out then the secondary EEPROM image is loaded.

2. The loader in its original form has error checking that shuts the system clock down on error requiring a manual reset of the Propeller to continue. This behavior was modified to reboot the Prop allowing a second or more chances at programming via Bluetooth.

While testing I had communications running in its own cog, in this case simply an rx routine looking for a character which would call a reboot method, the reboot method presents you with the 15 second programming window. As long as the reboot method is included with every downloaded program the rest of the programming cycle takes care of itself and requires no additional code.

The pros and cons of all this, in its favor the code is compact, flexible, fast and fairly immune to getting in a situation where a manual reset would be needed. Downloads to RAM or EEPROM are possible just as with the Prop tool. There was really only one thing I had issues with and that was its failure to connect to the PC first time every time, probably more of an irritation while testing than when in use.

I have a simple demo on YouTube at this link http://youtu.be/LOyYW9ISQNk

Jeff T.

Comments

  • Don MDon M Posts: 1,653
    edited 2011-12-26 18:26
    Jeff- Could you attach your complete code for this demo?

    Don
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-12-26 18:52
    Hi Don, if you look at the ASM ( BT_Loader ) right at the bottom are the Constants, the first 5 are masks for the

    "Program mode LED" (P2)
    Serial rx (P1)
    Serial tx (P0)
    EEPROM sda (P26)
    EEPROM scl (P27)

    in that order
    the last constant "rebootdelay" is the length of time to stay in program mode

    BT_Loader is the program I loaded into the lower 32K of EEPROM

    if you go with a 64K EEPROM the address settings in the i2c routines will need adjusting

    I also attached BT_#1.spin which was one of the programs I used to test the BT coms and it has the terminate method that reboots the Prop from a terminal window. (using character "A")

    It also helps a little if you have the latest Prop tool , in port management there is the "post reset delay" , I set that to 200mS, I think that helped but I was doing fine before I altered it.

    The Bluetooth module I used was a Bluesmirf gold with default settings, I cannot say how other modules will respond.

    Jeff T.

    EDIT: I described "Program mode LED" (P3) when it should have been P2, I have corrected that in the text
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-12-27 09:59
    Hi, if you want to adjust the BT_Loader to read and write the upper 32K of a 64K EEPROM I think all that is needed is a constant and two additional lines in the ASM. Locate the ee_write routine (line #213) and add the two lines shown in the following
    Deleted for now, I need to revisit this
    
    

    then add this to the constants

    Upper_32K Long $8000

    It should be ok, I don't have any 64K to try with right now.

    Jeff T.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-12-30 14:45
    Unsoundcode: You have just given me another idea...

    Scanlime did a USB Bluetooth interface for the Prop. These USB bluetooth devices can be had for well under $2 and they are a tiny pcb that can be removed from the frame and soldered to a pcb via RA pins. Using a dedicated prop and USB bluetooth would in fact be cheaper than a bluesmirf.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-12-30 17:42
    Hi Cluso99, the Bluesmirf is something I had already in my box of misc. parts. I originally bought it because it has CTS/RTS but from what I can make out they can’t be used in SPP mode. I don’t remember what it cost maybe $25 to $35, they must have seen me coming.

    I can’t take credit for the BT_Loader it is actually the Propellers own boot loader. What I did discover though was that instead of going straight into the handshaking protocol it was possible to sit and wait indefinitely or with an extended timeout and still trigger from the Proptools serial port initialization. What amazed me even more is that once the protocol has been accepted then it will rarely fail to load EEPROM or RAM over a Bluetooth connection. I keep trying different files and file lengths and I am seeing 98% success as of now at distances of 4 or 5 meters. Of course other BT modules may vary, I would be interested to see what results you get from a $2 module. The YouTube thing was supposed to demonstrate a little more but my wife’s cam went dead on me thus the abrupt ending.

    A note to all, I edited my previous post because the code was way of track, accessing the upper 32K of 64K is very possible, I just didn’t get it right this time. For someone with ASM skills it should not take more than a couple of minutes to figure it out.

    Jeff T.
Sign In or Register to comment.