Information on EB500
StereoPonyz
Posts: 82
Hi, i have 3 eb500 each connected to·a BOE-Bot (rev c), which·I·wish·to use·them for communication. I found many examples on how to·establish connections between the bluetooths, however, they are using BS2 and was coded in PBasic.
I would like to find out where i may be able to find one manual that is based on Javelin. Also, if i need to place a bluetooth class in the lib first before coding it?
I would like to find out where i may be able to find one manual that is based on Javelin. Also, if i need to place a bluetooth class in the lib first before coding it?
Comments
These must be stored in folder ...\lib\stamp\peripheral\wireless\eb500
Create the eb500 folder if it does not exist.
regards peter
If there is by any chance a manual to code eb500 in java?
INPUT 5
'WAIT FOR the eb500 radio TO be ready
PAUSE 1000
'Connect TO the remote device
SEROUT 1,240,[noparse][[/noparse]"CON 00:0C:84:00:54:F7",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
WaitForConnection:
IF IN5 = 0 THEN WaitForConnection
DEBUG "Connected",CR
'WAIT FOR 20 seconds
PAUSE 20000
'I/O Line 6 allows us TO switch TO Command Mode
OUTPUT 6
'Switch TO Command Mode
LOW 6
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
'Disconnect from the remote device
SEROUT 1,240,[noparse][[/noparse]"dis",CR]
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
DEBUG "Disconnected",CR
if instance, for the PBASIC codes abv, SEROUT means to send command via output pin 1 at 9600 baud. So to code in Java, i will use UART instead of SEROUT/SERIN and system.out.println instead of DEBUG?
regards peter
made an error in creating the folders (you must use the exact names, no capital letters for example,
and check for spaces at the end of folder name)
or you did not place the files in folder eb500
Please check.
regards peter
I have read the manual on eb500, and tried the codes (PBasic) shown in Step4: Connect the eb500-SER on the SumoBoard to the eb500-SER on the BOE, which is why i think only One Bot needed to be coded for purely one sided connection.
Actually, i am trying to code BotA to keep feeding BotB with xpos and ypos, then Bot B·will move according to the parameters· based on some equations i had already tried out.
The attached is the terminal o/p from trying some of your codes. I had tot after initialsing the eb500, it will print its own address out.
===================================================
package stamp.peripheral.wireless.eb500;
import stamp.core.*;
import stamp.util.text.*;
public class eb500Test {
··· static Uart EB500RX = new Uart(Uart.dirReceive,CPU.pin0, Uart.dontInvert, Uart.speed9600, Uart.stop1);
··· static Uart EB500TX = new Uart(Uart.dirTransmit,CPU.pin1, Uart.dontInvert, Uart.speed9600, Uart.stop1);
public static void main(){
··· clearEB500Link();
··· eb500Connect();
··· }
public static void clearEB500Link()
{
··· // eb500 clear & Initialize
··· if (CPU.readPin(CPU.pin5) == true)
··· {
······· System.out.print("EB500 is alive in DATA mode, clearing.....");
······· // drive pin LOW
······· CPU.writePin(CPU.pin6,false);
······· CPU.delay(2000);
······· // disconnect
······· EB500TX.sendString("dis");
······· EB500TX.sendByte(13);
······· System.out.println("ok");
··· }
··· else
··· {
······· System.out.print("EB500 is alive in CMD mode, clearing.....");
······· EB500TX.sendByte(13);
······· EB500TX.sendByte(13);
······· System.out.println("ok");
······· return;
··· }
}
public static void eb500Connect() {
··· int data = 0;
··· EB500TX.sendString("get addr");
··· EB500TX.sendByte(13); // return
// wait a tick
CPU.delay(2500);
while (EB500RX.byteAvailable() == true)
{
··· System.out.print((char) EB500RX.receiveByte());
}
// connect
System.out.print("Connecting.....");
EB500TX.sendString("con XX:XX:XX:XX:XX:XX"); // address of the remote device
EB500TX.sendByte(13);
CPU.delay(5000);
while (EB500RX.byteAvailable() ==true)
{
···· data = (char) EB500RX.receiveByte();
···· if (data != ' ' && data != '\r')
···· {
········· System.out.print(data);
···· }
}
System.out.println("...ok");
// wait for connection
System.out.print("Wait for connection.....");
System.out.println("ok!");
System.out.println("Connection OK!");
}
}
===================================================
EB500TX.sendString("get addr");
should be
EB500TX.sendString("get address");
regards peter
I read the info in your eb500.java, it says if the syntax is correct an ACK string or NAK string is returned, followed by a carriage return. I saw NAK> from the terminal which means the eb500 and Javelin are communicating. However, output is not right. The address of the eb500 is 00:0C:84:00:4E:C5.
May i know if the eb500 (A) is able to stream data continously to another eb500 (B)?
· public int sendCommand(int command, char chr) {
··· int k = assembleStart(command);
··· k = Format.bprintf(sendbuf,k," %c",chr);
··· k = assembleFinish(command,k);
··· esc = chr; //remember esc character
··· return send(k);
· }
this will be the code i have to implement? sorry i cannot understand how to apply...
"con 00:0C:84:00:4E:C5 30" where the 30 is a timeout value.
For my eb500 class, the commands would be
· static Uart tx = new Uart(Uart.dirTransmit,CPU.pin2,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static Uart rx = new Uart(Uart.dirReceive,CPU.pin3,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static eb500 eb = new eb500(rx,tx,CPU.pin0,CPU.pin1);
· static String addr = "00:0C:84:00:4E:C5";
· static String name = "devicename";
· static String key = "1234567890";
· static int timeout = 30;
· static void main() {
··· eb.sendCommand(eb.Connect,addr,timeout);
··· while (!eb.response()) ;
··· eb.print();
··· eb.sendCommand(eb.ReturnToDataMode); //enter data mode
··· while (!eb.response()) ;
··· eb.print();
··· //once connected and in data mode, use·tx.sendByte() to send data,·rx.receiveByte()·to receive data
··· //other code
·· while (true) ;
· }
If all is well, the responses should be ACK>\r
which is printed by eb.print()
regards peter
static Uart myUart = new Uart(Uart.dirReceive,CPU.pin2,Uart.invert,Uart.speed9600,Uart.stop1);
Can i use other pins for eb500? like pin4 and 5?
static Uart tx = new Uart(Uart.dirTransmit,CPU.pin4,Uart.dontInvert,Uart.speed9600,Uart.stop1);
static Uart rx = new Uart(Uart.dirReceive,CPU.pin5,Uart.dontInvert,Uart.speed9600,Uart.stop1);
static eb500 eb = new eb500(rx,tx,CPU.pin0,CPU.pin1);
May i know if the abv segment of codes is to detect eb500 mounted on Another Bot which has an address of "00:0C:84:00:4E:C5", not for reading its Own eb500 address?
I have tried out the codes, however, it has no output. Where should i place the connect command, "con 00:0C:84:00:4E:C5 30" ?
or Javelin Demoboard, then you must use the pins as given in the manual.
· static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);
If you do not stick the eb500 on the appmod header, then you can use other pins
by using wires from the eb500 connector to the appmod header.
The get address command should return the address of the eb500 that is
directly connected. Once you know the address of the other eb500 module,
that is the address used in the connect command.
regards peter
Sometimes it will return error msg like: ACK>
····························································· err3
I looked into your eb500.java·for info but i am not sure what err3 is.
Post Edited (StereoPonyz) : 1/21/2010 5:24:24 AM GMT
import stamp.util.text.*;
import stamp.core.*;
public class eb500Test3 {
· static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);
· static String addr = "00:0C:84:00:4E:C5";
· static int timeout = 30;
· static String OwnAddr = "00:0C:84:00:54:F7";
· static byte xpos = 55;
· static void main() {
··· eb.sendCommand(eb.Connect,addr,timeout);
··· while (!eb.response()) ;
··· eb.print();·//......................................................................................ACK
··· eb.sendCommand(eb.ReturnToDataMode); //enter data mode
··· while (!eb.response()) ;//..................................................................Keep Looping
··· eb.print();
··· eb.sendCommand(eb.SetBaud9600);
··· System.out.println("Baud Rate is set to 9600");
··· tx.sendByte(xpos);
··· System.out.println("xpos is sent over");
··· //once connected and in data mode, use tx.sendByte() to send data, rx.receiveByte() to receive data
··· //other code
·· while (true) ;
· }
}
==========================================================================
Hi Peter, from the abve code i can receive ACK followed by >·But it is not able to execute my other·commands..
I had used debugger to step thru the codes, i realised that it keeps looping ard the while cond for the·second sendcommand.
Post Edited (StereoPonyz) : 1/21/2010 6:44:47 AM GMT
Like Bot(A) connect to BOT(B), once it is successful, BOT(B) will send "ACK" to BOT(A) to print out.
As for the tx.sendByte command BOT(B) must receive it, so that it can send "ACK" back to BOT(A) for print out? Means that BOT(B) must have codes that is waiting to receive Byte?
My serial cable to connect to BOT(A) for javelin terminal output.
succesful connection.
So,
public class eb500Test3 {
· static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);
· static String addr = "00:0C:84:00:4E:C5";
· static int timeout = 30;
· static String OwnAddr = "00:0C:84:00:54:F7";
· static byte xpos = 55;
· static void main() {
··· eb.sendCommand(eb.Connect,addr,timeout);
··· while (!eb.response()) ;
··· eb.print();·//......................................................................................ACK
At this point, if ACK was received (and you should check the receive buffer, meaning
adding a method to the eb500 class to compare receive buffer against string)
the eb500 entered data mode.
·· while (!CPU.readPin(CPU.pin5)) ; //wait until pin5 is high (= datamode)
·· tx.sendString("this text is sent to a remote receiver via eb500");
You should indeed have the remote receiver in data mode to receive the above text string.
Check the manual for communication via 2 eb500 modules.
regards peter
Can i also know if 2 Bots need to have the codes ( eb.sendCommand(eb.Connect,addr,timeout); ) to connect to each other, or just one Bot is needed?
Below are the 2 individual codes loaded into the respective Bots.
================================================================================================
<<Codes loaded in BOT A>>
static void main() {
eb.sendCommand(eb.Connect,addr,timeout);
while (!eb.response()) ;
eb.print();
eb.sendCommand(eb.GetName);
eb.print();
while (!CPU.readPin(CPU.pin5)) ; //wait until pin5 is high (= datamode)
tx.sendString("this text is sent to a remote receiver via eb500");
Format.printf("Test is sent over\n");
tx.sendByte(xpos);
Format.printf("Byte sent over\n", xpos);
while (true) ;
}
<<Codes loaded in BOT B>>
static void main() {
eb.sendCommand(eb.Connect,addr,timeout);
while (!eb.response()) ;
eb.print();
rx.receiveByte();
eb.print();
while (true) ;
}
<<Codes loaded in BOT B>>
static void main() {
eb.sendCommand(eb.Connect,addr,timeout);
while (!eb.response()) ;
eb.print();
int receivedData = rx.receiveByte();
Format.printf("Received Data = %d\n",receivedData);
regards peter
is some respond byte.
Best advice is to take the BS2 example from the manual and convert it
to javelin. Test and adapt the javelin code until you get the same results
as the BS2 program. I would start with one eb500 module and a pc blue tooth
adapter to get data to and from hyperterminal.
regards peter
SEROUT 1,84,[noparse][[/noparse]"get address",CR]
:SEROUT-->Output Data
:1--> “P1” of the AppMod header, is the UART data input pin.
that line means to output data using uart input pin? quite confusing, it had to output data need to use UART output pin.
Next, For printing outputs, BS2 always use this code --> SERIN 0,84,[noparse][[/noparse]STR szData\17]. What may be the conversion for Javelin?
Post Edited (StereoPonyz) : 1/28/2010 5:29:56 PM GMT
Pin out
The eb500 module features a 20 pin connector with 0.1” spacing for direct connection to a
Parallax AppMod header. Currently, nine of the pins are in use (seven when flow control is
set to none). The other pins are reserved for future use.
Pin Parallax Pin Function Description Usage
CN1 - 1 GND GND Ground Required
CN1 - 2 GND GND Ground Required
CN1 - 3 P0 TX Serial Transmit line from eb500 Required (so javelin receives at P0)
CN1 - 4 P1 RX Serial Receive line to eb500 Required (so javelin transmits at P1)
CN1 - 5 P2 RTS Request-to-Send on the serial port interface between the eb500 and the BASIC Stamp Optional
CN1 - 6 P3 CTS Clear-to-Send on the serial port interface between the eb500 and the BASIC Stamp Optional
CN1 - 8 P5 Status Bluetooth connection status (0 = not connected, 1 = connected) Required
CN1 – 9 P6 Mode Command/data mode toggle (0 = command, 1 = data) Required
CN1 - 20 VCC VCC Power Required
Table 4: eb500 Pin out Description
So it appears pin0 must receive, and pin1 must transmit.
regards peter
Post Edited (StereoPonyz) : 2/1/2010 3:18:13 AM GMT
(BOT A)·····
························<<Stargazer Codings>>
······················· int a = xpos/100;
························ byte b =(byte)a;
················· ·· ··· eb.sendCommand(eb.Connect,addr,timeout);
·························tx.sendByte(b);
(BOT
··· eb.sendCommand(eb.Connect,addr,timeout);
··· while (!eb.response()) ;
··· eb.print();
··· int receivedData = rx.receiveByte();
··· Format.printf("Received Data = %d\n",receivedData);
The result shown in Bot B is always 99. When in fact Stargazer showed xpos as 21.86
I also tried tx.sendInteger(xpos); apparently there isnt such command.
Post Edited (StereoPonyz) : 2/1/2010 4:16:16 AM GMT
tx.sendByte(value); //send lowbyte
tx.sendByte(value >> 8); //send highbyte
To receive an integer, you must receive lowbyte and highbyte and assemble
int lowbyte = rx.receiveByte(); //receive lowbyte
int highbyte = rx.receiveByte(); //receive highbyte
int value = (highbyte << 8) | (lowbyte & 0xFF);
regards peter
Like in the case for Bot B, the commands for receiving the bytes are similar, rx.receiveByte().
How do i make it such that int lowbyte and int highbyte belongs to xpos, and int lowbyte2 and int highbyte2 belongs to ypos? Do i add argument inside the receive command brackets?
I had created 2 UART tx1, rx1 and tx2, rx2 for individual x and y bytes but it cant work... Both are printed out as xpos bytes.
======================================================================================
(Bot A)
int x = xpos/100;
byte valueX =(byte)x;
int y = ypos/100;
byte valueY =(byte)x;
tx.sendByte(valueX); //send lowbyte
tx.sendByte(valueX >> 8); //send highbyte
tx2.sendByte(valueY); //send lowbyte
tx2.sendByte(valueY >> 8); //send highbyte
(Bot
int lowbyte = rx.receiveByte(); //receive lowbyte
int highbyte = rx.receiveByte(); //receive highbyte
int valueX = (highbyte << 8) | (lowbyte & 0xFF);
Format.printf("Received Data = %d\n",valueX);
int lowbyte2 = rx2.receiveByte(); //receive lowbyte
int highbyte2 = rx2.receiveByte(); //receive highbyte
int valueY = (highbyte << 8) | (lowbyte & 0xFF);
Format.printf("Received Data = %d\n",valueY);
Post Edited (StereoPonyz) : 2/1/2010 4:56:12 PM GMT
For example, you could send
"!eb",xpos,xpos>>8,ypos,ypos>>8
On the receiver side, you then wait for reception of "!eb",
after which follow 4 bytes that make up the integers xpos and ypos.
regards peter
Sorry i dont understand the synchronisation method...
Do you mean: tx.sendByte("!eb",xpos,xpos>>8,ypos,ypos>>8) Has error...
I also tried: tx.sendByte("!eb",xpos,xpos>>8) Has error...
What does '!eb' mean?
Post Edited (StereoPonyz) : 2/2/2010 4:12:10 AM GMT
//on transmitter bot
int xpos,ypos;
tx.sendString("!eb");
tx.sendByte(xpos);
tx.sendByte(xpos>>8);
tx.sendByte(ypos);
tx.sendByte(ypos>>8);
//on receiver bot
int xpos,ypos;
void receiveXY() {
· 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
················ xpos = rx.receiveByte();
·················state = 4;
················ break;
····· case 4: //get xpos highbyte
················ xpos |= (rx.receiveByte() << 8);
·················state = 5;
················ break;
····· case 5: //get ypos lowbyte
················ ypos = rx.receiveByte();
·················state = 6;
················ break;
····· case 6: //get ypos highbyte
················ ypos |= (rx.receiveByte() << 8);
················ return; //at this point the·function returns
··· }
· }
}
receiveXY() waits for "!eb" and then sets xpos and ypos.
It should be called after establishing data mode.
regards peter
Post Edited (Peter Verkaik) : 2/2/2010 1:06:43 PM GMT