Shop OBEX P1 Docs P2 Docs Learn Events
Information on EB500 - Page 2 — Parallax Forums

Information on EB500

2»

Comments

  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-04 03:54
    Hi Peter,

    while (!eb.response()) ;
    can i ask what does the 'response' in this command means?

    Is it the response method of the bluetooth itself? or it is a response method i self-create?

    if it is the bluetooth method it will clash with another method which i had named it as 'reponse' too.
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-04 05:22
    Hi Peter, i would like to use the X and Y Bytes received to do some calculation, however, i cannot just use the value that appears in other case.

    ====================================================================================
    static void receiveXY() {
    · int Rmin = 20;
    · int RepulsiveF;
    · int valueY,valueX,valueY1,valueX1;
    · int state = 0;
    · int c;
    · while (true) {
    ··· switch (state) {
    ····· case 0: //wait for !
    ················ c = rx.receiveByte();
    ················ if (c == '!') state = 1;
    ················ break;
    ····· case 1: //wait for e
    ················ c = rx.receiveByte();
    ················ if (c == 'e') state = 2;
    ················ else if (c != '!') state = 0;
    ················ break;
    ····· case 2: //wait for b
    ················ c = rx.receiveByte();
    ················ if (c == 'b') state = 3;
    ················ else state = 0;
    ················ break;
    ····· case 3: //get xpos lowbyte
    ················ valueX = rx.receiveByte();
    ·············· //· Format.printf("Value X low : %d\n",valueX ); Same o/p as xpos highbyte
    ················ state = 4;
    ················ break;

    ····· case 4: //get xpos highbyte
    ················ valueX |= (rx.receiveByte() << 8);
    ················ Format.printf("Value X: %d\n",valueX );
    ················ state = 5;
    ················ break;

    ····· case 5: //get ypos lowbyte
    ················ valueY = rx.receiveByte();
    ············· //·· Format.printf("Value Y low : %d\n",valueY );
    ················ state = 6;
    ················ break;
    ····· case 6: //get ypos highbyte
    ················ valueY |= (rx.receiveByte() << 8);
    ················ Format.printf("Value Y: %d\n",valueY );
    ················ response();
    ················ valueX1 = xpos/100;
    ················ valueY1 = ypos/100;
    ················ RepulsiveF = (Rmin*Rmin) - (valueX1-valueX)*(valueX1-valueX) - (valueY1-valueY)*(valueY1-valueY);
    ················ if (RepulsiveF <= 0){
    ················ Straight();
    ················ return; //at this point the function returns
    ················ }
    ················ else{
    ················ turnAway();
    ················ return;
    ················ }
    ··· }
    · }
    }
    ====================================================================================
    917 x 718 - 86K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-02-04 11:39
    eb.response() is the method response() in·the eb500 class.
    You can have your·own response() method, there will be no name conflict.

    The variables
    · int Rmin = 20;
    · int RepulsiveF;
    · int valueY,valueX,valueY1,valueX1;

    should be declared outside receiveXY (so you can use them when receiveXY returns).
    That also has the benefit that you can print and use the variables outside receiveXY,
    so there is no need to add print statements or calculations to receiveXY().

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-04 17:23
    Thank You Peter for the explanation.

    Peter, may i find out why doesnt my Boe-Bot rotates its servo? Base on the outputs from the Javelin Terminal, it should rotate according to my turnAway() and Straight() subroutines. I had tried with no CPU.delay, with CPU.delay(300) and also CPU.delay(30000), none of them causes the servo to rotate.

    Post Edited (StereoPonyz) : 2/8/2010 9:09:15 AM GMT
    470 x 672 - 69K
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-09 16:42
    Hi Peter, the bluetooth seems to have lag time in receiving the bytes. So i created a few debugging sentences and noticed that it stuck at while(true) for·some time before executing it. The Bots have already established connection as observed from the lighting up of the LEDs and the distance in between the Bots·are v close.

    I think cos of the lag time, the receiving bot (bot B) will only move if both bots are programmed to move straight. If both bots are programmed to move in circle, receiving bot (bot B) is unable to receive any bytes from transmitting bot (bot A), it will stuck at while(true).

    =================================================================================================
    static void eb500Rcv(){
    Format.printf("Start of eb500Rcv\n");
    int state = 0;
    int c;
    while (true) {
    Format.printf("Inside While Loop\n");
    switch (state) {
    case 0: //wait for !
    c = rx.receiveByte();
    if (c == '!') state = 1;
    break;
    case 1: //wait for e
    c = rx.receiveByte();
    if (c == 'e') state = 2;
    else if (c != '!') state = 0;
    break;
    case 2: //wait for b
    c = rx.receiveByte();
    if (c == 'b') state = 3;
    else state = 0;
    break;
    case 3: //get xpos lowbyte
    valueX = rx.receiveByte();
    state = 4;
    break;

    case 4: //get xpos highbyte
    valueX |= (rx.receiveByte() << 8);
    state = 5;
    break;

    case 5: //get ypos lowbyte
    valueY = rx.receiveByte();
    state = 6;
    break;
    case 6: //get ypos highbyte
    valueY |= (rx.receiveByte() << 8);
    Format.printf("Reached State 6\n");
    return;
    }
    }
    }

    Post Edited (StereoPonyz) : 2/10/2010 2:25:31 AM GMT
    675 x 753 - 79K
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-10 08:41
    Hi, Peter, i had tested a segment of my main program with only bluetooth and stargazer codings. Strangely, in this way my Bots are able to move. When adding the very same segment of codes back into my main program, it fails to work.

    Anyway, adding on to my previous post, i noticed that the receiving bots took a long time before detecting the new X and Y bytes. May i know what may be the prob?

    I have tested a simplified version, hoping to reduce any unknown causes but, the receiving bot still have lag time in receiving correct bytes.

    Post Edited (StereoPonyz) : 2/10/2010 8:56:11 AM GMT
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-18 05:54
    Hi Peter, the problem still persist... i check under debug window and saw the program discard many packets. what does it mean?
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-19 06:19
    HI Peter, i have found out the cause that resulted the BOT to receive the Bytes with delay. It is due to the Stargazer subroutine. When i took out the Stargazer subroutine, my Bot can receive the Bytes almost accurately (though the reading is not instantenous).

    I realized that with Stargazer subroutine included, after i off the power to the transmitting BOT (A), receiving BOT (B) still print out Bytes from nowhere and those bytes printed are the repeated ones it received previously. It seems like the previous Bytes are latched in the memory. The repeated Bytes will only be cleared up after sometime before it will receive and print out the new Bytes.

    However, without the Stargazer subroutine, when BOT (A) is off, BOT (B) responded immediatedly and no Bytes was printed since there was nothing receive.


    Peter, i need to use the Bytes it receive and readings from Stargazer to compute equations. How can i do that?
Sign In or Register to comment.