From: Spehro Pefhany on
On Fri, 5 Mar 2010 12:32:47 -0800 (PST), Chris
<christopher.maness(a)gmail.com> wrote:

>On Mar 5, 11:59�am, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote:
>> On a sunny day (Fri, 5 Mar 2010 11:11:38 -0800 (PST)) it happened Chris
>> <christopher.man...(a)gmail.com> wrote in
>> <29529065-09fc-4636-9a29-c618cbc16...(a)x1g2000prb.googlegroups.com>:
>>
>>
>>
>> >I have posted several threads about converting 24Hz pulses to 60Hz
>> >basically a 5/2 ratio. �I tried a phase locked loop, it sorta works,
>> >but my chip count is getting high, and I am thinking about making more
>> >of these and selling them if I can write a computer program to resolve
>> >wave sound files.
>>
>> >Therefore, since I am not very familiar with micro controllers, I was
>> >not planning on using one. �However, I remember an engineer friend of
>> >mine mentioning the BASIC stamp. �I have dabbled in BASIC so, I might
>> >approach the problem with this as a solution, especially if I can do
>> >it with one or two chips.
>>
>> >I would think that I could sample the 24Hz side for one second. �Take
>> >that number and use it to divide a �much higher frequency quartz
>> >reference by some large value of N so that I can get it back down to
>> >60Hz. �Therefore my lock time would be one second. �I can have an easy
>> >lock indication and a fairly fast response to any changes in
>> >frequency.
>>
>> >What do you guys/gals think?
>>
>> >Regards,
>> >Chris Maness
>>
>> Years ago I posted a PIC 50 Hz PLL asm code here.
>> Or maybe it was 25 Hz.
>> I would not bother with BASIC, likely way too slow, and way too much resources hungry.
>> A 1$50 12 pin PIC should do...
>
>What are some models that would be good for that application. I see
>some 8 pin models that are only $2. The only problem is that I have
>NO clue how to start programming them.
>
>Regards,
>Chris

Just write code to initialize and make an LED flash at a visible rate.
The rest is easy...


From: Jan Panteltje on
On a sunny day (Fri, 05 Mar 2010 13:12:55 -0800) it happened Tim Wescott
<tim(a)seemywebsite.now> wrote in
<rKGdnSd76K6p6QzWnZ2dnUVZ_oYAAAAA(a)web-ster.com>:

>> You DO need an oscilloscope in my opinion, else no clue what PIC does.
>>
>But then you need an oscilloscope for an analog PLL, or no clue what
>it's doing.

As we play with electrons, and those are so small we cannot see them,
we will always need some instrument.
A digital voltmeter on a PIC output does give a nice voltage depending on the
duty cycle though.
If you play with the PLL in the audio range, you can get a lot of info by feeding it into an amp.
Even for higher frequencies by AC coupling the error voltage into an audio amp... etc etc.
All tricks I have used.
A 4046 makes a great audio FM modulator and demodulator too.

From: linnix on
On Mar 5, 2:29 pm, Spehro Pefhany <speffS...(a)interlogDOTyou.knowwhat>
wrote:
> On Fri, 5 Mar 2010 12:32:47 -0800 (PST), Chris
>
>
>
> <christopher.man...(a)gmail.com> wrote:
> >On Mar 5, 11:59 am, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote:
> >> On a sunny day (Fri, 5 Mar 2010 11:11:38 -0800 (PST)) it happened Chris
> >> <christopher.man...(a)gmail.com> wrote in
> >> <29529065-09fc-4636-9a29-c618cbc16...(a)x1g2000prb.googlegroups.com>:
>
> >> >I have posted several threads about converting 24Hz pulses to 60Hz
> >> >basically a 5/2 ratio.  I tried a phase locked loop, it sorta works,
> >> >but my chip count is getting high, and I am thinking about making more
> >> >of these and selling them if I can write a computer program to resolve
> >> >wave sound files.
>
> >> >Therefore, since I am not very familiar with micro controllers, I was
> >> >not planning on using one.  However, I remember an engineer friend of
> >> >mine mentioning the BASIC stamp.  I have dabbled in BASIC so, I might
> >> >approach the problem with this as a solution, especially if I can do
> >> >it with one or two chips.
>
> >> >I would think that I could sample the 24Hz side for one second.  Take
> >> >that number and use it to divide a  much higher frequency quartz
> >> >reference by some large value of N so that I can get it back down to
> >> >60Hz.  Therefore my lock time would be one second.  I can have an easy
> >> >lock indication and a fairly fast response to any changes in
> >> >frequency.
>
> >> >What do you guys/gals think?
>
> >> >Regards,
> >> >Chris Maness
>
> >> Years ago I posted a PIC 50 Hz PLL asm code here.
> >> Or maybe it was 25 Hz.
> >> I would not bother with BASIC, likely way too slow, and way too much resources hungry.
> >> A 1$50 12 pin PIC should do...
>
> >What are some models that would be good for that application.  I see
> >some 8 pin models that are only $2.  The only problem is that I have
> >NO clue how to start programming them.
>
> >Regards,
> >Chris
>
> Just write code to initialize and make an LED flash at a visible rate.
> The rest is easy...

Or something like this:

loop()
{
// sample 24Hz input
now = ACSR & (1<<INPUT_BIT_NUMBER); // Analog comparator
if(now && !before) // rising edge
{
// reload 60Hz timer
TCCR1B = 3; // prescale by 64
n = 2083; // 8,000,000 / 64 / 60
TCNT1H = (n<<8)&0xff;
TCNT1L = (n)&0xff;
}
before = now;
}

On_Timer1_Interrupt()
{
// pulse 60Hz output
}
From: Chris on
@linnix

p.s.

One more thing. I am really interested in what you did for your
debounce. I was planning on using a NE555 in monostable mode for 20ms
pulse to clean up the debounce. I was also planning on using a NE555
in mono for 60ms to latch and stay on as long as there is input into
the converter box, but shut the loop down when there is no input. I
do not want pulses going to the tape deck when the movie camera is not
running.

Regards,

and thanks a ton all of you guys,
Chris Maness
From: linnix on
On Mar 5, 8:00 pm, Chris <christopher.man...(a)gmail.com> wrote:
> @linnix
>
> p.s.
>
> One more thing.  I am really interested in what you did for your
> debounce.

For debouncing, you can just wait a few msec after the loop, or just
do some other processings.

> I was planning on using a NE555 in monostable mode for 20ms
> pulse to clean up the debounce.  

Atmel's PIC (Programmable IC) with crystal is far more accurate than
the 555.

> I was also planning on using a NE555
> in mono for 60ms to latch and stay on as long as there is input into
> the converter box, but shut the loop down when there is no input.  I
> do not want pulses going to the tape deck when the movie camera is not
> running.

So, limit the timer interrupt free-running counts.

Since you want a square output, use 120Hz timer interrupt.

Revised code:

loop()
{
// Analog comparator sample 24Hz input
now = ACSR & (1<<INPUT_BIT_NUMBER);
if(now && !before) // rising edge
{
// reload 120Hz timer
TCCR1B = 3; // prescale by 64
n = 1541; // 8,000,000 / 64 / 120
TCNT1H = (n<<8)&0xff;
TCNT1L = (n)&0xff;
run = 0;
// enable timer1 interrupt
}
before = now;

}

On_Timer1_Interrupt()
{
// toggle 60Hz output bit
OUTPUT_PORT ^= (1<<OUTPUT_BIT_NUMBER);
if(++run < 3)
//enable timer1 interrupt
}