We fixed the belt on with our new belt holder!
Also, we finished most of our optical train assembly, referencing the
Since the base plate for the optical train lacks a ditch on it,
we used CNC coupled with the 360 Fusion to cut.
Lastly, we perfected the code for xy-axis movement.
String protocolString = ""; boolean protocolWait = false; String parsedString = ""; int startIndex = 0; String totalString = "";
String ledString = "";
unsigned long Xstepcount = 0;
unsigned long Ystepcount = 0;
unsigned long Xstep = 0;
unsigned long Ystep = 0;
unsigned long Xmili = 0;
unsigned long Ymili = 0;
unsigned long Xstep1 = 0;
unsigned long Ystep1 = 0;
unsigned long Xstep_prev = 0;
unsigned long Ystep_prev = 0;
int period = 0;
void initOutput() {
//digitalWrite(ENNpin,HIGH); // Disable motors
//We are going to overwrite the Timer1 to use the stepper motors
// STEPPER MOTORS INITIALIZATION
// TIMER1 CTC MODE
TCCR1B &= ~(1<<WGM13);
TCCR1B |= (1<<WGM12);
TCCR1A &= ~(1<<WGM11);
TCCR1A &= ~(1<<WGM10);
// output mode = 00 (disconnected)
TCCR1A &= ~(3<<COM1A0);
TCCR1A &= ~(3<<COM1B0);
// Set the timer pre-scaler
// Generally we use a divider of 8, resulting in a 2MHz timer on 16MHz CPU
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10);
//OCR1A = 125; // 16Khz
//OCR1A = 100; // 20Khz
OCR1A = 80; // 25Khz
TCNT1 = 0;
TIMSK1 |= (1<<OCIE1A); // Enable Timer1 interrupt
//digitalWrite(ENNpin, LOW); // Enable stepper drivers
}// System Inialization Setup
const int dirpin = 13;
const int steppin = 12;
const int enpin = 8;
const int dirpin2 = 4;
const int steppin2 = 7;
int stepstate = LOW;
unsigned long pM = 0;
unsigned long pM2 = 0;
int vt = 1000;
void setup() {
pinMode(dirpin, OUTPUT);
pinMode(dirpin2, OUTPUT);
pinMode(steppin, OUTPUT);
pinMode(steppin2, OUTPUT);
pinMode(enpin, OUTPUT);
digitalWrite(dirpin, HIGH);
digitalWrite(dirpin2, LOW);
digitalWrite(steppin, LOW);
digitalWrite(steppin2, LOW);
digitalWrite(enpin, LOW);
pinMode(2, INPUT);
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
initOutput();
}
void loop() {
// Serial.println("pass");
if (Serial.available() > 0) {
protocol
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.