Category: Advanced Configuration
@andy, seems I have missed your reply:
The point of IO pins is to only write any state to them when you want to set the state, and let other parts of the net be in charge at other times.
Looking at your code for case 0, which is the initial state, you are setting 'index_enable = 0' so this version of the component permanently forces 'orient.index_enable' low until an orient command is issued (ie 'orient.enable' goes true):
case 0: // waiting
index_enable = 0;
if (enable) {
if (enable ^ last_enable) { // positive edge on enable
is_oriented = 0;
if (mode & 0x10){
index_enable = 1;
state = 3;
} else {
state = 1;
}
}
}
break;
Your code looks like it will always set index_enable true?
No, my version forces homing to index because the mechanism with adding 16 to the p word does not work and 'orient.index-enable' is not written to unless spindle orientation has been called (ie 'orient.enable' is true) because 'index_enable=0' is now inside the if (enable) { statement.
switch (state){
case 0: // waiting
if (enable) {
index_enable = 0;
if (enable ^ last_enable) { // positive edge on enable
is_oriented = 0;
if (1>0){
index_enable = 1;
state = 3;
} else {
state = 1;
}
}
}
break;