Shop OBEX P1 Docs P2 Docs Learn Events
how can I actually programming interface of PSC in c++ — Parallax Forums

how can I actually programming interface of PSC in c++

yoyokilleryoyokiller Posts: 8
edited 2008-01-22 16:54 in General Discussion
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!

Comments

Sign In or Register to comment.