Show Posts
Pages: [1] 2 3 ... 15
1  Using Arduino / Microcontrollers / Re: Anyone here use XMEGAs? on: May 07, 2014, 05:16:32 pm
I'd ask on AVRFreaks, they have a dedicated xmega board

EDIT: nevermind, looks like you already asked there!
2  Topics / Robotics / Re: Tracking position of an autonomous robot on: May 02, 2014, 07:23:19 pm
I reckon encoders on the wheels will lead to a lot of error over time because of slippage. I guess there's no one sensor that can precisely give position. The more I read about autonomous robots, the more it seems that people just average the readings of multiple different types of sensors to get a position reading. So far the sensors I'm thinking of using are an accelerometer, digital compass, and ultrasonic sensor. Will a digital compass be enough to reliably determine the rotation of the robot? Will the motors interfere with it? Or should I also include a gyroscope and average compass readings with it?

mirith, the map will only be 2 dimensional, so there isn't a whole lot of data to be read/written when following/creating the map.

I was also throwing around the idea of aiming the guts of an optical mouse at the ground and getting distance readings from that. Focusing on the ground while going over bumps might be an issue and I don't know if a mouse will read correctly at high speed. What do you guys think?
3  Topics / Robotics / Re: Position Control of a 12V DC Motor on: May 02, 2014, 03:27:31 pm
yeah, your loop is set up strangely. Just put each movement in its own while(1) loop and break out of it whem the motor is at the right position (encoderTicks == desiredPosition). Ideally you would make some sort of moveMotor() function that takes the desired position as an argument.
4  Topics / Robotics / Re: Position Control of a 12V DC Motor on: May 02, 2014, 01:35:41 am
Ok, there's some stuff I didn't catch at first glance.
Code:
//the driver is weird as -255 turns the motor slowly and -1 turns it at fullspeed
That's because analogWrite takes an unsigned 8 bit integer and you're shoving a negative number into it. Change the analogWrite in these parts
Code:
if(motorSpeed >= 0)
{
    ...
}
else
{
    ...
    analogWrite(pwmPin, motorSpeed);
to
Code:
analogWrite(pwmPin, abs(motorSpeed));
Your main problem is likely caused by this while statement
Code:
while (encoderTicks >=500 && timer > 3000)
Once your motor moves 12 ticks back from desiredPosition1 (512) , this loop will exit. Try replacing that while statement with this
Code:
while (timer < 3000){}//delay 3s

while (encoderTicks > desiredPosition2)
{
    ...
Also, it won't hurt to constrain motorSpeed for the second movement in the same way you constrained it for the first movement. Plop it in where the old map() used to be.
5  Topics / Robotics / Re: Position Control of a 12V DC Motor on: April 30, 2014, 12:57:39 am
Code:
motorSpeed = map(motorSpeed, -255, 255, 0, 255);
      if (motorSpeed >= 0)
      ...
      }
      else
      {
How is this supposed to evaluate false if you map all your values to be zero or greater? get rid of the map() and it should work.
6  Topics / Robotics / Re: nRF24L01 with existing Radio Control 2.4GHz on: April 30, 2014, 12:41:42 am
The 2.4GHz modules I once played with allowed you to set the transmitting channel so that you wouldn't get interference; maybe your module also has that option. Also, all but the cheapest 2.4 GHz RC systems automatically select an empty channel to transmit on so you shouldn't have problems.
7  Topics / Robotics / Re: Tracking position of an autonomous robot on: April 30, 2014, 12:35:38 am
The goal is to have the robot completely autonomous, so no beacons or markers on the ceiling, although I like the idea of the charging station having a beacon so help locate it. The station might also have a wireless link to the robot (not sure if it's useful enough to include). Memory shouldn't be problem as the robot will have an SD card. Also, the control board is going to be custom, so I'm not limited to regular arduino hardware. I think a Raspberry Pi is overkill for this, and it'll probably be so easy to implement with one that it wouldn't be any fun to build!

Just have it map the charging station before it starts to roam, then just have it return to that part of the map it made.
But how will it map the area and follow the map it it doesn't know how far it's moving? Or am I misunderstanding something?

The robot will have a pivoting ultrasonic sensor to determine how far away things are. If it could accurately determine its rotation, it could travel in a zig-zag pattern in hallways (and zig-zag to and from a wall in an empty room) so that there is always something moving in view of the sensor. Then, with some math I could figure out the total distance traveled down the hallway/along the wall. A compass IC would be best suited for getting rotation, right?

8  Topics / Robotics / Tracking position of an autonomous robot on: April 29, 2014, 06:59:59 pm
How do people usually go about determining the position of an autonomous ground robot (relative to a charging station)? The robot in question will roam around my house building a map of the walls and furniture, and maybe do something useful once it has all that information. I imagine it's possible with an accelerometer, but is there a sensor better suited to this task?
9  Using Arduino / Microcontrollers / Re: component of microcontroller on: December 24, 2013, 10:07:06 pm
The mega8u2? It acts as a virtual com port. Lets you talk to the arduino / upload code with a standard usb connection.
10  Using Arduino / Microcontrollers / Re: Problem uploading code with Optiboot on: December 23, 2013, 12:05:16 am
Ah, I didn't know that the bootloader couldn't write fuses, that clears it up. By "the watchdog is disabled" I meant that the watchdog fuse wasn't set, so I doubt that it's causing a problem. I guess I'll just suck this chip off and put a new one in since this has to be finished by tomorrow. I've never had a chip fail like this before though, it's quite strange.
11  Using Arduino / Microcontrollers / Re: Problem moving projects from Arduino Uno to Atmega328p on a breadboard on: December 22, 2013, 11:51:41 pm
Yes, you should have decoupling caps next to every chip. Try measuring the voltage of the wallwart and of the 5 volt rail while the program is running, if either voltage drops a lot when the LEDs turn on then you know you have power problems.
12  Using Arduino / Microcontrollers / Re: Problem uploading code with Optiboot on: December 22, 2013, 10:45:42 pm
Okay so I went ahead and burned the regular optiboot and then uploaded my code at 57600 baud. It wrote and verified properly, but it failed when trying to burn the fuses. Now for some reason the MCU seems to restart every 80 ms. WTF? I can still upload code and change the fuses with the dragon, but the code only runs for 15 ms then it does nothing for 65 ms, and then restarts.
Anyway, I tried again on another chip and it works fine, but I still can't write any fuses. I probably won't need to for firmware updates though. Question now is, how do I unbrick the first chip? What in the world would cause the code to run for 15 ms, idle for 65 ms, and then restart? The watchdog is disabled if that could have anything to do with it.
13  Using Arduino / Microcontrollers / Re: Problem uploading code with Optiboot on: December 22, 2013, 08:41:59 pm
I admit that I don't really know what I'm doing here and I've never messed aroud with makefiles so I thought editing the source was the way to go. Basically I just make a new project in atmel studio and threw all of the optiboot files in. Then I added
Code:
#define F_CPU 7900000L
#define BAUD_RATE 2400
  to the top of optiboot.c and and removed
Code:
#if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz
#ifndef SOFT_UART
#define SOFT_UART
#endif
#endif
to use the hardware uart.. I also changes a few of these
Code:
#elif defined(__AVR_ATmega328P__)
to this
Code:
#elif (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__))
so that it would compile for a 328. After the changes I just let atmel studio compile it for me (it ends up at 766 bytes, but that's good enough for me). Here is what AS6 says it's doing to compile:
Code:
avr-gcc -funsigned-char -funsigned-bitfields -DDEBUG  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328 -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"
to link:
Code:
avr-gcc -Wl,-Map="$(OutputFileName).map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega328
and to assemble:
Code:
avr-gcc -Wa,-gdwarf2 -x assembler-with-cpp -c -mmcu=atmega328 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -Wa,-g
I used my AVR dragon to burn the bootloader and to burn the BOOTSZ1, BOOTSZ0, and BOOTRST fuses. I have a feeling that the problem lies in the fuse settings, or the fact that my file is over 512 bytes, while optiboot expects itself to be less that 512 bytes (does it?). If you could provide me with a "correct" hex file for an atmega328 running at 8 MHz (7.9 to be exact) at a baud rate from 2400 to 115200 baud that would awesome.
14  Using Arduino / Microcontrollers / Re: Problem uploading code with Optiboot on: December 22, 2013, 09:15:58 am
Yeah, that's pretty much what I figured. I guess they just wanted to save a few bytes.
15  Using Arduino / Microcontrollers / Re: Problem moving projects from Arduino Uno to Atmega328p on a breadboard on: December 22, 2013, 07:46:02 am
Did you put decoupling caps (100 nF) next to the MCU as well as some bigger (10 uF) caps on the power rail? sounds like you might be browning out. Are there any heavy loads being driven from the same rail that's powering your MCU?
Pages: [1] 2 3 ... 15