I am using an Arduino Due board to manage an ads1256 DAC and a relays module simultaneously. The problem is: when activate the SPI to communicate with ads1256, the relays doesn't works. The sketch is very simple:
#include <SPI.h>
#include "ads1256_c.h"
double myVolts = 1.000000000000000;
int32_t val1;//Holds the returned value
unsigned long myTimer;//millis() timer, holds the next time
int myChannel;//used to toggle between the channels
float clockMHZ = 7.68; // crystal frequency used on ADS1256
float vRef = 2.5; // voltage reference
// Initialize ADS1256 object
float sensor1, sensor2, sensor3, sensor4;
int relay_pin = 36;
int blinkTime = 3270;
void setup() {
pinMode(relay_pin,INPUT_PULLUP);
blinkyBlinky(5, blinkTime); // 5 is number of blinks;
delay(1000);//let everything settle
Serial.begin(9600);
Serial.println("ads1256_Arduino_Due");
//initialize pins for the ADS
pinMode(ADS_CS_PIN, OUTPUT);
pinMode(ADS_RDY_PIN, INPUT);
pinMode(ADS_RST_PIN, OUTPUT);
SPI.begin();
//set up the ads1256 board
initADS();
}
void loop() {
//
}
// Aqui se comienza a ejecutar acciones del instrumento.
void blinkyBlinky(int repeats, int time)
{
swapChannel(0x01); //0-1 differential between channels
for (int i = 0; i < repeats; i++)
{
pinMode(relay_pin,OUTPUT);
digitalWrite(relay_pin,HIGH);
delay(30);
delay(time);
digitalWrite(relay_pin,LOW);
/*
swapChannel(0x01); //0-1 differential between channels
delay(30);
val1 = read_Value();
myVolts = (val1*1.000000000)*0.0000005960465;
Serial.println(myVolts, 7);
*/
delay(time);
}
}
When delete the swapChannel line, relays works well. Any idea to solve ???