In summer 2017, I also rebuilt my knitting machine. This worked well except for a few minor things.

I also wanted to replace the console. However, Hackerspace Bamberg's solution
does not work for me. It is unstable. I am a knitter. Therefore, the machine
must always work perfectly.

I chose a slightly different way. The knitting machine has been running error-free so far. In the VIDEO you see the knitting machine in action.

In my opinion there are several ways to control the knitting machine. I would like to point out only three central points, which should be considered regardless of the chosen path.


A first important point

The lock has two light sensors with a distance of 14 mm. The light sensors are moved over the guide rail, which has 2 mm wide holes at a distance of 3 mm. The 5mm correspond to a needle. When the lock is moved over the needle bed, the two light sensors produce a distinctive pattern due to the distances between the light sensors and the spacing of the holes on the guide rail. The position and direction of the lock can be determined by this pattern. Depending on the pattern, the electromagnets are switched on or off. As a result, the magnetic field of the metal plate next to the electromagnets is reversed. Depending on the polarity, the pushers are positioned. The position of the pushers determines which needles are selected and which are not. 


Unlike Hackerspace Bamberg, I programmed two interrupt routines for each lock. Why? Depending on the speed, there are more or less false selections if only one interrupt routine has been programmed. In order to work stably, two interrupt routines are required for each lock (one routine per sensor). I assume that the programmers of Passap used all the information from the sensors to register the exact position of the lock, regardless of the speed and movements during the knitting process.

Which information of the sensors do I use for my project? As soon as the status of a light sensor changes, the associated interrupt routine is triggered. Then the condition of the two light sensors is measured. Overall, eight patterns can be distinguished on this way.

The state of sensor A has changed, interrupt routine A is triggered: Sensor A on - sensor B off; sensor A on - sensor B on; sensor A off - sensor B on; sensor A off - sensor B off

The state of sensor B has changed, interrupt routine B is triggered: sensor B on - sensor A off; sensor B on - sensor A on; sensor B off - sensor A on; sensor B off - sensor A off

///////////////////////////////////////////////////////////////////////////////

// Interrupt Routines

///////////////////////////////////////////////////////////////////////////////

// Pin CSENSE (light sensor) has changed state and triggered an interrupt
// The switch statement in the loop method requires unique cases. Therefore, I add 3 to the state of the 
// light sensor CREF and multiply the result by 10. Thereafter, the state of 
// the light sensor CSENSE is added.
// In this way, 4 different codes can be generated: 30, 31, 40, 41

void interrupt_CSENSE() {
  
  interrupted = true;  //flag
  
  crefNow = digitalRead(PIN_CREF);
  csenseNow = digitalRead(PIN_CSENSE); 
  state = ((crefNow + 3) * 10) + csenseNow;
}

// Pin CREF (light sensor) has changed state and triggered an interrupt
// The switch statement in the loop method requires unique cases. Therefore, I add...
Read more »