ps2 controller with IFC

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

ps2 controller with IFC

Postby curious mind » Thu Jan 06, 2011 1:30 am

im using a ps2 controller with IFC-Playstation Controller Card and other IFC product. i cant seem to find how to control the joystick to move the motor. i have look through all the sample, library function n user manual, but can't find how to use the joystick. i would be greatfull if you can show me the sample coding which use IFC and playstation controller to move the motor for movement. tq
curious mind
Freshie
 
Posts: 4
Joined: Thu Jan 06, 2011 1:28 am

Re: ps2 controller with IFC

Postby robosang » Thu Jan 06, 2011 8:58 am

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?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: ps2 controller with IFC

Postby ober » Thu Jan 06, 2011 2:00 pm

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: ps2 controller with IFC

Postby curious mind » Thu Jan 13, 2011 8:46 am

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?


yes i have try the sample code. but it only show when we push a button in the ps2 controller, the screen will show what button we push. for the joystick, if we push up, there will show numbers in the screen. but there nothing about how to control a motor by using the joystick.
what i have prob is, how to assign the joystick, if we push up to its maximum, i want the motor to go maximum speed. if we push slightly up the motor will move with slower speed. if we let go of the joystick, the motor will stop. it is the same if we push the joystick down but with reverse rotation.
curious mind
Freshie
 
Posts: 4
Joined: Thu Jan 06, 2011 1:28 am

Re: ps2 controller with IFC

Postby curious mind » Thu Jan 13, 2011 9:10 am

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.


im using right now is IFC - main board, power card, control panel, brushless motor card, extension board, output card and playstation controller card.
right now i have a body with four vexta motor attach to it. i have read and use the sample code and library function. thanks to the instruction, i have able to move all the part needed by using IFC.
im controlling the robot movement by using the up, down, left and right button. it move perfectly. what i want to do is, when it move forward(push up), it also can move to the slightly to the right(push up and right at the same time). the solution is i set the speed of the motor (for example, right=150, left=255) when we push(up and right at the same time) and i set it for all other button as well. it just a matter of assign the different speed of each right and left motor. it does what im program it to do.
BUT, it will be really COOL if i can CONTROL THE ROBOT MOVEMENT by using the JOYSTICK (instead up,down, left and right button).

do you get what i meant?
curious mind
Freshie
 
Posts: 4
Joined: Thu Jan 06, 2011 1:28 am

Re: ps2 controller with IFC

Postby yonghui » Thu Jan 13, 2011 12:46 pm

hi,
i will like to try up tat.
tell u soon.

regards,
yh
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: ps2 controller with IFC

Postby hyng » Thu Jan 13, 2011 12:54 pm

Isn't there is a function name something like ps_joy(add_ps1, 2) ? it inside Card Library Function. Or it cannot work out?
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Re: ps2 controller with IFC

Postby yonghui » Thu Jan 13, 2011 8:39 pm

hi,

the function ps_joy() functioning well to give analog values of the PS joystick.
no problem.


regards,
yh
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: ps2 controller with IFC

Postby yonghui » Fri Jan 14, 2011 3:39 pm

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
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: ps2 controller with IFC

Postby curious mind » Sat Jan 15, 2011 11:58 am

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?


i have try that, but the robot move by itself without me control anything.

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


i will test this code, and will inform the outcome of the test. tq
curious mind
Freshie
 
Posts: 4
Joined: Thu Jan 06, 2011 1:28 am


Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 15 guests

cron