Activity Forums Questions & Troubleshooting Problem with SPI on Controllino Maxi

  • Problem with SPI on Controllino Maxi

  • RoydL

    Member
    September 10, 2023 at 6:54 am

    Hello,

    I have the same problem with the SPI on an Controllino Maxi in combination with a nRF24L01 wireless 2.4GHz device, as I saw on an earlier post from somebody else. Unfortunately I couldn’t find the answer in the comments that led me to the final solution. That’s why I ask it here. See complete code on the bottom of this message.

    When I put the program between two Arduino nano’s it works perfect. When I put the same receiver program in an Arduino Uno (and the transmitter program remains on an Arduino nano) it still works perfect. But as soon as I put the program in the Controllino Maxi, there is no communication. Also when I use the same cables and the same antenna, so because of the nano and Uno tests, I am sure that part of the hardware is working.

    I did find on this forum that I should call: “Controllino_RTC_init();” But I couldn’t find or that should be in de void setup, void loop or before the #include part. I tried it all, but in the end it was not the solution. I put “#include <Controllino.h> as extra library, that I don’t use in the nano and Uno.

    I also tried to put “pinMode(53, OUTPUT);” in de void setup, even when I don’t use that output. And I tried to use header pins 7 and 8 for CE and CSN. But I tried also pins 53 and 9 for CE and CSN.

    Does anyone have the final solution found already, why the receiver code works in a nano and Uno and not in the Controllino Maxi? And if so, what can I try or add at my code to get it work properly? I am using an external powersupply of 3,3Vdc to power VCC and GND of the nRF24L01 + PA + LNA chip and soldered a 10 uF capacitor on VCC and GND directly on that chip.

    Transmitter code Arduino nano (that works perfect with other Arduino nano and Uno):

    #include <SPI.h>

    #include <nRF24L01.h>

    #include <RF24.h>

    RF24 radio(7, 8); //CE, CNS

    const byte address[6] = “00001”;

    int slowUpInput = A0;

    int fastUpInput = A1;

    int slowDownInput = A2;

    int fastDownInput = A3;

    int leftInput = A4;

    int rightInput = A5;

    int slowForwardInput = 2;

    int fastForwardInput = 3;

    int slowBackInput = 4;

    int fastBackInput = 5;

    unsigned long startCommCheck = 0;

    unsigned long commCheckInterval = 500;

    //max 32 bytes.. Limit of the NRF24L01!

    struct Data_Package{

    byte slowUp = 0;

    byte fastUp = 0;

    byte slowDown = 0;

    byte fastDown = 0;

    byte left = 0;

    byte right = 0;

    byte slowForward = 0;

    byte fastForward = 0;

    byte slowBack = 0;

    byte fastBack = 0;

    byte commCheck = 0;

    };

    Data_Package data;

    void setup() {

    pinMode(slowUpInput, INPUT);

    pinMode(fastUpInput, INPUT);

    pinMode(slowDownInput, INPUT);

    pinMode(fastDownInput, INPUT);

    pinMode(leftInput, INPUT);

    pinMode(rightInput, INPUT);

    pinMode(slowForwardInput, INPUT);

    pinMode(fastForwardInput, INPUT);

    pinMode(slowBackInput, INPUT);

    pinMode(fastBackInput, INPUT);

    startCommCheck = millis();

    Serial.begin(9600);

    radio.begin();

    radio.openWritingPipe(address);

    radio.setPALevel(RF24_PA_MIN);

    radio.stopListening();

    }

    void loop() {

    Serial.print(“commCheck: “);

    Serial.println(data.commCheck);

    // Send the whole data from the structure to the receiver

    if(digitalRead(slowUpInput)== HIGH){

    data.slowUp = 1;

    }

    else{

    data.slowUp = 0;

    }

    if(digitalRead(fastUpInput) == HIGH){

    data.fastUp = 1;

    }

    else{

    data.fastUp = 0;

    }

    if(digitalRead(slowDownInput) == HIGH){

    data.slowDown = 1;

    }

    else{

    data.slowDown = 0;

    }

    if(digitalRead(fastDownInput) == HIGH){

    data.fastDown = 1;

    }

    else{

    data.fastDown = 0;

    }

    if(digitalRead(leftInput) == HIGH){

    data.left = 1;

    }

    else{

    data.left = 0;

    }

    if(digitalRead(rightInput) == HIGH){

    data.right = 1;

    }

    else{

    data.right = 0;

    }

    if(digitalRead(slowForwardInput) == HIGH){

    data.slowForward = 1;

    }

    else{

    data.slowForward = 0;

    }

    if(digitalRead(fastForwardInput) == HIGH){

    data.fastForward = 1;

    }

    else{

    data.fastForward = 0;

    }

    if(digitalRead(slowBackInput) == HIGH){

    data.slowBack = 1;

    }

    else{

    data.slowBack = 0;

    }

    if(digitalRead(fastBackInput) == HIGH){

    data.fastBack = 1;

    }

    else{

    data.fastBack = 0;

    }

    if(millis()-startCommCheck >= commCheckInterval){

    startCommCheck = millis();

    data.commCheck = !data.commCheck;

    }

    radio.write(&data, sizeof(Data_Package));

    delay(200);

    }

    Receiver code:

Viewing 1 of 1 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now