generationmake
Published © CERN-OHL

LED Sequencer with the MKR Vidor 4000

My LED sequencer itself is quite simple but I shows you how to use the Mini PCIe connector of the MKR Vidor 4000 with a breakout board.

IntermediateProtip4,897
LED Sequencer with the MKR Vidor 4000

Things used in this project

Hardware components

Arduino MKR Vidor 4000
Arduino MKR Vidor 4000
×1
VidorBreakout
data available at github: https://github.com/generationmake/VidorBreakout
×1
Through Hole Resistor, 3 kohm
Through Hole Resistor, 3 kohm
×17
3 mm LED: Green
3 mm LED: Green
×17

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Schematic of the VidorBreakout

Code

LED sequencer on Arduino MKR Vidor 4000

C/C++
this code shows how to access the pins on the Mini PCIe connector of the Arduino MKR Vidor 4000
#include "VidorPeripherals.h"
#define STARTDELAY 500

void setup() {
  Serial.begin(115200);
//  while (!Serial) {}
  // Let's start by initializing the FPGA
  if (!FPGA.begin()) {
    Serial.println("Initialization failed!");
    while (1) {}
  }

  // Let's discover which version we are running
  int version = FPGA.version();
  Serial.print("Vidor bitstream version: ");
  Serial.println(version, HEX);
  pinMode(LED_BUILTIN, OUTPUT);

  // Let's also ask which IPs are included in this bitstream
  FPGA.printConfig();

  // Ok, so we know now that the FPGA contains the extended GPIO IP
  // Please refer to the online documentation for the actual pin assignment
  // Let's configure pin A0 to be an output, controlled by the FPGA
  FPGA.pinMode(0, OUTPUT);
  FPGA.pinMode(1, OUTPUT);
  FPGA.pinMode(2, OUTPUT);
  FPGA.pinMode(3, OUTPUT);
  FPGA.pinMode(4, OUTPUT);
  FPGA.pinMode(5, OUTPUT);
  FPGA.pinMode(6, OUTPUT);
  FPGA.pinMode(7, OUTPUT);
  FPGA.pinMode(8, OUTPUT);
  FPGA.pinMode(9, OUTPUT);
  FPGA.pinMode(10, OUTPUT);
  FPGA.pinMode(11, OUTPUT);
  FPGA.pinMode(12, OUTPUT);
  FPGA.pinMode(13, OUTPUT);
  FPGA.pinMode(14, OUTPUT);
  FPGA.pinMode(15, OUTPUT);
  FPGA.pinMode(16, OUTPUT);
  FPGA.pinMode(17, OUTPUT);
  FPGA.pinMode(18, OUTPUT);
  FPGA.pinMode(33, OUTPUT);
  FPGA.digitalWrite(33, HIGH);

  // The same pin can be read by the SAMD processor 
  pinMode(A0, INPUT);
  Serial.print("Pin A0 is ");
  Serial.println(digitalRead(A0) == LOW ? "LOW" : "HIGH");

  FPGA.digitalWrite(33, LOW);
  Serial.print("Pin A0 is ");
  Serial.println(digitalRead(A0) == LOW ? "LOW" : "HIGH");
}

