1. 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.
    Dismiss Notice

where do i learn bout PIC ?

Discussion in 'Microcontrollers' started by kupikupi, Aug 21, 2005.

  1. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    The codes above simply initialise the USART, it doesn't actually 'do' anything - you also don't give any clue as to what you want to do?. 'Communicate with the PC' is so vague as to be meaningless?.
     
  2. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    sorry bout that... well .. for my project, there are 2 ways of uploading programs into the PIC one of them will be using a programmer called " pic start plus" i can only use it in the Uni lab, so , there is another way to upload program which is thru a serial port RS 232 using MAX 232 converter, but i was told that i cant upload a program directly without USART .. but how do i use USART??
     
  3. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    You don't need to worry about the USART, what you need is a bootloader program, you use the PICStart Plus to program the bootloader into the PIC. You can then use a PC program (which will be provided with the bootloader, or even something as simple as Hyperterminal) to transfer programs via RS232 to the PIC.

    There are various bootloader programs at http://www.microchipc.com/, I've never used the 18F ones, but the 16F ones are excellent!.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0

    thanx nigel... but when do we need to use USART ?
    this was fromm jay ...
    u said i dont have to worry bout USART.. may i ask wat takes care of the transmission??
     
  6. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    another question...
    lets say i have a LED blinking program in my PIC, i want to upload a motor driving program ...
    when i upload it ... do i have to do anything so that i wont overwrite the previous program or i just upload it and the bootloader will arrange it for me ?
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    The bootloader takes care of the USART, all you need to do is provide suitable hardware (as in a MAX232 connected to the USART pins).

    As I said, I've not used 18F bootloaders, but in the 16F the bootloader code is written at the very top of memory. Normal programs run in the lower parts of memory, so the bootloader code is out of the way. When you upload a new program, it overwrites the previous one, but the bootloader itself isn't touched (or shouldn't be!).

    There's no reason not to overwrite the previous program, not doing so wouldn't achieve very much?.
     
  8. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    so do u mean that the PIC can only take one program at once?
    meaning that if i want the PIC to perform multi tasks , i have to combine all the programs into 1 ?? i cant separate the programs?? i'm really new with PIC, i dont know how it works.... :?
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    Essentially yes!.

    There's nothing to stop you writing a multi-tasking operating system if you so wished?, bear in mind even a PC doesn't multi-task at all well!, the Intel processors are very badly suited for it!.

    But the small amounts of program memory available would waste too much of the OS, and not leave much available for programs. Bear in mind, this is a micro-controller, NOT a full blown computer with multi-megabytes of memory and gigabytes of hard disk.

    However, it's hard to think of anything that would require such an OS?, the PIC's huge advantage is it's small size and speed, multi-tasking would cripple the speed, just as it does on (almost!) everything else.
     
  10. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    i'm a little confused about the Tiny bootloader that Jay was talking about, is it a .hex file to program into the PIC or is it software like Mplab ?? from the previous post i understood that Tiny bootloader has the same function as Mplab(i used mplab to upload program into the PIC thru picstart plus,now i want to upload programs from home using serial port) so could i just use mplab instead of the the tiny bootloader ? is it the same ?? and i still need to upload a bootload .hex file into the pic thru picstart plus b4 i can do so right??
    i went thru the tiny bootloader site and i cant find any bootloader .hex file. could anyine help me out here??how do u rite a bootloader hex file?
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    The URL I posted earlier has source code for bootloaders, but to be honest, if you've got to ask you probably aren't capable of it? :cry:

    But there's no need, they are many bootloaders you can download, any site with them on should explain what you need on the PC - even if it's just a simple terminal program.

    I wouldn't expect MPLAB to perform this task?, it's basically an editor and simulator, with links to the MicroChip programmers (like the PICStart Plus) and the assembler MPASM.
     
  12. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    so is it that i can only use mplab to upload program to the PIC thru microchip programmers.. and for uploading via serial port .. i will need bootloader together with the bootloader software?? the one shown below?? are all bootloaders the same ?? meaning that i can just download any bootloaders and run with this software, Tiny bootloader??
     

    Attached Files:

  13. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    MPLAB is a development enviornment where the asm file is compiled/assembled into a HEX file. You can use either Microchip's programmers or other programmers or even build one yourself to send the HEX into the PIC. See here:

    A home made programmer

    This is an option that requires no programmer except a standard RS232 serial connection to the PC. Suitable for people who do not have access to programmers at home, like you are now.

    All bootloaders are different. Of course they are if not why we have so many?

    Every bootloader need a specific software to work. For some, that specific software is simply the terminal program like Hyperterm. For others, like TinyBootloader, you have to run it's software for it to work.
     
  14. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    eblc1388 ... i got it .. very clear explanation ... so now ... since im using the tiny bootloader codes, i'll have to use the software tinybootloader provides.. thanx alot....

    do u know how the IR module works with the PIC?? where is the receiver placed and where is the transmitter placed ?? wat components does the IR consist of and do i get it part by part or it's sold as 1 set?? if i use a joystick to control the direction of the motor .. how does a joystick send signal to the PIC?? and is the transmitter connected to the joystick ???
     
  15. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    The receiver is placed such that the IR beam from the transmitter can be seen.

    IR transmitter is just a diode like LED. It sends out IR instead of visible light. You can "see" the beam if you view it using a camera phone.

    The receiver is sold as a complete module, mostly with three pins. Two for supply and one for signal output. The signal is the ON/OFF pattern of IR beam.

    You'll need an interface between joystick and IR transmitter. You either build one or buy a cheap universal remote, use the internal components and wire the joystick switches to replace the original keys. You connect the receiver to one port pin of the PIC and using software to decode what command is being sent from the transmitter.
     
  16. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    ;*****************************************************************
    title "PIC PowerBoard: Program pre PIC18F452"
    subtitle "Version 1.00 (c) Jay.slovak 2005"
    ;*****************************************************************
    list p=18F452 R=DEC ; wat is this for
    #include <P18F452.INC>

    ERRORLEVEL 2 ; is it neccesary to put this?

    ;********** Definovanie uzivatelskych registrov *******************
    Fosc equ 20 ;Frekvencia Oscilatora v Mhz

    ZDRZ0 equ D'000' ;
    ZDRZ1 equ D'001'
    ZDRZ2 equ D'002'


    ;********** Zaciatok pamati programu ******************************
    ORG 0x0004 ; does it ont always start at 0?
    GOTO INIT
    ;********** Inicializacia procesora *******************************
    ORG 0x002A
    INIT MOVLW h'07' ; some led blinking program
    MOVWF ADCON1,a ; doesnt have this , will it still
    ; work??
    CLRF PORTA
    CLRF PORTB
    CLRF PORTC
    CLRF PORTD
    CLRF PORTE
    CLRF TRISA
    CLRF TRISB
    CLRF TRISC
    CLRF TRISD
    CLRF TRISE

    GOTO START
    ;********** Podprogramy Zdrzania @20Mhz *******************
    Zdrz8s CALL Zdrz4s ; this is the delay part, by how
    GOTO Zdrz4s ; much is the delay ?is it the
    ; same a the delay just below?
    Zdrz4s CALL Zdrz2s
    GOTO Zdrz2s

    Zdrz2s CALL Zdrz1s
    GOTO Zdrz1s

    Zdrz1s CALL Zdrz500m
    GOTO Zdrz500m

    Zdrz500m NOP
    MOVLW D'121'
    MOVWF ZDRZ0 ; i think Zdrz500m delays by
    MOVLW D'171' ; 500ms, but how is it here?
    MOVWF ZDRZ1 ;121+171+13?
    MOVLW D'13'
    MOVWF ZDRZ2
    GOTO Zdrz


    Zdrz100m NOP ; why do we use a nop ?? to delay ??
    NOP ; but i thought delay is done already ?
    MOVLW D'122'
    MOVWF ZDRZ0
    MOVLW D'137'
    MOVWF ZDRZ1
    MOVLW D'3'
    MOVWF ZDRZ2
    GOTO Zdrz

    Zdrz15m CALL Zdrz5m
    CALL Zdrz5m
    GOTO Zdrz5m

    Zdrz5m CALL Zdrz1m
    CALL Zdrz1m
    CALL Zdrz1m
    CALL Zdrz1m
    GOTO Zdrz1m

    Zdrz2m CALL Zdrz1m
    GOTO Zdrz1m

    Zdrz1m MOVLW D'140'
    MOVWF ZDRZ0
    MOVLW D'7'
    MOVWF ZDRZ1
    MOVLW D'1'
    MOVWF ZDRZ2
    NOP
    NOP
    GOTO Zdrz

    Zdrz100 CALL Zdrz40
    CALL Zdrz40
    CALL Zdrz10
    GOTO Zdrz10

    Zdrz40 CALL Zdrz10
    CALL Zdrz10
    CALL Zdrz10
    GOTO Zdrz10

    Zdrz10 MOVLW D'10'
    MOVWF ZDRZ0
    MOVLW D'1'
    MOVWF ZDRZ1
    MOVLW D'1'
    MOVWF ZDRZ2
    NOP
    NOP
    GOTO Zdrz

    Zdrz DECFSZ ZDRZ0,F
    GOTO Zdrz
    DECFSZ ZDRZ1,F
    GOTO Zdrz
    DECFSZ ZDRZ2,F
    GOTO Zdrz
    Return

    ;********** Hlavny Program *******************************
    Start SETF PORTA
    SETF PORTB
    SETF PORTC
    SETF PORTD
    SETF PORTE
    CALL Zdrz1s
    CLRF PORTA ; this part turns off the LED?
    CLRF PORTB
    CLRF PORTC
    CLRF PORTD
    CLRF PORTE
    CALL Zdrz1s

    GOTO Start
    end



    hi guys, i think i more or less understand the whole program , just that
    i'm a little confuse with the delay part, and for the one in bold that i commented , could u help me check if it's correct??
     
  17. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    any circuit diagrams or guide on how to do that ?? wat is a universal remote?
    i dun understand how to do it.. thanx

    is there any particular name for every IR module ?
    wat does"Serial port controlled infrared transmitter with PIC" means?
    is it the one i need to use ?? to control the direction of the wheelchair?? i am going to get the components soon, but i dont know how to buy it ? which one to choose ,
    i just repeat wat i need IR for ..
    i need to control the direction of the wheelchair manually ( with a sony joystick i guess, ) so the joystick tranmits the signal to the PIC to drive the motors ... so wat kind of IR module do i need??? is there any guide on how to connect all these parts? thanx alot
     
  18. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    Jay .... i tried to use the Tiny bootloader ... but it can't seem to work it shows this
     

    Attached Files:

    • tiny.jpg
      File size:
      281.3 KB
      Views:
      600
  19. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    hi guys,

    i just need some advice, i'm rushing to finish my current project and i'm really confuse, i don't know whether to learn c language or assembly, i need to submit my project in 3 weeks but i dont think i have time to learn either of them .. i tried to learn assembly but i think think it would really take quite some time to understand the whole thing... my C is a little ok ... well , at least it looks simpler and i could understand program i see quite fast, so i need some advice from u Pros to help me decide ... is there any tutorials about programming in C ?? i really need it urgently..
     
  20. Jay.slovak

    Jay.slovak Active Member

    Joined:
    Jan 11, 2005
    Messages:
    1,726
    Likes:
    5
    Did you program that PIC with bootloader HEX before with normal programmer? It won't work without it.
     
  21. kupikupi

    kupikupi New Member

    Joined:
    Aug 21, 2005
    Messages:
    84
    Likes:
    0
    yes... i did .. i changed this
    Code (text):
    LIST      P=18F4320 ; change also: Configure->SelectDevice from Mplab
    xtal EQU 20000000       ; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
    baud EQU 115200         ; standard TinyBld baud rates: 115200 or 19200
    to

    Code (text):
    LIST      P=18F452  ; change also: Configure->SelectDevice from Mplab
    xtal EQU 20000000       ; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
    baud EQU 19200          ; standard TinyBld baud rates: 115200 or 19200
    it's correct rite??

    but i think there might be a problem with the mplab in the lab.. i think i'll convert it to hex at home then try again ...

    thanx Jay ...
     

Share This Page