Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Microcontrollers / Re: Why do a lot of people want to burn bootloaders into chips? on: September 09, 2011, 12:50:22 pm
Quote
I wanted to program the boot loader into it so that I can develop the new software directly on the hardware it will run on.

I can see if your developing like that and need to access the serial port for debugging info via FTDI connections then that's a very good reason.

Quote
but I prefer working in the Arduino IDE instead of in the gcc command line environment.

Who doesn't! ... but the only time a command line is needed is to set the fuses - after that its IDE all the way smiley  I'm thinking that what's needed is an option in the IDE to just set the fuses to the same settings as they would be if you'd burned the bootloader for your device.
But then, there would just be lots of posts asking how to burn the fuses so no real gain smiley
So I've probably got the answer to the question smiley

Simon






17  Using Arduino / Microcontrollers / Re: Help understanding ISP programming, bootloading, cores, USB to serial on: September 08, 2011, 04:14:28 pm
Link to example
http://www.ebay.co.uk/itm/USBASP-USBISP-AVR-Programmer-AVRDude-USB-Port-/180666590548?pt=UK_AudioElectronicsVideo_Video_TelevisionSetTopBoxes&hash=item2a10916554
Si
18  Using Arduino / Microcontrollers / Re: Help understanding ISP programming, bootloading, cores, USB to serial on: September 08, 2011, 04:10:31 pm
Just a quick partial answer from another newbie whoes done it but you can purchase £5 USB programmer from HK  that can connect via [edit]6[/edit] pins to a standalone device that can then be re-programmed via a simple batch file to upload a new  .hex copy of your update sketch to your users device.

regards
Simon
19  Using Arduino / Microcontrollers / Re: Why do a lot of people want to burn bootloaders into chips? on: September 08, 2011, 03:35:15 pm
Quote
Find an error, fix it, download, all while keeping everything plugged in place.
Now, if you were plugged into the final hardware then this makes a lot of sense for testing and debugging

Quote
When all done, pull the chip & plug it into the standalone project.
But your not are you smiley

So why not just upload your final sketches to the standalone (non-bootloaded chip) project when its working smiley
(I'm sure that your method is good for some things but I'm wondering if people are spending time loading bootloaders when all they really need is to set the fuses to get their clock speeds right smiley )

Simon
20  Using Arduino / Microcontrollers / Why do a lot of people want to burn bootloaders into chips? on: September 08, 2011, 02:20:37 pm
As a 2 month newbie, I've bought a Uno, made a little project and transfered it (with a LOT of help from you all smiley ) to standalone hardware (just an ATMega328P with xtal,7805 regulator and the few capacitors needed plus the bits needed for my project)

My standalone doesn't (appears not to anyway) need the bootloader to run my sketch.  I can upload my sketch using my original Uno or via a £5 USB programmer.

So, why do lots of other people want/need a bootloader for their projects?

regards

Simon
21  Using Arduino / Microcontrollers / Re: Standard Fuse Settings for 16Mhz ATMega328p on: September 06, 2011, 03:32:21 pm
Quote
boards.txt

Ta smiley
I used the values in there and used my little USBasp programmer with
Code:
avrdude -c usbasp -p m328p -C ../etc/avrdude.conf -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

and my project imeidiately started running at the correct speed smiley

Simon
22  Using Arduino / Microcontrollers / Standard Fuse Settings for 16Mhz ATMega328p on: September 06, 2011, 03:05:29 pm
I've finally got myself a virgin ATMega328p and without uploading a bootloader, I've uploaded a simple variation of Blink and thought it was broken until I realised that because I hadn't set the fuses, the MCU was just using internal clock and running at 1MHz intead of 16MHz (I've included a crystal on my board).

So I'm thinking that if I set my fuses to the same as my ATMega328p Uno then I should be OK.

But I can't find what the bytes should be - could someone tell me please (I've given up trying to read them out from my Uno smiley-sad )

And of course, if the fuses should be different for a non-bootloader 16Mhz crystal clocked ATMega328p than my Uno, could I have those instead smiley

regards
Simon
23  Using Arduino / Programming Questions / Re: Problem adding another entry on: August 30, 2011, 03:30:57 pm
@wildbill
Quote
Since these strings are const, consider putting them in progmem.

