Hi all, hoping someone can help with an issue that has me stumped.
I am using a Mini Pro to control two BLDC motor controllers and add remote control functionality. This requires me to have 3 devices on the SPI bus, 2 x DACs and 1 x NRF24L01.
The problem I am having is the NRF24L01 communication with the Pro Mini only works with the FTDI connected and connected to my Mac. The SPI comms to the 2 x DACs always work.
The setup is powered via 48V battery that is stepped down to 12V via a LM2596HVS-12 which supplies the Arduino and the 12V is then stepped down to 3v3 for the NRF24L01 using a MIC5205-3.3YM5-TR and I have included two filtering capacitors a 10uF and 100nF to stabilise the voltage supply for the NRF24L01.
I am assuming there are no power supply issues as the moment I plug in the FTDI the commands that that NRF24L01 we instructed to send are received by the Arduino, so it appears that the NRF24L01 was sending the commands all along but the Arduino was not receiving it.
My setup looks like this:
void setup() {
pinMode(10, OUTPUT); // set the SS pin as an output
pinMode(7, OUTPUT); // set the SS1 pin as an output
pinMode(6, OUTPUT); // set the SS2 pin as an output
pinMode(4, OUTPUT); // On/Off switch set to output
pinMode(interruptPin, INPUT_PULLUP);
digitalWrite(10, HIGH); // set the SS1 pin to HIGH (OFF)
digitalWrite(7, HIGH); // set the SS2 pin to HIGH (OFF)
digitalWrite(6, HIGH); // set the SS3 pin to HIGH (OFF)
digitalWrite(4, LOW); // On/Off switch set to output
SPI.begin(); // initialize the SPI library
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate(RF24_250KBPS);
radio.maskIRQ(1, 1, 0);
radio.startListening();
attachInterrupt(digitalPinToInterrupt(interruptPin), remoteReceive, FALLING);
// Setup digital pins
pinMode(seatIn, INPUT_PULLUP); // sets the pin as Input & uses internal pull resistor
Wire.begin();
}
The remoteReceive Code is:
void remoteReceive() {
if (radio.available()) {
remoteData = 0;
detachInterrupt(digitalPinToInterrupt(interruptPin));
radio.read(&remoteData, sizeof(remoteData));
// Flush any other packets that might be in the buffer
while (radio.available()) {
int flushedData;
radio.read(&flushedData, sizeof(flushedData));
}
triggered = true;
}
}
The DAC code is:
void setVoltageLeft(uint16_t speedVoltLeft) {
digitalWrite(7, LOW); // set the SS pin to LOW (On)
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
word outputValueLeft = speedVoltLeft;
byte dataLeft = highByte(outputValueLeft);
dataLeft = 0b00001111 & dataLeft; // clear 4bit command field (optional)
dataLeft = 0b00110000 | dataLeft; // 0=DACA, 0=buffered, 1=1x, 1=output enabled
SPI.transfer(dataLeft);
dataLeft = lowByte(outputValueLeft);
SPI.transfer(dataLeft);
SPI.endTransaction();
digitalWrite(7, HIGH); // set the SS pin HIGH (Off)
}
Any help would be most appreciated - Thanks
1 post - 1 participant