Hello there,
I´m very desperated. I try to read the angle-data from a Murata Sensor called SCA830-D05.
Here you can see the data-sheet:
http://www.murata.com/products/sensor/catalog/pdf/sca8x0_21x0_3100_product_family_specification_82_694_00g.pdf
--> @ page 22 you can see the discription of the frames.
afterwards my code:
// include the library code:
#include <SPI.h>
#include <DSPI.h>
#include <SoftSPI.h>
#include <math.h>
// initialize the library with the numbers of the interface pins
//SPI Pins
#define slaveSelect 10 // Chip Select Pin
#define dataOut 11 // MOSI
#define dataIn 12 // MISO
#define spiClock 13 // SCK serial-clock
//----------------------------------------------------------------------
void setup()
{
pinMode(slaveSelect, OUTPUT);
pinMode(dataOut, OUTPUT);
pinMode(dataIn, INPUT);
pinMode(spiClock, OUTPUT);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
delay(10);
Serial.begin(9600);
}
//----------------------------------------------------------------------
void loop()
{
unsigned short int Yaxis;
float a, alpha;
//START SPI-------------------------------------------------------------
digitalWrite(slaveSelect,LOW);
delay(50);
SPI.transfer(0x15);
Yaxis = Yaxis | SPI.transfer(0x00);
digitalWrite(slaveSelect,HIGH);
Yaxis = Yaxis << 8;
digitalWrite(slaveSelect,LOW);
SPI.transfer(0x10);
Yaxis = Yaxis | SPI.transfer(0x00);
digitalWrite(slaveSelect,HIGH);
//END SPI---------------------------------------------------------------
a = (float)Yaxis / 32000.0 *90.0;
alpha = asin(a);
Serial.print(alpha,DEC);
Serial.println(" ");
delay(25);
}
I checked every signal, serial-clock, CSB, MOSI -everything is fine.
At MISO the output is 3.3 V.
After that I checked a digital-switch supplied by 3.3 V with digital.Read function -->it works...
Why is it impossible to show the code by serial.print on the serial monitor??
Is there a mistake?
I´m very thankful if somebody can help.
Thank you very much, kind regards Micha