Author Topic: 50 $ robot not working.. please help..  (Read 3259 times)

0 Members and 1 Guest are viewing this topic.

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
50 $ robot not working.. please help..
« on: May 28, 2013, 07:41:54 AM »
ok,I have built the 50$ robot but its not getting programmed. I have made the microcontroller and its fine. I have tested it at least hundred times and now the voltages are also fine. I have plugged in the atmega8 and the cheap serial port dongle programmer. I also compiled the photovore hex file and downloaded the ponyprog software. When I plug in the programmer and switch on the microcontroller, I select "Write All" from the ponyprog file. Then the error of missing device or unknown device keeps coming EVERY single time!! I checked the voltages and its alright.. My computer has only 1 serial port.. so I chose serial prog IO and selected COM1 from the interface setup in the ponyprog file.

By far, the only mistake i have made in the circuit is that the DIP socket for the ic is the wrong way (the u shaped side is on the opposite side of the pc  board.).. but I have plugged in the IC correctly.. Does this make a big difference?? please reply..

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: 50 $ robot not working.. please help..
« Reply #1 on: May 28, 2013, 11:34:00 AM »
The orientation of the socket doesn't matter as long as the actual IC is inserted correctly.
When programming Atmega microcontrollers, there are two things that commonly go wrong:
1) You must have power supplied to the microcontroller while you program it. Make sure the battery is on!
2) The 6-pin ICSP programmer cable can be plugged in backwards, which will result in the programmer not seeing the microcontroller. Re-plug the cable the other way on the 6-pin header if that's the case.

