• My programmer [not a shill post]

    05/10/2018 at 08:24 0 comments

    I used another arduino with the ISP sketch for years to program my stand-alone projects (all Atmegas). I think it's really really great you can do that. This helps the tinkerer a lot making standalone stuff the easy way.
    Doing things instead of installing gigabytes of toolchains and other software, yay!

    But there was a project involving an SD card which I did not disconnect before uploading a new sketch. The "programmer" uses 5V signals which the SD card didn't like too much (it shares the ICSP port), so I killed the SD that way.

    So for my last projects I ordered the Pololu Programmer v2 which has lots of nice features I would miss now if I ever had to go back to the Arduino-as-ISP-way.


    Look at these features. It summarises everything it can do:

    What I like most:

    • it's fast. Uploading 25kB or so could take 20 seconds with Arduino as ISP. It's more like 2 or 3 seconds now (you can change speed, see screenshot above)
      Hint: burning the initial bootloader (to set fuses etc) needs to be done at lower speeds or it will fail!
    • You may choose to supply the target with whatever voltage between 2 and 5V
    • Programming and Serial port are independent. This means: upload your program and have another terminal open all times (I use HTerm)
    • fully compatible with the STK500 hardware, you can even change parameters so every software recognises it as a genuine programmer
    • everything Pololu sells is kind of open, they give you circuit diagrams, 3D files, software is on GitHub ...

    I fully recommend this programmer. There is a better and cheaper! v2.1 out now it seems. I got the v2 and it does everything I need to do, so nothing to worry about.

  • Arduino Code Snippets

    10/17/2017 at 19:48 0 comments

    Working code snippets

    1. read DS18B20 at intervall. output via terminal. non-blocking code

    #include <OneWire.h>
    #include <DallasTemperature.h>
    #include <elapsedMillis.h>
    // Data wire is plugged into port 2 on the Arduino
    #define ONE_WIRE_BUS 2
    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensor(&oneWire);
    uint8_t SensorAdresse[8] = {0x28, 0x56, 0x2D, 0x11, 0x05, 0x00, 0x00, 0x14};
    elapsedMillis SensorIntervall;
    unsigned int Intervall = 1000;
    void setup(void)
    {
      Serial.begin(9600);
      sensor.begin();
      sensor.setResolution(SensorAdresse, 10);
      /*Berechnungszeiten (sind hier unwichtig, Code nicht blockend):
       *  9Bit Auflösung (0,5°C)  ->  102ms  
       * 10Bit Auflösung (0,25°C) ->  200ms
       * 12Bit Auflösung          ->  750ms
       */
      // LOG-Kopfausgabe:
      Serial.println("Ausgabeformat CSV, Trenner = ;");
      Serial.println("Zeit [s]; Temperatur [°C]");
      Serial.println("");
       
    }
    void loop(void)
    {
        sensor.setWaitForConversion(false);
        sensor.requestTemperatures();
        float tempC = sensor.getTempC(SensorAdresse);
        sensor.setWaitForConversion(true);
      
      if (SensorIntervall > Intervall)
      {
        Serial.print(millis()/1000);
        Serial.print(";");
        Serial.println(tempC);
        SensorIntervall = 0;
      }
    }