![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Ok, we may be getting closer. That period and those duty cycles will be relatively easy to do even on a small 8 pin PIC microcontroller. I would like to check out the controller data sheet but neither of those pdf file links are bringing up my Acroread program. Let me investigate. I may have a problem with some ad-ware on my laptop (argh!!!)... | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Just tried the two links in Foxfire and they opened with the Foxfire/adobe plugin. Try these links...they are from the Manufacturer's websites http://www.lumileds.com/pdfs/DS46.pdf http://www.leddynamics.com/LuxDrive/...1-BuckPuck.pdf | |
| |
| | (permalink) |
| If you setup a basic interrupt to count seconds and minutes, then your 90% through the battle. EG; Code: Device = 18F452
Clock = 20
Dim TMR2IE As PIE1.1, // TMR2 interrupt enable
TMR2IF As PIR1.1, // TMR2 overflow flag
TMR2ON As T2CON.2, // Enables TMR2 to begin incrementing
mS As Word, // mS register
S As Byte, // Seconds register
M As Byte // Minutes register
Interrupt TMR2_Interrupt()
Save(0) // Back up system variables
If TMR2IF = 1 Then // Check if the interrupt was from TMR2
TMR2IF = 0 // Clear the TMR2 interrupt flag
Inc(mS) // Increment the mS counter
If mS = 1000 Then
mS = 0
Inc(S)
If S = 60 Then
S = 0
Inc(Min)
EndIf
EndIf
EndIf //
Restore // Restore system variables
End Interrupt
Private Sub TMR2_Initialize()
TMR2ON = 0 // Disable TMR2
TMR2IE = 0 // Turn off TMR2 interrupts
T2CON.0 = 1 // 00 = Prescaler is 1
T2CON.1 = 0 // 01 = Prescaler is 4
// 1x = Prescaler is 16
PR2 = 249 // TMR2 Period register PR2
T2CON.3 = 0 // 0000 = 1:1 postscale
T2CON.4 = 0 // 0001 = 1:2 postscale
T2CON.5 = 1 // 0010 = 1:3 postscale...
T2CON.6 = 0 // 1111 = 1:16 postscale
TMR2 = 0 // Reset TMR2 Value
TMR2IE = 1 // Enable TMR2 interrupts
TMR2ON = 1 // Enable TMR2 to increment
Enable(TMR2_Interrupt)
End Sub
// Start Of Program...
mS = 0 // Reset Timer registers
S = 0
M = 0
TMR2_Initialize // Setup and enable TMR2
__________________ Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net Last edited by gramo; 6th October 2007 at 12:24 AM. | |
| |
| | (permalink) |
| The above program will provide an interrupt driven timer. Very useful tool for countless applications, for your use, perhaps the "main program" could consist of; Code: Include "PWM.bas"
// local duty variable...
Dim Duty As Word
// main program...
Duty = 40
PWM.SetFreq(10000, 40) // Initialize the Duty output (10Khz @ 40% Duty)
While Duty < 100 // Create loop to reach 100% duty
While M < 1 // Wait for 1 minute to occur
Wend
M = 0 // Reset the Minute register
Inc(Duty, 5) // Increase the Duty Cycle by 5%
PWM.SetDuty(Duty) // Set the new duty cycle
Wend
While True // 40-100% has finished, loop for ever here
Wend
__________________ Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net | |
| |
| | (permalink) | |
| Quote:
GRAMO, thanks for the code. With each new project I tackle I realize not only the benefits but the need to learn to program micro controllers...etc. My next post may very well be for assistance on which programmer, software...yada yada yada... iONic Last edited by iONic; 5th October 2007 at 11:00 PM. | ||
| |
| | (permalink) | |
| Quote:
Perfectly you are thinking-- as learning is a continuous process
__________________ Regards, Sarma. | ||
| |
| | (permalink) | |
| Quote:
Yes indeed. I knew that and love learning new things, but have been complacent in m was. I have returned once again. | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| 'schematic software' needed for microcontroller | kiranmayi | Micro Controllers | 9 | 11th February 2007 04:42 PM |
| help needed .. data storage from microcontroller to pen drive | amit_kr | Micro Controllers | 4 | 5th June 2006 04:43 PM |
| Programming the Mini-Max 8051 microcontroller | blimon | Micro Controllers | 8 | 13th July 2005 03:42 AM |
| Connection of Siemens c167 microcontroller to peripherals. | Roslan | Electronic Projects Design/Ideas/Reviews | 3 | 23rd March 2004 07:52 PM |
| Microcontroller Simplest Project Help needed | waqar | Electronic Projects Design/Ideas/Reviews | 0 | 1st April 2003 01:53 PM |