To use the node in your project you should have the cbaf41sluder/wiplinescanblock library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
node {
// Sensor interface:
#define AOpin 0 // Analog output - yellow
#define SIpin 3 // Start Integration - orange
#define CLKpin 2 // Clock - red
// Vcc - brown
// GND - black
#define NPIXELS 128 // No. of pixels in array
byte Pixel[NPIXELS]; // Field for measured values <0-255>
#define FASTADC 1
// defines for setting and clearing register bits
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
void setup(void)
{
pinMode(SIpin, OUTPUT);
pinMode(CLKpin, OUTPUT);
//pinMode (AOpin, INPUT);
digitalWrite(SIpin, LOW); // IDLE state
digitalWrite(CLKpin, LOW); // IDLE state
#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2);
cbi(ADCSRA,ADPS1);
cbi(ADCSRA,ADPS0);
#endif
Serial.begin (115200);
}
void loop (void)
{
int i;
int expTime;
delayMicroseconds (1); /* Integration time in microseconds */
delay(10); /* Integration time in miliseconds */
digitalWrite (CLKpin, LOW);
digitalWrite (SIpin, HIGH);
digitalWrite (CLKpin, HIGH);
digitalWrite (SIpin, LOW);
delayMicroseconds (1);
/* and now read the real image */
for (i = 0; i < NPIXELS; i++) {
Pixel[i] = analogRead (AOpin)/4 ; // 8-bit is enough
digitalWrite (CLKpin, LOW);
delayMicroseconds (1);
digitalWrite (CLKpin, HIGH);
}
Serial.write ((byte)0); // sync byte = 0
for (i = 0; i < NPIXELS; i++) {
Serial.write ((byte)Pixel[i]+1);
}
}
}
auto inValue = getValue<input_IN>(ctx);
emitValue<output_OUT>(ctx, inValue);
}
}