Problem on starting up my hardware project

Status
Not open for further replies.

MahmoudJaser

Newbie level 5
Joined
Apr 4, 2012
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,363
my project is Home automation with power saving technique i have used 2*PIC 16F877A ,OSC = 4Mhz ,Mikrobasic language program and the connection diagram is as in the picture

my problem is when i have connected the hole project hardware and start it up no response from LCD at all pls guide me about:
1-what is the best supply needed and do i have to use two separate sources and if any part of my project needs its own source??
2-i used timer0 interrupt only so no external or internal interrupt are used what are the best configuration bit for me
3- what is the amount of capacitance needed for both Vss,Vdd and the master CLR and the oscillator
4-what is might be the problem in LCD as it worked perfectly on Proteus the configuration i used is:
LCD_config(portb,7,6,5,4,portb,1,2,3)
and this is a sample of display code:
Code:
   LCD_Cmd(LCD_CLEAR)
    LCD_Cmd(LCD_CURSOR_OFF)
    LCD_Out(1,1,"******WELCOME******")
    LCD_Out(2,1,"     H.M.H HOME     ")
    LCD_Out(3,1,"  AUTOMATED SYSTEM  ")
is there any special connection needed ,like when i connect the 15 and 16 pin's of the LCD to 0,5 volts to turn it on ??
5-what are the best wiring length (For parallel port connection and for the sensors and leds ....etc )
6-is there any difference between built-all and built operation when compiling the project ??
7-the code 100% works i checked every may-happen scenario so nothing wrong with the code it appeare to be hardware problem as nothing even starts up
* note: the ROM in the 1st PIC (left on the graph) is reaching 88% and on the other one reaches 75%

please help me its my graduation project and it must work !!!!!
additional photos

 

Attachments

  • new (1).rar
    31.1 KB · Views: 101
Last edited by a moderator:

I only have following suggestion although i'm not sure.
Use separate supply microcontroller and high power circuit (motors).
Don't write and read data too fast from/to LCD.
 

don't expect to make it work from one shot unless you are an expert.

it seems a very complete project, so you need to test step by step...

1. it's recommended to have one supply for the logical data, and another for power supply (like your step motors) also you need some capacitors for each integrated circuit of 1uF ~ 10 uF on each VCC (tantalum capacitor recommended)
2. NOWDT, POR_ENABLE, XT_OSC, NO_LVD, mmmm i think they are the most important.
3. as stated before something arounf 1uF ~10uF between VDD-VSS
4. sadly you must debug this issue apart from the rest of the circuit... maybe your contrast pot (VEE) is too high... i usually set it near GND (even directly connected to VDD) and see the black row of boxes (2 intercalated in your case).. if it passes the configuration and initialization, there should be 2 rows of blackboxes (4 in your case)... if it even can't do this, maybe you have communication issues, or mis align pin issues...
5. you need more information about this, but as your circuit shows, i wouldn't put anything more than 1m (3ft) away the microcontroller... except maybe motors and rs232 to pc...


i sadly think that you didn't builded thsi circuit in real life, and expect to work just because it worked in proteus...
you need to check and recheck...
1 oscilator configuration (no watch dog, xt oscilator and NO LVP!!!!!)
2 VCC and GND values IN THE PIC
3 crystal oscilating (very difficult without and oscilloscope)
4 MCLR voltage value (must be 5V-VCC no noise)
5 noise from other sources...


at first i would test a blinking led (nothing fancy just the pic and a led with resistor) then after it's working make test of the LCD... just LCD and nothing else...
then after that i would test the keypad (with help of the lcd)... when all this works then communication RS232 and after that intercomunication between pics..

then

and just then i would implement the real application...

as you already have the complete application... you will have a pain to debug your circuit without some simpler programs to test...
 

Thanks very much for your help i will try these steps and i'll let u know if any updates appears
 

Hi,

Would agree with the above comment plus for the actual hardware :-

The 4meg xtal should use 22pf capacitors.

Mclre should be tied to Vdd , direct or via a 10k resistor, if you want to use a cap, then 100nf is all thats needed.

Fit a 100nf cap across and as close as possible to each pics Vss and Vdd pins, do the same for every other chip.

Pins 15 and 16 on the lcd are for a backlight, if fitted, and nothing to do with the lcds logic.

Cannot see the part number clearly on your pngs, posting your .dsn would be better.
Think the sensors are the Lm34 or 35s ? - if you want several meters of cable then suggest you change to the ds18B20 which is designed for longer cables.
To avoid noise problems use shielded cables to all the i/o devices.

You mention parallel ports connections, don't know where that is, or what the GSM serial port connects to either ?

