Окт 232014
 

Разводка платы для проектов: ATMEGA1284P

Как превратить ATmega1284P в Arduino проверенно работает.

SanguinoPinBindings

 

Прошивка для Atmega 1284P.

Программирование через Arduino ISP


Programming Uno     Target board (1284P)

D10 (SS)            Reset - pin 9 (green)
D11 (MOSI)          Pin 6 (yellow)
D12 (MISO)          Pin 7 (orange)
D13 (SCK)           Pin 8 (black)

Gnd                 Gnd (blue)
+5V                 +5V (red)

IMG_1221

 Posted by at 11:41
Июн 242014
 

Простое чтение данных.

#!/usr/bin/perl
    use GPS::NMEA;
    use Data::Dumper;
    
    my $gps = GPS::NMEA->new(Port => '/dev/cuaa0', # or COM5: or /dev/ttyS0
                             Baud => 4800);
    while(1) {
        $gps->parse;
    
        # Dump internal NMEA data:
        $gps->nmea_data_dump;
    
        # Alternative to look at the internal NMEA data:
        require Data::Dumper;
        print Data::Dumper->new([$gps->{NMEADATA}],[])->Indent(1)->Useqq(1)->Dump;
    }

Печатаем координаты.


 #!/usr/bin/perl
    use GPS::NMEA;
    use Data::Dumper;
    
    my $gps = GPS::NMEA->new(Port => '/dev/cuaa0', # or COM5: or /dev/ttyS0
                             Baud => 4800);
    while(1) {
        $gps->parse;
    
        # Dump internal NMEA data:
        $gps->nmea_data_dump;
    
        # Alternative to look at the internal NMEA data:
        require Data::Dumper;
        print Data::Dumper->new([$gps->{NMEADATA}],[])->Indent(1)->Useqq(1)->Dump;
    }

Дамп всех NMEA данных с порта.

 #!/usr/bin/perl
    use GPS::NMEA;
    use Data::Dumper;
    
    my $gps = GPS::NMEA->new(Port => '/dev/cuaa0', # or COM5: or /dev/ttyS0
                             Baud => 4800);
    while(1) {
        $gps->parse;
    
        # Dump internal NMEA data:
        $gps->nmea_data_dump;
    
        # Alternative to look at the internal NMEA data:
        require Data::Dumper;
        print Data::Dumper->new([$gps->{NMEADATA}],[])->Indent(1)->Useqq(1)->Dump;
    }
 Posted by at 17:22
Июн 192014
 

Cubieboard / Cubietruck Debian Wheezy SD card image

Fex Guide — Описание FEX стандарта

Cubieboard1&2_HW.pdf

/boot/cb2-hdmi.bin
# bin2fex cb2-hdmi.bin > cb2-hdmi.txt
# fex2bin cb2-hdmi.txt cb2-hdmi.bin

PH20 — Зеленый светодиод на плате.

Все порта должны быть прописаны а также не должны пересекаться.

[gpio_para]
gpio_used = 1
gpio_num = 3
gpio_pin_1 = port:PH20<1><default><default><1>
gpio_pin_2 = port:PH21<1><default><default><1>
gpio_pin_3 = port:PD1<1><default><default><1>

#cd /sys/class/gpio
#ls -al
 export
 gpiochip1 -> ../../devices/platform/gpio-sunxi/gpio/gpiochip1
 unexport

Активация порта PH20. (echo 3 -> для PD1)
# echo 1 > /sys/class/gpio/export 
# ls -al
 export
 gpio1_ph20 -> ../../devices/platform/gpio-sunxi/gpio/gpio1_ph20
 gpiochip1 -> ../../devices/platform/gpio-sunxi/gpio/gpiochip1
 unexport

Включаем режим вывода.
# echo out > gpio1_ph20/direction 

Читаем из порта.
# cat gpio1_ph20/value
 0

Записываем в порт.
# echo 1 > gpio1_ph20/value
# cat gpio1_ph20/value
 1


Проверенно, работает.

http://blog.radiotech.kz/blog/cubieboard/34.html

gpio_defination_large

 Posted by at 15:16
Июн 032014
 

