I am prototyping a piece of exercise equipment for research. This machine measures the tension in elastic bands attached to bar. The anchor point is attached to a cable that is controlled by a DC motor. This alows for the modulation of the load lifted in real time. Currently I am using a 3.5 with a load cell amp (HX711) and Adafruit BLE Breakout (using SPI). I need top add a draw wire linear position sensor. I have Super Droid ls7366r Encoder Buffer board (https://www.superdroidrobots.com/shop/item.aspx/dual-ls7366r-quadrature-encoder-buffer/1523/) to read the encoder count and pass counts. Both the BLE and the Encoder work independantly on SPI, but I cant get bot to work either by sharing the SPI (MOSI, MISO, & SCK) and assinging a seprate CS pin.
Is there a method i to initialize the SPI1 or 2? Ive changed the SPI to SPi1 in the Encoder H file, but the compiler sends an error.
Is there a method i to initialize the SPI1 or 2? Ive changed the SPI to SPi1 in the Encoder H file, but the compiler sends an error.
Code:
#include <Adafruit_BLE_UART.h>
#include <SPI.h>
#include <Encoder_Buffer.h>
#define ADAFRUITBLE_REQ 10 // Buffer CS 20
#define ADAFRUITBLE_RDY 2
#define ADAFRUITBLE_RST 9
const int ENCODER_BUFFER_CS_PIN = 15;//do i need to initilize this pin to be a CS?
//Encoder shres MOSI,MISO, and SCK opn SPI
//How can I use SPI1 for the Encoder
Adafruit_BLE_UART uart = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);
Encoder_Buffer Encoder1(ENCODER_BUFFER_CS_PIN);
void aciCallback(aci_evt_opcode_t event)
{
switch (event)
{
case ACI_EVT_DEVICE_STARTED:
Serial.println("Advertising started");
break;
case ACI_EVT_CONNECTED:
Serial.println("Connected!");
break;
case ACI_EVT_DISCONNECTED:
Serial.println("Disconnected or advertising timed out");
break;
default:
break;
}
}
void setup(){
// set the slaveSelectPin as an output:
pinMode (ENCODER_BUFFER_CS_PIN, OUTPUT);
// initialize SPI:
SPI.begin();
Serial.begin(9600);
while (!Serial);
uart.setACIcallback(aciCallback);
uart.setDeviceName("uart");
uart.begin();
uart.pollACI();
}
void loop() {
uart.pollACI();
Serial.println(Encoder1.readEncoder());
delay(10);
}