robosang WROTE:Din really use the IFC from Cytron, wanted to try, but no time and not needed in my project
Curious to know, I thought Cytron always provide sample source code for their product, don't IFC come with sample source code? Have you try that and which part you don't understand?
ober WROTE:Yes, we do provide sample source code of IFC-PS01 and other card such as motor driver and other.
Basically with IFC, is just calling functions. Can you roughly share the exercises or tests you have working on? And we can give some guidance based on your current work.
while(1)
{
Left_val=ps_joy(add_ps,joy_ll);
Right_val=ps_joy(add_ps,joy_lr);
speedRy=ps_joy(add_ps,joy_ry);
if( ps_sw(add_ps,2)==0)
{
bh_1_brake(add_bh);
bh_2_brake(add_bh);
}
else
{
if (speedRy<128)
{
speedRy=127-speedRy;
bh_1_ccw(add_bh); // Run motor 1 in clockwise
bh_2_cw(add_bh); // Run motor 1 in clockwise
}
else if(speedRy>128)
{
speedRy=speedRy-128;
bh_1_cw(add_bh); // Run motor 1 in clockwise
bh_2_ccw(add_bh); // Run motor 1 in clockwise
}
else
{
speedRy=0;
}
if(speedRy>Left_val)
speedcountL=(speedRy<<1)-(Left_val<<1);
else
speedcountL=0;
if(speedRy>Right_val)
speedcountR=(speedRy<<1)-(Right_val<<1);
else
speedcountR=0;
bh_1_speed(add_bh,speedcountL); // motor 1 speed
bh_2_speed(add_bh,speedcountR); //motor 2 speed
}
}
hyng WROTE:Isn't there is a function name something like ps_joy(add_ps1, 2) ? it inside Card Library Function. Or it cannot work out?
yonghui WROTE:hi,
here is my codes for the motor control of a simple 2 wheels mobile robot.
- CODE: SELECT_ALL_CODE
while(1)
{
Left_val=ps_joy(add_ps,joy_ll);
Right_val=ps_joy(add_ps,joy_lr);
speedRy=ps_joy(add_ps,joy_ry);
if( ps_sw(add_ps,2)==0)
{
bh_1_brake(add_bh);
bh_2_brake(add_bh);
}
else
{
if (speedRy<128)
{
speedRy=127-speedRy;
bh_1_ccw(add_bh); // Run motor 1 in clockwise
bh_2_cw(add_bh); // Run motor 1 in clockwise
}
else if(speedRy>128)
{
speedRy=speedRy-128;
bh_1_cw(add_bh); // Run motor 1 in clockwise
bh_2_ccw(add_bh); // Run motor 1 in clockwise
}
else
{
speedRy=0;
}
if(speedRy>Left_val)
speedcountL=(speedRy<<1)-(Left_val<<1);
else
speedcountL=0;
if(speedRy>Right_val)
speedcountR=(speedRy<<1)-(Right_val<<1);
else
speedcountR=0;
bh_1_speed(add_bh,speedcountL); // motor 1 speed
bh_2_speed(add_bh,speedcountR); //motor 2 speed
}
}
although its not very optimized, hope u find it helpful
rgds,
yh
Users browsing this forum: No registered users and 35 guests