Shop OBEX P1 Docs P2 Docs Learn Events
Activitybot C code for qti sensors won't run — Parallax Forums

Activitybot C code for qti sensors won't run

Hi
We are having trouble loading code for qti sensors from the Activitybot C code folder (most recent version). We keep getting this error: simpletools.h: No such file or directory. We are using the most recent version of the Learn folder. Does anyone know how we can fix this?

Comments

  • Please post your code, preferably between code blocks (click on the "C" in the edit bar and paste your code between them.

    thanks
    Tom
  • I would seem that where ever you have the QTI library it is outside the SimpleIDE folder.

    It's having a problem finding the base include files.

    Mike
  • #include "simpletools.h" 
    #include "abdrive.h"  
    
    // ------ Global Variables and Objects ------
    int item;
    int left = 0;
    int leftPrev = 0;
    int right = 0;
    int rightPrev = 0;
    int driveLeft, driveRight;
    int scale = 1000; // Recommended speed at scale = 1000.  
                      // To make it go 1.25 times as fast, change scale to 1250.  
                      // To make it go 0.75 times as fast, change it to 750 
    
    
    // ------ Function Declarations ------
    int getQTIs(int highPin, int lowPin);
    
    
    // ------ Main Program ------
    int main()
    {
      drive_speed(0,0);
      pause(1000);
      drive_setAcceleration(FOR_SPEED, 2000);
      while (1)
      {
        QTIs();
        switch (item)
        {
          case 0b1000:
            left = 0;
            right = 32;
            break;
          case 0b1100:
            left = 16;
            right = 32;
            break;
          case 0b1110:
            left = 32;
            right = 46;
            break;
          case 0b0100:
            left = 46;
            right = 64;
            break;
          case 0b0110:
            left = 64;
            right = 64;
            break;
          case 0b0010:
            left = 64;
            right = 46;
            break;
          case 0b0111:
            left = 46;
            right = 32;
          case 0b0011:
            left = 32;
            right = 16;
            break;
            break;
          case 0b0001:
            left = 32;
            right = 0;
            break;
          default:
            if(leftPrev > rightPrev)
            {
              left = 32;
              right = 0;
            }
            else if(rightPrev > leftPrev)
            {
              left = 0;
              right = 32;
            } 
            else
            {
              left = 64;
              right = 64;
            }                   
        }
        driveLeft = scale * left / 1000;
        driveRight = scale * right / 1000;
        drive_speed(driveLeft, driveRight);
        leftPrev = left;
        rightPrev = right;
        pause(20);
      }
    }
    
    // ------ Functions ------
    int getQTIs(int highPin, int lowPin);
    {
      set_outputs(7, 4, 0b1111);
      set_directions(7, 4, 0b1111);
      pulse_out(26, 230);
      set_directions(7, 4, 0b0000);
      pulse_out(26, 230);
      item = (get_states(7, 4));
      //print("%04b\r", item);  // uncomment to view in terminal 
    }
    
  • RichTRichT Posts: 7
    edited 2018-04-16 14:45
    THanks. The qti folder is inside the Simple IDE learn folder. One of the qti programmes runs, the one I posted doesn't.
  • When I tried to compile the code above I got a couple of errors.
    The first was the ";" after the function name (line 96 in SimpleIDE).
    int getQTIs(int highPin, int lowPin);
    

    There should not be a semicolon after the function name in the function.

    The next was line 30, the line before the switch statement
    QTIs();
    

    I think this should be
    getQTIs(pin number, pinnumber);
    
    I'm not sure what highpin and lowpin are in your program. I just used 7 and 6 to see if it would compile and it did.
    getQTIs(7, 6);
    

    I did not get an error
    simpletools.h: No such file or directory
    

    My version of SimpleIDE is 1.1.0, and I have the 1/23/18 library update.

    Hope this helps
    Tom
  • Thanks. I will try this.
Sign In or Register to comment.