Hello everyone,
I am currently working on my master's thesis and there is a task involving Arduino.
I have a Hall sensor (SS39ET/SS49E/SS59ET Series Linear Hall-effect Sensor ICs) , which is connected to a Converter (TLA2518 Small, 8-Channel, 12-Bit ADC with SPI Interface and GPIOs) through SPI and then to Arduino(UNO).
I have connected them as follows:
MISO to pin 12
MOSI to pin 11
SCK to pin 13
Vcc with Vcc
GND with GND
I have CS on GNS, which is always low.
I have written the code, but I keep getting -1 as the values and I am unable to figure out where the error is.
#include <SPI.h>
// Definieren der SPI-Pins
#define MOSI_PIN 11
#define MISO_PIN 12
#define SCK_PIN 13
// Initialisieren des SPI-Objekts
SPISettings settings(1000000, MSBFIRST, SPI_MODE0);
void setup() {
// Initialisieren der seriellen Schnittstelle
Serial.begin(9600);
// Initialisieren der SPI-Kommunikation
SPI.begin();
SPI.beginTransaction(settings);
// Konfigurieren des TLA2518-IC
byte configByte = 0b00000000; // Konfigurationsbyte
byte resultByte = 0;
SPI.transfer(configByte);
resultByte = SPI.transfer(0); // Lesen des Ergebnisbytes
Serial.println(resultByte);
}
void loop() {
// Lesen des Hall-Sensor-Werts
int sensorValue = 0;
SPI.transfer(0); // Dummy-Byte senden
sensorValue = SPI.transfer16(0); // Lesen des Sensorwerts
// Ausgabe des empfangenen Sensorwerts
Serial.print("Sensorwert: ");
Serial.println(sensorValue);
delay(2000);
}
I have a Hall sensor (SS39ET/SS49E/SS59ET Series
Linear Hall-effect Sensor ICs) , which is connected to an Converter (TLA2518 Small, 8-Channel, 12-Bit ADC with SPI Interface and GPIOs) through SPI and then to Arduino(UNO).
SS is required to select the slave. Not selected slaves don't respond. See the SPI examples in the IDE. You can choose any output pin as the SS for your device, one for each slave.
The TLA2518 itself needs CS to go high to start a conversion. No conversion = no data.
In many other situations it wouldn't be necessary but not here : CS required