Archive

Archive for February, 2013

Desenarea functiilor sinus si cosinus pe GLCD cu PIC16F887

February 15th, 2013 No comments

Desenarea functiilor sinus si cosinus pe GLCD cu PIC16F887

Desenarea functiilor sinus si cosinus pe GLCD cu PIC16F887

char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS at RB2_bit;
sbit GLCD_RW at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;

}

void main() {
int ii;

Glcd_Init();
Glcd_Fill(0x00);

Glcd_Rectangle(0, 0, 127, 63, 1);
Glcd_H_Line(0, 127, 31, 2);
Glcd_V_Line(0, 63, 63, 2);

while(1) {

Glcd_Write_Text(“sin”, 1, 0, 0);
for (ii=0; ii<127; ii++){
Glcd_Dot(ii,32+(sin(((ii*2.85)*3.14)/180)*31),2);
delay_ms(1);
}

Glcd_Write_Text(” “, 1, 0, 0);
Glcd_Write_Text(“cos”, 1, 0, 0);
for (ii=0; ii<127; ii++){
Glcd_Dot(ii,32+(cos(((ii*2.85)*3.14)/180)*31),2);
delay_ms(1);
}
}
}
}

Categories: electronica Tags: ,

PICkit 2 Device Data File Editor

February 15th, 2013 No comments

PICkit 2 Device Data File Editor

This program provides a simple interface for editing the device data file PKDeviceFile.dat that comes with the PICkit2 windows programs.
pk2devicefileeditor

Usage:

File Menu:

Open – loads and decodes file
Save – overwrites the loaded file with the data in memory
Save As – writes the data in memory to a file of your choosing

Right click on any leaf node (in the left treeview panel) for a popup menu to:

Duplicate – make an identical copy of the selected family/part/script
Remove – delete the selected family/part/script

Number formats:

– where a field is displayed as hex (dec), you can enter
Hex: e.g. 0xfa44 or &hfa44 or fa44h
Binary: e.g. 0b11110010 or %11110010
Decimal: e.g. 1443

– where a field is displayed as decimal, you can enter
Hex: e.g. 0xfa44 or &hfa44
Decimal: e.g. 1443

The program is generally only useful for adding new parts not currently supported by the devicefile bundled with the PICKit 2. The process, after opening the devicefile, is simply to choose an existing PIC from the list of devices, right click on it and select Duplicate Item. There will now be a copy of the part you selected. Change the properties of the new part, including the part name, to appropriate values for the new part. Then save the file and you’re done.
It’s possible to find the appropriate fields from the datasheet and programming specification documents for the particular PIC part. Sometimes it’s a little bit hard to find what you’re looking for, or to even know what you should be looking for; feel free to ask on the Microchip Forums (in particular under this thread: PK2 Device File Editor Thread); there’s some very knowledgeable and experienced members there.
There is sometimes updates devicefiles available from Microchip (maybe search the Microchip forums).
Categories: software Tags:

Sinewave pe TFT 3.2” (SSD1289) si Arduino

February 14th, 2013 No comments

Sinewave pe TFT 3.2” (SSD1289) si Arduino

Sinus - Cosinus - Tangenta TFT 3.2"

Sinus – Cosinus – Tangenta TFT 3.2″

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Uncomment the next line for Arduino 2009/Uno
UTFT myGLCD(ITDB32S,19,18,17,16); // Remember to change the model parameter to suit your display module!

// Uncomment the next line for Arduino Mega
// UTFT myGLCD(ITDB24E_16,38,39,40,41); // Remember to change the model parameter to suit your display module!

void setup()
{
randomSeed(analogRead(0));

// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
int buf[318];
int x, x2;
int y, y2;
int r;

// Clear the screen and draw the frame
myGLCD.clrScr();

myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 319, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 226, 319, 239);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print(“* SIN / COS / TAN – SSD1289 *”, CENTER, 1);
myGLCD.setBackColor(64, 64, 64);
myGLCD.setColor(255,255,0);
myGLCD.print(“<http://electronicaupit.com/forum>”, CENTER, 227);

myGLCD.setColor(0, 0, 255);
myGLCD.drawRect(0, 14, 319, 225);

// Draw crosshairs
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(159, 15, 159, 224);
myGLCD.drawLine(1, 119, 318, 119);
for (int i=9; i<310; i+=10)
myGLCD.drawLine(i, 117, i, 121);
for (int i=19; i<220; i+=10)
myGLCD.drawLine(157, i, 161, i);

// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255);
myGLCD.print(“Sin”, 5, 15);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,0,0);
myGLCD.print(“Cos”, 5, 27);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,255,0);
myGLCD.print(“Tan”, 5, 39);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
}

