Bluetooth Programming [Demo]
Unsoundcode
Posts: 1,532
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.
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
"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
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.
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.
I cant 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 wifes 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 didnt 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.