mj Posted March 3, 2016 Share Posted March 3, 2016 Will the analog shield work with an arduino yun? Link to comment Share on other sites More sharing options...
JColvin Posted March 4, 2016 Share Posted March 4, 2016 Hi mj, I'm not certain if it will work or not. The original code written by a Stanford student was only made to support a standard Arduino (such as an Arduino Uno) and Digilent has only updated the code to work with our line of microcontroller boards that share a similar pinout. I think in principle it should work, but I do not have any confirmation on this. Thanks, JColvin Link to comment Share on other sites More sharing options...
mj Posted March 10, 2016 Author Share Posted March 10, 2016 I spent a few days looking at the driver code, Yun/Uno schematics, and ADC/DAC datasheets, and came up with "normal" (not doing direct register/pin access like the driver code does) Arduino code that more or less runs the board. In a simple-minded proportional control, I can get about 3kHz running all 4 ADC/DAC pairs. Below is my version of pass-thru; just reading the ADCs takes about 100us: /* ADC & DAC Testing */ #include <SPI.h> const int ADC_CSNPin = 2; const int ADC_RDYPin = 3; const int DAC_SYNCNPin = 5; const int DAC_LDACPin = 6; void setup() { Serial.begin(9600); pinMode(ADC_CSNPin, OUTPUT); pinMode(ADC_RDYPin, INPUT); pinMode(DAC_SYNCNPin, OUTPUT); pinMode(DAC_LDACPin, OUTPUT); // initialize SPI: SPI.begin(); SPI.beginTransaction (SPISettings(14000000, MSBFIRST, SPI_MODE0)); digitalWrite(ADC_CSNPin, HIGH); } void loop() { byte ADCControlMask[] = { B10010110,B11010110,B10100110,B11100110 }; byte DACControlMask[] = { B00000000,B00000000,B00000000,B00100000 }; word value12 ; byte value3; word value123[4]; // go through the 4 channels of the ADC: digitalWrite(ADC_CSNPin, LOW); SPI.beginTransaction (SPISettings(14000000, MSBFIRST, SPI_MODE0)); for (byte channel = 0; channel < 4; channel++) { byte ADC_Command = ADCControlMask [channel]; SPI.transfer(ADC_Command); byte ADC_Flag = digitalRead (ADC_RDYPin); while (ADC_Flag == 0){ ADC_Flag = digitalRead (ADC_RDYPin); } value12 = SPI.transfer16(0); value3 = SPI.transfer(0); value123[channel] = value12 << 1; if (value3 == 0x80 ) { value123[channel] += 1;} } digitalWrite(ADC_CSNPin, HIGH); // go through the 4 channels of the DAC: SPI.beginTransaction (SPISettings(14000000, MSBFIRST, SPI_MODE1)); for (byte channel = 0; channel < 4; channel++) { byte DAC_Command = DACControlMask [channel] | (channel << 1 ); DACWrite(DAC_Command, value123[channel] - 0x8000); } } void DACWrite(byte DAC_Command, word value) { digitalWrite(DAC_SYNCNPin, LOW); SPI.transfer(DAC_Command); SPI.transfer16(value); digitalWrite(DAC_SYNCNPin, HIGH); } Link to comment Share on other sites More sharing options...
Question
mj
Will the analog shield work with an arduino yun?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.