Javelin stamp and LISY300 communication
FreskFesk
Posts: 3
Hi all,
I've encountered a problem with my javelin. My javelin and my gyro (lisy300) won't communicate properly. I do get signals which vary as a gyro should, but they aren't correct. I've connected all wires like on the example code on the BS2. Here is my code:
CODE
import stamp.core.*;
import stamp.math.*;
class gyrotest{
static int dout;
static int sclk;
static int csn;
static int value;
public static void main() {
dout=CPU.pin0;
sclk=CPU.pin1;
csn=CPU.pin2;
value=0;
CPU.writePin(csn,true);
CPU.writePin(sclk,false);
CPU.delay(500);
value=readGyro();
forst=value;
while(true){
value=readGyro();
System.out.println(value/*area*/);
CPU.delay(50);
}
}
public static int readGyro(){
CPU.writePin(csn,false);
int x=CPU.shiftIn(dout,sclk,13,CPU.POST_CLOCK_MSB);
CPU.writePin(csn,true);
return x;
}
}
CODEEND
I think there is a problem with the trailing zeroes or something like that.
Example of output is:
0
0
0
0
3
0
0
0
0
0
0
6
0
0
3
3
0
Thank for reading my post, all replies are welcome!
I've encountered a problem with my javelin. My javelin and my gyro (lisy300) won't communicate properly. I do get signals which vary as a gyro should, but they aren't correct. I've connected all wires like on the example code on the BS2. Here is my code:
CODE
import stamp.core.*;
import stamp.math.*;
class gyrotest{
static int dout;
static int sclk;
static int csn;
static int value;
public static void main() {
dout=CPU.pin0;
sclk=CPU.pin1;
csn=CPU.pin2;
value=0;
CPU.writePin(csn,true);
CPU.writePin(sclk,false);
CPU.delay(500);
value=readGyro();
forst=value;
while(true){
value=readGyro();
System.out.println(value/*area*/);
CPU.delay(50);
}
}
public static int readGyro(){
CPU.writePin(csn,false);
int x=CPU.shiftIn(dout,sclk,13,CPU.POST_CLOCK_MSB);
CPU.writePin(csn,true);
return x;
}
}
CODEEND
I think there is a problem with the trailing zeroes or something like that.
Example of output is:
0
0
0
0
3
0
0
0
0
0
0
6
0
0
3
3
0
Thank for reading my post, all replies are welcome!
Comments
http://forums.parallax.com/showthread.php?138677-Javelin-stamp-and-LISY300-communication