Questions about C version Xan's Phoenix Code

Hi, I am studying the code of the hexapod and I have some doubts.
which, in the following parts of the code.
The code is in "c ", but I think you can understand.

There are 3 parts of code.

[code]********************************************************************************************
if (bit_test(DualShock[1],5) == 0 & bit_test(LastButton[0],5)){ //Right Button test
if (RegNo<31)
RegNo++;
}


And here?:


if (bit_test(DualShock[2],6) == 0 & bit_test(LastButton[1],6)){ //X Button test
if (SetupMode == 0){
SetupMode = 1;
generate_tone(2000,100);
generate_tone(10000,100);
}
else{
SetupMode = 0;
generate_tone(8000,250);
}
}


and this function is used to?:


//Setup
void Setup(void){
char Res[5];
short Neg;
int Val,Val1,Val2,Val3,I,c,d;
RegNo=32;
//while(){
for (RegNo=0;RegNo<=31;RegNo++){
d=0;
for(c=0;c<=4;c++){
Res[c]=’.’;
}
printf(“R%u%c”,(RegNo+32),13);
Neg=0;
for(c=0;c<=4;c++){
Res[c]=getch();
if((Res[c]==’-’)&(c==0)){
Neg=1;
}
if(Res[c]==13){
break;
}
}
Val1=255;
Val2=255;
Val3=255;
d=c-1;
for(i=0;i<=d;i++){
if(Neg&i==0){
continue;
}
switch(Res*){
case ‘0’:Val=0;
break;
case ‘1’:Val=1;
break;
case ‘2’:Val=2;
break;
case ‘3’:Val=3;
break;
case ‘4’:Val=4;
break;
case ‘5’:Val=5;
break;
case ‘6’:Val=6;
break;
case ‘7’:Val=7;
break;
case ‘8’:Val=8;
break;
case ‘9’:Val=9;
break;
}
//printf(“Val=%d%c”,Val,13);
if(Neg){
switch(I){
case 1:Val1=Val;
break;
case 2:Val2=Val;
break;
case 3:Val3=Val;
break;
}
}
else{
switch(I){
case 0:Val1=Val;
break;
case 1:Val2=Val;
break;
case 2:Val3=Val;
break;
}
}
}
//printf(“Val1=%u Val2=%u Val3=%u%c”,Val1,Val2,Val3,13);
if(Val2==255&Val3==255){
ValReg[RegNo]=(signed int)Val1;
}
else{
if(Val3==255)
ValReg[RegNo]=(signed int)(Val110+Val2);
else
ValReg[RegNo]=(signed int)(Val1
100+Val2*10+Val3);
}

	if(Neg){
		ValReg[RegNo]=ValReg[RegNo]*-1;
	}

	printf("ValReg%u]=%d%c",(RegNo+32),ValReg[RegNo],13);
	//delay_ms(10);
}
//return;
RegNo=0;
while (SetupMode){
	Ps2Input();
	printf("#%u PO %d%c",RegNo,ValReg[RegNo],13);
	printf("R%u = %d%c",(RegNo+32),ValReg[RegNo],13);
	delay_ms(100);
} 

}


[/code]

thanks for the help
MA_BLACK*

Sorry I don’t know what you are asking for here?

Theres lots of stuff not in your code fragments…

I don’t like the if statements…

if (bit_test(DualShock[1],5) == 0 & bit_test(LastButton[0],5)){ //Right Button test
That is I don’t think you want a bitwise and… it should probably be:

if (bit_test(DualShock[1],5) == 0 && bit_test(LastButton[0],5)){ //Right Button test
But again I don’t know what issues you have with these three fragments…

Kurt

Are you asking if you need the bit tests? You do if you want the buttons. Or was there another question.

Kurt has picked up on the bitwise vs. logical and (&).

I have a C code version I can probably dig up. but it’s pre-Phoenix.

What C compiler are you using?

Good luck!

Alan KM6VV

What I want to know is what the hexapod, when you press the button left or right.

and the second code that makes the robot by pressing the button on the x.

In the last part of the function code is “setup” and not making the code here. The hexapod program is not created by me and is a version of Phoneix of xan,

I’m also looking for is to understand how does the robot motion sequences, where it would have this information.

This version of the code in C is the CCS compiler, and is a modification of the basic atom pro version1.3.

It would be better than working with basic microcontroller atom pro, with a microchip pic, no?

Hi, hope you don’t mind, but I split this off from Xans thread as it is not really related to his code base.

Still don’t understand your questions?

What the hexapod does? Don’t know? When you press the right button it increments a variable RegNo if it is less than 31. What RegNo is used for???

As for the “X” key it looks like it toggles you into or out of setup mode and makes different sounds. It looks like it does some different things when it is in setup mode, but I have not completely analyzed the code. My gut tells me that it is issuing “R” type commands to the SSC-32. The commands are defined in the on line SSC-32 manual: lynxmotion.com/images/html/b … m#ssc32reg

My guess is that in setup mode it probably reads in the current servo offsets, allows you to use some input such as PS2 buttons to update the servo offsets and than maybe writes the updated offsets back to the SSC-32. But that is just a guess…

Note: I have ported over the Phoenix 2.x code to C that is using some Arduino like functions that runs on the Bap28. This is covered in the topic: viewtopic.php?t=6196&p=66210#p66210

Good Luck
Kurt

Well the truth is that I’m a bit lost, the robot moves, but I do not understand the program, I attach the code if anyone knows it, not mine and I have passed.

It would be better to use atom pro that pic 18F4550
ccs.rar (152 KB)

The AtomPro uses a Renisys chip, not a USB PIC.

I’d suggest you simply start with an AtomPro and the Phoenix code for it. But if you understand and can program in C, then you should be able to figure it out…

You might get more explanations of what’s going on for the AtomPro code.

Alan KM6VV