|
|
View previous topic :: View next topic |
Author |
Message |
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Thu Feb 05, 2009 3:32 pm |
|
|
Yes now it's working, it's working. I change two wires
But I have one more question: how can I use backlight for this lcd? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 05, 2009 4:28 pm |
|
|
Here is a web page with an LED series resistor calculator:
http://www.bowdenshobbycircuits.info/led.htm
You can put in these values:
(These numbers come from the RC2004 data sheet in your link)
Code: |
Total LEDs LED voltage LED current Total Voltage
1 4.2 280 5
|
Then press the "Find Resistor" button to calculate the series resistor value
and watts.
I got 3 ohms, and .213 watts, so you really should use a 1/2 watt resistor.
Connect +5v to the 3 ohm resistor, then connect the other side of the
resistor to the "A" pin on the LCD. Connect the "K" pin to ground.
Make sure your voltage regulator and power supply for your board can
supply the extra 280 ma to run the backlight.
----------------
Edit: Updated the link.
Last edited by PCM programmer on Sat Jan 22, 2011 1:24 pm; edited 1 time in total |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Sat Feb 07, 2009 10:54 am |
|
|
Thanks... The backlight it's working now
But now I had another problem :(
I try to make a thermostat with DS18B20 sensor.
I used some sources from http://loginway.net/the-ds18b20-digital-thermometer-and-pic16f877a-microcontroller-on-pic-01-development-board/
main.c:
Code: |
#include <16F887.H>
#device adc=8
#include <math.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP, NOCPD
#use delay(clock = 20000000)
#include "Flex_LCD416.c"
#include "1wire.h"
int i,read_ok;
byte buffer[8];
signed int16 t,t1;
int fTemp=0;
int iWrite=0;
void main()
{
float temperature;
SET_TRIS_B(0x01);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
//setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(VREF_LOW|-2);
delay_ms(50);
// The lcd_init() function should always be called once,
// near the start of your program.
lcd_init();
// Clear the LCD.
printf(lcd_putc, "\f");
//start here
printf(lcd_putc, "\fThis is a test");
printf(lcd_putc, " program!");
delay_ms(1000);
printf(lcd_putc, "\f");
while(1)
{
if(init_1wire())
{
write_1wire(0xcc); //skip ROM
write_1wire(0x44); //convert T
}
if(init_1wire())
{
write_1wire(0xcc); //skip ROM
write_1wire(0xbe); //read scratchpad
for(i=0;i<8;i++)
buffer[i]=read_1wire();
read_ok=1;
}
if(read_ok)
{
t=make16(buffer[1],buffer[0]); //calculate temperature
t=(float)t/16.0; //Calculation 0.1 deg C resolution
printf(lcd_putc, "\f");
printf(lcd_putc, "ok = true");
fTemp = (int)t/16.0;
temperature = (float)t/16.0;
delay_ms(500);
}
lcd_gotoxy(1,1);
//printf(lcd_putc,"Temp= %3.1f \uC", t);
printf(lcd_putc, "\f");
printf(lcd_putc,"Temp1= %2.1f \uC", temperature);
lcd_gotoxy(1,2);
printf(lcd_putc,"X= %3i \ori", iWrite);
lcd_gotoxy(1,3);
printf(lcd_putc,"Temp2= %3.1d \uC", fTemp);
iWrite++;
//\u displays degree sign
delay_ms(500);
}
} |
and 1wire.h:
Code: |
//-----------------------------------------------------
// 1wire.h
//-----------------------------------------------------
//-------------------------data pin definition-----------
#define DQ pin_a1
//I used RA1.
//--------------------------1wire reset-----------------
|
and the result is:
Temp1 = 0.0 uc
Temp2 = 0 uc
x= ... (is not importing)
and ok = true ...
Can you help me with this problem ?
Thanks ;) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Feb 07, 2009 12:44 pm |
|
|
I have not used the DS18B20 sensor. There are many posts on the
forum with sample code for that chip. Use the forum's search page to
find it. There is code in the Code Library forum. |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Mon Feb 09, 2009 2:13 am |
|
|
I made some researches, and in this moment it's showing a 16 time smaller temperature.
I don't know what the problem is, but here
Code: | t=(float)t/16.0; //Calculation 0.1 deg C resolution |
it showing 1.5 deg C, and here
Code: | t=(float)t; //Calculation 0.1 deg C resolution |
It is showing 25 deg C, and a camera thermometer is showing 26 deg.
I will test it with lower and higher temperatures. |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Tue Feb 10, 2009 1:11 am |
|
|
I have another question. I want to use 4 proximity sensors in my application.
I found GP2Y0A02YK0F 200-1500mm, but the price is not very good (4 * 25 $ = 100 $). Doesn't exist something cheaper?
A Golden Eye parking system (http://www.autoaccesorii.ro/standard_products.php?id=3184 ) is only 70$. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|