Author Topic: Questions about the $50 robot  (Read 2211 times)

0 Members and 1 Guest are viewing this topic.

Offline chezzaTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Questions about the $50 robot
« on: October 10, 2011, 06:58:35 AM »
Sorry to do this as I searched so saw that questions about this come up a lot.

The tutorial is good and if I bought the parts think I could follow it, but I do have a few questions.

The tutorial is a few years old and Im wondering if there is an alternative to the AVR ISP2 Programmer e.g is there something better/cheaper available now?

I ask as Im in the UK and it seems to be out of stock also it is £32 (approx $50)




Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Questions about the $50 robot
« Reply #1 on: October 10, 2011, 07:23:33 AM »
You can use any programmer supported by the microcontroller You want to use. If You have RS-323 port You can make ISP DIY style that is very cheap --> AVR In-Circuit Serial Programmer or something similar. Try Google to find more circuits.

You can also try places like ebay to find cheap ready-made ISP programmers.

Note: To start with ISP programmer is a good enough cheap (ish) solution, however, If You plan to work with uC programming for long time and also get involved with more complex projects, i believe You will also need a tool for live debugging, hence - a more expensive and robust tool (programmer). You might want to think twice and invest into better tool that will satisfy Your needs for longer, on the other hand if You do not know what programming is and what to eat it with - buy something simple and cheap.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline chezzaTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Questions about the $50 robot
« Reply #2 on: October 10, 2011, 08:04:16 AM »
thank you - that is helpful.

Mainly I don't want to spend the £30 (which granted isnt much) if the robot building turns out to be harder than I think, ends up frustrating me and then I give up.

http://www.rapidonline.com/SearchResults.aspx?kw=73-4290 Is the microcontroller I was going to use.

Id prefer to use one of the cheap ready made programmers how do I know which will fit, would any form your ebay link work ?

Again thanks for your help

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Questions about the $50 robot
« Reply #3 on: October 10, 2011, 08:59:44 AM »
Here are a couple other possibilities. I have one of each and they both work well.

http://www.pololu.com/catalog/product/1300
http://www.adafruit.com/products/46

Joe

Offline chezzaTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Questions about the $50 robot
« Reply #4 on: October 10, 2011, 11:14:23 AM »
Thanks, so as long as I buy an ISP AVR programmer, I will be able to do the programming part/put the program onto the robot from the pc?

I am completely new to this, tho this is probably obvious

Offline chezzaTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Questions about the $50 robot
« Reply #5 on: October 10, 2011, 11:20:40 AM »
Scratch that, I just realised that the programmers list compatible chips. Ive fouind a cheap one on ebay http://www.ebay.co.uk/itm/USB-ASP-Downloader-ISP-AVR-Programmer-Adapter-Cable-/180718312291?pt=LH_DefaultDomain_3&hash=item2a13a69b63#ht_2003wt_952(here) so am going to order this.

Hopefully it will go well, and then I can look at more expensive bits for next time

Thanks

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Questions about the $50 robot
« Reply #6 on: October 11, 2011, 12:34:22 AM »
Any ISP programmer will do for the chip that supports IPS programming  ;D I use AVRISP mkII clone that cost me around £10 as far as I remember. Bare in mind that with ISP programmer You will only be able to "burn" HEX file into the chip, in other words - no live debugging, hence if something does not work in Your program, You'll have to figure it out Yourself.

Good luck.

P.S. I've just started learning uC programming myself, if You want, I can post You source codes, with comments, for simple stuff as PWM (LED dimmer), Analog To Digital conversion and LCD controll.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline chezzaTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Questions about the $50 robot
« Reply #7 on: October 11, 2011, 03:15:11 AM »
Thanks again.
Yeah if you don't mind posting and sharing your code - Id appreciate it.Ive never done any programming before but this is possibly the part that Im most looking forward to

cheers


Edit
Ive ordered parts total of £76 ($118) but I needed bit like a soldering iron aswell, should have the parts by the weekend so by Sunday should have a working robot - wish me luck
« Last Edit: October 11, 2011, 08:03:44 AM by chezza »

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Questions about the $50 robot
« Reply #8 on: October 11, 2011, 01:31:44 PM »
OK, all the code is written for ATmega48, if You want to reuse it for another controller - You must analyse datasheet of Your uC and find corresponding registers.

So, I've started my learning path by compleating these tutorials:
Newbie's Guide to AVR Timers
Part Nine - Pulse Width Modulation (PWM)

Then I've built a simple circuit with 1x LED and 1x Button. By pressing Button PWM Duty Cycle could be varied.
Code: [Select]
/*
 * pwm.c
 *
 * Created: 24/09/2011 11:02:02
 * Author: Maz
 */

#define F_CPU 1000000UL

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

