Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic programming help

Status
Not open for further replies.
thanks

Thank you very much Nigel Goodwin....i thought it will be very difficult .but it seems a slight difference in the code..anyway thank u very much..so this will work fine..i will test it and let u know about it..


It was my remort controller project...and after completion i will post it to my web site aswell as this forum too..hope u guys will love it.

Nigel Goodwin thank u for the tutorials in your site and it is very help full :)
 
thanks

hello Nigel Goodwin...the modification u made to the code works fine..but the thing is..i need to change it to this way....

Code:
      bsf    STATUS,RP0   
      movlw    b'00000000'      
      movwf    LEDTRIS
   movlw   b'00001111'
   movwf   trisa
   bcf   STATUS,RP0   
   clrf   LEDPORT         

Read
   movf   porta, w ;changed      
   call   Table   
   movwf   LEDPORT         
   goto   Start         

Table ANDLW b'00001111' ;added - ESSENTIAL!   
        ADDWF   PCL, f         
 ;      retlw   b'00000000'
        retlw   b'00000001'
        retlw   b'00000010'
        retlw   b'00000100'
        retlw   b'00001000'
        retlw   b'00010000'
        retlw   b'00100000'
        retlw   b'01000000'
        retlw   b'10000000'
 ;       retlw   b'00001001'
  ;      retlw   b'00001010'
   ;     retlw   b'00001011'
    ;    retlw   b'00001100'
     ;   retlw   b'00001101'

   end

will it works like this!!
 
Re: thanks

techknow said:
hello Nigel Goodwin...the modification u made to the code works fine..but the thing is..i need to change it to this way....

Code:
      bsf    STATUS,RP0   
      movlw    b'00000000'      
      movwf    LEDTRIS
   movlw   b'00001111'
   movwf   trisa
   bcf   STATUS,RP0   
   clrf   LEDPORT         

Read
   movf   porta, w ;changed      
   call   Table   
   movwf   LEDPORT         
   goto   Start         

Table ANDLW b'00001111' ;added - ESSENTIAL!   
        ADDWF   PCL, f         
 ;      retlw   b'00000000'
        retlw   b'00000001'
        retlw   b'00000010'
        retlw   b'00000100'
        retlw   b'00001000'
        retlw   b'00010000'
        retlw   b'00100000'
        retlw   b'01000000'
        retlw   b'10000000'
 ;       retlw   b'00001001'
  ;      retlw   b'00001010'
   ;     retlw   b'00001011'
    ;    retlw   b'00001100'
     ;   retlw   b'00001101'

   end

will it works like this!!

If you're shortening the table to only 8 values, rather than 16, you should alter the ANDLW accordingly to b'00000111', so you can't jump past the end of the table.
 
help

heheh here i am with a problem, to solve...just same like other posts ..
i am having an keypad the out put is 4bit binary...i am interfacing it to PIC16F628... to porta and i want to make portb bit 7 to be high when the person enters the right code...i want to make password as "1234" .i am having the difficulties to write the code so can anyone help me. step by step of coding..heheh

i hope this time Nigel Goodwin will help me too...

thanks in advance :)
 
Re: help

techknow said:
heheh here i am with a problem, to solve...just same like other posts ..
i am having an keypad the out put is 4bit binary...i am interfacing it to PIC16F628... to porta and i want to make portb bit 7 to be high when the person enters the right code...i want to make password as "1234" .i am having the difficulties to write the code so can anyone help me. step by step of coding..heheh

i hope this time Nigel Goodwin will help me too...

Try looking at my keypad tutorials, one of them implements a keypad lock.
 
techknow said:
i have seen the tutorials..but i need to make it from porta. and my keypad is giving an 4bit binary code...and i want it like i have said in above post....so pls pls give some tips dood..

Simply modify the tutorial, it calls a subroutine to read the keypad - simply replace that subroutine with one of your own!.
 
i am looking at the manual for the PIC 16F628A , this is an amazing chip.!!.
it has all the makings of a analog to digital converter even though it technically doesnt have one. it has a resistor network and two comparators with switchable inputs .. this is so cool..!!.
 
williB said:
i am looking at the manual for the PIC 16F628A , this is an amazing chip.!!.
it has all the makings of a analog to digital converter even though it technically doesnt have one. it has a resistor network and two comparators with switchable inputs .. this is so cool..!!.

Try the 16F819, it's the same size 18 pin chip, but has 10 bit A2D converters on board!

Both have internal oscillators, the 16F819 has an 8MHz one, but is switchable to lower speeds.
 
help

hello Nigel Goodwin i tried your keypad project..and that one is different from the one i am talking about..i am using just porta (RA0,RA1,RA2 and RA3)
just binary in put...so i did not have any idea to make it....i want to use a password to make porta,1 high...and pass word should be (1234) and i should able to change it.....so can u give me an code ..pls pls..
 
Re: help

