Results 1 to 4 of 4

Thread: C program for AX

  1. Lightbulb C program for AX

    Hello all!

    I have two questions, I hope you could help me with.

    I am programming AX motor in C with Cortex 4F processor, and I have some problems.

    (1) I am not sure whether problem is in UART. I placed it on oscilloscope and noticed that it gives 3.3V when not transmitting and drops voltage down when transmitting data. Is this inverted logic okay for UART communication? I am no expert, so this got me confused.

    (2) I wrote a C code, following e-manual on Robotis, and I am not sure why the motor won't move. Can you see it, please and tell me if there is a problem?

    Code:
    int main () {
             
             int i = 0;
    
             uint8_t send_data [11];
             uint8_t position_LP, position_HP,
                        speed_LP, speed_HP;
    
             position_LP = 512 & 0x00FF;
             position_HP = ((512 & 0xFF00) >> 8);
    
             speed_LP = 300 & 0x00FF;
             speed_HP = ((300 & 0xFF00) >> 8);
    
             checksum = 255 - ((0x01 + 0x07 + 0x03 + 0x30 + position_LP + position_HP + speed_LP + speed_HP) %256);
    
             send_data [0] = 0xFF; // START
             send_data [1] = 0xFF; // START
             send_data [2] = 0x01; // DEVICE ID
             send_data [3] = 0x07; // NUMBER OF PARAM
             send_data [4] = 0x03; // WRITE
             send_data [5] = 0x30; // ADDRESS OF GOAL POSITION REGISTER
             send_data [6] = position_LP; // 8bit LOW
             send_data [7] = position_HP; // 8bit HIGH
             send_data [8] = speed_LP; // 8bit LOW
             send_data [9] = speed_HP; // 8 bit HIGH
             send_data [10] = checksum;
     
             while (i < 11) {
                   uartTX_byte (send_data [i]);
                   i++;
             }
    
    }
    Do you see a mistake, or can you direct me to a way how to deal with this problem?

    I have configured AX to ID = 1, baud = 1MHz via Trossen's DynaManager. Currently, it is not on 512 position. None of the given positions work.

    Thanks!

  2. #2

    Re: C program for AX

    As this is not specific to Trossen Hardware, you might want to try asking up on the Robotis forum: http://en.robotis.com/service/forum.php

    Note: The communications with servos is bidirectional, that is the servos will try to send back response... So you normally need to do something like, either have the driver chip/hardware like Robotis shows in their documents. Or you may need a way to setup the half duplex communications... For example I do this with Teensy processors (PJRC), a variety of different ways, including buffer chip as to get the signal to 5v which the spec for the servos shows.

    Or the Teensy processors UARTS have a way to setup a half duplex communications where you need to tell it when to send or when to receive (basically only in transmit configuration when I am actually sending data)...

    Also hard to know why it does not move, like what type of power is actually provided to the servo? How do you have it hooked up to your processor? I assume you have a ground wire also going back to processor...

    Also did not see anything that actually configures UART it goes from main to simply setup structure and call some tx byte...

  3. Re: C program for AX

    Thanks, I'll write there!

    Yeah, I have the common ground between them, 12V supply to the motor. I am also shutting down UART_TX after sending information so I do not pick up the motor's response.

    Init function is in uartTX_byte (it is limited to execute only on first function call). This is just the tryout code.

  4. #4

    Re: C program for AX

    Yes, a zero bit is sent as wire-to-ground on the TTL UART bus. It works fine to wire a microcontroller UART straight to the servo, EXCEPT when the servo tries to send a response back, the microcontroller should not be trying to drive the wire high. Also, the bus is defined to use 5V, but 3.3V usually works in practice.

    For the servo to move, you have to enable torque by sending a packet to set the TORQUE_ENABLE register (24) to 1 after power-on.
    Other than that, you'd want to see if you get a response packet from the servo, to see whether you are communicating correctly.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. I need help of this C++ program
    By lo0lo0999 in forum Software and Programming
    Replies: 7
    Last Post: 03-13-2012, 03:24 AM
  2. Question(s) Robot plus program
    By blastdog in forum Humanoids, Walkers & Crawlers
    Replies: 1
    Last Post: 09-07-2011, 06:18 PM
  3. Who uses what cad program?
    By rebel in forum Software and Programming
    Replies: 20
    Last Post: 02-14-2011, 01:13 AM
  4. Help to finish off program
    By nolimit44 in forum Software and Programming
    Replies: 17
    Last Post: 02-11-2011, 10:52 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
  •