(Note that I'm assuming the $50 robot uses the standard 6-pin programming header -- if not, then case 2 above might not apply)

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: 50 $ robot not working.. please help..
« Reply #2 on: May 28, 2013, 03:09:05 PM »
cheap serial programmers, specially the ponyprog one, are known to be problematic. they work on some computers and some os but not all. usbasp ($3 on ebay) are trouble free and generally work better than programmers costing 10x more. better to switch than fight.

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #3 on: May 28, 2013, 06:54:35 PM »
"(Note that I'm assuming the $50 robot uses the standard 6-pin programming header -- if not, then case 2 above might not apply)"

@ Jwatte, thank you very much for the reply but unfortunately, i am not using the 6 pin programmer. I have a ten pin programmer (exactly the same one shown in the tutorial). Should I try switching the pins? I make sure the batteries are on when i try to program it..

The voltages are fine and the programmer is also being supplied with 4.94 volts.. So I am confident that voltage is not the problem.. Is there any specific detail related to the configuration of the serial port??

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #4 on: May 28, 2013, 06:56:52 PM »
@ Johnwarfin, are the pinouts for the usbasp programmer the same as those of the cheap programmer??

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: 50 $ robot not working.. please help..
« Reply #5 on: May 29, 2013, 11:36:47 AM »
all usbasp have standard 10 pin atmel pinout.  for a couple bucks more you can get ones from hobbyking with 10pin to 6pin cable or on ebay you can get an adapter for the end of the standard cable. i have no need of either because i use simple custom 4 pin inline for programming.

none of this matters as long as you hook up mosi, miso, sck, and reset correctly.
« Last Edit: May 29, 2013, 11:40:24 AM by johnwarfin »

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #6 on: June 01, 2013, 01:43:15 PM »
Ok, I just found out that when I put my multimeter on the resistance setting (20k) , connect one lead to ground and another to AREF ( or the positive lead of the LED), the multimeter shown a certain resistance of about 10-11 ohms.. When I plug in the 9 volt battery, and test e voltage with the multimeter by putting the two test leads o. He ends of the programmer, I get 4.96 volts.. Is this right? Since I am getting a resistance between ground and AREF, AVCC, I am confused.. This wasn't happening before but the voltages are fine..

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #7 on: June 01, 2013, 02:41:51 PM »
Btw, on which pins should the voltage be approx 5 volts? I'm asking this because I don't know if the ic chip is being powered. In other rods, here should I connect the leads of the multimeter to check if the Voltages are fine EXCEPT the servo buses, the sensor buses and the ends of the programmer which are connected to ground and power?

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 270
  • Helpful? 12
Re: 50 $ robot not working.. please help..
« Reply #8 on: June 01, 2013, 04:09:12 PM »
That information should be found in whatever you used to wire up the circuit or in the data sheet.
« Last Edit: June 01, 2013, 04:13:25 PM by jkerns »
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #9 on: June 02, 2013, 11:29:49 PM »
Got a new problem.. The good thing is that this seems to be a simple one..  I am sorry I can't get the robot to work.. I am getting a proper voltage of 4.96 volts at the programmer ends and the sensor outputs when I don't connect the photo resistors by the three pin headers.. The moment I connect the photoresistors, the voltage drops to 1-2 volts and the regulator becomes really hot.. This means there is some kind of shorting or something.. I checked the wires of the photoresistor correctly and the connections seem to be alright.. I will surely recheck but I can't seem to solve this problem.. Help!!!  Thank you in advance.

P.s when I connect the multimeter to ground and AVCC/AREF, the multimeter shows a resistance of around 10.58 k ohms... Is this supposed to happen???
« Last Edit: June 02, 2013, 11:36:19 PM by ankshah13 »

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #10 on: June 03, 2013, 01:43:10 AM »
currently i am plugging my servos to the microcontroller and trying to program it via the cheap avr stk serial port programmer.. no matter what i do, the error of "missing or unknown device" keeps appearing.. I am not in a state to buy another programmer.. Please suggest some solutions. I am directly connecting the programmer to a serial port (com1). The voltages are fine without the sensors.. the programmer shows a voltage of 4.97~5 volts and i always switch on the batteries when i program the controller.
NOTE: While programming the servos, I have not plugged in the photoresistors..
 Is this alright?
can i plug in the sensors after programming the servos??
If yes, then why isnt my robot working.. ?? please help..
thanks in advance to whoever replies..

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: 50 $ robot not working.. please help..
« Reply #11 on: June 03, 2013, 11:33:41 AM »
if you cannot afford the $3 shipped for a proper programmer then you are probably in the wrong hobby. and if you insist on using the flaky one you might try disconnecting everything except the chip when flashing. even the best dongles will not provide enough current to drive motors. and as mentioned even then theres a good chance it wont work due to com port issues.

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #12 on: June 05, 2013, 07:37:26 PM »
ok, now I have decided to buy the usbasp programmer..
@Johnwarfin, please help me select the right one from this link.

http://www.ebay.in/sch/i.html?_trksid=p3907.m570.l1313&_nkw=usbasp+programmer&_sacat=0&_from=R40#item3cd24c08ff

Secondly, which software should I download to upload the hex file to the atmega8 via the usbasp programmer? Can it directly work with avr studio? Please explain how to upload programs to my microcontroller via this programmer.. thanks

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: 50 $ robot not working.. please help..
« Reply #13 on: June 06, 2013, 10:18:39 AM »
the two blue ones in your link look ok. the second has 6 pin connector wich some people like. i didnt convert rs but anything around $3 usd is good. i have purchased several of these:

http://www.ebay.com/itm/USBASP-USBISP-AVR-Programmer-USB-ATMEGA8-ATMEGA128-/171046130769?pt=LH_DefaultDomain_0&hash=item27d324d451#ht_4411wt_903

avrdude is my favorite programming software. it is universal for arduino and can be made to work with atemel studio too. i dont know the details because my favorite setup is basic winavr. both arduino and studio are just shells for the winavr core and imo are overkill and overly complex. but they are all very useable toolsets.

Offline greywanderer012345

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: 50 $ robot not working.. please help..
« Reply #14 on: June 20, 2013, 11:20:36 PM »
Whoa, Whoa, Whoa!

  Simple answers first, people!
  The absolute FIRST thing you need to try is disconnecting all of the sensors and servos while programming. Also, if your photosensors being attached are making the regulator get really hot, you've probably got the resistor tied into them incorrectly, and you very well may have fried your MCU. Check the photosensors, even if you have to take them apart, and make sure nothing is shorting out. (Check with a multimeter first. No 2 leads of the photosensor should have anywhere near zero resistance) If you realize that you shorted out the sensor, through the MCU, you might want to order a second MCU. (even if your problem is on your board somewhere, you're eventually going to build that second robot anyway, right?)
   Don't even attach the servos or sensors before you've successfully programmed the MCU at least once, for any project. Make the LED flash if you want a test on the board side. I would even test each pin by programming it to go high then low every second or so, then check them with the multimeter. (One pin at a time, or else you aren't testing that the pins aren't shorted to each other) It might seem like redundant work, but considering that it all takes less than an hour, and how much time it saves you if anything IS wrong, it's definitely worth doing. I actually like to allow each pin to control an LED in addition to the leads on the board. It makes your robot board look more high tec, and eliminates the need for testing with a multimeter. (Not just for testing pins when you first build, but also for learning how to program the pins)
