PIC Basic LED Clock

Status
Not open for further replies.

robadobalus

New Member
Hello,

For an A2 electronics project I am making an LED clock with the use of PIC's.

To start with I have one pic generating a steady accurate 1hz pulse. This clocks into shift registers for 60 seconds before resetting. I plan to take the 60th pulse and use that as a minute pulse for the next sub system. I plan to use PIC 16F882/883/886 in a dot matrix configuration to give me x64 combinations and then use the 60th output to reset the count and be the hourly clock for my final sub system; which will include a 16F84A.

I am planning to use the Timer0 module inside the pic's to count the number of pulses on a specific pin and then with this information stored I can write the rest of the program.

At the moment I have written the hour program but it does not seem to be working properly. I have read through the data sheet and have done what I think should work...

As I am new to PIC Basic programming am writing the program as simple as possible so that I can see what I am doing. At the moment its just the program that is holding me back, as I have completed all the hardware and everything else, so If anyone can see what I have got wrong in the program any advice would be appreciated. I am not 100% sure on how to use the timer0 module and all my googling seems to have come up with stuff with isnt basic enough for my level or just not explain how to write the program for the timer module.

Thanks,

Rob
P.s. the program is added below.

Device = 16F84
XTAL = 4

Start:
OPTION_REG = %10111000
TRISA = %10000
TRISB = %00000000
PORTB = 0
PRTA = 0

Dim Timing As Byte 'Declare Timing as value 0 to 255

Timing = TMR0 'Vairable timing should be data from the Timer

Timer:
If Timing = 0 Then PORTB.0 = 1
If Timing = 1 Then PORTB.1 = 1
If Timing = 2 Then PORTB.2 = 1
If Timing = 3 Then PORTB.3 = 1
If Timing = 4 Then PORTB.4 = 1
If Timing = 5 Then PORTB.5 = 1
If Timing = 6 Then PORTB.6 = 1
If Timing = 7 Then PORTB.7 = 1
If Timing = 8 Then PORTA.0 = 1
If Timing = 9 Then PORTA.1 = 1
If Timing = 10 Then PORTA.2 = 1
If Timing = 11 Then PORTA.3 = 1
If Timing = 12 Then TMR0 = 0
GoTo Timer
 
Sadly its the only way i can do it because its what we have been taught in our Alevel Electronics course.

Any ideas on the code?
 
Schematic

Have attached a Circuit Drawing of how I intend to wire up the circuit. The orange section shows how I would like to do the Minuites and the Red section the Hours. This is the section of Program I need to write.

I have also attached a flowdiagram of how I thought about running the program, however as new to Basic can't work out the code.

Any tips would be appreciated.

Thanks,

Rob
 

Attachments

  • Elec Flowdiagram V2.pdf
    5.1 KB · Views: 426
  • LED Clock.pdf
    67.4 KB · Views: 493
Hi Rob,

The 60 "second" LEDs and the 12 "hour" LEDs are pretty self-explanatory but what are you doin' with the 8x8 matrix?

Mike
 
Hi Rob,

The 60 "second" LEDs and the 12 "hour" LEDs are pretty self-explanatory but what are you doin' with the 8x8 matrix?

Mike

Using it as a Dot matrix. Basically using the 16 outputs from the PIC to give me 64 outputs. I could have a 10x6 matrix as there 60 minuites in an hour instead.

Hope that makes sense.

Rob
 
I suppose the real question i should be asking is if anyone has an example program in Basic using the Timer0 module in the 16F84 to count an external amount of pulses and then re-set after x pulses.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…