Reply by Don Kinzer October 28, 20052005-10-28
--- In basicx@basi..., Wim Nijntjes <wimn@r...> wrote:
> Why would you make it more complicated than it is?
> Why adding external one-shots?

The design of embedded systems involves many trade-offs, including the
hardware/software trade-offs. Sometimes, adding a bit of external
hardware solves a difficult problem whose solution fully in software
is "too expensive" in terms of the limited resources available - time,
RAM, code space, etc. Also, a software-only solution may not provide
the accuracy that is required in a particular circumstance.

It may be that using Delay() to implement the timing necessary for
accurate pulse width discrimination is a pefect solution in your
situation. Be aware, however, that Delay() only guarantees a
*minimum* delay, not a *maximum* delay. Depending on what other tasks
in your system are doing, the actual delay could be much longer than
the maximum delay that would allow accurate discrimination.

Don



Reply by Wim Nijntjes October 28, 20052005-10-28
Why would you make it more complicated than it is?
Why adding external one-shots?
The call sleep() does the same thing.
Now it works, just some formatting stuff to do.
Look:

00000000000000001001100100000100010000101101000011010000
01
22:9 28-10-5

0000000000000000100100001001010001000010110100001101000001
22:10 28-10-5 Public Sub Main()

Call PutPin(DCF77,bxInputPullup)
do
tb = 0.0
do while (tb < 1.2)
t1 = timer
call getbit(bit)
debug.print cstr(bit)
t2 = timer
tb = t2 - t1
debug.print cstr(tb)
loop

debug.print "Sync gevonden"
dim i as integer
for i = 1 to 58
call getbit(bit)
debug.print cstr(bit);
index = i
call leesbaar(index,bit)
next
debug.print

debug.print cstr(uur);":";cstr(minute);"
";cstr(cal);"-";cstr(maand);"-";cstr(jaar)
loop
end sub sub getbit(bit as integer)
CB = 0

do while (cb = 0) 'Wait for a 1
CB = GetPin(DCF77) 'Get clock output
loop

call sleep(60) 'pass the 100mSec
CB = GetPin(DCF77) 'Get clock output
if (cb = 1 ) then 'still a 1 ?
bit =1 'So it's a long pulse
else
bit = 0 'It's a short pulse
end if
call sleep(100) 'to prevent entering the do-while
with a value of 1
end sub
--- arhodes19044 <spamiam@spam...> wrote:

> --- In basicx@basi..., "Don Kinzer"
> <dkinzer@e...> wrote:
> > Would that it were so. The formula is fairly
> simple. The pulse
> width
> > is 0.45 * R * C for the LS123.
>
> Yeah, I thought you put a bit more effort in your
> reply than your words
> suggested.
>
> -T >
>


Wim Nijntjes
Oranjekanaal 38 NZ
9415TP Hijken
The Netherlands

__________________________________


Reply by arhodes19044 October 28, 20052005-10-28
--- In basicx@basi..., "Don Kinzer" <dkinzer@e...> wrote:
> Would that it were so. The formula is fairly simple. The pulse
width
> is 0.45 * R * C for the LS123.

Yeah, I thought you put a bit more effort in your reply than your words
suggested.

-T



Reply by Don Kinzer October 28, 20052005-10-28
--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> Do you just know the R & C values off
> the top of your head for the 1-shot...

Would that it were so. The formula is fairly simple. The pulse width
is 0.45 * R * C for the LS123. It's different for other
technologies. With the HC series, it also varies based on supply
voltage.

Don


Reply by Wim Nijntjes October 28, 20052005-10-28
Tom, I got it working now. Surprizing short piece of
code afterward.
I'm not shure if it's realy failsave and how reliable
my receiver delivers it's pulses.

Thanks for your inputs!

Wim

--- Tom Becker <gtbecker@gtbe...> wrote:

> Actually, now that I think about it, my
> MSF/DCF77/WWVB decoder is an
> assembly language TSR...[]


Reply by Wim Nijntjes October 27, 20052005-10-27
Works! so simple afterward. do
CB = 0

'Wait for a 1
do while (cb = 0)
CB = GetPin(DCF77) 'Get clock output
loop

call sleep(60) 'pass the 100mSec
CB = GetPin(DCF77) 'Get clock output
if (cb = 1 ) then 'still a 1 ?
bit =1 'So it's a long pulse
else
bit = 0 'It's a short pulse
end if
debug.print cstr(bit)
call sleep(100) 'to prevent in enters the
'do-while with a value of 1
loop


Reply by Wim Nijntjes October 27, 20052005-10-27
Don, I'm close to the solution I think.
I now use 2 do while loops.

First waits for the raising edge. Next is starting a sleep of 120 mSec
Then a check if it's still high.
If not we have a short ( 100mSec)
If yes we have a long ( 200mSec)

Wim
[]


Reply by arhodes19044 October 27, 20052005-10-27
That is a nice "quick" sketch! Do you just know the R & C values off
the top of your head for the 1-shot (3.3M, 0.1uF)?

-Tony


Reply by Tom Becker October 27, 20052005-10-27
Actually, now that I think about it, my MSF/DCF77/WWVB decoder is an
assembly language TSR, so it will be of little use. I was thinking it
was a QuickBasic app that might be useful for structure, but I doubt
the assembly code will serve any useful purpose. Tom



Reply by Don Kinzer October 27, 20052005-10-27
--- In basicx@basi..., "wimn.rm" <wimn@r...> wrote:
> I need to measure incoming pulses of 100 and 200 milliseconds.

On further reflection, I assume that you're trying to decode the
pulse-width-modulated DCF77 signal. In that case, you might
consider using external hardware to discriminate between the pulse
widths.

One way to do that simply is to use a one-shot that is triggered by
the incoming pulse. The pulse width of the one-shot should be set
to 150mS. Use the trailing edge of the one-shot's pulse to clock a
D flop whose data input is the original pulse signal. If the
original pulse was 100mS long the D flop will store a zero and if it
was the longer 200mS pulse it will store a 1.

The trailing edge of the one-shot's pulse could also set another
flip-flop to indicate that data is ready to be read. Your code
would then read the D flop output and then reset the "data-ready"
flip-flop.

I've put a quick sketch of such a circuit at:
http://www.kinzers.com/don/BX24/dcf77.jpg

The proposed circuit requires 3 I/O pins on the BX-24 but you could
reduce that to 2 by using the /RESET output to multiplex the DATA
RDY and DATA signals.

Don