Skip to main content
deleted 78 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

Transfer 10-bit via arduinoArduino-to-arduino spiArduino SPI protocol

The task I need to accomplish is as followedfollows:

I have an analog/digital converter witchthat sends out a 10 bit-bit signal. This bit signal needs to be transferred to an Arduino Uno using the SPI protocol. Because the SPI protocol works with a 16 bit pattern I need to expand the incoming signal. The Slaveslave Arduino then needs to put out the transferedtransferred number as ain decimal one.

For my task I will imitated the ADC with another Arduino Uno, setting it as a Mastermaster, but unfortunately at the time I only havehad one Arduino so I can'tcouldn't test my code. And furthermoreFurthermore, I don't really have a clue how to "expand" a 10 bit-bit signal to a 16 bit-bit one. Can someone please explain it to me and have a look at my codescode?

Code for the Mastermaster Arduino:

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
 
  pinMode(SS, OUTPUT);
  pinMode(MOSI, OUTPUT);
  SPI.beginTransaction(SPISettings(62500, LSBFIRST, SPI_MODE0));
}

void loop() {
 
  byte x=0000001101;
  byte y=0011111111;
 
  digitalWrite(SS,LOW);
  SPI.transfer(x,y);
  digitalWrite(SS,HIGH);
 
  delay(1000);
}

Code for the Slaveslave Arduino:

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
 
  pinMode(SS, INPUT);
  pinMode(MOSI, INPUT);
  
}

void loop() {
  byte x=SPDR;
  byte y=SPDR;
  printf(x,DEC);
  printf(y,DEC);
 
  delay(1000);
}

Transfer 10-bit via arduino-to-arduino spi protocol

The task I need to accomplish is as followed:

I have an analog/digital converter witch sends out a 10 bit signal. This bit signal needs to be transferred to an Arduino Uno using the SPI protocol. Because the SPI protocol works with a 16 bit pattern I need to expand the incoming signal. The Slave Arduino then needs to put out the transfered number as a decimal one.

For my task I will imitated the ADC with another Arduino Uno setting it as a Master, but unfortunately at the time I only have one Arduino so I can't test my code. And furthermore I don't really have a clue how to "expand" a 10 bit signal to a 16 bit one. Can someone please explain it to me and have a look at my codes?

Code for the Master Arduino

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
 
  pinMode(SS, OUTPUT);
  pinMode(MOSI, OUTPUT);
  SPI.beginTransaction(SPISettings(62500, LSBFIRST, SPI_MODE0));
}

void loop() {
 
  byte x=0000001101;
  byte y=0011111111;
 
  digitalWrite(SS,LOW);
  SPI.transfer(x,y);
  digitalWrite(SS,HIGH);
 
  delay(1000);
}

Code for the Slave Arduino

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
 
  pinMode(SS, INPUT);
  pinMode(MOSI, INPUT);
  
}

void loop() {
  byte x=SPDR;
  byte y=SPDR;
  printf(x,DEC);
  printf(y,DEC);
 
  delay(1000);
}

Transfer 10-bit via Arduino-to-Arduino SPI protocol

The task I need to accomplish is as follows:

I have an analog/digital converter that sends out a 10-bit signal. This signal needs to be transferred to an Arduino Uno using the SPI protocol. Because the SPI protocol works with a 16 bit pattern I need to expand the incoming signal. The slave Arduino then needs to put out the transferred number in decimal.

I imitated the ADC with another Arduino Uno, setting it as master, but unfortunately at the time I only had one Arduino so I couldn't test my code. Furthermore, I don't really have a clue how to "expand" a 10-bit signal to a 16-bit one. Can someone please explain it to me and have a look at my code?

Code for the master Arduino:

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
  pinMode(SS, OUTPUT);
  pinMode(MOSI, OUTPUT);
  SPI.beginTransaction(SPISettings(62500, LSBFIRST, SPI_MODE0));
}

void loop() {
  byte x=0000001101;
  byte y=0011111111;
  digitalWrite(SS,LOW);
  SPI.transfer(x,y);
  digitalWrite(SS,HIGH);
  delay(1000);
}

Code for the slave Arduino:

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {
  pinMode(SS, INPUT);
  pinMode(MOSI, INPUT);
}

void loop() {
  byte x=SPDR;
  byte y=SPDR;
  printf(x,DEC);
  printf(y,DEC);
  delay(1000);
}
Source Link
Xenox
  • 123
  • 1
  • 4

Transfer 10-bit via arduino-to-arduino spi protocol

The task I need to accomplish is as followed:

I have an analog/digital converter witch sends out a 10 bit signal. This bit signal needs to be transferred to an Arduino Uno using the SPI protocol. Because the SPI protocol works with a 16 bit pattern I need to expand the incoming signal. The Slave Arduino then needs to put out the transfered number as a decimal one.

For my task I will imitated the ADC with another Arduino Uno setting it as a Master, but unfortunately at the time I only have one Arduino so I can't test my code. And furthermore I don't really have a clue how to "expand" a 10 bit signal to a 16 bit one. Can someone please explain it to me and have a look at my codes?

Code for the Master Arduino

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {

  pinMode(SS, OUTPUT);
  pinMode(MOSI, OUTPUT);
  SPI.beginTransaction(SPISettings(62500, LSBFIRST, SPI_MODE0));
}

void loop() {

  byte x=0000001101;
  byte y=0011111111;

  digitalWrite(SS,LOW);
  SPI.transfer(x,y);
  digitalWrite(SS,HIGH);

  delay(1000);
}

Code for the Slave Arduino

#include <SPI.h>
#define SS 10
#define MOSI 11

void setup() {

  pinMode(SS, INPUT);
  pinMode(MOSI, INPUT);
  
}

void loop() {
  byte x=SPDR;
  byte y=SPDR;
  printf(x,DEC);
  printf(y,DEC);

  delay(1000);
}