Alternative Open Propeller Project #1: Android to Propeller BOE
John Abshier
Posts: 1,116
I don't, won't, buy Apple. Not sure what I would do if given one. So this project will be Android to Propeller.
A little background about my strengths and many more weaknesses. A little over 50 years ago I started programming in FORTRAN with card on an IBM 1401. I did a little FORTRAN programming while getting an Aerospace Engineering degree in the late 1960's. Then I too a little over a decade off from programming to shoot cannons and fly helicopters. I then became an Operations Research Analyst, getting a MS in Computer Science with an emphasis in Operations Research. I have never been a professional programmer, but have programmed to do my job and also as a hobby (mainly robotics). In one organization we couldn't even admit to programming since that was reserved for the Directorate of Management Information Systems. I have programmed in various FORTRANs, BASICs, Pascal, PL/I, GPSS H, Simscript II.5, Java, Dynamo, C, AWK, Python, RCA machine language (hand assembled), IBM 360 assembler, and, of course, Spin and PASM. Also, although some may not consider them programming languages, SAS, SQL, Lotus 123, and Excel. I wonder if anyone recognizes all those languages without Google. Network programming experience: none, nada, zilch. Android programming experience: see network programming.
On the Prop side I will be using a BOE, because that is what I have. It should generalize to the Activity Bot. I will use Spin. I know it and Spin will save the time of learning the Prop specific idioms of C for the Prop.
Connection between Android devices and the Prop will be by a Digi XBee S6B. Bluetooth would be another option. A hard wired USB connection looks to be feasible but harder than I want to attack.
Android devices will be an old DroidX, a Galaxy S III, and old and new versions of Nexus 7.
I considered five languages for Android. MIT's App Inventor for Android, a graphical 12 Blocks, Scratch, like system would work over Bluetooth. Java, I looked at it and didn't want to go there. Basic4android is a commercial product ($59 with 2 months free upgrades) may be the best solution, especially if you want to use the USB connection. RFO BASIC! is a free dialect of Dartmouth BASIC that allows you to write and run programs directly on an Android device (http://laughton.com/basic/). I was tempted to use RFO BASIC! and may go back to it if time and interest level allow. I selected Processing mainly because it had more books listed on Amazon. Processing is to JAVA as Arduino code is to C/C++
John Abshier
A little background about my strengths and many more weaknesses. A little over 50 years ago I started programming in FORTRAN with card on an IBM 1401. I did a little FORTRAN programming while getting an Aerospace Engineering degree in the late 1960's. Then I too a little over a decade off from programming to shoot cannons and fly helicopters. I then became an Operations Research Analyst, getting a MS in Computer Science with an emphasis in Operations Research. I have never been a professional programmer, but have programmed to do my job and also as a hobby (mainly robotics). In one organization we couldn't even admit to programming since that was reserved for the Directorate of Management Information Systems. I have programmed in various FORTRANs, BASICs, Pascal, PL/I, GPSS H, Simscript II.5, Java, Dynamo, C, AWK, Python, RCA machine language (hand assembled), IBM 360 assembler, and, of course, Spin and PASM. Also, although some may not consider them programming languages, SAS, SQL, Lotus 123, and Excel. I wonder if anyone recognizes all those languages without Google. Network programming experience: none, nada, zilch. Android programming experience: see network programming.
On the Prop side I will be using a BOE, because that is what I have. It should generalize to the Activity Bot. I will use Spin. I know it and Spin will save the time of learning the Prop specific idioms of C for the Prop.
Connection between Android devices and the Prop will be by a Digi XBee S6B. Bluetooth would be another option. A hard wired USB connection looks to be feasible but harder than I want to attack.
Android devices will be an old DroidX, a Galaxy S III, and old and new versions of Nexus 7.
I considered five languages for Android. MIT's App Inventor for Android, a graphical 12 Blocks, Scratch, like system would work over Bluetooth. Java, I looked at it and didn't want to go there. Basic4android is a commercial product ($59 with 2 months free upgrades) may be the best solution, especially if you want to use the USB connection. RFO BASIC! is a free dialect of Dartmouth BASIC that allows you to write and run programs directly on an Android device (http://laughton.com/basic/). I was tempted to use RFO BASIC! and may go back to it if time and interest level allow. I selected Processing mainly because it had more books listed on Amazon. Processing is to JAVA as Arduino code is to C/C++
John Abshier
Comments
John Abshier
Would you like us to get behind your OPP Alt #1? This is what our involvement would mean:
- we rename your project OPP #2 (eventually these will become stickies, until there are too many and we'll find another alternative)
- we add a graphic to the first post
- we drive a little more attention to it, sometimes distributing hardware to key parties to help them move forward with the effort
- occasional check-in, and when it's mostly "done" we mark it as such and people can freely harvest the code, etc
Please let me know.
Ken Gracey
Parallax Inc.
John Abshier
I am tempted to jump to Part III--Using Peer-To-Peer Networking, but I will be not posting much as I work thru parts I and II, using the screen, sensors, and cameras.
John Abshier
Warning, big download straight ahead! I had to download the 32-bit version since the 64-bit version didn't work with my JDK1.7. No idea why. Both packages are 0.5GB.
John Abshier
I don't know why there is a blank line between "Sending to WiFi num" and the name read.
John Abshier
Today I finished Chapter 2: Working with the touch screen display. Several things didn't work because Processing changed. My paper copy of the book arrives Tuesday and is a few months later than the draft electronic copy I am using. Next chapter is motion and position sensors. Still a ways to go to get to WiFi and WiFi Direct.
John Abshier
I played around with the android SDK a couple of years ago and never did much with it. I fired it up today, updated some files ,sent a "hello Brian" program to my tab3 and it worked. I don't know how much help I will be for you, but at least I can test stuff on my end.
My Tab 3 is version 4.1 android.
Brian
I am interested in using Android with a Cubieboard as an interface to the Propeller. While the Raspberry Pi might provide Android, or I could buy an Android pad of some sort, the Cubieboard offers me lower cost that the pad, and more power than the Raspberry Pi.
Is this going to be committed to an Xbee wireless interface, or are other alternatives being considered (Wifi, Bluetooth, and such)?
www.cubieboard.org
blue tooth to serial, OBC has played with this project
I used the usb library to connect to the propeller plug or it will work with any FTDI board
John Abshier
I started on hardware but never moved into android dev.. thats basically the only thing stopping the prop from taking over the android.
Im surprised parallax hasn't already hired an android dev to make a parallax serial terminal for android, and even a Propeller (android)Tool for on the go prop dev.
Bluetooth is the best method, then usb.
I needed to buy a special usb converter from samsung for my tab2.
So cheapest method would be to get a bluetooth device for the prop.
(but it needs a working DTR or RTS in both android and on the prop side bluetooth module)
http://www.parallax.com/product/30086
And dev an android app. to serially talk to the prop over bluetooth spp (serial profile).
Here is a Processing program to send data to the Propeller
Here is a sample of the output to my PC.
John Abshier
Edit: PS. Cannot get to work on Android devices.
PPS. Google and persistence will eventually pay off. Nexus 7 to Propeller successful. Two things required. First, Processing sketch must have a directory "code" That directory must have a copy of net.jar. Second, in Processing IDE, go to Android-Sketch Permissions and check the internet box.
Great project. I've been doing Android apps using various methods including Java, HTML5 & Phone Gap and for the past few months Delphi XE5. My latest project is with the propeller chip- Bluetooth to Delphi XE5/Android. I'll follow your progress with interest.
Bob
The book I am using has a chapter titled, Networking Devices with WiFi and one titled Peer-To-Peer Networking Using Bluetooth and WiFi Direct.
What is the title of the book?
John Abshier
And for Android
Three grumpy old man observations:
1. I am not even close to fluency in Processing. Lots of dumb errors and time looking stuff up. The Processing web site Reference page is nice.
2. The men (I assume they are men.) responsible for the LF, CR, LF+CR mess and not in hell only because God is forgiving.
3. The 30 or so seconds it takes to establish a WiFi connection seem like eternity when you are just siting watching the monitor and not sure your program works.
What's next. Sending and receiving from Prop to Android proves the project is feasible. I am reminded of something from the math world. Proving that something exists may be much easier than an algorithm to find it. What is needed is a protocol for the two devices to use for communication. I think there is an art to designing a protocol. Too simple, it may not be robust enough for the real world. Too complex, it will be slow, hard to implement, and impossible to understand. However, all is not lost. This wheel has been invented, and reinvented. On my Kindle I found a book that I haven't gotten around to reading: A Hardware Interfacing and Control Protocol, that uses the Propeller as its target microcontroller. Also a Google search for "robot communication protocol" gives 1,470,000 wheels.
John Abshier
And for Android
John Abshier
John Abshier
!<command><CR>[<integer><CR>]
The [] are not sent and items inside them are repeated 0 to n times.
The Android device is the master and initiates all messages. The slave Propeller will respond with data requested by command, if no data requested !ACK<CR>, or !NAK<CR> for error. Format for sending data is !<command><CR><integer><CR>[<integer><CE>] Master needs to know what to expect the Prop to return.
Protocol. ASCII or binary? The only advantage I see to binary is that it is faster. 128 requires 3 ASCII characters, 4 with <CR>, versus 1 for a byte. At the default XBee baud rate that is roughly 1 millisecond versus 3 or 4. Plus there is the time to encode/decode from binary to ASCII and back. The advantage to ASCII is that it is human readable. Some would say self documenting. What is 0xE1 compared to Set_left_motor_speed_with_ramping? To the computer there is no difference, they are both used in an if statement. The ASCII example given is not self documenting to a non-English reader. Sadly it is not self documenting to an English reader. Is it RPM, radians per second or a power level. If it is a power level, is it -100 to 100 or 0-255 with 0 being full reverse and 255 full forward? I am going to use ASCII to start because I can read it and also can type it in a terminal program for testing. If performance becomes an issue, I will increase the XBee baud rate and then consider switching to a binary format.
Many protocols have sender/receiver addresses. I don't need that because the combination of IP address/port number serve that purpose.
Most protocols have at least a checksum or a CRC for error discovery. I am going to rely on the TCP/IP stack.
I am not going to send a message length/number of data items. The command knows how many data items it needs.
I am assuming that with TCP/IP that if we have a connection, it is relible. But we could lose the connection at any time (Robot went into the culvert. Phone battery died.). So I need to know when the connection is lost and be able to resync when communication is reestablished. If the connection is lost the Propeller code will time out and resume looking for the ! sync character. Additionally, after a longer time out, the Propeller code will go into a "Safe" mode. The Android app should do something if the Propeller doesn't respond in a reasonable time. I haven't thought much about that.
Back to more reading.
John Abshier
I actually had to take a test in most of the languages you named off and some that were not listed. While you were off shooting the cannons I was state side as contractor fixing stuff that required the company of an armed guard.
The languages you mentioned do not seem to be in order though or at least not any order that I understand.
One of those languages dates me close to the time I decided to head closer to home and work field service instead of 'up Nawath' or 'way out west'. ]8>D
I had a good run because each time one of those companies listed bought all or part of another company in the list I was always kept on the job.
These days I carry nothing around with that will intrude with my concentration in keeping some tentative grasp on reality. (u do rd hippy code - right?)
Tim
<grinning like a mule eatin' briars>
re:Rapid Android Development: Build Rich, Sensor-Based Applications with Processing by Daniel Sauter (May 2, 2013)
Thanks!
This is the native way to make the Propeller idiot proof communicate with Android. I didn't have any real purpose beyond proving it worked, so I haven't built anything more elaborate.
Whether I wanted to or not, it seems the most direct way of supporting the Propeller is via a native Java app on Android. I have Eclipse and setup to do Android dev. It really helps if you're using Linux as the dev environment, as Android really works better with Linux IMHO.
John Abshier
John Abshier
<RANT> Spent hours getting the computer hooked up to my TV working again. I now think (after buying a different USB wireless network adapter) the offending software is the TV tuner driver. But I don't know for sure. Thirty years ago, I enjoyed the challenge of getting computers to work. Now I just wish they would work. </RANT>
John Abshier
John Abshier
At the top is a virtual joystick, click/tap in the gray circle to move the joystick. The go button enables the servos/motors. When enabled the go button is replaced with a red stop sign. The blue rectangle displays Ping reading. I haven't decided if it will be constantly updated or only updated when you click in the rectangle. The red and green rectangles at the bottom display status and toggle state of two LEDs.
I need to get a move on. The first shooting match of the year is only 3 weeks away and Prop time will decrease as shooting time increases.
John Abshier
PS. Sorry for small image size. If you click on it, you get an image big enough to read.
Today: If you (I) reverse dataOut and dataIn in a call to a serial driver start method, things don't work. And I can look at working and non-working code for a loooong time before seeing the difference. The next 4 or 5 days will be eaten by other priorities, but i hope to finish the application in the above post next week.
John Abshier