Results 1 to 7 of 7

Thread: PIN(s) to do an interruption in an arbotix-arduino

  1. PIN(s) to do an interruption in an arbotix-arduino

    Hello everyone,


    I want to make a program in arduino that has an emergency button and I would like to know which pins of the arbotix-m are the adequate ones to make an interruption and how can i do the code in arduino.

    I know witch pins of the microcontroller (ATmega644P/V) are the ones that can have an interruption


    Thank you,


    Urko.

  2. #2

    Re: PIN(s) to do an interruption in an arbotix-arduino

    I believe that all of the IO pins 0-31 can serve as an Interrupt pin on the Atmega644p. I might avoid pin 0 as it has the LED on it, but would probably work...

    You should be able to do something like:

    Note I am assuming a more recent version of Arduino IDE... As I don't want to look at 1.0.x versions ...
    Assume pin 1, and that you are wiring the button to have the other pin go to ground.
    Code:
    void setup() {
        pinMode(1, INPUT_PULLUP);  // 
        attachInterrupt(1, &YourInterruptFN, FALLING);
    }
    
    void YourInterruptFN(void) {
      // your button was pressed
    }
    Note: I probably would use the Arduino Bounce library to handle the IO pins value going up and down maybe a few times as the button is pressed...

  3. Re: PIN(s) to do an interruption in an arbotix-arduino

    thank you KurtEck!!

    I tried what you told me, but it did not work ... the thing is that the interruption pins of the arbotix are the TX and RX, and those are the ones I use for the communication between the servos and the computer, so there's to configure the digital pins as an interruption. The ATmega644P / V microcontroller's datasheet is very extensive, but I was lucky to find this link where they gave the code of the program that had to be used to convert / configure some digital pins of the arbotix in interruptions:

    http://forums.trossenrobotics.com/sh...rupt-Me-please

    Here I leave my part of the program about the interruption in a single pin of the arbotix (D1).

    #include <avr/interrupt.h>
    #define EMERGENCY_BUTTON (PINB&0x02)
    int interrupt_state;

    void setup()
    {
    PORTB |= 0x1E;
    PCICR |= (1 << PCIE1);
    PCMSK1 |= 0x1E;
    interrupt_state = 0;
    interrupts();
    }

    void loop() {}


    ISR(PCINT1_vect) {
    interrupt_state = (PINB & 0x1E) >> 1;
    //what yo want to do, is like a function, when the program notice a change in the pin, it will do what you put here.
    }

  4. #4

    Re: PIN(s) to do an interruption in an arbotix-arduino

    You don't need the interrupt capture pins; any pin can work with a PinChangeInterrupt.

    Also, this code looks weird:
    Code:
    interrupt_state = (PINB & 0x1E) >> 1;
    interrupt-state will have some value between 0 and 15 (0xF) after this. Meanwhile, you define EMERGENCY_BUTTON as 0x2 (although you don't use that define anywhere.)

  5. Re: PIN(s) to do an interruption in an arbotix-arduino

    Hello again!

    Once I have managed to make an interruption in the pin, what I want now is that when I press the emergency button, i want the robot stops (that is, to stop the motors). I have tried to do it by means of the following code: (the part of the code that I teach below is the one that is inside the function of the button, that is, what happens once you press the button.)

    Code:
    ISR(PCINT1_vect) {
    interrupt_state = (PINB & 0x1E) >> 1;
    j=1;
    while (j=1) {
    Serial.println("EMERGENCY BUTTON!");
    TorqueOn(SERVO_ID[0]);
    TorqueOn(SERVO_ID[1]);
    TorqueOn(SERVO_ID[2]);
    TorqueOn(SERVO_ID[3]);
    delay(2000);
    }
    }

    And yes, it works, but what happens is that depending on what position is the robot when i press the botton, it asks for too much load in one or more motors, and that motor makes a strange noise, as of not being able to support so much load, and then it stops working and the red alarm LED goes on, so the robot does not get stop (the motor that stop working get free and this part of the arm fall down.

    Having seen this problem, and since at the moment I do not know how to solve it, I have thought about doing something different. I explain, instead of pressing the emergency button and the robot stops, I thought about making the robot go to a fixed position, at a very small speed.

    The problem now is that by putting the code "setgoalposition" to the motors, the motors go to that position as quickly as possible, so,i have been testing different codes like setting the torque, speed,... before give the order to move but... :
    Code:
    ISR(PCINT1_vect) {
    interrupt_state = (PINB & 0x1E) >> 1;
    j=1;
    while (j=1) {
    Serial.println("EMERGENCY BUTTON!");
    ax12SetRegister(SERVO_ID[0], AX_TORQUE_LIMIT_L ,50);
    ax12SetRegister(SERVO_ID[1], AX_TORQUE_LIMIT_L ,50);
    ax12SetRegister(SERVO_ID[2], AX_TORQUE_LIMIT_L ,50);
    ax12SetRegister(SERVO_ID[3], AX_TORQUE_LIMIT_L ,50);
    dxlSetGoalPosition(SERVO_ID[0], 3820);
    dxlSetGoalPosition(SERVO_ID[1], 400);
    dxlSetGoalPosition(SERVO_ID[2], 230);
    dxlSetGoalPosition(SERVO_ID[3], 2395);
    delay(2000);
    }
    }
    But they do not work for me, so if someone knew how to make the robot not ask for so much load (first problem) or if someone knew how to make the engines go at a low speed to the desired position, I would appreciate it.

    Urko

  6. #6

    Re: PIN(s) to do an interruption in an arbotix-arduino

    In the first snippet you're turning Torque on, not off.
    In the second snippet, you're turning down only the low byte of the two-byte value. Try setting register TORQUE_LIMIT_H to 0 instead to get a lower torque.

  7. Re: PIN(s) to do an interruption in an arbotix-arduino

    HI!

    I have already tried to set the TORQUE_LIMIT_H to 0, but it has not worked. The robot also goes extremely fast to the positions that I put them using the SetPosition. It's as if the program did not give have time to execute what happens when I press the button.(everything what I´m programing for the robot to move more slowly) ... and I do not know how I can solve it, if the problem is that the interruption is not well used, if it is because in the type of interruption that I use you can not put things like this or that ...


    jwatte you told me that any pin can work with PinChangeInterrupt, but what would the program be like or what would it do? Because in his day I tried what KurtEck told me but it did not work :
    Code:
    attachInterrupt (1, & YourInterruptFN, FALLING);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Arbotix-M Arduino IDE Problems on OS X
    By ericshi in forum Software and Programming
    Replies: 1
    Last Post: 05-30-2016, 09:19 PM
  2. Arbotix on Arduino 1.5(will be 1.0.2) IDE?
    By KurtEck in forum Arbotix, Microcontrollers, Arduino
    Replies: 16
    Last Post: 03-05-2014, 12:42 PM
  3. Question(s) Arbotix and Arduino 1.0.1
    By generallee989 in forum Software and Programming
    Replies: 5
    Last Post: 11-02-2012, 04:36 PM
  4. Arbotix, Arduino, and Timers
    By draikani in forum Software and Programming
    Replies: 8
    Last Post: 04-07-2012, 08:49 PM
  5. Question(s) arbotix and arduino pro
    By Bunkerman in forum Arbotix, Microcontrollers, Arduino
    Replies: 0
    Last Post: 05-01-2011, 10:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •