I am using a arduino micro, micro to std hdmi connectors I made as a shield using kicad and macrofab.
the micro side go to 4 layer boards that are capacitive sensors with the hdmi cable using as a way to conenct the two. The LTC2400 is not talking to the arduino or just sending 0s all the time.
//LTC2400 24bit ADC Module
//4.096 precision reference: TI REF3040
//by joshua wojnas
//libaries
#include <Stdio.h>
#include<stdlib.h>
// the sensor communicates using SPI, so include the library:
#include <SPI.h>
//constants for pin numbers to be replaced by arduino digital pin
#define LTC_CS A0 // LTC2400 Chip Select
#define LTC_MISO MISO // LTC2400 SDO Select
#define LTC_SCK SCK // LTC2400 SCK Select
#define ARD_SS SS // arduino slave Select
//these are arduino digital pins a0 analog 0 1 is digital pin one on arduino
//used to mask out bits not needed
//Sensor's memory register addresses:
const int PRESSURE = 0x1F; //3 most significant bits of pressure
const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure
const int TEMPERATURE = 0x21; //16 bit temperature reading
const byte READ = 0b11111100; // SCP1000's read command
const byte WRITE = 0b00000010; // SCP1000's write command
//these pins might be the arduino pin number
// pins used for the connection with the sensor
// the other you need are controlled by the SPI library):
//const int dataReadyPin = 1; //not used in this application
const int chipSelectPin = A0;//f7 a0
//ref https://electronics.stackexchange.com/questions/67087/analogread0-or-analogreada0
//vareables used in code
byte inByte = 0; // incoming byte from the SPI 8 bit value
unsigned int result = 0; // result to return
float output =0;
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
// while the serial stream is not open, do nothing:
while (!Serial) ;
//the data direction of arduino pins
// initalize the data ready and chip select pins:
// pinMode(dataReadyPin, INPUT);//not used in this application
pinMode(chipSelectPin, OUTPUT);//a0 f7 36 for sensor 1
pinMode(ARD_SS, OUTPUT);//(SS/PCINT0) PB0 RXLED make slave select output to not have arduino slected
pinMode(LTC_SCK, OUTPUT);//ext clk sck low when cs low
//spi.begin sets ss to output
digitalWrite(ARD_SS, HIGH);
// start the SPI library:
SPI.begin();
// give the sensor time to set up:
delay(163);//after chip select
}
void loop() {
// put your main code here, to run repeatedly:
delay(163);//after chip select
//configure spi port
//ltc2400 msb first
/*"out the SDO pin on each falling edge of SCK. This enables
external circuitry to latch the output on the rising edge of
SCK." so SPI_MODE0
*/
//this is not set in examples?
SPI.beginTransaction(SPISettings(14000, MSBFIRST, SPI_MODE0));
// take the chip select low to select the device:
digitalWrite(LTC_SCK, LOW);
digitalWrite(ARD_SS, HIGH);
digitalWrite(chipSelectPin, LOW);
delay(163);//after chip select
//read 4 bytes from adc ltc2400
// send a value of 0 to read the first byte returned:
result = SPI.transfer(0x00);
Serial.print(result);
Serial.print(",");
// shift the first byte left, then get the second byte:
result = result << 8;
inByte = SPI.transfer(0x00);
Serial.print(inByte);
result = result << 8;
inByte = SPI.transfer(0x00);
// combine the byte you just got with the previous one:
result = result | inByte;
result = result << 8;
inByte = SPI.transfer(0x00);
// combine the byte you just got with the previous one:
result = result | inByte;
SPI.endTransaction();
// close SPI transaction
//float output = (float)result;//equation to filter bits
// Serial.print(result);
//Serial.print(output);
// Serial.print(",");
//more sensors
Serial.println("");
//deselect device wait for conversion
digitalWrite(chipSelectPin, HIGH);
}
//result is a unsigned int here they convert it to float after
//shifting and then and ing lower bytes inbyte vareable is used for other transfers.
/*
// convert the temperature to celsius and display it:
float realTemp = (float)tempData / 20.0;
Serial.print("Temp[C]=");
Serial.print(realTemp);
*/