Could you give an example/pointer to how to do this sort of thing please? smiley

Simon
[edit]PS I've modified my prog to work OK now by just modifying/trimming my array but would be interested how to get const data into progmem still for future reference[/edit] smiley
24  Using Arduino / Programming Questions / Re: Problem adding another entry on: August 30, 2011, 03:28:54 pm
@wildbill
Thanks smiley
While I was ordering an extra ATMega328P today, I was looking at the spec in the catalogue in the shop and suddenly realised that I'd forgotton that I don't have 1G or available RAM to program in :lol:

Time to remember/re-use the sort of techniques I used to employ on my 4K UK101 computer from 30 years ago smiley

regards
Simon
25  Using Arduino / Project Guidance / Arduino in Primary (Age 9-11) Education on: August 29, 2011, 05:46:09 pm
My daytime job is an ICT Technician in a few primary schools and I run some after school ICT clubs using Scratch to introduce programming to kids.

I've played with an Arduino this summer and got S4A working with it but I'm wondering if others have done something similar and could suggest projects/ideas to work with next years club?

regards

Simon
26  Using Arduino / Programming Questions / Re: Problem adding another entry on: August 28, 2011, 01:09:19 pm
PS Ken's IR library available via http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

regards

Simon
27  Using Arduino / Programming Questions / Problem adding another entry on: August 28, 2011, 01:07:46 pm
I've got this code which is a infra-red decoder which reads an input IR sig and transcodes it to something else.
Code:
/*
 * IRTrans: receive and transcode IR signals
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * An IR LED must be connected to the output PWM pin 3.
 * A resistor and visible LED can be connected to STATUS_PIN to provide status.
 *
 * The logic is:
 * If a valid IR code in a lookup table is received
 * a corresonding different IR is transmitted
 * otherwise send the original code
 *
 * Version 0.1 September, 2011
 * Copyright 2011 Simon Walters based on code copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 4;
//int BUTTON_PIN = 12;
int STATUS_PIN = 2;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

const int lRows = 19;
const int lCols = 6;
const char* lookupTable[lRows][lCols] = {
  {
    "SONT", "338", "SONY", "A8B47","20", "Red->PWR"  }  ,
  {
    "SONT", "F38", "SONY","42B47","20","Blue->Home"  }  ,
  {
    "SONT", "538", "SONY","BCB47","20","Sel->Sel"  }  ,
  {
    "SONT", "490", "SONY","9CB47","20","Up->Up"  }  ,
  {
    "SONT", "C90", "SONY","5CB47","20","Down->Down"  }  ,
  {
    "NEC", "1DE2B946", "SONY","DCB47","20","Left->Left"  }  ,
  {
    "SONT", "290", "SONY","3CB47","20","Right->Right"  }  ,
  {
    "SONT", "B38", "SONY","A8B47","20","Green->PWR"  }  ,
  {
    "SONT", "5E25", "SONY","58B47","20","Play->Play"  }  ,
  {
    "SONT", "738", "SONY","98B47","20","Yellow->Pause"  }  ,
  {
    "NEC", "1D8000FF", "SONY","D8B47","20","Rew->Rew"  }  ,
  {
    "NEC", "1DE2F00F", "SONY","38B47","20","FF->FF"  }  ,
  {
    "NEC", "1D8033CC", "SONY","98B47","20","Stop->Pause"  }  ,
  {
    "SONT", "1D0", "SONY","18B47","20","Backup->Stop"  }  ,
  {
    "NEC", "1DE2D926", "NEC","1D00D926","32","VolUp->AVVolUp"  }  ,
  {
    "NEC", "1DE259A6", "NEC","1D0059A6","32","VolDwn->AVVolDwn"  }  ,
  {
    "SONT", "A50", "NEC","20DFD02F","32","Help->TvAV"  }  ,
  {
    "SONT", "A90", "NEC","20DF10EF","32","Pwr->TvPwr"  }  ,
  {
    "SONT", "90", "NEC","20DF00FF","32","ChUp->ChUp"  }
};
unsigned long valueLTable[lRows][lCols];


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  //  pinMode(BUTTON_PIN, INPUT);
  pinMode(STATUS_PIN, OUTPUT);

  for (int checkRows =0;checkRows<lRows;checkRows++) {
    Serial.println(lookupTable[checkRows][1]);
    String outCode = lookupTable[checkRows][3];
    Serial.println(outCode);
    unsigned long decCode = 0;
    unsigned long multiplier = 1;
    for (int i=0;i<outCode.length();i++) {
      int chr = (int)outCode.charAt(outCode.length()-i-1);
      if (chr < 58) {
        decCode += (chr-48) * multiplier;
      }
      else {
        decCode += (chr-55) * multiplier;
      }
      multiplier *= 16;
      Serial.println(decCode,HEX);
    }
    valueLTable[checkRows][3]=decCode;


    outCode = lookupTable[checkRows][4];
    Serial.println(outCode);
    decCode = 0;
    int chr = (int)outCode.charAt(1);
    decCode += (chr-48);
    chr = (int)outCode.charAt(0);
    decCode += (chr-48)*10;

    valueLTable[checkRows][4]=decCode;
    Serial.println(valueLTable[checkRows][3]);

    Serial.println(valueLTable[checkRows][4]);

    if (lookupTable[checkRows][2] == "SONY") {
      valueLTable[checkRows][2] = SONY;
    }
    if (lookupTable[checkRows][2] == "NEC") {
      valueLTable[checkRows][2] = NEC;
    }
    Serial.println(valueLTable[checkRows][2]);

  }



}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

// Stores the code for later playback
// Most of this code is just logging
void storeCode(decode_results *results) {
  codeType = results->decode_type;
  int count = results->rawlen;
  if (codeType == UNKNOWN) {
    Serial.println("Received unknown code, saving as raw");
    codeLen = results->rawlen - 1;
    // To store raw codes:
    // Drop first value (gap)
    // Convert from ticks to microseconds
    // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
    for (int i = 1; i <= codeLen; i++) {
      if (i % 2) {
        // Mark
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
        Serial.print(" m");
      }
      else {
        // Space
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
        Serial.print(" s");
      }
      Serial.print(rawCodes[i - 1], DEC);
    }
    Serial.println("");
  }
  else {
    if (codeType == NEC) {
      Serial.print("Received NEC: ");
      if (results->value == REPEAT) {
        // Don't record a NEC repeat value as that's useless.
        Serial.println("repeat; ignoring.");
        return;
      }
    }
    else if (codeType == SONY) {
      Serial.print("Received SONY: ");
    }
    else if (codeType == RC5) {
      Serial.print("Received RC5: ");
    }
    else if (codeType == RC6) {
      Serial.print("Received RC6: ");
    }
    else {
      Serial.print("Unexpected codeType ");
      Serial.print(codeType, DEC);
      Serial.println("");
    }
    Serial.println(results->value, HEX);
    codeValue = results->value;
    codeLen = results->bits;
    //    Serial.println(codeLen);
  }
}

void sendCode(int repeat) {
  if (codeType == NEC) {
    if (repeat) {
      //      irsend.sendNEC(REPEAT, codeLen);
      //      Serial.println("Sent NEC repeat");
    }
    else {
      Serial.print("Sent NEC ");
      Serial.println(codeValue, HEX);
      irsend.sendNEC(codeValue, codeLen);
      //      for (int i=1;i<=2;i++) {
      codeValue =0xFFFFFFFF;
      Serial.print("Sent NEC Repeat Code");
      Serial.println(codeValue, HEX);
      //      }
    }
  }
  else if (codeType == SONY) {
    for (int i=1;i<=3;i++) {
      irsend.sendSony(codeValue, codeLen);
      Serial.print("Sent Sony ");
      Serial.println(codeValue, HEX);
    }
  }
  else if (codeType == RC5 || codeType == RC6) {
    if (!repeat) {
      // Flip the toggle bit for a new button press
      toggle = 1 - toggle;
    }
    // Put the toggle bit into the code to send
    codeValue = codeValue & ~(1 << (codeLen - 1));
    codeValue = codeValue | (toggle << (codeLen - 1));
    if (codeType == RC5) {
      Serial.print("Sent RC5 ");
      Serial.println(codeValue, HEX);
      irsend.sendRC5(codeValue, codeLen);
    }
    else {
      irsend.sendRC6(codeValue, codeLen);
      Serial.print("Sent RC6 ");
      Serial.println(codeValue, HEX);
    }
  }
  else if (codeType == UNKNOWN /* i.e. raw */) {
    // Assume 38 KHz
    irsend.sendRaw(rawCodes, codeLen, 38);
    Serial.println("Sent raw");
  }
}


