Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] This project is easy for you but difficult for me

Status
Not open for further replies.

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
This project is easy for you but difficult for me + choosing the best compiler for C

Hi every body
I am new in PIC and C language and I should do this project , so please say that which C commands can help me in this project . and the project is :
I have 10 LEDs and a 4*4 keypad , and if hold the key number 1 for the 1s the first LED should be on for 10s , and if hold the key number 1 for the 2s the second LED should be on for 9s , and this way continue till the 10th LED ... when hold the key number 1 for 10s the 10th LED should be on for 1s and if you hold the key number 1 less than 1s the LEDs should be turn on and off each 0.1s for 10s

beside to solve this project , I want to choose the best PIC compiler for C language so please introduce me your compiler (that have worked with it ) and say why do you think is the best ?and i am using CCS compiler right now so if you have example please give me
Thanks
 
Last edited:

john blue

Advanced Member level 3
Joined
Jun 7, 2007
Messages
821
Helped
213
Reputation
430
Reaction score
204
Trophy points
1,323
Activity points
4,749
you have mikroC, C18 and hi tech C to choose from. And everybody has their preference. First, try all the C's and see which suits you.
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,222
Helped
1,147
Reputation
2,313
Reaction score
1,124
Trophy points
1,403
Location
Brazil
Activity points
53,688
The first step to you perform is draw a flowchart describing the working you expect.

+++
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
if you are new to programming PICs you need get some understanding of how to operate the IO pins and use a timer, e.g. setiing TRIS bits and LAT bits etc
start with some simple programs, e.g.
1. implement a for() loop blinking a LED on/off
2. read a switch using the on/off value to switch an LED on/off
3. using a timer blink LED on/off 1 second period

you now have the basic knowledge to start implementing the flowchart recommended in previous posts.
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
you have mikroC, C18 and hi tech C to choose from. And everybody has their preference. First, try all the C's and see which suits you.

thanks for your reply , but you know I have CCS compiler , can you send for the source of the compiler you said , I want to try them

---------- Post added at 06:49 ---------- Previous post was at 06:44 ----------

The first step to you perform is draw a flowchart describing the working you expect.

+++

can you help me for drawing a flow chart ? i am new in this item too

---------- Post added at 06:53 ---------- Previous post was at 06:49 ----------

if you are new to programming PICs you need get some understanding of how to operate the IO pins and use a timer, e.g. setiing TRIS bits and LAT bits etc
start with some simple programs, e.g.
1. implement a for() loop blinking a LED on/off
2. read a switch using the on/off value to switch an LED on/off
3. using a timer blink LED on/off 1 second period

you now have the basic knowledge to start implementing the flowchart recommended in previous posts.

can you write the commands that can read a key from keypad ?
 

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
are you using a development board? which microcontroller?
What do you mean by development board ? and i am using PIC 16f877A and my compiler is CCS

---------- Post added at 11:05 ---------- Previous post was at 11:01 ----------
 

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
development boards typically have a range of peripherals and are used to develop prototype systems before designing a PCB for the target project, e.g.
Explorer 16 Development Board
Mechatronics Demonstration Kit
I am so thanks full but there is a problem , the microchip website has filtered in my country so i could not open the links , by the way do you CCS compiler has HELP in its options like other software or not because my version ccs_4.084 does not have!!!! and I want to know its my software problem or this compiler does not have HELP ?!!!!!!!!!
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
Using the HI-Tech compiler on the Microchip mechatronics board this blinks two LEDs and copies the value of switch to an LED
Code:
// blink two LEDs and copy a switch to LED
//
// connect SW2 ro RA0
// connect RD7, RD6 and RD5 to LEDs

#include <htc.h>

// delay function
void delay(int x)
{
	int i;
	for(i=0;i<10000;i++);
}

void main(void)
{
	while (1){
        RP0=1;
		TRISA0=1;        	// RA0 is input
  		TRISD7=0;			// RD7 is output
  		TRISD6=0;			// RD6 is output
  		TRISD5=0;			// RD5 is output
		ANSEL=0;			// set RA0 digital input
		CMCON0=7;			//     "
		RP0=0;
		RD7=0;				// initialise the LEDs
		RD6=1;
		RD5=1;
        while(1)
 			{
			RD5=RA0;		// copy sw2 to LED
			delay(1000);
		    RD7=!RD7;		// invert LED
		    RD6=!RD6;		// invert LED
			}
		
	}
}
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
Using the HI-Tech compiler on the Microchip mechatronics board this blinks two LEDs and copies the value of switch to an LED
thank you so much , can you explain more about pros and cons of HI-tech ? and compare it with CCS and micro C compilers ? because i am at the begin of the way and i am looking forwards to finding the best compiler for the C language and PIC microcontroller
 

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
Does any body know , what is the formula for build real time ? because i can turn on and turn off LEDs with push-button but now I want to control lighting Time and build times 1s ,2s,....10s and as I said before I use CCS , and C language.