« Last Edit: June 20, 2013, 11:22:37 PM by greywanderer012345 »

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #15 on: July 12, 2013, 10:47:16 AM »
ok, the electronics problem is solved. Thank you for your advice. I had made a mistake in the photoresistor wiring... Now comes the programming problem.. :D

 I have bought a usbasp programmer to program my 50 buck robot. The programmer works and I have already installed the driver software. The connections on my microcontroller are fine because the voltages are ok. The multimeter shows exacly 4.96 volts everytime I test the mcu.
I am programming the atmega8 via avrdude.. Avrdude works fine on my laptop. Now, when i write the commads for programming, an error appears. It is exactly as shown below:

" avrdude: warning cannot set sck period. please check for usbasp firmware update
  avrdude error: program enable target doesn't answer.1
 avrdude intialization failed
Please double check your connections and try again or use F- to override this check."


Please tell me how to proceed further.. How do i install the firmware and make the usbasp burn the hex file into the atmega8..

Offline greywanderer012345

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: 50 $ robot not working.. please help..
« Reply #16 on: July 17, 2013, 12:20:49 AM »
I'm not the most experienced around here, but just in case you don't get any other replies...

I haven't seen those warnings, and I've only used the AVRISP MKII for programming, so I hope someone else has a more definite answer for you. It's possible that you need to update the firmware on the programmer, as the warning suggests. However, I still think the most likely problem is the MCU. If your regulator got hot, and the only thing it was powering was the incorrectly wired sensors, that's way more current than your MCU should have running through it, and it might be fried. I'd order another MCU if no one has an alternate suggestion.

Also, when I googled your errors, people got them for many reasons, including incorrect wiring, firmware needing updating(which requires another programmer...), and not setting a speed(done through a menu in AVRStudio, so I have no Idea about doing this with ponyprog, but I thought there was a default value set in a register for this anyway...)

http://forum.arduino.cc/index.php?topic=123191.0

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=956655

Offline ankshah13Topic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: 50 $ robot not working.. please help..
« Reply #17 on: July 17, 2013, 12:49:50 AM »
Thank you very much for the reply.. I successfully programmed the atmega8 now with a software called eXtreme burner for usbasp. I had not connected the 0.1 uF capacitor to AVCC and that was the cause of the problem.. Thank you to all the people who replied.. :D

Offline greywanderer012345

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: 50 $ robot not working.. please help..
« Reply #18 on: July 17, 2013, 11:32:43 AM »
The Photovore code isn't great for adding onto. Many people start using webbotlib or other libraries. If you're like me and want to understand the programming at a lower level rather than learning a new library, I've got a simple alternative to admin's code that also doesn't use any additional libraries. Everything is included in this code. It doesn't need SoRUtils, Webbotlib, or any headers other than the avr/io.h and avr/interrupt.h. It is heavily commented. I wrote it, so ask me if you don't get any of it.


Code: [Select]
//Photovore atmega328p @ 1MHz
//Be sure to set optimization in IDE to zero for delay to work

#include <avr/io.h>
#include <avr/interrupt.h>

//volatile unsigned int   clock_2millisecond=0;
//^^^Uncomment the above if you want to time anything else in
//the timer ISR. Remeber to reset it to zero if it gets above
//500.
//Add a clock_second, ...minute, etc., counter if you need to

//This is used to count milliseconds by 2
volatile unsigned int   servo_2millisecond=0;
volatile unsigned int   sensor_2millisecond=0;

uint8_t leftEye = 0;
uint8_t rightEye = 0;

//speed range is -20 to 20, negative speeds = reverse
volatile int leftSpeed = 0;
volatile int rightSpeed = 0;

