Results 1 to 5 of 5

Thread: Arbotix digitalRead() interfered by motors?

  1. Arbotix digitalRead() interfered by motors?

    I need to send simple commands from IOIO to Arbotix.
    I have been trying to connect them using UART as the protocol, with the SoftwareSerial library.
    I have managed sending data from the IOIO using Uart.getOutputStream().write() on the IOIO side and on the Arbotix side.

    Everything works until I connect my AX-12 motors.

    Then, when I start fresh, I can send the 1st byte and then no more bytes are received. The Arbotix loop continues to run, but SoftwareSerial.available() keeps returning 0. Resetting Arbotix again enables receiving 1 byte and again no more.
    My serial line is connected to digital pin 2 on the Arbotix with a pull-up 10K resistor to 5V.
    I have tried powering the Arbotix from both FTDI and the motor 12V source with same results.

    To make the setup simpler, I also tried just a simple digitalRead() from a push button connected to digital 2. Again, everything works until I connect the motors and start receiving strange inputs.

    Any ideas?

  2. #2

    Re: Arbotix digitalRead() interfered by motors?

    What baud rate are you using? SoftwareSerial is not a very high speed library, and also locks out other processes/interrupts while working.

  3. Re: Arbotix digitalRead() interfered by motors?

    I am using 9600 baud.
    However, the problem is not with SoftwareSerial since I am also getting strange input even if I just try to read a push button.
    The push button digitalRead() works OK, but the moment I connect the motors, I start getting strange inputs.
    It must have something to do with the current the AX-12 is taking, but I am no electronics expert.

  4. #4

    Re: Arbotix digitalRead() interfered by motors?

    Note: I am not an Arbotix expert, but do have some experience with them.

    From the information, it is hard for me to guess what is going on, without knowing the setup nor the code involved.

    Whenever I run into issues where it is acting strange, me first instinct is to check your power setup. Are you using battery? If so is it charged. If wallwart does it have enough amperage to handle the motors...

    As jwatte mentioned, SoftwareSerial does not work well with anything that relies on timely processing of interrupts as it disables interrupts for the time it takes to process one character. Both on output as it specifically disables interrupts and on input as once it receives a pin change interrupt to start the input, it stays in the interrupt handler until it processes inputting the entire character. So at 9600 baud, it will disable interrupts for a little over 1ms per character or about 16.67K clocks.

    Now using digitalRead(), I don't know what issues you are having with strange inputs. One thing I ran into when I was porting the Phoenix code base to work with the PhantomX, is with the default Bioloid library, the code in Bioloid Controller (void BioloidController::interpolateStep() ) when called when hang in this code until a specified amount of time (default 1/30th of a second), since the last time it was called. This caused my code not to work the way I wanted it to as I wanted my code to call this in several different places as to not starve the processing of the servos, but I also wanted to process other things. So I built my own version of the library, where I could pass in a boolean (void interpolateStep(boolean fWait=true) ) to control if I wanted the code to perform this wait.

    So for example in your code if you are looping off calling interpolateStep, and then doing a digitalRead, you will only do this digitalRead about 30 times per second. Again not sure if this is the issue you are running into?


  5. #5

    Re: Arbotix digitalRead() interfered by motors?

    First, a meta question about your approach to debugging:
    Do you have an oscilloscope, or a (USB) logic analyzer? If so, you should start seeing what's going on electrically. If not, you'll likely want to get one of each.
    The absolutely cheapest Chinese crap isn't likely to help, but there are some reasonably low-cost items that do work wonders for knowing what's going on. These are the one I got when I ran into debugging brick walls, and they did unlock the problems:
    Owon PDS5022T oscilloscope, $279:
    Saleae Logic 8-channel analyzer, $149:

    The oscilloscope has a bit of noise, but is fine for these kinds of problems (and many others.)
    The logic analyzer comes with fantastic software, and even runs on Linux.

    Now, for actual debugging:

    I second the suggestion to check the battery, and check the wall wart. You may very well be seeing brown-outs because of insufficient power supply. You may be able to measure something with a multimeter, but a o'scope would tell you for sure.

    If the problem is noise -- either on power, or on the signal wires -- then a fat capacitor across the +/- will often help. You can't do this on the signals so much (it will filter them) but on the power bus. Put a 10 uF ceramic AND a 220 uF electrolytic across the power bus to make sure there's no problems there.

    Finally, are you feeding power to the servos through the Arbotix? (I don't have one; don't know how it works exactly.) You may want to break out the power, and actually feed it through a separate power injector, like the SMPS2Dynamixel, or just a cut-off piece of 3-wire cable. Just make sure you don't feed it on the wrong wire, or it will be expensive to fix :-)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Question(s) ArbotiX with LabVIEW: Low-level ArbotiX Commands?
    By vogonpoet42 in forum Software and Programming
    Replies: 2
    Last Post: 03-01-2013, 10:25 AM
  2. Question(s) Arbotix Board and Brushless Motors
    By dandbd in forum Arbotix, Microcontrollers, Arduino
    Replies: 8
    Last Post: 05-20-2012, 12:05 PM
  3. Replies: 0
    Last Post: 05-06-2012, 09:23 PM
  4. Question(s) 6(+)A motors with arbotix?
    By Stobs in forum Arbotix, Microcontrollers, Arduino
    Replies: 4
    Last Post: 03-23-2011, 11:01 AM
  5. 24v. Motors
    By ctx32 in forum Power
    Replies: 7
    Last Post: 12-25-2008, 07:21 PM

Tags for this Thread

Posting Permissions

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