int main(void)
{
PORTD |= 1 << PORTD2; // Set PD2 (INT0) high (pull - up)

TCCR1A |= 1 << COM1A1; // Set OC1A on Compare Match when up counting, clear - when down counting
TCCR1A |= 1 << WGM11; // PWM, phase and frequency correct

TCCR1B |= 1 << WGM13; // PWM, phase and frequency correct
TCCR1B |= 1 << CS10; // No prescaling

ICR1 = 3; // PWM top value

OCR1A = 0; // PWM compare value;

EICRA |= 1 << ISC01; // The falling edge of INT0 (PD2) generates an interrupt request

EIMSK |= 1 << INT0; // Enable INT0 external interrupt

sei(); // Enable global interrupt

DDRB |= 1 << DDB1; // Set PB1 (OSC1A) as output

for(;;)
{}
}

ISR(INT0_vect) // Routine when interrupt occurs
{
while(PIND & (1 << PIND2)){} // Button pressed detection

if(OCR1A < 3)
{
OCR1A++; // Increase PWM compare value by 1 (increase duty cycle)
}

else
{
OCR1A = 0; // Set PWM compare value to 0 (set duty cycle to 0%)
}

_delay_ms(250);
}

After that, I completed Newbie's Guide to the AVR ADC tutorial after which I made another circuit using pot instead of the button, now PWM Duty Cycle (LED brightness) can be adjusted by voltage level coming from pot.
Code: [Select]
/*
 * ADC.c
 *
 * Created: 01/10/2011 17:14:43
 *  Author: Zydrune ir Mazvydas
 */

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

int main(void)
{
initPwm(); // Initialize PWM

initAdc(); // Initialize ADC

sei(); // Enable Global Interrupts

for(;;){}
}

ISR(ADC_vect) // Routine when interrupt occurs
{
OCR0A = ADCH;
}

int initAdc(void)
{
ADMUX |= 1 << REFS0; // Set ADC reference to AVCC
ADMUX |= 1 << ADLAR; // Left adjust ADC result to allow easy 8bit reading

ADCSRA |= 1 << ADPS2; // Set ADC prescaler to 16 - 62.5kHz sample rate @ 1MHz
ADCSRA |= 1 << ADATE; // Set ADC to Free-Running Mode
ADCSRA |= 1 << ADEN; // Enable ADC
ADCSRA |= 1 << ADIE; // Enable ADC Interrupt
ADCSRA |= 1 << ADSC; // Start A2D Conversions
}

int initPwm(void)
{
TCCR0A |= 1 << COM0A1; // Set OC0A on Compare Match when down counting, clear - when up counting
TCCR0A |= 1 << WGM00; // PWM, phase correct

TCCR0B |= 1 << CS00; // No prescaling

OCR0A = 0; // PWM compare value;

DDRD |= 1 << DDD6; // Set PB1 (OSC1A) as output
}

And now I'm working with HD44780 LCD module with help of [Tut] – Using HD44780 based LCDs – JHD162A tutorial.
Code: [Select]
/*
 * LCD.c
 *
 * Created: 09/10/2011 17:33:37
 *  Author: Zydrune ir Mazvydas
 */

#include <avr/io.h>

int main(void)
{
setPins();

initLcd();

clearLCD();

write();

    while(1)
    {

    }
}

int initLcd(void)
{
PORTC |= 1 << PORTC3;

PORTD |= (1 << PORTD2) | (1 << PORTD3);

enable();
}

int setPins(void)
{
DDRC |= (1 << DDC3) | (1 << DDC4) | (1 << DDC5);

DDRD |= (1 << DDD0) | (1 << DDD1) | (1 << DDD2) | (1 << DDD3) | (1 << DDD4) | (1 << DDD5) | (1 << DDD6) | (1 << DDD7);
}

int clearLCD(void)
{
PORTD = 0b00000001;
enable();
}

int enable(void)
{
PORTC &= ~(1 << PORTC3);

for(int counter = 0; counter < 90; counter++){}

PORTC |= 1 << PORTC3;
}

int rsOn(void)
{
PORTC |= 1 << PORTC5;
}

int rsOff(void)
{
PORTC &= ~(1 << PORTC5);
}

int rwOn(void)
{
PORTC |= 1 << PORTC4;
}

int rwOff(void)
{
PORTC &= ~(1 << PORTC4);
}

int write(void)
{
rsOn();

PORTD = 0b01001101;//M
enable();

PORTD = 0b01111001;//y
enable();

PORTD = 0b01101100;//l
enable();

PORTD = 0b01101001;//i
enable();

PORTD = 0b01110101;//u
enable();

PORTD = 0b11111110;// "space"
enable();

PORTD = 0b01011010;//Z
enable();

PORTD = 0b01111001;//y
enable();

PORTD = 0b01100100;//d
enable();

PORTD = 0b01110010;//r
enable();

PORTD = 0b01110101;//u
enable();

PORTD = 0b01110100;//t
enable();

PORTD = 0b01100101;//e
enable();
}
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

 


Get Your Ad Here