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.

Would you rather build a clock or a frequency counter?

Status
Not open for further replies.
Hmm I'll have to read through the listing, I am using Timer0 but not the prescaler. I thought there was no way to read the prescaler data.
And they say a clock is more work... (Already made a basic clock twas easy)

I'd like to use timer0 for the counter
timer1 is the timebase
timer2 is display refresh
 
Last edited:
blueroomelectronics said:
Hmm I'll have to read through the listing, I am using Timer0 but not the prescaler. I thought there was no way to read the prescaler data.
And they say a clock is more work... (Already made a basic clock twas easy)

I'd like to use timer0 for the counter
timer1 is the timebase
timer2 is display refresh
Gosh, you really didn't take time to look at that listing, did you? Or the "Flush" routine I provided on the first page of this thread? Or perhaps you just didn't recognize what it was?

Your designs and your code seem to indicate you're not thinking about using PIC resources efficiently, yet. Timer 2 can easily be used for the display refresh and a Clock timebase or a Frequency Counter timebase. Dedicating RB6 and RB7 for the ICD2 may be handy on one design but for Pete's sake, not on every design. Hell, that's what the Simulator is for.

You seem to want to learn things on your own so I'll shut up, leave you alone, and stop trying to make suggestions to get you thinking along a different path (grin).

... A Clock is harder if it's done the right way. You have to come up with a simple method for flashing each display group when in Set mode, debounce switches, manage the various displays (Clock, Calendar, Alarm, Appliance Timer, Outside Temp, Inside Temp), etc.
 
I posted an early version of the schematic on this site. Your suggestions Mike were using a specialized shift register instead of a CMOS chip and some .10 transistors.
Not one mention of USER I/O assignment and I thought carefully about pin assignments.

I will generally leave MCLR, PGC & PGD dedicated to the ICD2 as these are educational kits aimed squarely at hobbiests, students & experimenters much like to oodles of demo boards out there. You don't use the debugger but most everone else that uses an ICD seems to think it's a great thing myself included. I've retired my old ICE as the modules were getting too expensive and the debugger is a teriffic tool IMHO.

I do take advice and haven't had a chance to fully go through the code yet as just glancing at it gives me ideas. I changed the display to single digits per the advice of Gayan, but missed the rather minor but wish I spotted it Pommie suggestion of swapping RA6 & RA7

I did want ports AN1 & AN2 available and thought the I2C ports were also handy. TMR0 is available too and I'm having lots of fun with the kit.
 
Wow Mike that empty the prescaler routine is very cool, I'm not sure but are you gating TMR0 using the TRIS? This would mean some form of hardware buffer on the pin as your making an input into a output.
 
blueroomelectronics said:
I'm not sure but are you gating TMR0 using the TRIS? This would mean some form of hardware buffer on the pin as your making an input into a output.
Use a 1K resistor on the T0CKI input as a "load" for your frequency counter input conditioning circuitry when T0CKI is an output (R4 in the example below)...
 

Attachments

  • Freq Counter - Serial 12F683.JPG
    Freq Counter - Serial 12F683.JPG
    49.7 KB · Views: 156
It also occured to me on chips with an open collector RA4 it wouldn't matter if you made the pin an output and pulled it high.

I wonder how fast the comparators are? can they do 50MHz?

Your schematic reminds me of a cheap logic probe I wanted to build.
Basically an 8 pin PIC with 3 LEDs instead of the RS232 like yours.
Would act like a normal logic probe till > 10Hz (High, Low, Open)
then at 10Hz or higher (1s, 10s, multiplier) flashing LEDs
 
Last edited:
Bill,

I've been having a hard time trying to decipher your Clock code. Could you tell me what the interrupt interval is please?

<added>

Forgive me. I got it. 512 interrupts per second.
 
Last edited:
LOL I owe that routine to Pommie, I used to wish Timer1 wasn't a 16bit timer with a 32KHz crystal, that special CCP1 mode works very nicely.
My keyboard routine is crude but workable.

Looks like the next kit will be Ladybug LAN controller
6 relays (ULN2803 driver), 4 opto iso inputs, ENC28J60, LCD/expansion connector, PIC18F4620, 25LCxxx EEPROM, RS485
Slightly larger than my typical designs, but should integrate nicely with the lab.

Similar to the attached design with a few changes that I'll post here before I have the PCBs made.

PS Mike, if you can get a frequency counter running on the Dragonfly I'll send you a Ladybug PCB when they're done. I'd like to post the code as a project of the week with credit to yourself of course.
 

Attachments

  • PIC18F4620-ENC28J60-1.5b.pdf
    333.9 KB · Views: 167
Last edited:
blueroomelectronics said:
PS Mike, if you can get a frequency counter running on the Dragonfly I'll send you a Ladybug PCB when they're done. I'd like to post the code as a project of the week with credit to yourself of course.
I'm still in the process of cleaning up your Clock code. Gads, what a mess. I'm adding significant comments and streamlining it a bit and will pass it along for you to look at (uh, ignore... grin).

Still haven't figured out why you flipped a couple display digits for pseudo colons. They're in the wrong place, aren't they?

Anyway, a Frequency Counter, an Appliance Timer or Photo Timer, and some other simple apps' are easy enough. Unfortunately, I'm not sure how to implement multi-function apps' without that 7th column of indicator LEDs I suggested. Just no simple way to tell you're lookin' at the Alarm display or the Clock display or the Calendar display, unless we use the decimal points with a legend underneath, or something like that.
 
There's that wee LED at the top, as long as you're not using RS485 makes a handy indicator.

Alarm displays don't need all 6 digits, you could say ALxxxx when setting the alarm function. or xx:xx_A _B _C _D etc for multiple alarms.

Never thought about a calender on the thing, could display it as Jun_23
I've posted my own seven segment font on the site with alphabet in the download section even has the normal/flipped digit colons.

The reversed final colon was not intended as a colon but an degree indicator for temperature 23'c sort of thing. If it's a counter just put all the decimals along the bottom when you build it... or flip the colon xx:xx:xx would be common, a socket works but is so ugly.

PS the 100ohm current limiters when used with Super or HE red displays is very very bright. 470ohm calms it down to bright. I'd install those last and play with the values before soldering them in.

And yes my code can be crude
 
Hi Bill,

Just wanted to say that your code is becoming more impressive as I study it. It's always interesting to me to see how someone else tackles a problem and comes up with a creative solution I never would have thought of. For example, you've come up with a simple intuitive way to implement "repeat" switch capability by simply polling the switches once per second in the ISR. Genius!

I would only suggest some comments before significant code sections that explain what you're doing.

Mike
 
Thanks Mike.
Building electronics and programming is like a art, I'll look at code and see something new all the time. The hard part is feeling it's good enough to publish but often never feels quite finished :) Always want to tweak it a little more. Same with PCB design, drives my girlfriend crazy when I'm looking at the layout over and over.

PS having fun with the Ladybug SPI stuff and an ENC28J60. Quite the chip. I've used I2C before but never SPI.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top