PDA

View Full Version : I have a couple of questions

ccake
03-12-2010, 02:13 AM
Hi All

I'm a newbie here.· I have a couple of questions about using Pics for counting and converting binary count to BCD.· I'm kinda new to these Pic processors.· I got a Basic Stamp Homework Board for Christmas. Have been going thru the book trying to learn.· Also have ordered a sampling of Picaxe chips too.· My Idea was to go to the mpu route for all my future bench test equipment projects.

My first project this year is a UHF Frequency Counter.· And I have already gotten the UHF pre-scaler (divide by 16) working.· But have been stumped trying to decide how to convert the Binary count from the prescalers back into Decimal.· Looks like regular logic ICs will require a bit of construction effort.

So my question is - can I use a pic (BS2 or Picaxe) to count down to 6-digits and convert the binary to BCD?

I want to use 6 each 7-segmant LED displays in the counter.

I kinda have an Idea what needs to be done, just need help in deciding which way to go and what hardware to use.

My initial design was to use discrete logic ICs for the counter, but I ran into a snag with the UHF prescaler. I had some trouble trying to convert the Binary count back into Decimal.· That got me to consider using either the BS2 or a Picaxe.

Any Ideas anyone?

Post Edited By Moderator (Joshua Donelson (Parallax)) : 3/12/2010 12:25:00 AM GMT

Mike Green
03-12-2010, 02:32 AM
A BS2 is not a PIC. The BS1 and BS2 Stamps use a PIC for their microprocessor, but both include a Basic interpreter and cannot be programmed in native PIC instructions. Other BS2 Stamp models use a different microprocessor entirely (the Scenix SX) which also can only be programmed in compiled Basic.

Because of the interpreter, instruction execution time is much slower than that of the native PIC, on the order of 100s of microseconds for simple operations. The Stamps could be used for counting and converting binary to displayable information, but not at the speeds you sound like you need. One of the primitive operations in Stamp Basic is a COUNT statement which counts the number of pulses presented to an I/O pin during a user specified interval expressed in milliseconds and a minimum pulse width of just under 5us. Your counter would only be able to handle frequencies over 4MHz with a divide by 16 prescaler. You could certainly use an additional counter to use as a further prescaler. Another alternative would be to use a Propeller instead of a Stamp. The Propeller can easily handle the displays and can count pulses up to about 40MHz using the built-in counters.

ccake
03-12-2010, 11:22 AM
Thanks Mike.·· Guess I have a lot more 'learning' to do on these processors.· I like electronics hobby but up to now, have mostly used discrete components for stuff.

Have been trying to find a good circuit for dividing by 25, or dividing by 125 (for the divide by 4 prescaler), to get my binary count converted back to decimal. That had caused me to wonder if the BS2 or Picaxe might work.· I don't even have the programmer downloaded yet for those 'other' chips. And still trying to do basic circuits on the BS2 breadboard.· Not smart enough yet to design any counters in basic.· And I already have all the main parts for a discrete circuit counter. I guess thats how I'll go. Until I learn more.

Someone suggested if I would divide the Time base counter by the same 'prescale' value and then gate the displays using that, then I'd be good.· It works out ok on paper. Some day I want to do such as this with micro-processors

Regards...· CCake

Mike Green
03-12-2010, 12:26 PM
Do look at the description of the COUNT statement in the BASIC Stamp Syntax and Reference Manual (here: www.parallax.com/tabid/440/Default.aspx (http://www.parallax.com/tabid/440/Default.aspx)). If you add another 8 bits of prescaling counter, that would theoretically put your maximum frequency at 1000MHz. Keep in mind that the accuracy of the Stamp's time base is limited. It uses a resonator which isn't as accurate as a crystal and that would be limited anyway with manufacturing limitations and temperature sensitivity.