Hi All,
I am working on a 3D printer with slight modifications. I am trying to incorporate a dry powder dispensing device to the printer so that I can print using it instead of the extruder. For this purpose, with the help of I2C, communication is established between Gen 6 and Arduino board. Currently, it only brings the 3 axes to home position. In order to get the device running, I need analogue and digital signal. To get analogue signal, I am using MCP 4921 chip and here is the routine.
#include "SPI.h" // necessary library
int del=0; // used for various delays
word outputValue = 0; // a word is a 16-bit number
byte data = 0; // and a byte is an 8-bit number
void setup()
{
//set pin(s) to input and output
pinMode(10, OUTPUT);
SPI.begin(); // wake up the SPI bus.
SPI.setBitOrder(MSBFIRST);
}
void loop()
{
for (int a=0; a<=4095; a++)
{
outputValue = a;
digitalWrite(10, LOW);
data = highByte(outputValue);
data = 0b00001111 & data;
data = 0b00110000 | data;
SPI.transfer(data);
data = lowByte(outputValue);
SPI.transfer(data);
digitalWrite(10, HIGH);
delay(del);
}
delay(del+25);
for (int a=4095; a>=0; --a)
{
outputValue = a;
digitalWrite(10, LOW);
data = highByte(outputValue);
data = 0b00001111 & data;
data = 0b00110000 | data;
SPI.transfer(data);
data = lowByte(outputValue);
SPI.transfer(data);
digitalWrite(10, HIGH);
delay(del);
}
delay(del+25);
}
You are all familiar with the Five_D program I am sure. I just want to know where and how can I initialize this SPI routine in the main program