delay(10000);

}

Ceas de timp real RTC cu DS1307 si Arduino

February 13th, 2013 No comments

Ceas de timp real RTC cu DS1307 si Arduino

RTC-DS1307 LCD-RC0802A Arduino 2009 - Atmega328

RTC-DS1307 LCD-RC0802A Arduino 2009 – Atmega328

RTC-DS1307 LCD-RC0802A Arduino 2009 - Atmega328

RTC-DS1307 LCD-RC0802A Arduino 2009 – Atmega328

Schema modulului RTC cu DS1307 si EEPROM 24C32 (opt. DS18B20)

Schema modulului RTC cu DS1307 si EEPROM 24C32 (opt. DS18B20)

Conectarea modului RTC DS1307 la Arduino Duemilanove

Conectarea modului RTC DS1307 la Arduino Duemilanove

/* Exemplu utilizarea librarie MD_DS1307 si afisare pe LCD 8×2, fara posibilitatea de reglare a ore */

/* Tema:  “Reglarea orei si a datei prin Serial Monitor” */

#include <LiquidCrystal.h>
#include <MD_DS1307.h>
#include <Wire.h>

LiquidCrystal lcd(11, 10, 9, 8, 7, 6);  //conexiunile LCD-ului RC0802A la placa Arduino (RS, E, D4, D5, D6, D7)

void setup()
{
lcd.begin(8,2);
lcd.clear();
lcd.noCursor();
}

void p2dig(uint8_t v)
// print 2 digits leading zero
{
if (v < 10) lcd.print(“0”);
lcd.print(v);
}

void printTime()
{
lcd.setCursor(0,0);
p2dig(RTC.dd);
lcd.print(“/”);
p2dig(RTC.mm);
lcd.print(“/”);
int year;
year = RTC.yyyy – 2000;
lcd.print(year);

lcd.setCursor(0,1);
p2dig(RTC.h);
lcd.print(“:”);
p2dig(RTC.m);
lcd.print(“:”);
p2dig(RTC.s);
}

void loop()
{
RTC.ReadTime();
printTime();
delay(100);
}

 

Descarca catalogul ciruitului – DS1307

Mira de bare color pe TFT 3.2” (SSD1289) si Arduino

February 10th, 2013 No comments

Mira de bare color pe TFT 3.2” (SSD1289) si Arduino

mira_bare_color_tft_3.2b

Cod: Arduino cu ATMEGA328

// UTFT_Bitmap (C)2012 Henning Karlsen

#include <UTFT.h>
#include <avr/pgmspace.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Uncomment the next line for Arduino 2009/Uno
UTFT myGLCD(ITDB32S,19,18,17,16);

// Uncomment the next line for Arduino Mega
//UTFT myGLCD(ITDB32S,38,39,40,41);

extern unsigned int Bitmap_Image[0x280];

void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
myGLCD.fillScr(0, 0, 0);
myGLCD.setColor(255, 255, 255);
myGLCD.print(” *** Mira de bare color pe TFT 3.2′ *** “, CENTER, 228);
//for (int x=0; x<10; x++)
for (int y=0; y<228; y++)
myGLCD.drawBitmap (0, 1*y, 320, 1, Bitmap_Image);

delay(5000);
}

Cod: linia 1 bare color – bmp 320×1 px

// Time generated: 2/9/2013 11:13:16 AM
// Dimensions    : 320×1 pixels
// Size          : 640 Bytes

#include <avr/pgmspace.h>

prog_uint16_t Bitmap_Image[0x140] PROGMEM ={
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,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0x0080 (128)
0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0,   // 0x0090 (144)
0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0, 0x07E0,   // 0x00A0 (160)
0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F,   // 0x00B0 (176)
0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F,   // 0x00C0 (192)
0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF81F, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800,   // 0x00D0 (208)
0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800,   // 0x00E0 (224)
0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800,   // 0x00F0 (240)
0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F,   // 0x0100 (256)
0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F,   // 0x0110 (272)
0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,   // 0x0120 (288)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,   // 0x0130 (304)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,   // 0x0140 (320)
};