Show Posts
Pages: 1 2 [3] 4 5 ... 20
31  Using Arduino / Networking, Protocols, and Devices / Re: RF24: one loop takes 30ms :( on: November 24, 2013, 05:32:19 am
I just tried using radio.setDataRate(RF24_2MBPS); and that does speed things up. Still not as fast as I want but maybe that's the limit of the hardware (and my lack of coding skills :p ). Should have tried this a long time ago  smiley-red
32  Using Arduino / Networking, Protocols, and Devices / Re: RF24: one loop takes 30ms :( on: November 24, 2013, 05:02:22 am
When running the test sketches I have zero packet loss. I'm using modules with amp and preamp, each powered by its own 3V3 regulator and a 100µF electrolytic and a 0.1µF ceramic capacitor on the output of the vreg. I don't think that's the problem...
33  Using Arduino / Networking, Protocols, and Devices / RF24: one loop takes 30ms :( on: November 23, 2013, 06:53:52 pm
I have a remote controlled Dagu Rover 5 ("robotic vehicle"): https://vimeo.com/42465800
The Rover 5 has an ATmega1280 and a nRF24L01 module, the remote control has an ATmega328 and a nRF24L01 module. I have been using it for more then a year without problems. I use the Maniacbug RF24 library. Now recently I connected the 4 encoders to the ATmega1280 and wrote some code to control the speed of the motors using encoder feedback.
Now I tried to integrate my encoder code in to my remote control sketch and ran in to some trouble. I found out that one loop takes a very long 30 milliseconds. This doesn't play well with my encoder code. Leaving out the RF24 radio code the loop takes less then a millisecond.
I have installed this fork of the RF24 library but to no avail. https://github.com/gcopeland/RF24
Is there any way to let this code run faster?

This is the radio code I use:
Rover 5:
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

unsigned long startTime;
unsigned long endTime;
int time;

typedef struct{
  int X;
  int Y;
  int Z;
  int A;
  int B;
  int C;
  int D;
}
struct1_t;

typedef struct{
  float motors;
  float batRover;
  int distance;
  int bearing;
}
struct2_t;

struct1_t remote;
struct2_t rover;

RF24 radio(48,49);
const uint64_t pipes[2] = {
  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

void setup()
{
  Serial.begin(115200);
  delay(100);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  radio.startListening();
  }
 
void loop(void)
{
  startTime = millis();
 
  // radio stuff
 
  radio.stopListening();
  bool ok =radio.write( &rover, sizeof(rover) );
  radio.startListening();
 
  unsigned long started_waiting_at = millis();
  bool timeout = false;
  while ( ! radio.available() && ! timeout )
    if (millis() - started_waiting_at > 100)
      timeout = true;

  if ( timeout )
  {
    Serial.println("Failed, response timed out.");

  }
  else
  {
    radio.read( &remote, sizeof(remote) );

  }
 
  // end of radio stuff
  endTime = millis();
  time = endTime - startTime;
  Serial.print("time = ");
  Serial.println(time);
  }


Remote control:
Code:
// Remote
// µController = ATmega328

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

typedef struct{
  int X;
  int Y;
  int Z;
  int A;
  int B;
  int C;
  int D;
}
struct1_t;

typedef struct{
  float motors;
  float batRover;
  int distance;
  int bearing;
}
struct2_t;

struct1_t remote;
struct2_t rover;

RF24 radio(8,9);
const uint64_t pipes[2] = {
  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };


unsigned long startTime;
unsigned long endTime;
int time;

void setup()
{
  Serial.begin(57600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);
  radio.startListening();
}

void loop(void)
{
  startTime = millis();
 
    // radio stuff
  if ( radio.available() )
  {
    bool done = false;
    while (!done)
    {
      done = radio.read( &rover, sizeof(rover) );
    }
    radio.stopListening();
    radio.write(&remote, sizeof(remote) );
    radio.startListening();
  }
  // end of radio stuff
 
  endTime = millis();
  time = endTime - startTime;
  Serial.print("time = ");
  Serial.println(time);
}
34  Using Arduino / General Electronics / Re: LM2596 Step-down 5V>4V adjustable output voltage on: November 22, 2013, 09:50:03 am
There is a potentiometer (the blue "thing") on the board that lets you adjust the output voltage. Take a good look at the datasheet of the LM2596, I don't think it's possible to get 4V from an LM2596 with an input voltage of 5V. You will need to find a regulator with a smaller drop out voltage.
35  Topics / Robotics / Re: Dagu Rover 5 chassis robot demo on: November 19, 2013, 04:33:16 am
Greetings.
I've been working on modelling and control of this platform for a while now and I have a question to ask if it is possible. The encder pulses seem to be quite long or slow to be able to get a good PID control from them. Has anyone tride this? have you been successful? can you share with me the method you used for speed measurment? I'll be more than thankful for any answer.
Cheers.

I've finally hooked up the encoders on my Rover 5 and wrote some code for them: http://www.bajdi.com/rover-5-encoder-speed-control/ Just trying to make all 4 motors rotate at the same speed. It works but maybe a PID control would be better?
36  Using Arduino / Project Guidance / Re: 3 DOF Hexapod Algotithm on: November 08, 2013, 05:11:27 pm
I've built a hexapod with 3DOF legs: https://vimeo.com/67994924
I used inverse kinematics to code the positions of the legs / angles of the servos. Then I spent countless hours figuring out how to move the servos in little steps using a timer (millis). Took me a long time but I got it to work in the end. To be honest it's not that hard but I'm a noob programmer. I would recommend you use inverse kinematics, as it makes coding the different walking gaits a lot easier.
37  Using Arduino / Sensors / Re: Is it possible to connect two Mag3110 sensors to one Arduino? on: October 28, 2013, 06:29:55 am
Google I2C multiplexer.
38  Topics / Robotics / Re: Turtle from an Arduino Uno on: October 12, 2013, 03:53:56 am
The Doodle bot is made by Dagu. They have a support site here: https://sites.google.com/site/daguproducts/ There you can find the instruction manual and sample code. Looks like a nice kit.
39  Topics / Robotics / Re: Dagu hexapod + IR sensors + PIR sensors on: October 09, 2013, 01:59:10 pm
Have you selected the right board in the Arduino IDE? From the photos on your site I can see that you are using a Dagu Red back spider controller. The first versions of this board had the ATmega1280, the latest versions have the ATmega2560. I suggest you take a good look at the chip on your board to see which micro controller you have and select the right board in the Arduino IDE (Arduino Mega 2560 or Arduino Mega 1280).
40  Using Arduino / Project Guidance / Re: How to interface Arduino Uno with nRF 2.4Ghz Transciever???? on: October 06, 2013, 04:40:22 am
You mean the Nordic nRF24L01 modules? Take a look at this: http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
41  Using Arduino / Microcontrollers / Re: ATmega8L-8AU bootloader with external crystal on: September 30, 2013, 01:33:13 pm
Boot flash size is set to 256 words. Boot start address is $0F00.
I recompiled the bootloader, but how can I see how big it is?

/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L   '-DLED_START_FLASHES=3' '-DBAUD_RATE=38400'   -c -o optiboot.o optiboot.c
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L   '-DLED_START_FLASHES=3' '-DBAUD_RATE=38400' -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega8.elf optiboot.o
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-size optiboot_atmega8.elf
   text    data     bss     dec     hex filename
    480       0       0     480     1e0 optiboot_atmega8.elf
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega8.elf optiboot_atmega8.hex
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-objdump -h -S optiboot_atmega8.elf > optiboot_atmega8.lst
rm optiboot.o optiboot_atmega8.elf

Is the 480 the size of the bootloader? A bit of extra space wouldn't hurt smiley
42  Using Arduino / Microcontrollers / Re: ATmega8L-8AU bootloader with external crystal on: September 29, 2013, 06:15:03 am
I got it to work with these settings:

##############################################################

atmega8l.name= Bajdi ATmega8L

atmega8l.upload.protocol=arduino
atmega8l.upload.maximum_size=7168
atmega8l.upload.speed=38400

atmega8l.bootloader.low_fuses=0xbf
atmega8l.bootloader.high_fuses=0xcc
atmega8l.bootloader.path=optiboot
atmega8l.bootloader.file=optiboot_atmega8.hex
atmega8l.bootloader.unlock_bits=0x3F
atmega8l.bootloader.lock_bits=0x0F

atmega8l.build.mcu=atmega8
atmega8l.build.f_cpu=8000000L
atmega8l.build.core=arduino
atmega8l.build.variant=standard

Had to recompile the bootloader for a baudrate of 38400, couldn't upload any sketches with a baudrate of 115200. According to this site 115200 is much to fast for 8MHz: http://www.wormfood.net/avrbaudcalc.php
43  Using Arduino / Microcontrollers / Re: ATmega8L-8AU bootloader with external crystal on: September 28, 2013, 12:54:27 pm
make atmega8
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L   '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'   -c -o optiboot.o optiboot.c
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L   '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega8.elf optiboot.o
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-size optiboot_atmega8.elf
   text    data     bss     dec     hex filename
    480       0       0     480     1e0 optiboot_atmega8.elf
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega8.elf optiboot_atmega8.hex
/home/mathias/Arduino/arduino-mvm/hardware/tools/avr/bin/avr-objdump -h -S optiboot_atmega8.elf > optiboot_atmega8.lst
rm optiboot.o optiboot_atmega8.elf

Ok, I've managed to compile an optiboot bootloader for the ATmega8 @ 8MHz using the tools provided with the IDE. Took me some time to figure everything out. But I can't fugure out the fuses, so many options. Anyone that can help me? I have an ATmega8L-8AU with an external 8MHz crystal, chip is running at 5V.
44  Using Arduino / Installation & Troubleshooting / Re: Arduino Robot upload problems on: September 27, 2013, 04:05:58 pm
You are selecting the right board in the IDE? There is a different entry in the board selection for the robot control board and the robot motor board.
45  Using Arduino / Microcontrollers / ATmega8L-8AU bootloader with external crystal on: September 27, 2013, 12:25:39 pm
I've just soldered up a new board. It has an ATmega8L-8AU micro controller with an external 8MHz crystal. Now I want to burn an Arduino bootloader with my USBasp. But I haven't found the right boards.txt and bootloader setting for this combination. I did find a bootloader for an ATmega8L but it uses the internal clock. http://www.hackmeister.dk/2011/01/new-bootloader-file-for-atmega8l/
Can I use this bootloader and just change the fuse settings in boards.txt? If so how what value should they be set?
Pages: 1 2 [3] 4 5 ... 20