void DelayLoops(uint16_t nloops){
   while(nloops>0){
      nloops--;
   }
}

void InitADC() {
   ADMUX=(1<<REFS0)|(1<<ADLAR); // Aref=AVcc, Left Adjusted
   ADMUX|=0b00000101; //Start by reading pinC5
   ADCSRA|=(0<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); // Prescalar=8, be sure to change for different MCU Hz
   ADCSRA|=(1<<ADEN); //Enable ADC
   ADCSRA|=(1<<ADSC); //Start ADC
   ADCSRA|=(1<<ADIE); //Enable ADC Interrupt
   
}

int main() {
   //Set PinD as Output
   DDRD = 0xFF;
   //Clear PORTC
   PORTC= 0x00;

   InitADC();

   //Set up the timer1
   //Set Prescaler to 8 and mode to CTC
   TCCR1B=(1<<WGM12)|(1<<CS10);

   //The below compare value for 2ms was found empirically with the debugger
   // and will differ with other frequencies
   OCR1A=2000;

   //Enable the Output Compare A interrupt (Will be TIMSK, without the '1', on MCU's with only 1 of these timers)
   TIMSK1|=(1<<OCIE1A);

   //Enable interrupts globally
   sei();

   //infinite loop
   while(1); //This will be skipped if optimization is used

   return 0;
}

//ISR called every 2ms. why 2? had rounding issues w/ 1ms
ISR(TIMER1_COMPA_vect) {
   clock_2millisecond++;
   servo_2millisecond++;
   if(servo_2millisecond==10)
   {
      servo_2millisecond=0;
  //Send Servo Signals

  //Right Servo (PORTD Pin 2)
  PORTD|=0b00000010;
  DelayLoops(81+rightSpeed);
  PORTD=0x00;
     
  //Left Servo (PORTD Pin 1)
  PORTD|=0b00000001;
  DelayLoops(81-leftSpeed);
  PORTD=0b00010000;
   }   
   if(clock_2millisecond>=500){
      clock_second++;
  clock_2millisecond=0;
   }
}

//Called when A/D Conversion completes
ISR(ADC_vect){
   if((ADMUX & 0b00000111) == 0b00000101){ //If current pin is C5

      // read left photosensor, the +20 is an adjustment I made
      // to account for a diffence the sensors were reading
      // when the light was in front of the bot and may need adjusting
      leftEye=ADCH + 20;

ADMUX&=0b11111000; //Clear pin register (right 3 bits only)
ADMUX|=0b00000001; //Set pin to C1

if(leftEye < rightEye-8) // The -8 acts as a threshhold
    rightSpeed=-20;
      else
    rightSpeed=20;
     
      //Small delay, might not be necessary. I added this on the
      //same debug run as the other changes that got the bot to
      //work. This might make the ISR too long if you add more
      //code. If it makes trouble, take it out or enable nested
      //interrupts.
      DelayLoops(50);

      //start next conversion
      ADCSRA|=(1<<ADSC);
   }
   else if((ADMUX & 0b00000111) == 0b00000001){ //If current pin is C1
      rightEye=ADCH;
ADMUX&=0b11111000; //Clear pin
ADMUX|=0b00000101; //Set pin to C5
if(rightEye < leftEye-8)
    leftSpeed=-20;
      else
    leftSpeed=+20;
      DelayLoops(50);
      ADCSRA|=(1<<ADSC);
   }
}

« Last Edit: July 17, 2013, 11:57:09 AM by greywanderer012345 »

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 270
  • Helpful? 12
Re: 50 $ robot not working.. please help..
« Reply #19 on: July 18, 2013, 07:54:26 AM »
It is heavily commented. I wrote it, so ask me if you don't get any of it.

It's nice to see well commented code. Makes it a lot easier to understand and maintain. I think a lot of people underestimate the value of well written comments.
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: 50 $ robot not working.. please help..
« Reply #20 on: July 18, 2013, 11:13:56 AM »
if thats the code from $50 robot it cerainly answers the question about sensor voltage. no on/off here.

and it is one of the best commented programs ive ever seen.  a great learing tool not only for robotics but c programming in general.

 


Get Your Ad Here

data_list