top / week 2/22 / week 2/29 / week 3/07
/ week 3/21 / week 4/04 / week 4/11
/ week 4/25 / week 5/02 / final

assignment: component demonstration



I built a 2-row prototype of solid knitting machine holders.


For example, when you send 1 2 through serial communication, the motor attached to the row 1 rotates twice, which lifts loops on the holders up by 2 pitches.
For another example, 0 -3 means the motor attached to the row 0 rotates 3 times counterclockwise. This moves the loops down for 3 pitches.


It actually does not work well especially when loops are on the holders.



Cast-on loops (the very first loops) need to be put this way, and the holders leaned closer to each other due to the elasticity of the cord.
This makes collisions between the holders which causes them not rotate correctly.



For driven rods, the rods are fixed and only the "screw" parts rotate around the rods.
I just applied adhesive to fix the rod to the stand but it did not work.
Keeping it cheap was the design concept since I want to prepare a bunch of this holders eventually, but it seems designed too cheaply.

To do:
- Make the halls for the rods as small as the rods so that the rods get fixed more stably
- If the making-the-halls-small plan still does not work well, change the design to the rods-rotating one ("screw" are fixed onto the rods and the rods rotate using bearings)
- Modulate


I used Arduino Mega 2560 alternative (Whats Next? Green - WN00002) with DRV8825 stepper motor drivers.

Arduino code:

            
#define rowNum 2
#define onerevsteps 200

int mspp = 1000; // microsecondsPerPulse

int dir[rowNum] = {44, 46};
int stp[rowNum] = {45, 47};

void setup() {
Serial.begin(9600);

for (int i=0; i < rowNum; i++) {
    pinMode(dir[i], OUTPUT);
    pinMode(stp[i], OUTPUT);
}
}

void loop() {
if (Serial.available() > 0) {
    String receivedStr = Serial.readString();
    executeCommands(receivedStr, onerevsteps, mspp);
}
}

void executeCommands(String str, int oneRevSteps, int microsecondsPerPulse) {
String strs[10];
int strCount = 0;

// Split the string into substrings
while(str.length() > 0){
    int index = str.indexOf(' ');
    if (index == -1){ // No space found
    strs[strCount++] = str;
    break;
    }else{
    strs[strCount++] = str.substring(0, index);
    str = str.substring(index + 1);
    }
}

int rowIndex = strs[0].toInt();
int steps;

if (rowIndex % 2) { // if rowIndex is odd 
    steps = strs[1].toInt() * oneRevSteps;
} else { // if rowIndex is even
    steps = strs[1].toInt() * oneRevSteps * (-1);
}

rotateStepper(dir[rowIndex], stp[rowIndex], steps, microsecondsPerPulse);
}

void rotateStepper(int PIN_DIR, int PIN_STP, int steps, int microsecondsPerPulse){
if(steps > 0){
    digitalWrite(PIN_DIR, HIGH);
}else if(steps < 0){
    digitalWrite(PIN_DIR, LOW);
    steps = steps*(-1);
}
for(int i = 0; i < steps; i++) {
    digitalWrite(PIN_STP, HIGH); 
    delayMicroseconds(microsecondsPerPulse); 
    digitalWrite(PIN_STP, LOW); 
    delayMicroseconds(microsecondsPerPulse); 
}
}