Vixen -> Arduino -> Snoodle/Grinch/595/shift register

Ok, in my previous post, I was able to run a simple Arduino code to shift 1’s and 0’s into an MBI5027 shift register and latch it to make sure all the communication was working.  That’s great if you just want to flash the output pins back and forth, but now we need to control those outputs from Vixen.
Back when I designed the Snoodle, based off the Grinch (which is 4 x MBI5027 shift registers), I was using Vixen 2.5.  With that version, you basically defined a controller, the channels, and started sequencing.  Vixen 2.5 is still available for download.  The same settings work perfectly with Vixen 3.x as well.

Here is the working Arduino code with an example for 32 channels that works perfect with Vixen.  When setting up the plugin, choose your Arduino serial port, be sure to set the speed to 57600, and the header text to “Snoodle” without the quotes as shown below:

If your Arudino is showing up on a COM higher than 4, you’ll need to change it as Vixen 2.5 can’t talk to a COM port higher than 4.  Here are the quick steps to change it.  If you don’t know how to get to the device manager on your version of windows, Google it.

  1. Open device manager
  2. Under “Ports (COM & LPT), right-click on your Arduino and select Properties
  3. Click the “Port Settings” tab and then the “Advanced…” button
  4. Select the “COM port number” drop down and choose one that is not listed as (in use) between COM1 and COM4

NOTE!  Change the #define CHANNELS 32 to match the number of channels you have less than or equal to 200 channels.  The 200 limitation is built into the Shifter library.  If it ever becomes an issue for me, I’ll update the library to allow for more channels and post it on this site.  This also needs to match the number of channels defined in Vixen 2.5/3.x

#include <Shifter.h>

// Pins connected to shift register(s)

#define SERIAL_Pin 5 //SDI (Pin 2)
#define CLOCK_Pin 6 // Clock (Pin 3)
#define LATCH_Pin 7 // Latch (Pin 4)

// Number of channels to control, should be a multiple of 8 or 16
// depending on the type of shift register(s) used.
// Must be less than or equal to 200 channels using the
// Arduino shifter library
#define CHANNELS 32

//intensity value to turn on channels
#define CHANNEL_TRIGGER_LEVEL 128

//set output status
#define CHANNEL_ON HIGH
#define CHANNEL_OFF LOW

Shifter shifter(SERIAL_Pin, LATCH_Pin, CLOCK_Pin, CHANNELS/8);
byte FrameHeader[] = "Snoodle";
byte FrameHeaderLength = sizeof(FrameHeader) - 1;
byte FrameHeaderIndex = 0;
int CurrentChannelIndex = 0;

void setup() {
Serial.begin(57600);
// set up for a new frame
FrameHeaderIndex = 0;
CurrentChannelIndex = 0;

// Start with all registers cleared.
shifter.clear(); //set all pins on the shift register chain to LOW
shifter.write(); //send changes to the chain and display them
}

void loop() {
// Is there data to process?
while (Serial.available() > 0) {
// Yes, are we looking for the frame header or processing data?
if (FrameHeaderIndex < FrameHeaderLength) {
// Looking for the frame header
if( Serial.read() == FrameHeader[FrameHeaderIndex]) {
// Matching so far...
++FrameHeaderIndex;
} else {
// not the expected value. Start searching at the beginning again
FrameHeaderIndex = 0;
}
} else {
// Processing data
shifter.setPin(CurrentChannelIndex, (Serial.read() < CHANNEL_TRIGGER_LEVEL) ? CHANNEL_OFF : CHANNEL_ON);
++CurrentChannelIndex;

// Did we get settings for all of the channels?
if (CurrentChannelIndex == CHANNELS) {
// Yes, send out the data.
shifter.write();
CurrentChannelIndex = 0;
FrameHeaderIndex = 0;
} // Nope, keep getting more data over the serial port.
}
}
}

Comments are closed.