Author Topic: 50$ robot - Led supposed to light up??  (Read 253 times)

0 Members and 1 Guest are viewing this topic.

Offline washb0ardTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 1
50$ robot - Led supposed to light up??
« on: July 16, 2014, 05:31:23 PM »
Hello all,

 I see the below piece of code in the photovore_v1.c.. And based on how the Led is wired up in the pcb. I am confused whether it is supposed to glow when LED_off is called, can someone please explain?

 I feel that when LED_on is called a digital is in output on the pin DP4 which is connected to the negative of LED and the positive of LED is connected to 5V(Vcc). Since there is no potential difference iam not sure if it supposed to glow

Code:
        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

   /*********ADD YOUR CODE BELOW THIS LINE **********/
   delay_cycles(500);//a small delay to prevent crazy oscillations
   LED_off();//turn LED on


Offline washb0ardTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 1
Re: 50$ robot - Led supposed to light up??
« Reply #1 on: July 16, 2014, 06:48:45 PM »
The reason I am trying to get my led to light up is because i am trying to trobleshoot. I get a WRITE FAILED from pony prog but my robot is doing something(always turning to the right) also Led never lights up.

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 251
  • Helpful? 12
Re: 50$ robot - Led supposed to light up??
« Reply #2 on: July 17, 2014, 07:16:46 AM »
Per the diagram, http://www.societyofrobots.com/images/sbs_avr_schematic.png the LED goes between PD4 and VCC, so to turn the LED on you need to set PD4 low.

From the code (SoR_Utils.h):

void LED_on(void)
   {
   PORT_OFF(PORTD, 4);//turn LED on
   }
void LED_off(void)
   {
   PORT_ON(PORTD, 4);//turn LED off
   }

The function LED_on uses PORT_OFF  which is:

#define PORT_ON( port_letter, number )         port_letter |= (1<<number)
#define PORT_OFF( port_letter, number )         port_letter &= ~(1<<number)

and results in PORTD pin 4 going low which should turn the LED on.

So, to turn the LED on, you would call LED_on.

I have not used the pony prog so no help on that.
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

 


Get Your Ad Here