Shop OBEX P1 Docs P2 Docs Learn Events
Open Propeller Project #1: iPad to ActivityBot - Page 3 — Parallax Forums

Open Propeller Project #1: iPad to ActivityBot

1356711

Comments

  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-17 07:47
    Heater. wrote: »
    Brian_B,

    I don't mean to belittle the project as such or Parallax's role in education.

    I do question the "Open Propeller Project" idea when it turns out there is nothing open about it's first project.

    My first expectation would have been that something called "Open Propeller Project" as an umbrella project would launch with a big splash about propgcc, SimpleIDE, openspin and a bunch of other open source tools that people have been sweating over for months and years now.
    Well, to be fair. I think any code that gets written as part of this project will be open. It's just that some of the tools needed to run it are not open. I'm hoping that eventually TechBasic could be replaced by jazzed's web-based interface and that would open it up to non-Apple devices. Of course, I'm certainly not a spokesman for this project and am barely even working on it. That's what I think the goal should be though.
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2014-01-17 07:56
    Heater. wrote: »
    Brian_B,

    I don't mean to belittle the project as such or Parallax's role in education.

    I do question the "Open Propeller Project" idea when it turns out there is nothing open about it's first project.

    My first expectation would have been that something called "Open Propeller Project" as an umbrella project would launch with a big splash about propgcc, SimpleIDE, openspin and a bunch of other open source tools that people have been sweating over for months and years now.

    Everything that we can make open, shall be open. There will always be parts of a project that can't be open for whatever reason, and we'll not get into the debates about where "open" begins and ends because in many ways parts of any project are closed (techBASIC app code, the iPad on which it runs, the XBee that sends the data, etc.). While we can debate the pieces of openness, perhaps the most important part is that the community is developing, their efforts are open, and everybody is sharing.

    But there's more coming in the future, including much attention towards the efforts you pointed to. We have stood by the three efforts you identified above, financially, technically, and support-wise over a long period of time and will of course continue to do so. In no way do I consider attention on something different to belittle those efforts.

    This project is only an ice-breaker of what's to come, depending on what we encounter as we proceed. Comments are fine, too.

    Ken Gracey
  • Brian_BBrian_B Posts: 840
    edited 2014-01-17 14:40
    Jeff,
    Got my xbee hooked up ,loaded your code on the ipad & ran it :

    Comm.openTCPIP(1,"my_xbee_ip",my_xbeeport)
    sensors.setAccelRate(0.01)
    DIM quit AS Button
    quit=GraphicsNewButton(10,10) <<<< getting "Runtime error: Type mismatch"


    Thanks' Brian
  • tdlivingstdlivings Posts: 437
    edited 2014-01-17 15:18
    David Betz wrote: »
    Didn't someone here say they were using the WiFly module that Sparkfun sells? It seems to have a better manual than the Digi Wi-Fi module but doesn't have the API mode where you can interact with the module with binary commands rather than ASCII. Costs the same amount as the Digi Wi-Fi module as well and it says it has 128k of RAM.

    Edit: Even though it has 128K of RAM it doesn't look like it is user accessible.

    Dave
    The Sparkfun WiFly page does show this as on of the features and I have seen a youtube using it to do http get's to
    get weather info from a web site.
    • Onboard TCP/IP stack includes DHCP, UDP, DNS, ARP, ICMP, HTTP client, FTP client and TCP
    I do not see that kind of statement on the Digi SB6 doc's , does not mean it does not though

    I have both a WiFly and SB6 on order from Sparkfun been 5 days since got ship notice email but no sign of them.
    I guess they are talking to each other in the box. LOL

    Today I ordered an SB6 from Parallax, a second one is needed to try and have them talk to each other anyway.

    I think it was UnSound that was using the WiFly

    Tom
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-17 15:24
    tdlivings wrote: »
    Dave
    The Sparkfun WiFly page does show this as on of the features and I have seen a youtube using it to do http get's to
    get weather info from a web site.

    Hi Tom,

    I'm trying to do the reverse of what you're describing. I want the Propeller attached to the Xbee WiFi module to act as a web server so I want the Propeller to be able to *receive* GET and POST requests, not send them. I think the Digi Xbee WiFi module can send GET and POST requests but it seems to have trouble receiving them and passing them on to the attached MCU (ActivityBoard in our case). I posted some questions on the Digi site but have received no answers so far. They're definitely not as good at customer support as Parallax! :-)
  • Brian_BBrian_B Posts: 840
    edited 2014-01-17 15:52
    Hi,
    I have 2 Xbee's, one hooked to my PC with the X-CTU program updated for the S6B's running and 1 in the PropBoe board with the DO and DI pin's connected. I'm trying to do a range test ,but I get no return ping ,any thoughts ?

    Thanks'
    Brian

    Edit , found the problem ,here is some setup info:

    https://learn.sparkfun.com/tutorials/xbee-wifi-hookup-guide/using-x-ctu
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-17 16:44
    @Brian, sorry about that Brian, there should be a period between Graphics and NewButton <Graphics.NewButton> it must have got lost in the copy and paste.

    You don't have to have the wifi modules to test the code just comment out the stuff associated with wifi.

    Jeff T.
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2014-01-17 18:42
    Question #1: Are you guys finding that once you've associated the WiFi device and ran the correct techBASIC code that the connection is reliable and results are consistent? My prior experiences with embedded WiFi were a bit messy and inconsistent, so I'm interested to to know if hardware improvements have made the results more predictable.

    Question #2: Once you've got a working framework of techBASIC and Propeller code, do you think it'll be fairly straightforward to add some kind of graphical control to the system and associate serial commands with those objects?

    I might not be asking the questions very clearly, not sure.

    Brian, Jeff, Tom, David, Thomas?

    I've got the hardware too, but I haven't been able to set it up yet. At some point I'll join in the fun.

    Thanks,

    Ken Gracey
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-17 19:13
    Ken Gracey wrote: »
    Question #1: Are you guys finding that once you've associated the WiFi device and ran the correct techBASIC code that the connection is reliable and results are consistent? My prior experiences with embedded WiFi were a bit messy and inconsistent, so I'm interested to to know if hardware improvements have made the results more predictable.

    Question #2: Once you've got a working framework of techBASIC and Propeller code, do you think it'll be fairly straightforward to add some kind of graphical control to the system and associate serial commands with those objects?

    I might not be asking the questions very clearly, not sure.

    Brian, Jeff, Tom, David, Thomas?

    I've got the hardware too, but I haven't been able to set it up yet. At some point I'll join in the fun.

    Thanks,

    Ken Gracey
    I'm afraid I haven't gotten far enough in my adventures with the Xbee Wi-Fi module to know if it will be reliable. I did notice that it sometimes seems to have trouble connecting to my router. It will get part way through the negotiation process but then get stuck. I've had to power cycle it to get it to connect again but it may be that if I was just more patient it would have connected on its own. My biggest problem is that there seems to be a web server built into the Xbee module that interferes wit my attempts to implement a simple web server on the Propeller. I have a couple of questions posted on the Digi forum but so far haven't gotten a reply.

    Edit: By the way, I like your profile picture. Do you play in a band or orchestra? Is that a clarinet?
  • Brian_BBrian_B Posts: 840
    edited 2014-01-17 19:30
    Ken,
    Right now I have the simple wi-fly terminal program (from the book) on the iPad and a xbee hooked to the x-ctu terminal. The iPad see's the xbee ,I keep making changes to the xbee and the program ,but have yet to see them exchange anything.

    One thing I noticed is that it is very easy to mess up you program being the run screen and edit screen change mid finger swipe (big fingers).

    Brian
  • Brian_BBrian_B Posts: 840
    edited 2014-01-17 19:58
    Hi,
    Here is my xbee configuration , is this the right code to open up the wifi from the iPad ?

    comm.openTCPIP(1,"192.168.1.10",2616)

    the same as :

    comm.openTCPIP(ipad port , "wifi address" , xbee port)

    Thanks'
    Brian
    864 x 576 - 31K
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-17 20:40
    Hi Brian, check banjo's thread at this link

    http://forums.parallax.com/showthread.php/153072-XBee-Wifi-amp-Propeller-Activity-Board-how-to-connect/page2

    in post #29 he describes his port and IP settings.

    Ken, the WiFly is staying connected for the program tests that I am doing, the only thing that may sometimes kick me off is the iPad lock timer if I leave it sitting idle too long. I realize the Xbee is going to be a key piece in this so I want to try it with the Xbee unit so we are all on the same page, I will send you my info in a while.

    As far as a GUI there is no doubt you could put one together very quickly, not only control but also logging and plotting applications. TechBasic has its limitations it depends what you expect, as a learning/teaching aid it is perfectly adequate. At the moment I am still playing around sending and receiving small byte packets but I did get an opportunity to add in a little graphic.

    Jeff T.

    Edit: I just re-read you question #2, yes you could place a touch button on the screen that would interact with a ping or servo for example.
    700 x 525 - 91K
  • Brian_BBrian_B Posts: 840
    edited 2014-01-17 21:07
    Thanks' Jeff,
    It looks like as soon as I hit the magic port # then any program I try to run throws all kinds of errors , every time I hit run it finds a new error ,if I set the port to the wrong setting it try's to run just fine.

    Brian
  • banjobanjo Posts: 438
    edited 2014-01-17 23:38
    Brian_B wrote: »
    Thanks' Jeff,
    It looks like as soon as I hit the magic port # then any program I try to run throws all kinds of errors , every time I hit run it finds a new error ,if I set the port to the wrong setting it try's to run just fine.

    Brian

    Brian, do note that the default port on XBee is HEX2616 which is 9750 in decimal. So on TechBasic side I use 9750 for simplicity.
    I'll revert later with my other findings and comments, writing this on iPad which is a...well you've experienced the same 'challenges' yourself.

    -Thomas
  • banjobanjo Posts: 438
    edited 2014-01-18 02:14
    Ken Gracey wrote: »
    Question #1: Are you guys finding that once you've associated the WiFi device and ran the correct techBASIC code that the connection is reliable and results are consistent? My prior experiences with embedded WiFi were a bit messy and inconsistent, so I'm interested to to know if hardware improvements have made the results more predictable.

    Question #2: Once you've got a working framework of techBASIC and Propeller code, do you think it'll be fairly straightforward to add some kind of graphical control to the system and associate serial commands with those objects?

    I might not be asking the questions very clearly, not sure.

    Ken Gracey

    Ken,
    Q #1: Unfortunately I have issues in that the connection is not reliable in some cases.
    If I just 'spam' characters from XBee to TechBasic it continues 'forever' without problems. Yesterday I was also successful in modifying the 'spam-bot' to both send and receive data with TechBasic.
    But when using same principle with an enhanced version from Jeff of the iPad accelerometer code (see post #18 here for the first version: http://forums.parallax.com/showthread.php/153214-Open-Propeller-Project-1-iPad-to-ActivityBot?p=1235367&viewfull=1#post1235367), I start to quite often get connection issues. Sometimes I need to restart the PAB and TechBasic program 10-20 times and when eventually getting connected I might loose the connection after a short while.
    I'll however continue to look into the code and will post it when I get a chance.
    I've never been successful in getting a direct connection to work between XBee and iPad, so I run through a WLAN-router (I have a brand new router now as my old is dying). When trying a direct connection, I can connect from iPad but the TechBasic program is not connecting..

    What is worrying me is that every day after a few hours the XBee starts to give timeout errors after rebooting. Is something getting to hot? These issues arise both when powering through USB and through 5 NiMh batteries.
    I've not at all given up (it takes a lot for me to give up...), but these additional issues eats of the few precious hours I have available during the week.

    I'd be interested in hearing from others about possible connection or timeout issues.

    Q #2: Assuming you mean graphical control on iPad/TechBasic (TB), then yes, it should be straightforward. It is very easy to add controls in TB and associate them to sub-routines.

    -Thomas

    Edit:
    Added screenshots and code for a very simple bi-directional use case. The screenshots show what I've sent between XBee and TechBasic successfully once a connection is established.
    The relevant code excluding the XBee initialization on Propeller side is:
        while(1)  {
          ch = fdserial_rxChar(xbee);
          print("%c", ch);
    
          writeChar(xbee, 'T');
          writeChar(xbee, 'h');
          writeChar(xbee, 'a');
          writeChar(xbee, 'n');
          writeChar(xbee, 'k');
          writeChar(xbee, 's');
          writeChar(xbee, ' ');
    
          writeChar(xbee, 'P');
          writeChar(xbee, 'a');
          writeChar(xbee, 'r');
          writeChar(xbee, 'a');
          writeChar(xbee, 'l');
          writeChar(xbee, 'l');
          writeChar(xbee, 'a');
          writeChar(xbee, 'x');
          writeChar(xbee, '!');
          writeChar(xbee, ' ');
        }
    
    ...and on TechBasic side:
    DIM url AS STRING, t AS DOUBLE
    DIM sendstr AS STRING
    
    sendstr = "You're welcome :-) "
    sendlen = LEN(sendstr)
    i = 0
    
    url = "192.168.178.26"
    Comm.openTCPIP(1, url, 9750)
    print "Port open"
    
    
    
    Sub nullevent(time AS double)
    
      if i>sendlen then i=0
      i=i+1
    
      IF Comm.isreadyforoutput(1) THEN
        y~=asc(mid(sendstr,i,1))
        put #1,,y~
      end if
    
      if not eof(1) then
        GET #1,,b~
        print chr(b~);
      END IF
    
    End Sub
    
    
    t = System.ticks
    found = 0
    
    WHILE System.ticks - t < 5.0
      IF Comm.isreadyforoutput(1) THEN
        found = 1
        t = t - 1.0
      END IF
    WEND
    
    IF NOT found THEN
      PRINT "The connection to "; url; " failed."
    END IF
    

    you're welcome.jpg
    photo (2).PNG
    1024 x 506 - 127K
    640 x 480 - 204K
  • banjobanjo Posts: 438
    edited 2014-01-18 11:24
    David Betz wrote: »
    I'm afraid I haven't gotten far enough in my adventures with the Xbee Wi-Fi module to know if it will be reliable. I did notice that it sometimes seems to have trouble connecting to my router. It will get part way through the negotiation process but then get stuck. I've had to power cycle it to get it to connect again but it may be that if I was just more patient it would have connected on its own.

    I've noticed that even if the command ATAI replies 41 (=waiting for configuration to complete) instead of 0 (=successfully joined), it will typically connect a few secs later. If not, then by power cycling it most often connects.
    However it looses the connection to iPad & TechBasic 'randomly' after 5 - 30 secs and sometimes reconnects automatically after a short while to again disconnect permanently. I'm not yet sure if it is the XBee disconnecting from the router, or if the issue is on the iPad side.
    -Thomas
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-18 14:31
    FYI, I just tried enabling Soft AP mode (WiFi Direct) on the Xbee plugged into my ActivityBoard and I was able to make a direct connection from my MacBook Pro to the Xbee without going through a router and was able to exchange data between the Mac and the Propeller over that connection. I'm still struggling with making a browser-acceptable HTTP server that can be invoked from a web IDE though. There seem to be some security issues associated with making AJAX requests from a browser to the ActivityBoard. I can, however, communicate with the AB over a custom connection. That might be of use to those using TechBasic. You could use a derivative of my code on the Propeller side and open a TCP/IP connection from TechBasic to the AB. If someone will describe to me the functions that you're interested in having the AB perform, I might be able to create a program for the Propeller that will handle those requests.
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-18 14:47
    @banjo, Thomas, I wondered if you would mind trying the following code for me. It's basically a modification of your "Thanks Parallax" "Your Welcome" code. There are three reasons I have for wanting you to try this.

    First I wanted to slow things down a little so I included a timer to pace things down to once every 0.5 seconds.

    Second I noticed that with the Sparkfun WiFly as soon as I connected it would send the message *HELLO*, I didn't realize this until I caught it in a debug window and that is partly why I was getting the transposed data that I mentioned earlier in this thread. It might not be the case with the Xbee but perhaps you could pay special attention when it first connects, if you do get the extra characters the code I have posted here will need an extra couple of lines.

    My last reason is to get away from the console output and display the message in a GUI. The GUI has a counter that increments at each successful message, the counter will indicate if any failures are occurring at the same place.

    Your Simple IDE C code transmits 2 extra characters to what I was transmitting. On the end of "Thanks Parallax" you have an exclamation and an additional space character, can you remove those two characters. I didn't test the TB transmit string either so you may have to modify that a little but it looks ok to me.

    I am at a stage now where I am fairly happy with transmitting and receiving ASCII or binary data between TB and Prop.with the WiFly.

    I want to try a transparent button next where I can overlay it on a graphic, for an example I will put it over a LED that lights when I touch it.
    Comm.openTCPIP(1,url,port)
    
    DIM t AS double
    DIM a~(16) AS byte
    DIM int% AS integer
    
    t=System.ticks
    
    DIM quit AS Button
    quit=Graphics.NewButton(10,10)
    quit.setBackGroundColor(1,1,1)
    quit.setGradientColor(0.7,0.7,0.7)
    
    DIM debug AS TextField,echo AS TextField
    debug=Graphics.newTextField(Graphics.width/2,10,100)
    echo=Graphics.newTextField(140,10,500)
    
    System.ShowGraphics
    
    Sub nullevent(time AS double)
    
    if System.ticks-t >0.5 then
    print #1,"Your Welcome"
    
    echo.settext("")
    
    int%=int%+1
    t=System.ticks
    
    for i=1 to 15
    get #1,,a~(i)
    next
    
    for i=1 to 15
    echo.settext(echo.gettext & chr(a~(i)))
    next
    
    debug.settext(str(int%))
    
    End Sub
    
    Sub touchUpInside(ctrl AS Button,time AS double)
    
    If ctrl=quit Then
    STOP
    End If
    End Sub
    

    Jeff T.
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-18 14:57
    @David, that sounds promising David. I'm unsure how others might want the data set up but in my mind I see techBasic transmitting between 5 and 10 bytes of binary data preceded with a header maybe like "!ABOT" . On the Prop side it would respond to the header and received data by transmitting back between 5 and 10 bytes of binary data. That would take care of virtually any GUI and its controls, if it came to file transfers then that would require a different scenario.

    Jeff T.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-18 15:28
    @David, that sounds promising David. I'm unsure how others might want the data set up but in my mind I see techBasic transmitting between 5 and 10 bytes of binary data preceded with a header maybe like "!ABOT" . On the Prop side it would respond to the header and received data by transmitting back between 5 and 10 bytes of binary data. That would take care of virtually any GUI and its controls, if it came to file transfers then that would require a different scenario.

    Jeff T.
    What would these commands do? I thought we were talking about controlling an ActivityBot? Anyway, I could give you a framework that would allow you to receive and respond to that sort of command. So are you saying that a command sent from a tablet would be the characters "!ABOT" followed by, say, a byte count and then that number of bytes of data? Then the response would be in a similar format?
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-18 15:36
    Wasn't someone here talking to an ActivityBoard over Bluetooth? What module are you using? I can see one potentially big problem with using WiFi at least in WiFi Direct mode without using a router. My Mac seems to only be able to have one WiFi connection at a time and that means that if I'm talking directly to my ActivityBoard using the Xbee WiFi module, I can't also be connected to the Internet over WiFi. This means I couldn't use a cloud-based server to compile programs for instance. If I talked to the ActivityBoard over Bluetooth then I could still talk to the Internet over WiFi.
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-18 17:01
    What would these commands do? I thought we were talking about controlling an ActivityBot? Anyway, I could give you a framework that would allow you to receive and respond to that sort of command. So are you saying that a command sent from a tablet would be the characters "!ABOT" followed by, say, a byte count and then that number of bytes of data? Then the response would be in a similar format?

    Yes, !ABOT is a header format borrowed from other Parallax products, for example I think the Parallax servo controller used !PSC.

    The data bytes contain control data and their position in the array defines their function, for example byte[0] could be 8 digital outputs, byte[1] and byte[2] could be combined to form an analog output ranging 0 to 65535 perhaps scaled to position a servo etc.

    The data bytes returned from the bot are status indicators from, for example, ping sensors, encoders, digital switches etc.

    Maybe I'm trying to keep things too simple, I am not in control mine is only a suggestion and the opinion of others must be taken into account.

    I looked at this Bluetooth module, I dont know what would be involved getting that up and running.

    http://www.seeedstudio.com/depot/blebee-v100-p-1632.html

    Jeff T.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-01-18 17:01
    In case anyone would like to look at my Xbee WiFi code, it's checked into the propgcc project in the directory propgcc/demos/xbee-loader. If that's too awkward to use, I'd be happy to move it to some other repository that is more convenient. It's all written in C except the Xbee frame driver which is PASM.

    https://code.google.com/p/propgcc/source/browse/#hg%2Fdemos%2Fxbee-loader
  • Brian_BBrian_B Posts: 840
    edited 2014-01-19 08:35
    Hi
    Thanks' for all the useful links and info. I'm reading non-stop to get up to speed on this.

    I have had a little luck getting 2 xbee's talking to each other for about 3 minutes .When I tried to get the iPad in the mix I lost everything.


    Here is what my test set up consisted of.

    * parallax serial terminal (computer#1) > propeller (running jazzed code) > xbee > my home router > xbee > XCTU (computer #2)

    I could send strings of data back and forth for awhile.

    Thanks,
    Brian
  • banjobanjo Posts: 438
    edited 2014-01-19 13:16
    @banjo, Thomas, I wondered if you would mind trying the following code for me. It's basically a modification of your "Thanks Parallax" "Your Welcome" code. There are three reasons I have for wanting you to try this.

    First I wanted to slow things down a little so I included a timer to pace things down to once every 0.5 seconds.

    Second I noticed that with the Sparkfun WiFly as soon as I connected it would send the message *HELLO*, I didn't realize this until I caught it in a debug window and that is partly why I was getting the transposed data that I mentioned earlier in this thread. It might not be the case with the Xbee but perhaps you could pay special attention when it first connects, if you do get the extra characters the code I have posted here will need an extra couple of lines.

    My last reason is to get away from the console output and display the message in a GUI. The GUI has a counter that increments at each successful message, the counter will indicate if any failures are occurring at the same place.

    Your Simple IDE C code transmits 2 extra characters to what I was transmitting. On the end of "Thanks Parallax" you have an exclamation and an additional space character, can you remove those two characters. I didn't test the TB transmit string either so you may have to modify that a little but it looks ok to me.

    I am at a stage now where I am fairly happy with transmitting and receiving ASCII or binary data between TB and Prop.with the WiFly.

    I want to try a transparent button next where I can overlay it on a graphic, for an example I will put it over a LED that lights when I touch it.
    Comm.openTCPIP(1,url,port)
    
    DIM t AS double
    DIM a~(16) AS byte
    DIM int% AS integer
    
    t=System.ticks
    
    DIM quit AS Button
    quit=Graphics.NewButton(10,10)
    quit.setBackGroundColor(1,1,1)
    quit.setGradientColor(0.7,0.7,0.7)
    
    DIM debug AS TextField,echo AS TextField
    debug=Graphics.newTextField(Graphics.width/2,10,100)
    echo=Graphics.newTextField(140,10,500)
    
    System.ShowGraphics
    
    DIM sendtext AS string
    sendtext="Your welcome"
    
    Sub nullevent(time AS double)
    
    rem if System.ticks-t >0.5 then
    rem print #1,"Your Welcome"
    
    if System.ticks-t >0.5 then
      for i=1 to len(sendtext)                              REM *********** INSERTED *****************
        ch~=asc(mid(sendtext,i,1))                      REM                   
        put #1,,ch~                                            REM
      next i                                                       REM *****************************************
    
    
      echo.settext("")
    
      int%=int%+1
      t=System.ticks
    
      for i=1 to 15
        get #1,,a~(i)
      next
    
      for i=1 to 15
        echo.settext(echo.gettext & chr(a~(i)))
      next
    
      debug.settext(str(int%))
    
    endif
    End Sub
    
    Sub touchUpInside(ctrl AS Button,time AS double)
    
    If ctrl=quit Then
    STOP
    End If
    End Sub
    

    Jeff T.

    @unsoundcode, Jeff: I've not noticed those extra characters you are getting. Getting rid of the console is welcome, it seems to slow down thing a lot when it gets crowded.
    With some small modifications I was able to get your example to work. As I was not able to get the 'print #1, "Your welcome"', I modified the code a bit to use 'put #1...' instead, also inserted an 'END IF' towards the end of the sub routine. My modifications are shown in the code above.
    In GCC I amended the code slightly to read an exact amount of characters being sent from TB:
          for(j=0;j<12;j++)
          {
            ch = fdserial_rxChar(xbee);
            print("%c", ch);
          }
    
    While writing this the connection has been stable and the counter is now over 1500. I've noticed a slight extra delay every ~57th time, i.e. at 57,114,171 etc. This should not be an issue, and might even be fixable through some settings on the XBee.
    Thanks Jeff, this gives me something I can try tomorrow in the real scenario with the Ping sensor.

    -Thomas
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-19 13:39
    Thomas that sounds very encouraging, I can't wait to see how it works out tomorrow. If everything seems ok with the current set up then I would take the timer down from 0.5 to somewhere in the region of 0.1 - 0.15, that will give us a very fluent display of data in the GUI. Also eventually I thought we might go to 38400 or 57600 with the uart baud rate.

    Jeff T.
  • Brian_BBrian_B Posts: 840
    edited 2014-01-19 15:05
    :):):) < These icon smiles are not nearly big enough.

    Running "You're welcome" code on the iPad to xbee direct, then to prop and reading it on the prop terminal !!! ,now I can sleep


    Brian
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2014-01-19 16:04
    WTG Brian your perseverance paid off.

    Jeff T.
  • Br1wr2el3Br1wr2el3 Posts: 13
    edited 2014-01-19 16:29
    I have been looking at my first piece of code for this project. The result is a techBASIC non-graphic program to measure movement (tilt) on he iPad.

    The program displays four values: number and text representing the movement up or down of the right side of the iPad, number and text representing the movement of the top edge of the iPad away from or toward the user.

    It is set so you can hold the iPad at about 45 degrees in front of you and that is neutral. The two numbers that are output range from -125 to125 so they should be usable as right/left, forward/backward movement of the ActivityBot.

    Possible updates:
    - make it graphical
    - add touch so you could 'point' at where you want the ActivityBot to go.
    - increase the size o the neutral zone - the area where slight movements do not send movement values to the ActivityBot
    - Suggestions welcome

    ! Non-graphic program to measure tilt of iPad
    !
    ! Author: Bruce Elliott
    ! Date: Jan. 17, 2014
    !
    ! It seems that the best values to monitor are:
    ! y - right side of iPad moved up or down
    ! z - top of iPad moves away or forward
    ! x - computed but not currently used
    !
    ! Currently displays four values on one line:
    !
    ! y - adjusted value representing rightside movement
    ! y text result
    ! z - adjusted value represnting top edge of iPad
    ! z text result

    !Force iPad orientation to landscape w/button on right

    system.setAllowedOrientations(4)

    ! Create string variables for display

    dim xstr as string ! Display these strings
    dim ystr as string
    dim zstr as string

    ! Set neutral area
    !
    ! zadjust lets iPad be held at about 45 degrees

    xadjust = 0. ! these values allow iPad to be held at angle and
    yadjust = 0. ! still be neutral - no valid value
    zadjust = 45

    ! main loop

    while (1)
    system.wait (.5) ! short delay

    ! Clear console
    system.clearConsole

    ! Call readAccel to get current tilt values
    readAccel

    ! Clear output strings
    xstr = " "
    ystr = ""
    zstr = ""

    ! x - not currently used but still computed

    x = x + xadjust

    if x < 0 then
    xstr = "left down"
    else
    if x > 0 then
    xstr = "left up"
    end if
    end if

    ! Is right side up, even, down?

    y = y + yadjust

    if y < 0 then
    ystr = "right down"
    else
    if y > 0 then
    ystr = "right up"
    end if
    end if

    ! Is top away or forward?

    z = z + zadjust

    if z < 0 then
    zstr = "top away"
    else
    if z > 0 then
    zstr = "top forward"
    end if
    end if


    print y, ystr, z, zstr
    wend


    sub readAccel

    ! This reads the accelerometer, adjusts the values, then
    ! scales +/- 2.0 input values to +/- 125
    !
    ! Adjust sensitivity to minimize false values from minor shaking

    sensitivity = 0.01 ! Ignore values in the range +/- this level

    a= Sensors.accel ! Read the accelerometer

    x = a(1) ! Convert to x, y, and z
    y = a(2)
    z = a(3)

    if abs(x) < sensitivity then
    x = 0 ! Set to zero if in neutral zone
    else
    x = x / 2.0 * 125 ! Scale value to range +/- 125
    end if

    ! This appears to measure right side moving up or down
    ! Assumes iPad held in landscape w/button on right

    if abs(y) < sensitivity then
    y = 0
    else
    y = y / 2.0 * 125
    end if

    ! This appears to measure top moved away or forward

    if abs(z) < sensitivity then
    z = 0
    else
    z = z / 2.0 * 125
    end if

    !print x, y, z

    end sub
  • Brian_BBrian_B Posts: 840
    edited 2014-01-19 18:01
    Hi Bruce,
    That looks good ,I'll try it out.

    I don't have a activity bot ,but I have 2 servos connected to the PropBoe board , for right now I'm using a modified wifi terminal program (from book) to send letters(from the iPad key pad) to the xBee . The letter "f" makes the servo's go forward ,the letter "r" makes them go backwards and The letter "s" makes them stop.

    Although a fairly simple program it gives me the building blocks to build on and yes it's always cool to see something move :)

    Brian
Sign In or Register to comment.