EMG - PhantomX Reactor Robot

From RobolaboWiki
Revision as of 14:33, 24 February 2025 by Aguti (Talk | contribs)

Jump to: navigation, search


Timer

Note: Most of the information of this section is obtained from: https://www.prometec.net/timers/ Please refer to the previuos link and the library if you need more information.

A timer in electronics is a device or circuit used to measure and control time intervals. It generates precise delays or oscillations, making it essential in various applications like blinking LEDs, controlling motors or executing periodic events, between others.

It operates independently from the main program, allowing the microcontroller to perform other tasks simultaneously. Timers typically work by counting clock pulses from the microcontroller’s internal clock or an external source. They can be configured in various modes, such as delay generation, pulse width modulation (PWM), event counting, or frequency measurement.

Timers are configured by setting up several registers, to adjust the sampling time, durating, mode, starting, stoping,.... However, in our case, for the PhantomX React Robot, based on a AVR microcontroller, we will work with the TimerOne library.

TimerOne library

  • Download the TimerOne library from: [here ].
  • Uncompress the libraries to a path of your convenience. In this file you will find one folder: TimerOne
  • Copy TimerOne folders to the libraries folder in the <ARDUINO_MAIN_DIRECTORY>. In some Windows you will find this folder in My Documents\Arduino\libraries , while in others you will find it in Documents\Arduino\libraries . In Linux you will find this folder in ~/Arduino/libraries.
  • Important: If you do not have a libraries folder inside your <ARDUINO_MAIN_DIRECTORY>, create it and move the content inside it.

    Main Functions of TimerOne library

    This Section provides important information for the Timer handling. It is based on the explanation of different methods, but it does not explain the complete set of methods. To get and exahustive description of all methods the TimerOne.h must be studied.

    Main methods are as follows:

    • void initialize(unsigned long value) : Initializes and set the timer to value in microseconds
    • void setPeriod(unsigned long value) : Set the times to value in microseconds
    • void start(void): Starts the timer
    • void stop(void): Stops the timer


    • It opens the gripper, so it can release an object if already grasped.

    • void ROBOT_GripperClose(void) : It close the gripper, so it can grasp an object if correctly located.
    • void ROBOT_SetSingleTrajectory ( double *f_pos, uint16_t un_time, uint8_t un_trajectory_type ) : It performs a trajectory form one point (Q(t0)) to another point (Q(tf)). Q(t0) and Q(tf) are defined as generalized coordinates Q={q1,q2,q3,q4,q5}. Moreover, Q(t0) is defined as the coordinates at which the robot is located once the instruction is set.
      • double *f_pos : Q(tf) is coded as double * , for example:
        double m_fCoordTest[]       = {0,M_PI/2,-M_PI/2,0,0};
        


        EMG