How are you using the pics, both as indepentant programs or one master just slaving the other for its i/os.

For such a complex project a hardware debugger might be useful but you would have to free up Rb6 and Rb7.
Does your programmer support a hardware debug mode ?
 

Hi,
Cannot see the part number clearly on your pngs, posting your .dsn would be better.
i attached the DSN file in the rar file
about data transfer between PIC's
both as indepentant programs but the left one sends information 000,010.....etc and the right one operate depends on the income data and then resend one bit 0 or 1 in response
and about hardware debugger I don'r know what you are talking about but i use Mikrobasic 7.0.0.2 if you can tell me about it i would be greatfull
thanks for following up
 

Hi,

No .rar file ? - ah, found it on your original post ...

Not sure how it works with the high level languages like C or Basic but when you run an assembler program in MpLab / Proteus VSM you can Step though the code, either an instruction at a time or a whole block of code using breakpoints.


When you run the code on actual hardware I can connect my programmer , a Pickit2, to the 877A and from within MPlab and similary step through the program code to help isolate any problems.

MikroE do their own programmer and hardware debugger to work with their compliers, though not sure if you are using an EasyPic board ?

---------- Post added at 22:17 ---------- Previous post was at 22:03 ----------

Hi,

For your uln2001 drivers you need to use an input resistor, simpler to use either the uln2003 or 2803 which can be directly connected to the 877.
 
hi wp100 thanks for these info's really helpful
i will list the sensor type i used and i'll see if i can get my hand on one of these programs to check my code
thanks again..

---------- Post added at 01:10 ---------- Previous post was at 01:08 ----------

hi wp100 thanks for these info's really helpful
i will list the sensor type i used and i'll see if i can get my hand on one of these programs to check my code
thanks again..
 

2. NOWDT, POR_ENABLE, XT_OSC, NO_LVD, mmmm i think they are the most important.

how to make POR_ENABLE i cannot find it in mikrobasic configuration bits
also XT_OSC would it harm if it was HS_OSC as i use 4MHZ and i might increase it to 6MHZ
thank u again
 

how to make POR_ENABLE i cannot find it in mikrobasic configuration bits
also XT_OSC would it harm if it was HS_OSC as i use 4MHZ and i might increase it to 6MHZ
thank u again


Hi,

You should be ok with HS for 4 and 6 meg, though 8 meg is a more common choice; changing the xtal you will need to check how it affects your timings, so I would move to 8 meg now rather than later.

There is no POR, he probably means BOREN for the 877A, these are the options available -




Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;==========================================================================
 
 
 
;----- CONFIG Options  from MPlab Include files --------------------------------------------------
_FOSC_LP             EQU  H'3FFC'    ; LP oscillator
_LP_OSC              EQU  H'3FFC'    ; LP oscillator
_FOSC_XT             EQU  H'3FFD'    ; XT oscillator
_XT_OSC              EQU  H'3FFD'    ; XT oscillator
_FOSC_HS             EQU  H'3FFE'    ; HS oscillator
_HS_OSC              EQU  H'3FFE'    ; HS oscillator
_FOSC_EXTRC          EQU  H'3FFF'    ; RC oscillator
_RC_OSC              EQU  H'3FFF'    ; RC oscillator
 
_WDTE_OFF            EQU  H'3FFB'    ; WDT disabled
_WDT_OFF             EQU  H'3FFB'    ; WDT disabled
_WDTE_ON             EQU  H'3FFF'    ; WDT enabled
_WDT_ON              EQU  H'3FFF'    ; WDT enabled
 
_PWRTE_ON            EQU  H'3FF7'    ; PWRT enabled
_PWRTE_OFF           EQU  H'3FFF'    ; PWRT disabled
 
_BOREN_OFF           EQU  H'3FBF'    ; BOR disabled
_BODEN_OFF           EQU  H'3FBF'    ; BOR disabled
_BOREN_ON            EQU  H'3FFF'    ; BOR enabled
_BODEN_ON            EQU  H'3FFF'    ; BOR enabled
 
_LVP_OFF             EQU  H'3F7F'    ; RB3 is digital I/O, HV on MCLR must be used for programming
_LVP_ON              EQU  H'3FFF'    ; RB3/PGM pin has PGM function; low-voltage programming enabled
 
_CPD_ON              EQU  H'3EFF'    ; Data EEPROM code-protected
_CPD_OFF             EQU  H'3FFF'    ; Data EEPROM code protection off
 