void loop() {


  if (irrecv.decode(&results)) {
    digitalWrite(STATUS_PIN, HIGH);
    Serial.println(" ");
    storeCode(&results);
    //    irrecv.resume(); // resume receiver
    digitalWrite(STATUS_PIN, LOW);
    delay(200); // Wait a bit before retransmissions
    //    Serial.println("Transcoding Start");
    //    Serial.println("rcvd code: ");
    //    Serial.println(codeValue);
    //    String sCodeValue = String(2576,HEX);
    //Serial.println(sCodeValue);
    String sCodeValue = String(codeValue,HEX).toUpperCase();
    //    Serial.println(sCodeValue);
    boolean transcode = false;
    for (int checkRows =0;checkRows<lRows;checkRows++) {
      //      Serial.println(lookupTable[checkRows][1]);
      if (sCodeValue == lookupTable[checkRows][1]) {
        Serial.println("Found transcode");   
        digitalWrite(STATUS_PIN, HIGH);
        codeType = valueLTable[checkRows][2];
        codeValue = valueLTable[checkRows][3];
        codeLen = valueLTable[checkRows][4];
        sendCode(0);
        Serial.println(codeValue,HEX);
        Serial.println(lookupTable[checkRows][5]);
        digitalWrite(STATUS_PIN, LOW);
        transcode = true;
        delay(100); // Wait a bit between retransmissions
      }
    }
    if (!transcode) {
      //        Serial.println("Just repeat");
      //       delay(100);
      //        sendCode(0);
    }
    irrecv.enableIRIn(); // Re-enable receiver
    irrecv.resume(); // resume receiver
  }
}

