View previous topic :: View next topic |
Author |
Message |
erendogan83
Joined: 12 Aug 2016 Posts: 13
|
|
Posted: Sun Aug 14, 2016 11:27 am |
|
|
Dear friends,
thanks for your comments
let your stupid friend (me) ask you another question pls
is it possible to write values into mmc card in this circuit?
or should I use another pic like 18f452?
I am planning to make a video of this circuit
may I add your names to THANKS if doesnt bother u? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Sun Aug 14, 2016 11:40 am |
|
|
Honestly if you want to use an SD/MMC card, use a 3.3v PIC. Otherwise you need level shifting circuitry between the card and the PIC. Also since these involve large sectors (512bytes), you need a PIC with a reasonable amount of RAM.
An external EEPROM is easier, unless you need enormous sizes. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Sun Aug 14, 2016 6:12 pm |
|
|
Read again the data sheet and yes, Mr.T is right (like always?)
I miss the "Basic Centigrade Temperature Sensor (2°C to 150°C)" above the first drawing in the data sheet so 2°C=0 mV, 150°C=1500 mV, this should be the base of the calculation
Best wishes
Joe |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Mon Aug 15, 2016 3:36 am |
|
|
Not quite.
The sensor won't pull 'down' below the voltage for 2C (20mV). The output never goes to '0'.
Read the actual text. They are giving you the formula, not the voltage. So 'For a range of 2 to 150C', the output voltage is expected to be 0+10mV/C.
So at 2C, you get 2*10+0mV = 20mV.
Then at 10C, you get 10*10+0 =100mV.
and at 150C, you get 150*10+0 = 1500mV.
Now, I've just put the code with a couple of modifications into a chip, and it runs fine:
Code: |
#include <16f877.h>
#device ADC=10
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(a)
#use fast_io(b)
#use fast_io(d)
#define use_portb_lcd TRUE
//#include <lcd.c>
//changing to using UART - see below
#use RS232(UART1, baud=9600, ERRORS)
#define DEG_TO_MV(x) (x)*10
int16 sensor, voltaj, temp;
#INT_TIMER0
void TIMER0_isr(void)
{
if (temp>DEG_TO_MV(30))
output_high(pin_d1);
else
output_low(pin_d1);
}
void main ( )
{
int16 sum;
setup_psp(PSP_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_CCP1(CCP_OFF);
setup_CCP2(CCP_OFF);
set_tris_a(0x01);
set_tris_d(0x00);
output_d(0x00);
setup_timer_0(RTCC_INTERNAL |RTCC_DIV_4);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
setup_adc(adc_clock_div_32);
setup_adc_ports(AN0);
//lcd_init();
set_adc_channel(0);
delay_us(20);
//printf(lcd_putc,"\ftemp=");
while(TRUE)
{
sensor=read_adc(); // ADC sonucu okunuyor ve bilgi degiskenine aktariliyor
voltaj=(sensor*39)/8; //This gives integer 0 to 5000 for 0 to 5v.
//_efficiently_.
//Now damp this a little
sum+=voltaj;
voltaj=sum/4;
sum-=voltaj;
disable_interrupts(GLOBAL);
temp=voltaj; //copy with interrupts disabled
enable_interrupts(GLOBAL);
//lcd_gotoxy(10,1);
printf("%5.3LW Volts\n",voltaj); //Displays input voltage correctly
delay_ms(100);
}
}
|
I haven't got an LCD handy, so fed it out on the UART.
The output correctly switches at just on 30C. |
|
|
erendogan83
Joined: 12 Aug 2016 Posts: 13
|
|
Posted: Mon Aug 15, 2016 6:24 am |
|
|
You added RS232 function here.
Am I supposed to connect serial port of PC?
and this expression "%5.3LW" I dont understand it?
long integer shouldnt be LI? and why 5.3? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Mon Aug 15, 2016 7:15 am |
|
|
Just put yor LCD code back.
The point is this is running, but I don't have and text LCD's handy, so fed the output to serial.
The value in volta, is in integer mV. So to display it in 'volts', it wants to be displayed as if it had three decimals. So .3
0.1v is internally held as '100'. 1v as '1000'.
The .w format says "display an integer as if it had a decimal point so many digits to the left". To display mV as volts, we want it with the decimal 3 digits to the left. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Mon Aug 15, 2016 7:18 am |
|
|
re:
Quote: | this expression "%5.3LW" I dont understand it? |
Please, press F11 with your project open. It will 'magically' run the CCS C Help file. Simple go to the menu and open 'printf()' and you will see the formatting of the printf() function along with several examples.
5.3 = n.nnn as a 'format' if it's the same as FORTRAN.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Mon Aug 15, 2016 8:11 am |
|
|
temtronic wrote: | re:
this expression "%5.3LW" I dont understand it?
Please, press F11 with your project open. It will 'magically' run the CCS C Help file. simple go to the menu and open 'printf()' and you will see the formatting of the printf() function along with several examples.
5.3 = n.nnn as a 'format' if it's the same as FORTRAN..
Jay |
In Fortran with an integer, 5.3 would mean to output five characters, with a minimum of three digits.
Potentially very different.... |
|
|
erendogan83
Joined: 12 Aug 2016 Posts: 13
|
|
Posted: Tue Aug 16, 2016 1:09 am |
|
|
Houston we have a problem
Dear friends,
I am adding picture of my circuit while working
http://i.hizliresim.com/zn23Jj.jpg
problem is I dont want to use 9V external source for lcd
I used 18v adaptor feeding LM7812
LM7812 feeds my trigger transistor relay and my LM7805
LM7805 for my pic and lcd
but my lcd not working if I dont connect 9V battery directly to it
any ideas? |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Tue Aug 16, 2016 5:45 pm |
|
|
Can you post the circuit diagram of your posted picture?
Best wishes
Joe |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1636 Location: Perth, Australia
|
|
Posted: Tue Aug 16, 2016 10:23 pm |
|
|
erendogan83 wrote: | Dear friends,
is it possible to write values into mmc card in this circuit?
or should I use another pic like 18f452? |
Yes it is possible but not practical. Writes must be performed in 512 byte blocks. The PIC you are using does not have enough RAM to buffer a sector (512 byte block) but that does not prevent you from writing a chunk now and just ignore the SD card (leave it asserted) until you are ready to write the next chunk.
So yes, it is possible but as mentioned, not practical. A better PIC would be the PIC18F4620 or derivatives if you want to move stay in an 8 bit family. A far better choice is a PIC24/dsPIC33 processor. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
erendogan83
Joined: 12 Aug 2016 Posts: 13
|
|
Posted: Tue Aug 16, 2016 11:32 pm |
|
|
gjs_rsdi wrote: | Can you post the circuit diagram of your posted picture?
Best wishes
Joe |
bro here is picture of circuit
http://i.hizliresim.com/7AV025.jpg
it works fine in proteus but I have to add 9V battery for LCD in real circuit |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Aug 17, 2016 3:43 am |
|
|
Can't see your power supply in the drawing
I don't see nothing in the data sheet that will make the problem you are stating regarding the 9V. In the data sheet is stated:
Quote: | +5V single power supply |
In Fig. 4 Power supply shows how to connect power to the LCD
Best wishes
Joe |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19588
|
|
Posted: Wed Aug 17, 2016 4:07 am |
|
|
Also, a relay with no fly-back diode. How to kill other parts of the circuit.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Wed Aug 17, 2016 5:17 am |
|
|
Well I KNOW that you can run an LCD module AND 16F877A from the same 5 volt supply as I've done so for the past 20 years !
Your schematic is not correct with respect to the transistor/relay portion. wires' go to the wrong place, no power, as pointed out no 'flyback' diode across relay.
I suspect your hardware is not wired correctly.
Also putting 9 volts on an LCD module may damage it !!
Jay |
|
|
|