Shop OBEX P1 Docs P2 Docs Learn Events
Looking for Code for Gripper3 with Propeller1chip on Activity Bot 32500 (non ActivityBot 360)- — Parallax Forums

Looking for Code for Gripper3 with Propeller1chip on Activity Bot 32500 (non ActivityBot 360)-

Robot Articulation with gripper functionality combined -Will develop a program but there must be one already available. Found one for Basic bs but not for propeller

Comments

  • twm47099twm47099 Posts: 867
    edited 2020-05-24 06:08
    I don't have the gripper 3. I have an earlier version. But they both use standard servo to close and open the gripper.

    I have a program that uses a Sony TV remote with the gripper (below). You will also need a file tvcodes.h in the same directory as this. I located that below this program.

    Hope this helps.
    /*
      SIRC drive w grip TV remote.c
      Drive with continuous rot servo and gripper 
      
        -- has option to use either camera or tv codes (choose .h)
        
    1. Added gripper statements 
       This version uses TV remote
      Connect 38 kHz IR receiver to Propeller P10
      Decodes button presses on Sony-compatible IR remote 
      Commands Activitybot to move straight, pivot 45 deg, move in a curve,
       increase or decrease speed and curve radius, stop, and use gripper. 
      Load EEProm and Run
    
    */
    
    #include "simpletools.h"                      // Libraries included
    #include "sirc.h"
    #include "abdrive.h"                          // abdrive library
    #include "servo.h"                // for gripper 
    
    //  Choose either camera or TV remote, uncomment that include, and comment the other
    //#include "cameracodes.h"
    #include "tvcodes.h"
    
          // Sony remote control aliases 
    /*
               camera remote                         TV remote
    alias     SIRC   Key            command           SIRC  Key
     fwd      58   up arrow ...... forward ..........  2      #2
     stp       57   center ........ stop .............  5      #5
     rvs       59   down arrow .... reverse ..........  8     #8
     pl        62   left arrow .... pivot left .......  4     #4
     pr        63   right arrow ... pivot right ......  6      #6
     cvl       56   menu .......... curve left .......  1     #1
     cvr       61   trash can ..... curve right ......  3      #3
     ispd     74   rocker+ ....... increase speed ... 16  chan+
     dspd    75   rocker- ....... decrease speed ... 17  chan-
     grip     45   shutter ....... close grip ......  116  arrow up
     gopen  55   2 sec ......... open grip .......  117  arrow down
    */
    
    #define GRIPPIN 16
    
    int main()                                    // main function
    {
      int spd = 50;                 //  initial speed once fwd command given
      int dflg = 0;                 // direction flag = -1 fwd or rev, 0 = stopped, 1 = curve left, 2 = curve right
      drive_speed(0, 0);
      sirc_setTimeout(1000);        // -1 if no remote code in 1 s
      freqout(4, 2000, 3000);       // Speaker tone: 2 s, 3 kHz
      servo_angle(GRIPPIN, 0);      // open gripper  
    
      while(1)                                   // Repeat indefinitely
      {                                         
               //  decode signal from P10
        int button = sirc_button(10);     //  get code from remote
        switch(button)
        {
          case stp :
           drive_speed(0, 0);          //  Center button - Q
           dflg = 0;
           break;
    
          case fwd :
           drive_speed(spd, spd);      //  Top Arrow - M
           dflg = -1;
           break;
    
          case rvs :
           drive_speed(0, 0);
           drive_speed(-spd, -spd);      //  Down Arrow 
           dflg = -1;
           break;
    
          case pr :                                     //    Right Arrow - N
           drive_speed(0, 0);
           drive_speed(13, -13);                             //  Turn Right 45 deg & stop
           pause(1000);
           drive_speed(0, 0);
           dflg = 0;
           break;
    
          case pl :                                   //  Left Arrow - P
           drive_speed(0, 0);
           drive_speed(-13, 13);                             //  Turn Left 45 deg & stop
           pause(1000);
           drive_speed(0, 0);
           dflg = 0;
           break;
    
          case cvr :              //    Curve Right - L
           if (spd<25) spd=25;
           drive_speed(spd, spd-20);
           dflg = 2;
           break;
    
          case cvl :            //    Curve Left  - K
           if (spd<25) spd=25;
           drive_speed(spd-20, spd);
           dflg = 1;
           break;
    
          case ispd :      //    Increase speed
           if (dflg == 1)      // curving left - increase spd and move in curve at new spd
            {
              spd=spd+5;                                // Up rocker - H
              if (spd > 100) spd = 100;
              drive_speed(spd-20, spd);
              }
            else if (dflg == 2)      // curving right - increase spd and move in curve at new spd
             {
              spd=spd+5;                                // Up rocker - H
              if (spd > 100) spd = 100;
              drive_speed(spd, spd-20);
              }
            else if (dflg == -1)      // straight ahead - increase spd and move at new spd
             {
              spd=spd+5;                                // Up rocker - H
              if (spd > 100) spd = 100;
              drive_speed(spd, spd);
              }
            else 
             {
              spd=spd+5;                                // Up rocker - H
              if (spd > 100) spd = 100;
              }                                          
            break;                                                 // Finish up rocker
    
          case dspd :         //  decrease spd
           if (dflg == 1)      // curving left - decrease spd and move at new spd
            {
              spd=spd-5;                                // dn rocker 
              if (spd < 25) spd = 25;
              drive_speed(spd-20, spd);
              }
           else if (dflg == 2)      // curving right - decrease spd and move at new spd
            {
              spd=spd-5;                                // dn rocker 
              if (spd < 25) spd = 25;
              drive_speed(spd, spd-20);
              }
            else if (dflg == -1)      // straight ahead - decrease spd and move at new spd
             {
              spd=spd-5;                                // dn rocker 
              if (spd <0) spd = 0;
              drive_speed(spd, spd);
              }
            else                                  //  stopped
             {
              spd=spd-5;                                // dn rocker 
              if (spd <0) spd = 0;
              }  
            break;                                       // end decrease
            
          case grip :
           drive_speed(0, 0);
           pause(100);
           servo_angle(GRIPPIN, 1700);
           break;
           
          case gopen : 
           drive_speed(0, 0);
           pause(100);
           servo_angle(GRIPPIN, 0);
           break;
                                        
       default :
            break;
          }
      }  
    }
    

    Here is the tvcodes.h file
    // tvcodes.h   SIRC codes for Sony TV remote
    
    #include "simpletools.h"
    
    #define fwd 2
    #define stp 5
    #define rvs 8
    #define pl 4
    #define pr 6
    #define cvl 1
    #define cvr 3
    #define ispd 16      //  increase speed  need actual code
    #define dspd 17      //  decrease speed  need actual code
    #define grip 116     //  close gripper
    #define gopen 117    //  open gripper
    
  • TWM
    Thanks
    I'll try it
    Also did you use a camera ?
    Can you share that
    Al
  • TWM
    Did you use a resistor with the 38KHz IR receiver ? 220 ohm into pin ?
    and
    What model Sony was the TV remote I can get one from Amazon
  • Any objections on moving this thread to Robotics? Might be better exposure to the robot experimenters.
  • Found Remote and sensor Kit on Parallax - on order I should be okay
    Thanks
  • I'm going to leave the thread open so others can take advantage of @twm47099 code. I am going to move this to "Robotics"
  • I tried to compile this code and I can't seem to find "sirc.h" and "servo.h".
    Where should I look?
  • DaveJenson wrote: »
    I tried to compile this code and I can't seem to find "sirc.h" and "servo.h".
    Where should I look?

    They should be in the SimpleIDE, learn, simple libraries folders.
    Using Simple IDE click "help" and Simple Library Reference to see the documentation.
    Tom
  • TWM
    Thanks
    I'll try it
    Also did you use a camera ?
    Can you share that
    Al

    The program works with either the Sony TV remote or an older Sony camera IR remote (my remote came with the Sony A700 DSLR). The only difference in the program is that the camera remote needs
    //#include "cameracodes.h"
    #include "tvcodes.h"
    
    changed to
    #include "cameracodes.h"
    //#include "tvcodes.h"
    
    and camera codes.h is the following:
    // cameracodes.h  SIRC codes for Sony camera remote
    
    #include "simpletools.h"
    
          // Sony camera remote control aliases 
    
    #define fwd 58       //  forward
    #define stp 57       //  stop
    #define rvs 59       //  reverse
    #define pl 62        //  pivot left
    #define pr 63        //  pivot right
    #define cvl 56       //  curve left
    #define cvr 61       //  curve right
    #define ispd 74      //  increase speed
    #define dspd 75      //  decrease speed
    #define grip 45      //  close gripper
    #define gopen 55     //  open gripper
    
    

    My Sony TV remote, doesn't have any model number on it, and the TV no longer exists. The camera remote is Sony RMT-DSLR1. I believe that it has been discontinued.
    I also think (but am not sure) that the Parallax remote uses different codes than my TV remote, but that is not a big deal.
    If your remote has different codes, just decide what you want each button to do (from the list above). Then using the remote and the program "Test SIRC remote" in the SimpleIDE folder "SimpleIDE\Learn\Examples\Devices\TV Remote" Record the SIRC value for each button and change the number in the tvcodes.h defines.
    Hope this helps.
    Tom
    TWM
    Did you use a resistor with the 38KHz IR receiver ? 220 ohm into pin ?
    and
    What model Sony was the TV remote I can get one from Amazon

  • TWM
    Did you use a resistor with the 38KHz IR receiver ? 220 ohm into pin ?

    I have a photo of the wiring I use for the SIRC at the following link:
    forums.parallax.com/discussion/comment/1337873/#Comment_1337873
    This is for a different configuration of my ActivityBot (using Bluetooth radio control from a SAMSUNG Android Tablet joystick app) and whiskers for responding to obstacles. But the SIRC wiring is the same. It uses the 220- ohm resistor into P10 (same as in the tutorial:
    learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/ir-receiver-and-remote

    Hope this helps.
    Tom

  • I was wondering if anyone had success?
    Tom
  • Remote control issue " include " tv codes"
    Activity Bot (32500) board 32912 rev c
    Revisiting my old Activity Bot and forgot how I programmed it
    Want to run gripper with remote however get error see file attached . Reviewing above comment from Tom please tell me if this is correct for the " tv codes .h "

    Comment out camera codes , uncomment "tv codes .h "and add in code below "tv codes.h" line
    Is this right to correct my error in the attached ?
    If not please advise on how to correct
    Thanks

    1238 x 807 - 96K
    937 x 777 - 75K
Sign In or Register to comment.