My problem is that the code is working fine but if I add one more entry to the lookup table it misbehaves smiley-sad
I'd be very grateful if someone could test it out - you don't need and hardware as the fault manifests as a strange debug output from the serial com port.

To try and recreate the problem, load in the code (you'll need Ken Sheffiffs IRLibray) and monitor the serail port - you should see a debug list of the lookup table being output.

Now try and add in another entry to the lookup table (and increment lrows as well) and see what happens to the serial com output (it just outputs rubbish AFAIC) smiley-sad

Any help greatfully received smiley

Simon
28  Using Arduino / Microcontrollers / Re: Cheapest way to program standalone project on: August 25, 2011, 04:51:13 pm
Well, my cheap programmer eventually arrrived from HK
 http://www.ebay.co.uk/itm/USBASP-USBISP-AVR-Programmer-AVRDude-USB-Port-/180666590548#vi-desc
 and I downloaded the USBasp driver
 http://www.fischl.de/usbasp/
 connected the leads reset/vcc/gnd/miso/sck/mosi to the same pins on my ATmega328-PU  and used this
Code:
avrdude -c usbasp -p m328p -C ../etc/avrdude.conf
(which gave me the expected device error msg due to using a 328-PU and not a 328P-PU )
Code:
avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
I did the Shift-Compile trick to find where my system keeps its hex file and then just used
Code:
avrdude -c usbasp -p m328p -C ../etc/avrdude.conf -U flash:w:BlinkPin2.cpp.hex -u -F
and it ignored the device signature and uploaded and ran it smiley
29  Community / Website and Forum / Re: Permission to modify the playground wiki on: August 17, 2011, 08:53:01 am
I didn't notice that the the page I was trying to edit was part of the main site and not in the playground smiley-sad

So - who do I see about getting this page changed to reflect that the Uno can act as a programmer

http://arduino.cc/en/Tutorial/ArduinoISP


Simon
30  Community / Website and Forum / Permission to modify the playground wiki on: August 16, 2011, 05:05:02 pm
I have sucessfully used an Uno as a programmer for a standalone project and wanted to edit the Wiki to reflect that it can be done but when I clicked on edit it said I didn't have sufficient prvileges (or word to that effect)

How do I get these privleges or is it a non-editable wiki?

regards

Simon
Pages: 1 [2] 3 4