how can I actually programming interface of PSC in c++
yoyokiller
Posts: 8
Hi,
anybody did programming for PSC in C++, I don't know how actually give a high bytes and low byte to PSC, I did a pesdo here but alway can not drive it, if anybody know about it, give me some hints or similar example programming code?
void put(int ch, int angle){
· ·unsigned char buff[noparse][[/noparse]6];
· ·unsigned short int temp, ra;
· ·unsigned char pos_hi,pos_low;
· ·temp=angle&0x1f80;
· ·pos_hi=temp>>8;
· ·pos_low=angle & 0x8f;
· ·buff[noparse][[/noparse]0]='!SC';//start byte
· ·buff[noparse][[/noparse]1]=ch;//channel
···buff[noparse][[/noparse]2]=ra;//ramp number
· ·buff[noparse][[/noparse]3]=pos_hi;//high bits
···buff[noparse][[/noparse]4]=pos_low;//lowbits
···buff[noparse][[/noparse]5]='/r';//terminal 13
···write(com, &buff, 6, 0);
anybody can modify it and drive my servo go?
Thanks advance a million!
anybody did programming for PSC in C++, I don't know how actually give a high bytes and low byte to PSC, I did a pesdo here but alway can not drive it, if anybody know about it, give me some hints or similar example programming code?
void put(int ch, int angle){
· ·unsigned char buff[noparse][[/noparse]6];
· ·unsigned short int temp, ra;
· ·unsigned char pos_hi,pos_low;
· ·temp=angle&0x1f80;
· ·pos_hi=temp>>8;
· ·pos_low=angle & 0x8f;
· ·buff[noparse][[/noparse]0]='!SC';//start byte
· ·buff[noparse][[/noparse]1]=ch;//channel
···buff[noparse][[/noparse]2]=ra;//ramp number
· ·buff[noparse][[/noparse]3]=pos_hi;//high bits
···buff[noparse][[/noparse]4]=pos_low;//lowbits
···buff[noparse][[/noparse]5]='/r';//terminal 13
···write(com, &buff, 6, 0);
anybody can modify it and drive my servo go?
Thanks advance a million!
Comments
http://forums.parallax.com/showthread.php?p=611904
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support