techknow said:
hello Nigel Goodwin i tried your keypad project..and that one is different from the one i am talking about..i am using just porta (RA0,RA1,RA2 and RA3)
just binary in put...so i did not have any idea to make it....i want to use a password to make porta,1 high...and pass word should be (1234) and i should able to change it.....so can u give me an code ..pls pls..

As I mentioned in the post above, modify my tutorial code, add your keypad reading routine in place of the one I used.
 
Re: oh

techknow said:
so u guys dont have a solution dammm

You can hardly expect anyone to 'just happen to have' code for your exact hardware? - particularly when you are using an obscure keypad!.

I've told you about my tutorials, which will do almost exactly what you want - you only need to make extremely minor changes for your keypad.

We're not here to write your code for you, take a little time and learn to write it yourself - that's how you learn, and that's the point of my tutorials - not an 'idiots guide', but proven working code that you can modify for your exact requirements.
 
The pascal code immediatly below is a procedure, Frompic and is called during the Read operation after the pic has been programmed and essentially holds the address [0..1024] and the 14 bits of data comming from the pic16f628A..
so what it does , is take the data from the pic and converts it to HEX digits
1) question:: how can i "elegantly" achieve this.
2) problem:: the last four lines of code show what i mean..in there i take the two msb's that have four possible outcomes .ie bit14is 0 bit13 is 0 ::eek:utput is 0....bit14 is 0 , bit13 is a 1 ::eek:utput is one...ect...
ok as it is now each of the longer decision lines of code would require 16 lines of code, to test from 0 to F...
Is there another way to do it without 48 + 4 lines of code..??

Code:
Procedure Frompic;
  begin
if(picout[addr,4]=1)and(picout[addr,3]=1)and(picout[addr,2]=1)and(picout[addr,1]=1)  then write('F');
if(picout[addr,8]=1)and(picout[addr,7]=1)and(picout[addr,6]=1)and(picout[addr,5]=1)  then write('F');
if(picout[addr,12]=1)and(picout[addr,11]=1)and(picout[addr,10]=1)and(picout[addr,9]=1) then write('F');
if(picout[addr,14]=0)and(picout[addr,13]=0) then write('0');
if(picout[addr,14]=0)and(picout[addr,13]=1) then Write('1');
if(picout[addr,14]=1)and(picout[addr,13]=0) then write('2');
if(picout[addr,14]=1)and(picout[addr,13]=1) then write('3');writeln;

  end;
 
williB said:
The pascal code immediatly below is a procedure, Frompic and is called during the Read operation after the pic has been programmed and essentially holds the address [0..1024] and the 14 bits of data comming from the pic16f628A..
so what it does , is take the data from the pic and converts it to HEX digits
1) question:: how can i "elegantly" achieve this.
2) problem:: the last four lines of code show what i mean..in there i take the two msb's that have four possible outcomes .ie bit14is 0 bit13 is 0 ::eek:utput is 0....bit14 is 0 , bit13 is a 1 ::eek:utput is one...ect...
ok as it is now each of the longer decision lines of code would require 16 lines of code, to test from 0 to F...
Is there another way to do it without 48 + 4 lines of code..??

For a start, split the number into three single digits, you can do this by using AND with 15, and SHIFTING the original value. You can then use a simple 16 value lookup table to convert each value to a HEX digit. It's fast and simple!.
 
if(picout[addr,4]=1)and(picout[addr,3]=1)and(picout[addr,2]=1)and(picout[addr,1]=1) then write('F');
if(picout[addr,8]=1)and(picout[addr,7]=1)and(picout[addr,6]=1)and(picout[addr,5]=1) then write('F');
if(picout[addr,12]=1)and(picout[addr,11]=1)and(picout[addr,10]=1)and(picout[addr,9]=1) then write('F');
hmmm
well i have the data from the pic stored in picout[addr,1..14]...
so the data looks like this{1 1 1 1 , 1 1 1 1 , 1 1 1 1 , 1 1 } LSB comming out first.. {without the commas of course...}
i am not sure that i understand what you mean..?
 
williB said:
if(picout[addr,4]=1)and(picout[addr,3]=1)and(picout[addr,2]=1)and(picout[addr,1]=1) then write('F');
if(picout[addr,8]=1)and(picout[addr,7]=1)and(picout[addr,6]=1)and(picout[addr,5]=1) then write('F');
if(picout[addr,12]=1)and(picout[addr,11]=1)and(picout[addr,10]=1)and(picout[addr,9]=1) then write('F');
hmmm
well i have the data from the pic stored in picout[addr,1..14]...
so the data looks like this{1 1 1 1 , 1 1 1 1 , 1 1 1 1 , 1 1 } LSB comming out first.. {without the commas of course...}
i am not sure that i understand what you mean..?

I'm presuming each word (14 bits) is stored in a word length variable (16 bits), if you AND this value with 15 (binary 1111) you get the least significant HEX digit, shift the original value right four places and AND it again, this gets the second HEX digit, do the shift again to get the third, and lastly do the shift again to get the MSB (which is only two bits). YOu now have the four hexadecimal values for the 12 bit word, you can convert them to display as hexadecimal by using a simple 16 character lookup table.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top