_WRT_HALF            EQU  H'39FF'    ; 0000h to 0FFFh write-protected; 1000h to 1FFFh may be written to by EECON control
_WRT_1FOURTH         EQU  H'3BFF'    ; 0000h to 07FFh write-protected; 0800h to 1FFFh may be written to by EECON control
_WRT_256             EQU  H'3DFF'    ; 0000h to 00FFh write-protected; 0100h to 1FFFh may be written to by EECON control
_WRT_OFF             EQU  H'3FFF'    ; Write protection off; all program memory may be written to by EECON control
 
_DEBUG_ON            EQU  H'37FF'    ; In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger
_DEBUG_OFF           EQU  H'3FFF'    ; In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins
 
_CP_ON               EQU  H'1FFF'    ; All program memory code-protected
_CP_ALL              EQU  H'1FFF'    ; All program memory code-protected
_CP_OFF              EQU  H'3FFF'    ; Code protection off

 
Last edited by a moderator:
hello agian ......sorry for being late
i tried each idea of the above and this is what i did
i used several other codes (note mine) only to show the word WELCOME on the LCD and to make a LED blink and when i start up the hardware the LCD shows nothing except for black areas in the first and some times second row and the LED on the other hand works as i programed
samples of the code used and connection are attached her
pleaaaaaaaaaaaaaaaaase if any one can give a working LCD code in mikrobasic and a valid and tested hardware connection with risistance and capacitance values and hardware connection and supply value and connection it would be helpfull pleeeeeeease help
program lcdtest
first code tested
Code:
main:
trisd=%00000000
portc.2=0
delay_ms(1000)
lcd_config(portd,7,6,5,4,portd,3,2,1)
delay_ms(1000)
lcd_cmd(lcd_clear)
delay_ms(1000)
hamza:
    delay_ms(1000)
    lcd_out(1,1,"WELCOME")
    delay_ms(1000)
setbit(portc,2)
delay_ms(300)
clearbit(portc,2)
delay_ms(300)
goto hamza
end.

i also tried the above code wih
lcd_config(portd,7,6,5,4,portb,3,2,1) or lcd_config(portb,7,6,5,4,portb,3,2,1) or LCD_init(portb)or LCD_init(portd) insteade of lcd_config(portd,7,6,5,4,portd,3,2,1) and other connecions
and i connect as follow
for LCD_init(portb)
RW,d0,d1,d2,d3 ------------------> ground direct without pull or down resistances
d4------->RB4 direct without pull or down resistances
d5------->RB5 direct without pull or down resistances
d6------->RB6 direct without pull or down resistances
d7------->RB7 direct without pull or down resistances
Vee through 4.7 kohm potentiometer or directlygrounded
vcc ,ground as usual to 5v and ground
about OSC ---->4MHZ through two 22Mfarad capacitors to ground
MCLR through 10 Kohm Resistance to 5 volt
Vss and Vdd as usual with a capacitor connecting them
please help me............
 
Last edited by a moderator:

Hi,

From you first post it looked as if you had the lcd working ok with some code, so what has happened to make it not work ?

Assume you are now using actual hardware rather than simulation, but what about the LCD, what type are you actually using 2 x 16 or 4 x 16 ?

I do not use Basic, but would expect it may have a different routine for a 2 line and 4 line lcd ..??

If you are getting the black blocks on the lcd it does seems it is working in part, more that program not running correctly.

Your connections sound ok, have you got both pairs of VDD pins 11,32 and VSS pins 12,31 connected ?

Can you send a .dsn of your exact circuit you have built and I will try and run some of my assembler code on it.
 


sorry i'm not a MikroE fan or use MikroBasic but....
as far as i remember the mikroelectronica LCD library, uses
4 data pin AND 3 control pin
you didn't mention WHERE you connect your control pin (RS,RW,EN) well except RW which you say you leave it in GND (0v) !!!! this alone will not work with the mikroelectronica LCD library!!!!!!
please state where RS and EN are connected it's very important... (as you seem to use PORTD please use it in the LCD_INIT procedure...)
 

thanks guys the Lcd works the prblem was with the source it was not enough
know i had a problem with the keypad the coonection scheme was as follow
row #1 from up to down------>RD4
row #2 ------>RD5
row #3 ------>RD6
row #4 ------>RD7
column #1from left to right ------>RD0
column #2 ------>RD1
column #3 ------>RD2
ground-------->RD3
and it seems to work fine using Proteus using
Code:
keypad_init(portd)
but when i connect it it gives continuous 6666 or 2222 or 3333 as there is a key pressed
is there any special connection using pull up or down resistors for port d and the keypad if there is please attach a correct tested one with resistance values and connection and if there is any other solution or wrong connection i made please inform me
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…