---------- Post added at 11:24 ---------- Previous post was at 11:23 ----------

cannot help with advice as I have not used the PIC16 for many years and then I only used the Hi-Tech compiler


Thank you very much , I want to instull a Hi-Tech compiler but , that Has some internal problem so can you introduce a free link ?
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
cannot help with advice as I have not used the PIC16 for many years and then I only used the Hi-Tech compiler


Thank you very much , I want to instull a Hi-Tech compiler but , that Has some internal problem so can you introduce a free link ?
try downloading the lite version from
HI-TECH C for the PIC10/12/16 MCU Family
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
I have problem with making time , because as i mentioned in this project I need These times , 1s,2s ... 10s but the problem is I dont know how should I use the Timer/Counter to making these times , please help me
 

john blue

Advanced Member level 3
Joined
Jun 7, 2007
Messages
821
Helped
213
Reputation
430
Reaction score
204
Trophy points
1,323
Activity points
4,749
Please read the compiler's manual and the dataheet
 

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
finally I did it , i did it :-D and here is my codes but i should mention that i use LCD and instead of 10 LEDs i just one LED by the way i used micro C compiler instead of CCS
//// this project adjust the lighting ON and OFF the LED according by
////the holding time of key 1 a 4*4 key pad
////////////////Define variants////////////////////
unsigned short kp;
unsigned char txt[1];
unsigned char txt1[1];
unsigned short kp1;
unsigned short count;
/////////////This Function showes numbers on the LCD and according the time of
////////////holding the key 1 turn on and turn off the LED
void LCDshow(){
kp = Keypad_Read();
if (kp==1) count++;
WordToStr(kp, txt);
Lcd_out(1, 10,txt);
WordToStr(count, txt1);
Lcd_out(2, 10,txt1);
delay_ms(500);
Lcd_Cmd(LCD_CLEAR);
if (kp!=1) {
if(count==2) {portc.f0=1;delay_ms(10000);portc.f0=0;}
if(count==4) {portc.f0=1;delay_ms(9000);portc.f0=0;}
if(count==6) {portc.f0=1;delay_ms(8000);portc.f0=0;}
if(count==8) {portc.f0=1;delay_ms(7000);portc.f0=0;}
if(count==10) {portc.f0=1;delay_ms(6000);portc.f0=0;}
if(count==12) {portc.f0=1;delay_ms(5000);portc.f0=0;}
if(count==14) {portc.f0=1;delay_ms(4000);portc.f0=0;}
if(count==16) {portc.f0=1;delay_ms(3000);portc.f0=0;}
if(count==18) {portc.f0=1;delay_ms(2000);portc.f0=0;}
if(count==20) {portc.f0=1;delay_ms(1000);portc.f0=0;}
count=0;
}
}
/////////////Main Function/////////////////////////////////////////
void main() {
// portc.f0=0;
trisc.f0 =0;
Keypad_Init(&PORTB);
Lcd_Config(&PORTc,1,2,0,7,5,4,3); // Initialize LCD on PORTC
Lcd_Cmd(LCD_CLEAR); // Clear display
Lcd_Cmd(LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "Key :");
while(1){
LCDshow();
}
}
 

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
now I want to make real time with timers . dose any body can help me ?
 

dv_sa559

Advanced Member level 4
Joined
Dec 3, 2009
Messages
106
Helped
31
Reputation
62
Reaction score
30
Trophy points
1,308
Location
Iran
Activity points
1,819
Hi
if you need high precision rtc you need to use rct ic such as DS1307 .
 
  • Like
Reactions: mf1364

    mf1364

    Points: 2
    Helpful Answer Positive Rating

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
189
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,721
no buddy , i want to use timers just for learning how to use them because i am so new in pic by the way i am using pic16873A and miKroC compiler . i am hardly looking forward to finding a pdf for learning how to use timer/counter especially for pic16873A
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top