I hope that's not really a question since post #50 doesn't include intosc.basNot using it?? INTOSC.BAS module!
That wouldn't surprise me. There's lots of stupid stuff out there.As for the ELSE statement in # 50, have seen this in lots of code examples
IF Position1 = 0 THEN
TOGGLE(pLAYER1)
DELAYMS(50)
ELSE
// if you get here, Position1 must already be = 1, otherwise the IF-THEN part would have executed
// since Position 1 is already 1, why set it to 1 again? You can get rid of the whole ELSE part
// besides THIS TRIES TO WRITE TO A PIN THAT'S AN INPUT!!!!!! YOU CAN'T SET AN INPUT. IT IS WHAT IT IS.
Position1 = 1
END IF
Get ONE lot of code working first, understand the code and optimize it. In fact choose the most simple version and make sure it both works as intended, is as heavily commented as you can make it including exactly what each line does and which registers it affects.Sorry I grabbed the wrong code. I have the INTOSC.BAS module in my code that I am using with all the bel;ls and whistles included. Have numerous snippets to test out different code variations.
....As for the ELSE statement in # 50, have seen this in lots of code examples. not really needed but....
IF Position1 = 0 THEN
.....
ELSE
Position1 = 1
End If
IF Position1 = 0 THEN
I'm happy
ELSE
I'm sad LOL
End If
Which brings me straight in to encoders.......Does SF have an encoder lib? I cant find the part number at the moment, but i have a really odd encoder that isnt playing ball! Also i have never seen an encoder with 6 wires??
I will check that out!! As mentioned in another thread, i am looking at cell fracturing using ultrasonics or resonant frequencies. Some cells are easy and others flex and mishapen but dont seem to fracture. The other big surprise was the wide range of frequency involved, in a cell you would think the frequencies would be pretty close each other. That would open a whole new area of research for things like cancer treatment if each cell type had its own frequency.
But that kind of stuff is way out of my league!! no nobel prize this year then for me
const char lookup_table[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
DecState<<=2;
if(DecA1)
DecState+=2;
if(DecA2)
DecState++;
DecState&=15;
Pos+=lookup_table[DecState];
Thanks Mike thats handy! Also the 6 wires finally slowly (very slowly) dawned upon me and a sudden revelation took place, or in other words..........I stopped being thick and worked it outFor rotary encoders I normally use this,
It uses the current and previous states of A and B (DecA1 and DecA2 above) to make a 4 bit number and uses that to index into the lookup table.Code:const char lookup_table[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0}; DecState<<=2; if(DecA1) DecState+=2; if(DecA2) DecState++; DecState&=15; Pos+=lookup_table[DecState];
Mike.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?