Cubieboard / Cubietruck Debian Wheezy SD card image.

  • Debian Wheezy 7.5 based
  • Kernel 3.4.91 with broad hardware support, headers included
  • Ethernet adapter with DHCP and SSH server ready on default port (22) with regenerated keys @ first boot
  • Wireless adapter with DHCP ready but disabled (/etc/network/interfaces, WPA2: normal connect or AP mode)
  • Enabled audio devices: analog, spdif and I2S
  • Advanced IR driver with RAW RX and TX
  • Bluetooth ready (currently working only with supported external USB devices)
  • Clustering / stacking
  • USB redirector — for sharing USB over TCP/IP (disabled by default /etc/init.d/rc.usbsrvd)
  • root file-system auto resize
  • Graphics desktop environment upgrade ready
  • NAND and SATA install script included (/root)
  • Disabled LED blinking, logo, boot messages (/etc/init.d/disable_led.sh, kernel.config, kernel parameters in uEnv.txt)
  • Total memory is exactly 2000Mb (disabled all memory reservations for GPU)
  • Login script shows Cubietruck / Cubieboard 2 auto MOTD with current CPU temp, hard drive temp & actual free memory
  • MAC address from chip ID, manual optional
  • Fastest Debian mirror auto selection @ first boot
  • root password=1234
  • sunxi-tools included: fex2bin, bin2fex, nand-part
  • Performance tweaks:
    • /tmp & /log = RAM, ramlog app saves logs to disk daily and on shut-down
    • IO scheduler NOOP for SD, CFQ for sda (mechanical hard drive). (change in /etc/sysfs.conf)
    • journal data writeback enabled. (/etc/fstab)
    • commit=600 to flush data to the disk every 10 minutes (/etc/fstab)
    • optimized CPU frequency scaling 480-1200Mhz with interactive governor and small 20% overclock (/etc/init.d/cpufrequtils)
  • Known bugs or limitations
    • On board Bluetooth unstable / unusable (firmware issue)
    • NAND install script sometime fails. Dirty but working workaround — installing Lubuntu to NAND with Phoenix tools and run the nand-install again.
    • Gigabit ethernet transfer rate is around 50% of its theoretical max rate (hardware or firmware issue)
    • Shutdown, reboot and battery troubles regarding poor AXP chip driver (firmware issue, probably solved in development kernel)
  • Unzipped images can be written with Image Writer on Windows or with DD command in Linux/Mac (dd bs=1M if=filename.raw of=sd card device). Kernel package should be uncompressed under root user to / Change boot parameter if your old kernel has different name.
 Posted by at 11:51
Май 072014
 

Термометр на ATmega 168P-PA
BA56-12GWA 7-сегментный трехразрядный светодиодный индикатор
Датчик DS18B20, схема основана на Arduino Pro.
Я думаю дорисовать и развести схему и плату не составит труда.
R2-R3 и так далее = 220 ом
R4 — 4.7 ком

7seg

#include "OneWire.h"

// #include "DallasTemperature.h"

#define ONE_WIRE_BUS 2

// OneWire oneWire(ONE_WIRE_BUS);

OneWire ds(ONE_WIRE_BUS);


// DallasTemperature sensors(&oneWire);
// DeviceAddress insideThermometer = { 0x28, 0x0C, 0x49, 0x7F, 0x05, 0x00, 0x00, 0x7E };

// const int LED = 6; // Test LED

byte addr[8] = { 0x28, 0x0C, 0x49, 0x7F, 0x05, 0x00, 0x00, 0x7E };
byte data[12];

#define LED 6

#define A A4
#define B A2
#define C 10
#define D 8
#define E 7
#define F A3
#define G 11

#define CA2 A0
#define CA1 13
#define CA3 A1

#define DP 9      // Точка

#define COOLER 5  // Вентилятор Не работает

const int segs[7] = { A, B, C, D, E, F, G };

const byte numbers[10] = {  
  0b1000000, 
  0b1111001, 
  0b0100100, 
  0b0110000, 
  0b0011001, 
  0b0010010,
  0b0000010, 
  0b1111000, 
  0b0000000, 
  0b0010000 };

long previousMillis = 0; 
long interval = 1000;
unsigned long currentMillis;
boolean run = false;

     int thousands = 0;
     int hundreds = 0;
     int tens = 0;
     int ones = 0;

