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

Open Propeller Project #1: iPad to ActivityBot

13468911

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-25 15:18
    Hi Brian, thanks for taking the time to try this for me. I have been running at 115200 but change the spin baud to 9600 it will be fine.

    Also find the Comm tcpip and set the port settings to what yours will work at.

    Jeff T.
  • Brian_BBrian_B Posts: 842
    edited 2014-01-25 15:39
    Jeff,
    I changed comm settings to mine , It errors out when it is waiting for a response from the propeller. I'll keep checking.

    Brian
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-25 17:44
    Configuring an adhoc network for the XBee S6B.

    If you have altered settings and are not sure what you altered use the xctu software to reset to the default firmware and write the default settings. Then enter the settings below.

    AH1 IBSCreator
    CE1 Soft AP mode
    ID <TYPE A NAME FOR YOUR NETWORK>
    IP1 TCP
    MA1 Static
    GW 192.168.1.1
    MK 255.255.255.0
    MY 192.168.1.1

    At the iPad leave the default which should be IP Address DHCP and HTTP Proxy off. After configuring the XBee it will take several seconds for the iPad wifi to connect to the XBe, this will be indicated by the name you gave the ID with a blue check mark next to it.

    When using techBasic to connect the ip will be 192.168.1.1 and the port number will be 9750.

    Jeff T.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-25 18:08
    Brian I have re-wrote this post because I misinformed you with the previous reply, the error is in the spin file. The line that reads ptr:=0 should actually be ptr:=1, I have been so focused on the techBasic I have not been paying attention to the spin, sorry.

    Jeff T.
  • Brian_BBrian_B Posts: 842
    edited 2014-01-25 19:06
    Jeff,
    Ok I'm on the same page as you,made changes and everything is working. Here is your spin code modified to look at what's coming in.

    Good Job !

    Brian


    Hmm , I take it ArrayIn is where the data from the Ipad is stored ,but I can not see it, even if I change the dataOut var.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-25 19:30
    Thanks Brian. What about the XBee are you communicating direct and does it seem a reliable connection. Did you see the post on how I have the XBee configured for adhoc.

    Jeff
  • Brian_BBrian_B Posts: 842
    edited 2014-01-25 19:39
    Jeff,
    Have all my settings like yours , running direct. I'll leave it run and see if it kicks it off.

    Brian
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-25 19:42
    Ok that's good to know, with regard to the spin file use this one I attach now. It's not perfect but it will run with the demo. Forget about debug to the PC use the GUI of the iPad as your debug its all there.

    Jeff
  • banjobanjo Posts: 447
    edited 2014-01-26 07:05
    Jeff, I'll try to find time to test it soon, been stuck with my paid job almost 24/7. Seems interesting!
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-26 07:08
    Thanks Thomas, I was excited to be able to connect direct (post #154) it has been a pain from the start. If we all can connect without a router it will be easier to progress.

    Jeff
  • Brian_BBrian_B Posts: 842
    edited 2014-01-26 07:32
    Jeff,
    What I'm seeing is that the ipad sends data as soon as you connect and then none after that, but it appears to be sending data. That is why I was using a debug to verify what I was seeing.

    Brian
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-26 08:13
    Ok Brian I'm with you. I took your spin file and reformatted the output that's seen on PST, it's working good at this end with the original techBasic source, can you try it again with the attached spin file.

    thanks
    Jeff

    EDIT I adjusted the TX/RX pins they will need putting back to your configuration.
  • tdlivingstdlivings Posts: 437
    edited 2014-01-26 08:40
    Hi Jeff
    I will take a look at it today.
    Been working on some Tech Basic to just put the Accel values on the iPad screen.
    Then I want to send some values back from the Activity board and see about byte order.
    I notice you are sending bytes and getting bytes back a good way to start, maybe the best way
    overall.
    Your scaling of Accel values to a byte seems to not account for the fact Accel values are plus and minus.
    Then again maybe I am ahead and what you have is only for debug. As I always say you have to walk before
    you run.

    As I said in another post with Brian the ip address concerns me as it is the same ip as my router and most likely
    yours also. The WiFly module uses a completely different range. I have not tried getting direct to work recently,
    actually been shoveling snow a lot.

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-26 13:39
    Are any of you using the Digi Xbee Wi-Fi module that Parallax now sells? I've been working with it for a while and am having a problem with transfers of large amounts of data to the module from the PC. It seems like the Xbee throws away data when it's buffers fill up without attempting to do TCP/IP flow control back to the host. Have you noticed that? I'm trying to determine if this is a characteristic of the Xbee module or if it is a bug in my code. I'm using API mode which means that I receive data in frames rather than just a continuous stream of data. Are you using transparent mode where you just get the data sent by the PC and no header information containing the source IP address, port, etc?
  • Brian_BBrian_B Posts: 842
    edited 2014-01-26 19:06
    David Betz wrote: »
    Are any of you using the Digi Xbee Wi-Fi module that Parallax now sells? I've been working with it for a while and am having a problem with transfers of large amounts of data to the module from the PC. It seems like the Xbee throws away data when it's buffers fill up without attempting to do TCP/IP flow control back to the host. Have you noticed that? I'm trying to determine if this is a characteristic of the Xbee module or if it is a bug in my code. I'm using API mode which means that I receive data in frames rather than just a continuous stream of data. Are you using transparent mode where you just get the data sent by the PC and no header information containing the source IP address, port, etc?

    David,
    I'm using a xbee wifi but I'm not fluent on all the technical web stuff, what I can tell you is that if your use the usb to xbee converter that it might be causing some problems. I think it does not supply enough power to the xbee, I might be wrong... but it seems that way.


    Brian
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-26 19:36
    Brian_B wrote: »
    David,
    I'm using a xbee wifi but I'm not fluent on all the technical web stuff, what I can tell you is that if your use the usb to xbee converter that it might be causing some problems. I think it does not supply enough power to the xbee, I might be wrong... but it seems that way.


    Brian
    I'm not using a USB to xbee converter. I just have an Xbee module plugged into an ActivityBoard and am talking to it over WiFi from a PC through a router. I've also tried the Soft AP mode but mostly use a router connection. There is no USB in my connection. I just use USB to the Propeller board for downloads and debugging console I/O.
  • tdlivingstdlivings Posts: 437
    edited 2014-01-26 19:38
    David
    I am using the SB6 sold by Parallax but only in transparent mode sending and receiving text.
    Only short strings.

    I will see tomorrow if I can something longer by sending a long string. How long do you think would be to much.

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-26 19:40
    tdlivings wrote: »
    David
    I am using the SB6 sold by Parallax but only in transparent mode sending and receiving text.
    Only short strings.

    I will see tomorrow if I can something longer by sending a long string. How long do you think would be to much.

    Tom
    I had trouble sending 1024 bytes at a time but 512 seems to work okay. Again, this is in API mode so transparent mode may be different. Also, my problems might be due to a bug in my code that I haven't discovered yet. That's why I was asking if anyone else had experienced similar problems.

    Thanks,
    David
  • tdlivingstdlivings Posts: 437
    edited 2014-01-26 20:04
    I was successfull at sending the Accel values from the iPad as a comma separated string to
    the Activity Board and then back to the Tech Basic Program .
    I am using the router method of connecting.
    I did get bit by the fact I turned on another computer and DHCP gave me a different ip address than the
    other day for the XBEE Wifi, took a bit for me to realize what happened.

    I wanted to see the Accel x,y,z values as numbers as I wiggled the iPad around to see how they changed.

    The code in the Activity Board is "C" code using SimpleIDE and the Simpletools , SimpleText libraries
    What the Activity Board receives is displayed on the SimpleIDE terminal and then echoed back to iPad to display
    Execute the code by loading the code to RAM and launching the terminal.
    I attached a zip file of the project.

    The Tech Basic Code
    [FONT=Helvetica]REM Display Accel values in Console and send a[/FONT]
    [FONT=Helvetica]REM CSV line out to XBEE WiFi on Activity board[/FONT]
    [FONT=Helvetica]REM which will get echoed back[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]Dim xlbl as Label, ylbl as Label, zlbl as Label[/FONT]
    [FONT=Helvetica]Dim xdisplay as Label[/FONT]
    [FONT=Helvetica]Dim ydisplay as Label[/FONT]
    [FONT=Helvetica]Dim zdisplay as Label[/FONT]
    [FONT=Helvetica]Dim echodisplay as Label[/FONT]
    [FONT=Helvetica]Dim lasttime as Double[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]xcenter = Graphics.Width/2[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]DIM quit AS Button[/FONT]
    [FONT=Helvetica]quit = Graphics.newButton(xcenter,400)[/FONT]
    [FONT=Helvetica]quit.setTitle("Quit")[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]Comm.openTCPIP(1, "192.168.1.105", $2616)[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]xlbl = MakeLabel(xcenter-100,20,"X:")[/FONT]
    [FONT=Helvetica]ylbl = MakeLabel(xcenter-100,60,"Y:")[/FONT]
    [FONT=Helvetica]zlbl = MakeLabel(xcenter-100,100,"Z:")[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]xdisplay = Graphics.newLabel(xcenter,20,200)[/FONT]
    [FONT=Helvetica]xdisplay.setFont("Monospaced",24,1)[/FONT]
    [FONT=Helvetica]xdisplay.setText("*")[/FONT]
    [FONT=Helvetica]ydisplay = Graphics.newLabel(xcenter,60,200)[/FONT]
    [FONT=Helvetica]ydisplay.setFont("Monospaced",24,1)[/FONT]
    [FONT=Helvetica]ydisplay.setText("*")[/FONT]
    [FONT=Helvetica]zdisplay = Graphics.newLabel(xcenter,100,200)[/FONT]
    [FONT=Helvetica]zdisplay.setFont("Monospaced",24,1)[/FONT]
    [FONT=Helvetica]zdisplay.setText("*")[/FONT]
    [FONT=Helvetica]echodisplay = Graphics.newLabel(20,150,500)[/FONT]
    [FONT=Helvetica]echodisplay.setFont("Monospaced",24,1)[/FONT]
    [FONT=Helvetica]echodisplay.setText("*")[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]Echo$ = ""[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]sensors.setAccelRate(0.1)[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]! Lock the screen in the current orientation.[/FONT]
    [FONT=Helvetica]orientation = 1 << (System.orientation - 1)[/FONT]
    [FONT=Helvetica]!System.setAllowedOrientations(orientation)[/FONT]
    [FONT=Helvetica]!Only allow landscape home on right[/FONT]
    [FONT=Helvetica]System.setAllowedOrientations(4)[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]!Pass 1 to go full screen and in this[/FONT]
    [FONT=Helvetica]!mode setAllowedOrientations works[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]Graphics.setFont("Monospaced",18,1)[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]REM USE FULL SCREEN[/FONT]
    [FONT=Helvetica]System.showGraphics(1)[/FONT]
    [FONT=Helvetica]REM SHOW GRAPHICS WITH DEBUGGER TOOLBAR[/FONT]
    [FONT=Helvetica]!System.showGraphics[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]REM DEBUGING[/FONT]
    [FONT=Helvetica]!PRINT "Screen Height = "; Graphics.Height[/FONT]
    [FONT=Helvetica]!PRINT "Screen Width = "; Graphics.Width[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]!PRINT "Font Name is "; Graphics.fontName[/FONT]
    [FONT=Helvetica]!PRINT "Font Size is "; Graphics.fontSize[/FONT]
    [FONT=Helvetica]!PRINT "Font Style is "; Graphics.fontStyle[/FONT]
    [FONT=Helvetica]!PRINT "Line Height is "; Graphics.lineHeight[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]SUB nullEvent(time AS Double)[/FONT]
    [FONT=Helvetica]!Measure Accel evey 0.1 sec[/FONT]
    [FONT=Helvetica]tmp$ = ""[/FONT]
    [FONT=Helvetica]IF lasttime = 0 THEN[/FONT]
    [FONT=Helvetica]lasttime = time[/FONT]
    [FONT=Helvetica]ELSE[/FONT]
    [FONT=Helvetica]IF time - lasttime > 0.1 THEN[/FONT]
    [FONT=Helvetica] ac = sensors.accel[/FONT]
    [FONT=Helvetica] PRINT $  tmp$ USING "+#.#####"; ac(1);[/FONT]
    [FONT=Helvetica] csv$ = tmp$ & ","[/FONT]
    [FONT=Helvetica] xdisplay.setText(tmp$)[/FONT]
    [FONT=Helvetica] PRINT $  tmp$ USING "+#.#####"; ac(2);[/FONT]
    [FONT=Helvetica] csv$ = csv$ & tmp$ & ","[/FONT]
    [FONT=Helvetica] ydisplay.setText(tmp$)[/FONT]
    [FONT=Helvetica] PRINT $  tmp$ USING "+#.#####"; ac(3);[/FONT]
    [FONT=Helvetica] csv$ = csv$ & tmp$[/FONT]
    [FONT=Helvetica] zdisplay.setText(tmp$)[/FONT]
    [FONT=Helvetica] !Print csv string to console which will add a cr[/FONT]
    [FONT=Helvetica] PRINT #1, csv$[/FONT]
    [FONT=Helvetica] lasttime = time[/FONT]
    [FONT=Helvetica]END IF[/FONT]
    [FONT=Helvetica]END IF[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica] WHILE NOT EOF(1)[/FONT]
    [FONT=Helvetica]   GET #1,,b~[/FONT]
    [FONT=Helvetica]   IF b~ = 10 THEN[/FONT]
    [FONT=Helvetica]     echodisplay.setText(Echo$)[/FONT]
    [FONT=Helvetica]     Echo$ = ""[/FONT]
    [FONT=Helvetica]   ELSE[/FONT]
    [FONT=Helvetica]     Echo$ = Echo$ & CHR(b~)[/FONT]
    [FONT=Helvetica]   END IF[/FONT]
    [FONT=Helvetica] WEND[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]END SUB[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]FUNCTION MakeLabel(x,y,title as string) as Label[/FONT]
    [FONT=Helvetica]DIM lbl AS Label[/FONT]
    [FONT=Helvetica]lbl = Graphics.newLabel(x,y)[/FONT]
    [FONT=Helvetica]lbl.setText(title)[/FONT]
    [FONT=Helvetica]lbl.setAlignment(3)[/FONT]
    [FONT=Helvetica]lbl.setFont("Monospaced",24,1)[/FONT]
    [FONT=Helvetica]END FUNCTION[/FONT]
    [FONT=Helvetica]
    [/FONT]
    [FONT=Helvetica]SUB touchUpInside(ctrl AS Button, when AS Double)[/FONT]
    [FONT=Helvetica]if ctrl = quit then[/FONT]
    [FONT=Helvetica] STOP[/FONT]
    [FONT=Helvetica]end if[/FONT]
    [FONT=Helvetica]end sub[/FONT]
    [FONT=Helvetica]
    [/FONT]
    

    The SimpleIDE code

    /*
     Receive and Echo a line from the XBEE Wifi installed in
     Activity Board
    
    
    */
    #include "simpletools.h"                      
    #include "fdSerial.h"
    
    
    #define MAXCHARS 78                         
    
    
    int RX = 9, TX = 8;       // XBEEwifi connected pins
    
    
    fdserial; *xbwifi;
    
    
    int main()                                    // Main function
    {
    char aline[80];                               //A line of text from the XBEE
    int lineix;                                   //Index to where to store next XBEE rec char
    int ch;                                       // Characters from XBEE
    unsigned int linecount;                       // Add linecount to each line received from XBEE
    
    
      // Add startup code here.
      print("Hi There:\n");
      xbwifi = fdserial_open(RX,TX,0,9600);       // Full Duplex serial to XBEE
      putchar(CLS);                              // Clear terminal screen
      fdserial_rxFlush(xbwifi);                        // Clear Serial Buffer
      pause(100);
    
    
    // Clear our line buffer to all NULLS
    void ClearLine(char *s) {
     // Hard coded for our aline array, 
     for(int i=0;i<80;i++) {
      s[i] = 0;
     }
    }
    
    
    
    
     
      while(1)
      {
        // Add main loop code here.
    
    
      //Check for incoming data from iPad Wifi connection
           ch = fdserial_rxCheck(xbwifi);
           if( ch != -1) {
             if(ch == '\n') {
               aline[lineix] = 0;        //Add a NULL to end of line
               print("%c%s",HOME,aline);      // Show it on terminal so we can see what is happening
               writeLine(xbwifi,aline);  // Send it back to iPad
               lineix = 0;                // Get ready for the next line from XBEE
               ClearLine(aline);
               fdserial_rxFlush(xbwifi);
             }
             else {
              aline[lineix] = ch;       // Add next char to line at index
              lineix++;                 // Increment index
              if(lineix > MAXCHARS){          // Limit index to prevent runnning wild
                lineix = MAXCHARS;
              }
             }
           }// End if ch -1
      
      }// End while(1)  
    }
    
    
    

    I paced it at 0.1 sec and when it is running it does consume the router. Just for grins I tried to open a browser on another
    computer and it would not until I stopped the TB code. If I first opened a browser and the ran the TB code I could load a web
    page but slowly.
    If others in the house need the WiFi connection when using a router to connect to a bot and send data back and forth they
    are not going to be happy. Ha

    I also tried to capture the Tech Basic screen like it says in the manual by clicking share while it was running or by clicking the
    wrench icon and all I got was a white square in my Photo's . A picture of a polar bear in a snow storm. Ha

    Tom

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-27 05:25
    Hi Tom , looks like a good example I will try it later today. The fact you are running succesfully through a router is a plus. I am doing everything direct but I am happy with that but I do intend to go through a router at some time.

    Reading through your TB code real quick I see a couple of methods I have not tried yet which is interesting and also the 'C' which I have been neglecting and need to get upto speed with.

    1/10 th of a second sounds like good timing to me, the TB event handlers are a nice feature and help keep the GUI responsive.

    A couple of the things I would like to check out next is the error handling and manual input of ip and port numbers.

    If you would like to take an iPad screen shot hold in the on/off/power button and then press the home button and hold them both until you hear the "camera click". The screen shot will appear in the photo folder.

    Jeff
  • Brian_BBrian_B Posts: 842
    edited 2014-01-27 08:22
    I'm been reading up on programming in C , this code confuses me. Is fdserial parsing out the x and y data ,I'm expecting to see a chunk of bytes that are not yet been converted into a number that is useable.


    Brian





    if(x != -1)
    {
    y = fdserial_rxChar(xbee); // receiving y (direction) from iPad
    if(y != -1)
    if(x > 124 && x < 130) // "dead zone" to avoid jittering speed
    drive_speed(0, 0);

    if(x > 129)
    {
    drive_rampStep((0 - (x - 127) - (y - 127)), (0 - (x - 127)) - (127 - y));
    }
    if(x < 125)
    {
    drive_rampStep((127 - x) + (y - 127), (127 - x) + (127 - y));
    }
    }
    if(cm < 20)
  • banjobanjo Posts: 447
    edited 2014-01-27 10:18
    Brian, you have not pasted the complete code, so what's not visible in your post is the place where 'x' is read.
    x = fdserial_rxChar(xbee);                // receiving x (speed) from iPad
    ...
    [COLOR=#333333]y = fdserial_rxChar(xbee);                // receiving y (direction) from iPad[/COLOR]
    
    which reads the speed component.
    So, the TechBasic application is sending one byte for speed and another for direction. The C-application is obviously reading the data in a similar way and order. So I would not really call it parsing, just reading raw data.
    Now it is obviously important that the TechBasic and Propeller applications stay in sync, otherwise speed and direction are switched with interesting behaviour :smile: (I probably experienced that once as the bot was somewhat controllable, but not in a logical way)
  • Brian_BBrian_B Posts: 842
    edited 2014-01-27 10:37
    Ok,
    So you are receiving 2 byte's of data one for x and one for y , not a x + Data and a y + data. So if the ipad sent a "O" and a "Z", speed would be 79 and direction would be 90.


    Thanks'
    Brian
  • banjobanjo Posts: 447
    edited 2014-01-27 11:13
    Correct! Did not want to make it complex.
  • tdlivingstdlivings Posts: 437
    edited 2014-01-27 19:09
    I did get the direct connection to connect using Jeff's ip address range. The other settings I had were the same
    and I even changed to 192.168.1.3 as a test and it followed.
    The connection does pause for about a second every once in a while, runs for many minutes and will pause and
    return right away. Both blue and red less on AB go out. I may have saw that also with router connection will have to
    watch that tomorrow.
    As far as range it was better than the regular XBEE's I played with this summer. When I walk into my family room with the
    AB transmitting from my bench downstairs a regular XBEE quits right away. The normal browse the internet using router
    wifi signal strength is only one bar and works. With the XBEE Wifi I again saw a big drop in signal strength but it kept
    receiving and I was thinking humm much better, that is until I turned a bit and must have hit a null spot and it went dead.
    With the regular XBEE's all I had to do was return to higher signal and they came back not so with this XBEE Wifi SB6.
    Even rerunning the program did not do it . I had to go back downstairs and power everything off and back on again and even
    reboot iPad, not sure reboot was needed . It was about 25 min of repeating the procedure of getting connected and then it
    connected again and was fine.

    One thing I noticed is it takes a very steady hand to hold a accell value on x,y,z.

    Tom
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2014-01-27 19:47
    @ Ken,Thomas,Brian,Bruce and Tom , guys will you try this code out and give me some feedback, the sample runs with or without wifi. If you want to try the wifi scroll down to the Comm command and make sure your ip and port are entered.

    Jeff, this looks awesome. Right along the path of what I had hoped to see developed. I have yet to be able to run these programs, but I'm frothing to get started this week. At this moment I have to go to San Francisco for the MicroMedic wrap-up at a conference tomorrow, but I'll jump in and run the program as soon as I can.

    Thank you for your efforts and sharing this early success!

    Ken Gracey
  • banjobanjo Posts: 447
    edited 2014-01-27 21:20
    Tom, I've experienced exactly the same as you. Also that a steady hand is needed. With my C code on Propeller side, I've though put in a dead zone that easily can be enlarged. A few posts above you see the code snippet from Brian, and the values below 127 can be reduced more, values above enlarged similarly.
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2014-01-27 21:54
    banjo wrote: »
    Tom, I've experienced exactly the same as you. Also that a steady hand is needed. With my C code on Propeller side, I've though put in a dead zone that easily can be enlarged. A few posts above you see the code snippet from Brian, and the values below 127 can be reduced more, values above enlarged similarly.

    Yeah, good solution. I also think the deadband is probably more appropriate on the ActivityBot side of things. At least most of us can probably code that easier than techBASIC for now. It's been painful to only watch this fun from the sidelines, but I hope to change that soon. I'll be at a conference in San Francisco on Tuesday but back in Parallax by Wednesday, when I'll go for the iPad/XBee/Propeller setup!
  • Brian_BBrian_B Posts: 842
    edited 2014-01-29 04:58
    Hi,
    I know this is not the "learn c" forum , but this c stuff is driving me up a wall .I started out with banjo's receiving program and have been beaten down to a simple test program that still doesn't work. Here is the code ,what concept am I missing ?

    My hair Thanks' you in advance :)


    Thanks'
    Brian



    #include "simpletools.h" // Include simpletools header .
    #include "fdserial.h"

    fdserial *term;

    int main()
    { simpleterm_close();
    term = fdserial_open(31, 30, 0, 115200);

    int n ;
    while(1)
    {
    dprint(term,"> ");

    n = readChar(term);
    if(n == 5 ) // I've also tried if(n == "d%",5) and if(n == 5, "%d")
    {
    dprint(term,"Five");
    }
    else
    {
    n = n + 1;
    writeChar(term,n);
    }
    }

    }
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2014-01-29 05:20
    Hi Brian, I downloaded SimpleIDE a couple of days ago and have yet to use it so I'm pretty much in the same boat you are.

    What I want is a routine written in C that will receive a 6 byte array plus ASCII header and echo the array back.

    Hopefully someone will jump in and gives us a few pointers, no *pun intended.

    I am at work now but when I get back to "base" I will post with a few more techBasic ideas I have in mind.

    Jeff
Sign In or Register to comment.