void loop() {
  // put your main code here, to run repeatedly:
  int delaytime=STARTDELAY;

  FPGA.digitalWrite(1, HIGH);
  FPGA.digitalWrite(2, HIGH);
  FPGA.digitalWrite(3, HIGH);
  FPGA.digitalWrite(4, HIGH);
  FPGA.digitalWrite(5, HIGH);
  FPGA.digitalWrite(6, HIGH);
  FPGA.digitalWrite(7, HIGH);
  FPGA.digitalWrite(0, HIGH);
  FPGA.digitalWrite(8, HIGH);
  FPGA.digitalWrite(9, HIGH);
  FPGA.digitalWrite(10, HIGH);
  FPGA.digitalWrite(11, HIGH);
  FPGA.digitalWrite(12, HIGH);
  FPGA.digitalWrite(13, HIGH);
  FPGA.digitalWrite(14, HIGH);
  FPGA.digitalWrite(15, HIGH);
  FPGA.digitalWrite(16, HIGH);
  delay(delaytime);
  FPGA.digitalWrite(1, LOW);
  FPGA.digitalWrite(2, LOW);
  FPGA.digitalWrite(3, LOW);
  FPGA.digitalWrite(4, LOW);
  FPGA.digitalWrite(5, LOW);
  FPGA.digitalWrite(6, LOW);
  FPGA.digitalWrite(7, LOW);
  FPGA.digitalWrite(0, LOW);
  FPGA.digitalWrite(8, LOW);
  FPGA.digitalWrite(9, LOW);
  FPGA.digitalWrite(10, LOW);
  FPGA.digitalWrite(11, LOW);
  FPGA.digitalWrite(12, LOW);
  FPGA.digitalWrite(13, LOW);
  FPGA.digitalWrite(14, LOW);
  FPGA.digitalWrite(15, LOW);
  FPGA.digitalWrite(16, LOW);
  delay(delaytime);

  for(delaytime=STARTDELAY;delaytime-=100;delaytime>0)
  {
    digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(delaytime);
    digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
    FPGA.digitalWrite(1, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(1, LOW);
    FPGA.digitalWrite(2, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(2, LOW);
    FPGA.digitalWrite(3, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(3, LOW);
    FPGA.digitalWrite(4, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(4, LOW);
    FPGA.digitalWrite(5, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(5, LOW);
    FPGA.digitalWrite(6, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(6, LOW);
    FPGA.digitalWrite(7, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(7, LOW);
    FPGA.digitalWrite(0, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(0, LOW);
    FPGA.digitalWrite(8, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(8, LOW);
    FPGA.digitalWrite(9, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(9, LOW);
    FPGA.digitalWrite(10, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(10, LOW);
    FPGA.digitalWrite(11, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(11, LOW);
    FPGA.digitalWrite(12, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(12, LOW);
    FPGA.digitalWrite(13, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(13, LOW);
    FPGA.digitalWrite(14, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(14, LOW);
    FPGA.digitalWrite(15, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(15, LOW);
    FPGA.digitalWrite(16, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(16, LOW);
  }
  for(delaytime=STARTDELAY;delaytime-=100;delaytime>0)
  {
    FPGA.digitalWrite(1, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(2, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(3, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(4, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(5, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(6, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(7, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(0, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(8, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(9, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(10, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(11, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(12, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(13, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(14, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(15, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(16, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(1, LOW);
    delay(delaytime);
    FPGA.digitalWrite(2, LOW);
    delay(delaytime);
    FPGA.digitalWrite(3, LOW);
    delay(delaytime);
    FPGA.digitalWrite(4, LOW);
    delay(delaytime);
    FPGA.digitalWrite(5, LOW);
    delay(delaytime);
    FPGA.digitalWrite(6, LOW);
    delay(delaytime);
    FPGA.digitalWrite(7, LOW);
    delay(delaytime);
    FPGA.digitalWrite(0, LOW);
    delay(delaytime);
    FPGA.digitalWrite(8, LOW);
    delay(delaytime);
    FPGA.digitalWrite(9, LOW);
    delay(delaytime);
    FPGA.digitalWrite(10, LOW);
    delay(delaytime);
    FPGA.digitalWrite(11, LOW);
    delay(delaytime);
    FPGA.digitalWrite(12, LOW);
    delay(delaytime);
    FPGA.digitalWrite(13, LOW);
    delay(delaytime);
    FPGA.digitalWrite(14, LOW);
    delay(delaytime);
    FPGA.digitalWrite(15, LOW);
    delay(delaytime);
    FPGA.digitalWrite(16, LOW);
    delay(delaytime);
  }
  for(delaytime=STARTDELAY;delaytime-=100;delaytime>0)
  {
    digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(delaytime);
    digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
    FPGA.digitalWrite(16, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(16, LOW);
    FPGA.digitalWrite(1, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(1, LOW);
    FPGA.digitalWrite(15, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(15, LOW);
    FPGA.digitalWrite(2, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(2, LOW);
    FPGA.digitalWrite(14, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(14, LOW);
    FPGA.digitalWrite(3, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(3, LOW);
    FPGA.digitalWrite(13, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(13, LOW);
    FPGA.digitalWrite(4, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(4, LOW);
    FPGA.digitalWrite(12, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(12, LOW);
    FPGA.digitalWrite(5, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(5, LOW);
    FPGA.digitalWrite(11, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(11, LOW);
    FPGA.digitalWrite(6, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(6, LOW);
    FPGA.digitalWrite(10, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(10, LOW);
    FPGA.digitalWrite(7, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(7, LOW);
    FPGA.digitalWrite(9, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(9, LOW);
    FPGA.digitalWrite(0, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(0, LOW);
    FPGA.digitalWrite(8, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(8, LOW);
  }
  for(delaytime=STARTDELAY;delaytime-=100;delaytime>0)
  {
    FPGA.digitalWrite(16, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(1, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(15, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(2, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(14, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(3, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(13, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(4, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(12, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(5, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(11, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(6, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(10, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(7, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(9, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(0, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(8, HIGH);
    delay(delaytime);
    FPGA.digitalWrite(8, LOW);
    delay(delaytime);
    FPGA.digitalWrite(0, LOW);
    delay(delaytime);
    FPGA.digitalWrite(9, LOW);
    delay(delaytime);
    FPGA.digitalWrite(7, LOW);
    delay(delaytime);
    FPGA.digitalWrite(10, LOW);
    delay(delaytime);
    FPGA.digitalWrite(6, LOW);
    delay(delaytime);
    FPGA.digitalWrite(11, LOW);
    delay(delaytime);
    FPGA.digitalWrite(5, LOW);
    delay(delaytime);
    FPGA.digitalWrite(12, LOW);
    delay(delaytime);
    FPGA.digitalWrite(4, LOW);
    delay(delaytime);
    FPGA.digitalWrite(13, LOW);
    delay(delaytime);
    FPGA.digitalWrite(3, LOW);
    delay(delaytime);
    FPGA.digitalWrite(14, LOW);
    delay(delaytime);
    FPGA.digitalWrite(2, LOW);
    delay(delaytime);
    FPGA.digitalWrite(15, LOW);
    delay(delaytime);
    FPGA.digitalWrite(1, LOW);
    delay(delaytime);
    FPGA.digitalWrite(16, LOW);
    delay(delaytime);
  }
}

Credits

generationmake

generationmake

0 projects • 0 followers

Comments