![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips. |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#2
| |||
| |||
Hi The info you need is in the books supplied at this website https://www.sq-1.com/ I have purchased all but a couple of these books and they are brilliant. Wanna be to for the cost to get them to Australia lol. Seriously check it out . The books I would look at buying first are Easy Microcontrol'n and Microcontol'n Apps/ Also check out tutorial 10 on this website http://www.winpicprog.co.uk/pic_tutorial.htm. If you want a specific program written let me know and I will see what I can do? Buy the way also check out www.oshonsoft.com they have excellent pic simulators where you can write the program In MPlab ide then open it up in and see exactley what will happen, has a pretty good range of input and output screens eg lcd, led, 7 seg, switches etc. Cheers Greg |
|
#3
| ||||
| ||||
| Also I would have though you would get everything for this off the PicMicro site, all their app notes have sample code? Al.
__________________ CNC, Mechatronics Integration and Machine Design. “Logic will get you from A to B. Imagination will take you everywhere.” Albert E. |
|
#4
| |||
| |||
Thank you for the replies! So here is my code. Note the PIC is a 16F628A becuase I dont have a pic16F84 and am testing it with the newer one. The next thing to notice is that I have some trouble with the TMR0 register so I generated a simple loop to simulate the dalay. If some one has the time I would appreciate the help. Note allso that I need to make the delay with 16 prescaler and if someone coud explain me what this is. Code: list p=16f628a #INCLUDE <P16F628a.INC> __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _LVP_OFF count1 res 1 count2 res 1 count3 res 1 MOVLW 0X07 MOVWF CMCON BSF STATUS , RP0 MOVLW b'00000' MOVWF TRISA MOVLW b'00000000' MOVWF TRISB BCF STATUS , RP0 ;——————————- ZACETEK MOVLW b'00111111' ; 0 MOVWF PORTB call Delay500mS MOVLW b'00000110' ; 1 MOVWF PORTB call Delay500mS MOVLW b'01011011' ; 2 MOVWF PORTB call Delay500mS MOVLW b'01001111' ; 3 MOVWF PORTB call Delay500mS MOVLW b'01100110' ; 4 MOVWF PORTB call Delay500mS MOVLW b'01101101' ; 5 MOVWF PORTB call Delay500mS MOVLW b'01111101' ; 6 MOVWF PORTB call Delay500mS MOVLW b'00000111' ; 7 MOVWF PORTB call Delay500mS MOVLW b'01111111' ; 8 MOVWF PORTB call Delay500mS MOVLW b'01101111' ; 9 MOVWF PORTB call Delay500mS MOVLW b'01110111' ; A MOVWF PORTB call Delay500mS MOVLW b'01111100' ; b MOVWF PORTB call Delay500mS MOVLW b'00111001' ; C MOVWF PORTB call Delay500mS MOVLW b'01011110' ; d MOVWF PORTB call Delay500mS MOVLW b'01111001' ; E MOVWF PORTB call Delay500mS MOVLW b'01110001' ; F MOVWF PORTB call Delay500mS GOTO ZACETEK Delay500mS movlw .3 movwf count1 movlw .140 movwf count2 movlw .82 movwf count3 dloop1 decfsz count3,f goto dloop1 decfsz count2,f goto dloop1 decfsz count1,f goto dloop1 return END |
|
#7
| |||
| |||
| Hi Razer The way I see it with a crystal of 4Mhz, it gives you a cycle time of 1/(Fosc/4) , or 1uS. The maximum prescaler available is 256, which will leave the maximum TMR0 timeout at a quarter of a millisecond, not really useful if you want 0.5 seconds. Added to this, if you want to use timer 0 you will need to use interrupt driven software. At a Microchip seminar one of their inhouse troubleshooting experts said that 90% of PIC firmware problems came from interrupt routines. He advised us to avoid interrupts if at all possible. I like using delay routines like you have. If you insist on using the TMR0 you'll have to use a prescaler of 256 on a crystal frquency of 2 kHz. The prescaler is defined in the final 3 bits of the OPTION_REG register and clearing bit 3 of the same register to allocate the prescaler to Timer 0. ( ie your code should place the binary string xxxx0111 in OPTION_REG . you determine what replaces the xxxx according to your software requirements) |
|
#8
| |||
| |||
| James, What do you mean by ".....which will leave the maximum TMR0 timeout at a quarter of a millisecond"? Do you mean TMR0 will overflow in a quarter of a millisecond with a 256 prescaler? I get a different time with my calculations. The timer0 also needs to count to 256 before an overflow. TMR0 overflow = (1/(Fosc/4))*256*256 = 65.536 milliseconds. The first 256 in the equation is for the prescaler time divider. The second 256 is the actual TMR0 counting from 0 to 256. ~~~~~~~~~~~~~~~~~~~~~~ You could implement this problem using TMR0 and an interrupt service routine. If you change the prescaler from 256 to 16 you get a TMR0 overflow every 4.096 milliseconds. TMR0 overflow = (1/Fosc/4))*16*256 = 4.096 milliseconds. Now, if you count the number of TMR overflows to 122 you get a time lapse of about 0.5 seconds. You TMR0 interrupt service routine can count the number of overflows. Time lapse = 4.096 * 122 = 0.499712 seconds. (0.06 % error) |
|
#9
| |||
| |||
| Hi Megahertz. Thanks for the correction, you're perfectly right. The point I was trying to get across is that by using a well set up delay routine , Razer would avoid using interrupt routines. I have avoided using interrupts thus far and always had success. Thanks for your help. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| (DAEWOO) Fanuc System 6T with seven segment & LED display?? | parametric.ms | Fanuc | 3 | 03-26-2010 08:09 AM |
| Need Help!- Ver. 21 - How to add an end plate to Extruded Curve Segment | Sam A | BobCad-Cam | 5 | 10-02-2008 10:28 AM |
| Newbie- Multi Segment Acrylic Telescope Design and mold making | Mustafa Umut | Glass, Plastic and Stone | 0 | 06-18-2008 07:24 PM |
| RPM display | fatal-exception | Mach Mill | 0 | 11-24-2007 03:02 PM |
| DAKENG u-2 16f84 stepper translator | vacpress | PIC Programing / Design | 2 | 12-13-2005 07:58 AM |