void setup() {    

  Serial.begin(9600);
  
  //  sensors.begin();
  //  sensors.setResolution(insideThermometer, 9);

  pinMode(LED, OUTPUT);  

  pinMode(13,OUTPUT);  // Digital 1
  pinMode(A0,OUTPUT);  // Digital 2  
  pinMode(A1,OUTPUT);  // Digital 3

  pinMode(A4,OUTPUT); // SEG A
  pinMode(A2,OUTPUT); // SEG B
  pinMode(10,OUTPUT); // SEG C
  pinMode(8,OUTPUT);  // SEG D
  pinMode(7,OUTPUT);  // SEG E
  pinMode(A3,OUTPUT); // SEG F
  pinMode(11,OUTPUT); // SEG G

  pinMode(DP,OUTPUT);  // DP

  digitalWrite(LED,HIGH);

}


void loop() {

  byte i;
  
  currentMillis = millis();

  // sensors.requestTemperatures();

  lightDigit1(numbers[thousands]); // temp%10]);
  delay(5);
  lightDigit2(numbers[hundreds]); // int(temp/10)]);
  delay(5);
  lightDigit3(numbers[tens]); // int(8)]);
  delay(5);

  // temp = sensors.getTempC(insideThermometer);

  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;

    if (run) {
     ds.reset();
     ds.select(addr);    
     ds.write(0xBE);  
     for ( i = 0; i < 9; i++) data[i] = ds.read();
     run = false;
     
     int16_t raw = (data[1] << 8) | data[0];
     int celsius = ((float)raw / 16.0)*100;

     thousands = celsius/1000;
     hundreds = (celsius%1000)/100;
     tens = (celsius%100)/10;
     ones = celsius%10;

     // Serial.println(celsius);
     // Serial.println(ones);
     // Serial.println(tens);
     // Serial.println(hundreds);
     // Serial.println(thousands);
 
   }    
   
    if (!run) {
     ds.reset();
     ds.select(addr);
     ds.write(0x44,1);
     run = true;
    }    
    
    if (digitalRead(LED) == 1) { 
      digitalWrite(LED,LOW); 
    } 
    else { 
      digitalWrite(LED,HIGH); 
    }
  }
}

void lightDigit1(byte number) {
  digitalWrite(CA1,HIGH);
  digitalWrite(CA2,LOW);
  digitalWrite(CA3,LOW);  
  digitalWrite(DP, HIGH);
  lightSegments(number);
}

void lightDigit2(byte number) {
  digitalWrite(CA1,LOW);
  digitalWrite(CA2,HIGH);
  digitalWrite(CA3,LOW);    
  digitalWrite(DP, LOW);  
  lightSegments(number);
}

void lightDigit3(byte number) {
  digitalWrite(CA1,LOW);
  digitalWrite(CA2,LOW);
  digitalWrite(CA3,HIGH);
  digitalWrite(DP, HIGH);  
  lightSegments(number);
}

void lightSegments(byte number) {
  for (int i = 0; i < 7; i++) {
    int bit = bitRead(number, i);
    digitalWrite(segs[i], bit);
  }
}


Замечание: Исходник:

 
Смысл в том что ATmega168 не есть ATmega168P и у них разные сигнатуры. 
Решение:
В файле \arduino-1.0.3\hardware\arduino\boards.txt в строке
diecimila.build.mcu=atmega168 добавляете
буковку p (пэ англ.), сохраняете файл, 
перезапускаете IDE.

##############################################################
 
diecimila.name=Arduino Diecimila or Duemilanove w/ ATmega168
 
diecimila.upload.protocol=arduino
diecimila.upload.maximum_size=14336
diecimila.upload.speed=19200
 
diecimila.bootloader.low_fuses=0xff
diecimila.bootloader.high_fuses=0xdd
diecimila.bootloader.extended_fuses=0x00
diecimila.bootloader.path=atmega
diecimila.bootloader.file=ATmegaBOOT_168_diecimila.hex
diecimila.bootloader.unlock_bits=0x3F
diecimila.bootloader.lock_bits=0x0F
 
diecimila.build.mcu=atmega168p
diecimila.build.f_cpu=16000000L
diecimila.build.core=arduino
diecimila.build.variant=standard
 
##############################################################
И будет вам счастье.

 Posted by at 11:57