Author Topic: How bad did I screw up!? Please help! Blinking orange LED  (Read 1016 times)

0 Members and 1 Guest are viewing this topic.

Offline greywanderer012345Topic starter

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
How bad did I screw up!? Please help! Blinking orange LED
« on: January 16, 2011, 04:07:34 PM »
I just built the $50 robot, but I'm using the 4AA battery pack, isp mkII programmer, and the atmega328p. I haven't modified my servos yet, and I wanted to make sure my electronics was correct before doing that. I wanted to just successfully connect the programmer to the mcu, and program it. I wrote a simple program, which included SoR_Utils.h and just turned on the LED. The program compiled just fine. I connected the mkII to my pc. It downloaded the drivers successfully. I connected the mkII to my circuit, and plugged in the 9V battery. The LED on the programmer turned green. I programmed my LED_on hex file onto the mcu. No errors occurred, but my LED did not turn on. I tried unplugging the 9V, and plugging it back in. I also tried changing the program, recompiling, and programming again. I figured my LED might be bad or something, so I decided to plug in the servos, and try them out. I wrote a simple program which called servoleft() and servoright(). I programmed the mcu with that hex file, and the servos just buzzed. I rewrote the program several times. If I only called on one servo, only that servo buzzed. I had expected the servo to rotate to a specific angle, but neither servo ever moved. OK, HERE'S WHERE I REALLY REALLY SCREWED UP. (please know that I did not have access to internet as I was attempting this) I thought that maybe the mcu was running at the wrong frequency, so I ENTERED THE PROJECT CONFIGURATION OPTIONS and towards the bottom of the page with the option to use an external makefile, I CHANGED THE BLANK FREQUENCY BOX TO 8000000 Hz. I compiled the project, and as soon as I clicked the button to program my mcu, the LED in the programmer started blinking orange and I was no longer able to connect to my mcu. I unplugged the 9V, unplugged the programmer from my pc and my microcontroller, and even restarted my pc. Still, I am no longer able to connect my programmer to my mcu. As soon as I plug it in, the light blinks orange. Troubleshooting only told me that the voltage may be incorrect or the programmer may be plugged in backwards. I checked the voltage. It is still correct. My 9V has not died or anything, and I know that the wiring is correct because the programming was successful several times. Did I fry something? Do I need to reset a fuse or something? Please help me. Also, if anyone can tell me why my LED or servos were not working, please let me know. This was my source code:

#include "SoR_Utils.h"

int main(void){
      configure_ports();
      LED_on();
      while(1){
      }
      return 0;
   }

Also, my first attempt did not include configure_ports();
The code compiled just fine, and I WAS able to program my mcu with the hex file, but the LED never came on.

Here's my altered version of the Photovore_v1.c with which I was trying to make the servos rotate to, well, just anywhere. Last night was the first time I programmed an MCU, ever. I am an intermediate C++ programmer. This is my first attempt using C, as I understand avr has much more c support.

//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff


int main(void)
   {
   //declare variables here
   //int i=250;//a 'whatever' variable
   int sensor_left=0;//left photoresistor
   int sensor_right=0;//right photoresistor
   int threshold=8;//the larger this number, the more likely your robot will drive straight
   

   /****************INITIALIZATIONS*******************/
   //other stuff Im experimenting with for SoR
   //uartInit();  // initialize the UART (serial port)
   //uartSetBaudRate(9600);// set the baud rate of the UART for our debug/reporting output
   //rprintfInit(uartSendByte);// initialize rprintf system

   //timerInit(); // initialize the timer system
   
   configure_ports(); // configure which ports are analog, digital, etc.
   //a2dInit(); // initialize analog to digital converter (ADC)
   //a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
   //a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

   //rprintf("Initialization Complete\r\n");
   /**************************************************/

   
   /*********ADD YOUR CODE BELOW THIS LINE **********/
   LED_on();//turn LED on


   while(1)
      {
      //store sensor data
      //sensor_left=a2dConvert8bit(5);
      //sensor_right=a2dConvert8bit(4);


      //detects more light on left side of robot
      if(1==1)
         {//go left
         servo_left(35);
         servo_right(35);
         }

      //detects more light on right side of robot
      /*else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
         {//go right
         servo_left(25);
         servo_right(25);
         }

      //light is about equal on both sides
      else
         {//go straight
         servo_left(25);
         servo_right(44);
         }
         */


      /* Servo Test Code
      i=250;
      while(i>0)
         {
         servo_left(40);
         i--;
         }

      i=250;
      while(i>0)
         {
         servo_left(24);
         i--;
         }
      */

      //rprintf("Initialization Complete\r\n");
      
      //output message to serial (use hyperterminal)
      //print("Hello, World! Read My Analog: %u\r\n", sensor_0);

      delay_cycles(500);//a small delay to prevent crazy oscillations
      }
   /*********ADD YOUR CODE ABOVE THIS LINE **********/

   return 0;
   }

Offline greywanderer012345Topic starter

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #1 on: January 16, 2011, 04:21:27 PM »
sorry, admin, I did not mean to post this twice.

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #2 on: January 17, 2011, 12:16:57 AM »
Well a few things came to mind while reading what you wrote.

the first is make sure that on the first tab of the programming window where it gives you the option to erase device and select the device, make sure that the atmega328 is selected as the device that you want to program. if it is set as another chip it will program as usual and not show any errors.

A second thing to check is that your battery leads are not snapped inside. on many occasions i have had a problem with my battery connection cable snapping inside causing programming errors(i almost ended up buying a new programmer). get a multimeter and check for a voltage reading at the pads where the battery connectors are soldered while the battery is connected to see if you have a solid link.

to completely erase the device including lock bits and fuses go to the first tab in the programming window and click the button 'erase device'.

Offline greywanderer012345Topic starter

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #3 on: January 17, 2011, 10:16:08 PM »
I am no longer able to do anything to the device, since the LED on the programmer started blinking orange. I did have the atmega328p selected as my device. The error message I receive suggests a problem with an internal pullup resistor, but I still don't completely understand what that means, or how I can go about resetting something like that while my programmer will not connect. Can I force the mkII to connect, or is there any way to manually reset the mcu to manufacturer state such as shorting certain pins with the device plugged in? Is there some way to test if my mcu has been fried somehow? I was hoping someone would be able to tell me that what I did, changing that setting was a huge no-no that only a beginner would do. I'm fine with ordering a new atmega, but I want to be sure that that is the problem first. Thanks, again.

Offline greywanderer012345Topic starter

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #4 on: January 17, 2011, 11:00:46 PM »
I just read that AVR Studio version 4.13 has had some problems connecting with certain mcus and that the mkII will blink orange, but that updating will fix this. I'm going to try updating. (I only have internet access through a shared pc, not the one I program on, so others probably avoided this problem by updating through the program)

Offline greywanderer012345Topic starter

  • Robot Overlord
  • ****
  • Posts: 133
  • Helpful? 2
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #5 on: January 22, 2011, 06:35:40 PM »
I've got everything working now. My uC had popped out a little somehow. I pushed it down, and now everything is working fine.

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: How bad did I screw up!? Please help! Blinking orange LED
« Reply #6 on: January 23, 2011, 04:16:26 AM »
Good to hear.

fortunately for you it was an inexpensive solution!

 


Get Your Ad Here

data_list