Discussion forum for the BasicX family of microcontroller chips.
handling multiple interrupt sources? - arhodes19044 - Mar 27 10:39:00 2005
I have gotten the basics done on the rally computer.
I would like to have the timer generate an interrupt. I COULD do
this the crude way and have the PWM generator make something that
ticks at about one Hz, or a simple multiple thereof.
I could route the output of that to Pin 11 and trigger an
interrupt. However, I am already using Pin 11 for the wheel tick
interrupt.
So, I need to have either the wheel and/or the timer set off the
interrupt. But then I need to decide what one (or both) did it.
I am pretty sure this would be a simple TTL logic problem. But I
need to keep the source flagged (even if it goes off in the
interim) Until I have read it and then reset it. I assume I would
need a BX pin to reset each all the flags simultaneously [this might
need the use of an AND to reset only if the reset pin is high AND
the flag is high], and one other (pin 11) to create the interrupt.
Probably need another pin to read which interrupts actually need
servicing.
Is this a use of a "latch". I never used them or knew their actual
function. Maybe?? a 2 input XOR (inputs being the reset pin, and
its own output OR'ed with the interrupt. The reset pin probably
needs to be AND'ed with the XOR output so it does not toggle.
I don't know all the permutations of TTL devices. I bet there is
one device that does all this stuff internally!
-Tony
I knew I kept those TTL DIPs around for a reason
-Tony

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: handling multiple interrupt sources? - Don Kinzer - Mar 27 14:31:00 2005
--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> So, I need to have either the wheel and/or the timer set off the
> interrupt. But then I need to decide what one (or both) did it.
The external hardware that you need to combine input signals depends
on the nature of the signals. Are the levels important or is it the
edges.
If both signals are levels, you can use an S-R latch to "capture" the
fact that the level of interest has occurred. These are simple to
make using 2 NAND gates or 2 NOR gates cross connected. Which you
use depends on the level you're looking for. The NAND form is
activated by an active low signal, NOR for active high. Here is a
link showing a NOR S-R latch.
http://www.allaboutcircuits.com/vol_4/chpt_10/2.html
After you set up the two latches, you can then OR the signals
together and feed the output to pin 11 of the BX. You would probably
use a NOR and then use bxPinLow for the WaitForInterrupt() value.
You also have to feed the output of each S-R latch to a separate BX
input. That way, the interrupt task can read each input and discover
which input caused the interrupt (perhaps both did). After
determining which latch(es) are set, you need to reset them in
preparation for the next cycle. You do this by using two BX outputs,
one to each latch, connected to the other of the latches input (the
one not being used by your input signal).
If your input signals are edges (instead of levels as just discussed)
you probably want to used edge-triggered flip flops (e.g. 74xx109)
and wire them so that when they receive the edge of interest, they
get set. As before, you need one and one output per FF to be able to
read its state and reset it.
______________________________
Have a look at the new TI MCU Center on EmbeddedRelated.com!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: Re: handling multiple interrupt sources? - Tom Becker - Mar 27 15:27:00 2005
Tony, I've started a number of messages - and bailed out of each -
asking if you really want to do this. Each message provided anecdotes
of why you might not. In this message, I'll just summarize: it can be a
PITA.
FWIW, you will gain no more accuracy after bolting Timer1 to pin 11,
shared or not, because of the OS's time granularity. It's true that
you'll be notified when some time event occurs (not related to the OS's
RTC tick), but you can't assign any more resolution or accuracy to when
that happened than you can in software much more easily already.
Still, it'll be a great learning experience to go through the exercise
and learn all that you'll encounter, but it will not make you a better
rally computer, at least not yet, I'll bet. Sure you really want to try
this?
Tom
Tom Becker
--... ...--
GTBecker@GTBe... www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700
______________________________
TI's C2000 microcontrollers controlSUITE Desktop gives you instant access to all supporting software libraries, training, collateral, and more!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: handling multiple interrupt sources? - Don Kinzer - Mar 27 16:34:00 2005
--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> So, I need to have either the wheel and/or the timer set off the
> interrupt. But then I need to decide what one (or both) did it.
The external hardware that you need to combine input signals depends
on the nature of the signals. Are the levels important or is it the
edges.
If both signals are levels, you can use an S-R latch to "capture" the
fact that the level of interest has occurred. These are simple to
make using 2 NAND gates or 2 NOR gates cross connected. Which you
use depends on the level you're looking for. The NAND form is
activated by an active low signal, NOR for active high. Here is a
link showing a NOR S-R latch.
http://www.allaboutcircuits.com/vol_4/chpt_10/2.html
After you set up the two latches, you can then OR the signals
together and feed the output to pin 11 of the BX. You would probably
use a NOR and then use bxPinLow for the WaitForInterrupt() value.
You also have to feed the output of each S-R latch to a separate BX
input. That way, the interrupt task can read each input and discover
which input caused the interrupt (perhaps both did). After
determining which latch(es) are set, you need to reset them in
preparation for the next cycle. You do this by using two BX outputs,
one to each latch, connected to the other of the latches input (the
one not being used by your input signal).
If your input signals are edges (instead of levels as just discussed)
you probably want to used edge-triggered flip flops (e.g. 74xx109)
and wire them so that when they receive the edge of interest, they
get set. As before, you need one and one output per FF to be able to
read its state and reset it.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: handling multiple interrupt sources? - arhodes19044 - Mar 27 17:37:00 2005
Hey, that is so much help! I have a bunch of TTL gates in my bin,
and I can probably whip up the stuff I need. No flip-flops though.
Edge detection is OK, but level is ok too. As long as it gets
latched high when it GOES high and stays there even if the input
goes low, then I can talk a LITTLE time and process the interrupt.
Preferably before the next one strikes.
I have the PWM timer set to 3.5hz, and It will be used as the timer
interrupt. It will trigger a display update every 4th time it
fires. The wheel-tick interrupt will trigger an increment an
odometer and Calculated time readings.
I will try the TTL gates tonight If I have a chance.
Thanks again!
I will read that reference too!!! I bet is just the sort of thing I
need.
-TOny
--- In basicx@basi..., "Don Kinzer" <dkinzer@e...> wrote:
>
> --- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> > So, I need to have either the wheel and/or the timer set off the
> > interrupt. But then I need to decide what one (or both) did it.
>
> The external hardware that you need to combine input signals
depends
> on the nature of the signals. Are the levels important or is it
the
> edges.
>
> If both signals are levels, you can use an S-R latch to "capture"
the
> fact that the level of interest has occurred. These are simple to
> make using 2 NAND gates or 2 NOR gates cross connected. Which you
> use depends on the level you're looking for. The NAND form is
> activated by an active low signal, NOR for active high. Here is a
> link showing a NOR S-R latch.
>
> http://www.allaboutcircuits.com/vol_4/chpt_10/2.html
>
> After you set up the two latches, you can then OR the signals
> together and feed the output to pin 11 of the BX. You would
probably
> use a NOR and then use bxPinLow for the WaitForInterrupt() value.
> You also have to feed the output of each S-R latch to a separate
BX
> input. That way, the interrupt task can read each input and
discover
> which input caused the interrupt (perhaps both did). After
> determining which latch(es) are set, you need to reset them in
> preparation for the next cycle. You do this by using two BX
outputs,
> one to each latch, connected to the other of the latches input
(the
> one not being used by your input signal).
>
> If your input signals are edges (instead of levels as just
discussed)
> you probably want to used edge-triggered flip flops (e.g. 74xx109)
> and wire them so that when they receive the edge of interest, they
> get set. As before, you need one and one output per FF to be able
to
> read its state and reset it.
______________________________
TI's C2000 microcontrollers controlSUITE Desktop gives you instant access to all supporting software libraries, training, collateral, and more!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: handling multiple interrupt sources? - arhodes19044 - Mar 27 17:57:00 2005
Well, It is mostly an exercise to see if I can reproduce the rally
computer. It would be hard to make it a BETTER computer, that is
for sure. The Alfa Elite is really really good.
I do not know what that Alfa's granularity is, but 1/512 isn't bad.
Imprecise measurement of Real Time, whatever its granularity, is
bad. While the granularity if only 1/512 of a second is not great,
as long as the precision of the granularity is good, then it is OK.
You know the old issue of resolution versus precision.
I decided that it is not too important to trigger the update at the
exact top of the second. It just needs to be done about every
second. This is because there is a separate readout of the time
error in seconds. Therefore it is "exact" at the moment of
display. The RTC and CTC readouts are for general info.
regarding interrupt timer vs. polled timer: There are circumstances
where the navigator is busy doing some important data entry and the
CPU is occupied in a different loop. But some updates for the
driver are still necessary, Hence the need for a non-polled timer
routine.
Yes, this is all just an academic exercise in the end. But I want
to try to test the limits of the BX and myself.
-Tony
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> Tony, I've started a number of messages - and bailed out of each -
> asking if you really want to do this. Each message provided
anecdotes
> of why you might not. In this message, I'll just summarize: it
can be a
> PITA.
>
> FWIW, you will gain no more accuracy after bolting Timer1 to pin
11,
> shared or not, because of the OS's time granularity. It's true
that
> you'll be notified when some time event occurs (not related to the
OS's
> RTC tick), but you can't assign any more resolution or accuracy to
when
> that happened than you can in software much more easily already.
>
> Still, it'll be a great learning experience to go through the
exercise
> and learn all that you'll encounter, but it will not make you a
better
> rally computer, at least not yet, I'll bet. Sure you really want
to try
> this?
> Tom
>
> Tom Becker
> --... ...--
> GTBecker@R... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Sources and links - Tom Becker - Mar 28 9:13:00 2005
I'd like to update and lengthen the Links list of the group. It is
currently a poor representation of the many available sources.
I'd appreciate your source link list, or even a single link you find
particularly useful. You need do no more than respond to the thread
with a link, if you wish, but a short description will help, too. What
might be obvious sources to you are not known to some other folks.
For example:
http://www.halted.com/ HSC Electronics; new, old surplus
http://webtronics.com/wwvbsdr.html WWVB Radio Shack clock hack
http://www.steminc.com/ Laser modules +
http://www.picobytes.com Small motor and speed control modules
I'll sort and post them to the Links list and a summary email. Who's
your favorite supplier or where do you find technical inspiration?
Tom
______________________________
TI's C2000 microcontrollers controlSUITE Desktop gives you instant access to all supporting software libraries, training, collateral, and more!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - Mike Perks - Mar 28 10:11:00 2005
Tom,
See the links on my website http://home.austin.rr.com/perks/basicx/ .
Not all are relevant but most are. Don't forget to add my website as well.
I have some updates to this list of links so let me know when you need
it by.
Mike
> I'd like to update and lengthen the Links list of the group. It is
> currently a poor representation of the many available sources.
>
> I'd appreciate your source link list, or even a single link you find
> particularly useful. You need do no more than respond to the thread
> with a link, if you wish, but a short description will help, too. What
> might be obvious sources to you are not known to some other folks.
>
> For example:
>
> http://www.halted.com/ HSC Electronics; new, old surplus
> http://webtronics.com/wwvbsdr.html WWVB Radio Shack clock hack
> http://www.steminc.com/ Laser modules +
> http://www.picobytes.com Small motor and speed control modules
> I'll sort and post them to the Links list and a summary email. Who's
> your favorite supplier or where do you find technical inspiration?
> Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - artesina - Mar 28 19:06:00 2005
www.sparkfun.com micro stuff and 1-off $2.50/sq inch PCBs
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> I'd like to update and lengthen the Links list of the group. It is
> currently a poor representation of the many available sources.
>
> I'd appreciate your source link list, or even a single link you find
> particularly useful. You need do no more than respond to the thread
> with a link, if you wish, but a short description will help, too. What
> might be obvious sources to you are not known to some other folks.
>
> For example:
>
> http://www.halted.com/ HSC Electronics; new, old surplus
> http://webtronics.com/wwvbsdr.html WWVB Radio Shack clock hack
> http://www.steminc.com/ Laser modules +
> http://www.picobytes.com Small motor and speed control modules
> I'll sort and post them to the Links list and a summary email. Who's
> your favorite supplier or where do you find technical inspiration?
> Tom
______________________________
TI's C2000 microcontrollers controlSUITE Desktop gives you instant access to all supporting software libraries, training, collateral, and more!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: Sources and links - Tom Becker - Mar 28 21:40:00 2005
There's litle point in duplicating links on your site, Mike, so I've
just added a link to your excellent collection.
I'm still open to other links on the Basic-X site, though. There must
be hundreds of shops like Spark Fun; thanks artesina. Others?
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - tombhandley - Mar 29 4:07:00 2005
Tom, I have some BX-24 examples of interfacing sensors, etc, on
my 'crude', simple, web site. Mike has a link to it on his BasicX
Experiments page but if you are interested, check out:
http://home.comcast.net/~tomhandley/bx-24/bx-24.html
It's a work in progress...
- Tom
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> I'd like to update and lengthen the Links list of the group. It is
> currently a poor representation of the many available sources.
>
> I'd appreciate your source link list, or even a single link you find
> particularly useful. You need do no more than respond to the thread
> with a link, if you wish, but a short description will help, too.
What
> might be obvious sources to you are not known to some other folks.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - Thad Larson - Mar 29 9:04:00 2005
Tom,
It is usually a good idea to include general electronics supply as well - great starter
for newbies.
www.digi-key.com and www.jameco.com * charge extra for orders under $25
($20?)www.mouser.com
www.futurlec.com good prices, shipping takes a while.
And some surplus of interest...
www.mpja.com
http://www.goldmine-elec.com/default.htm
The following BasicX PlaySound utility might generate some interested...
http://fargo.itp.tsoa.nyu.edu/~jn429/playsound/
www.howstuffworks.com could easily be one of the best general starting points.
thanks Tom,
Thad
Tom Becker <gtbecker@gtbe...> wrote:
I'd like to update and lengthen the Links list of the group.
---------------------------------
______________________________
TI's C2000 microcontrollers controlSUITE Desktop gives you instant access to all supporting software libraries, training, collateral, and more!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: Sources and links - Tom Becker - Mar 29 11:35:00 2005
> ... And some surplus of interest...
Erbium Laser Rods. Yeah! Strap a Xenon flash lamp to it and smoke your
villians! My kind of place.
Tom
Tom Becker
--... ...--
GTBecker@GTBe... www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: Sources and links - Tom Becker - Mar 29 11:44:00 2005
Re: Sources and links - raunig2003 - Mar 29 12:23:00 2005
This link may useful to get at some old web pages or sites that have
discontinued access.
http://web.archive.org
rr
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> "April 22, 2003
> This tutorial and utility software were purchased by NetMedia..."
> http://fargo.itp.tsoa.nyu.edu/~jn429/playsound/
>
> Really?
> Tom
>
> Tom Becker
> --... ...--
> GTBecker@R... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - Don Kinzer - Mar 29 15:16:00 2005
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> http://fargo.itp.tsoa.nyu.edu/~jn429/playsound/
By the way in the text of the page above, the author says that using
zero for the fifth parameter to PlaySound() means "infinite". I say he
didn't wait long enough.
My experiments indicate that a repeat count of zero results in the
sound stream being repeated 65,536 times as one might suspect.
You can verify this by using an arbitrary sample data thusly:
Call PlaySound(12, 1000, 10, 10000, 0)
This says to play 10 samples using data beginning at 1000 in program
memory and to play the samples at a 10KHz rate. It should take
approximately 1ms to play the 10 bytes. If the repeat count of zero
means 65536, it should take about 65.5 seconds to run. Due to
overhead, it actually takes about 70 seconds according to my
stopwatch. You can't use the RTC for timing this because it isn't
updated during the process. :(
Also, if you're interested in using PlaySound(), you might consider
using a ByteVectorData element to hold the data. It's a lot cleaner
than appending the sound data to the .bxb file. Of course, you'll
probably have to write a program to run on your PC to produce the
initialization file for the ByteVectorData item.
Don

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - raunig2003 - Mar 29 17:28:00 2005
I did a search for the format of the text file that is produced by the
shareware program he mentions at the link below and I did not find
anything useful. Does any one have any info on ASCII float files?. I
would like to write my own conversion program for playsound. We should
not have to do this blindly without understanding the whole process.
At his point it looks like I have to download the goldwave program and
attempt to determine what the ASCII float file is.
RR
--- In basicx@basi..., "Tom Becker" <gtbecker@r...> wrote:
> "April 22, 2003
> This tutorial and utility software were purchased by NetMedia..."
> http://fargo.itp.tsoa.nyu.edu/~jn429/playsound/
>
> Really?
> Tom
>
> Tom Becker
> --... ...--
> GTBecker@R... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Sources and links - Don Kinzer - Mar 29 19:09:00 2005
--- In basicx@basi..., "raunig2003" <raunig2003@y...> wrote:
> Does any one have any info on ASCII float files?.
It is a simple as it sounds. Nothing more than a series of floating
point values, one per line, representing the samples of the sound.
Here is an excerpt of one such file:
0.001679
0.001770
0.000092
0.000214
-0.002258
-0.002136
-0.005280
-0.005249
-0.008332
These values represent the instantaneous value of the waveform at a
series of points in time, separated by the period of the sample
frequency. The units are arbitrary, it's the range of the values
that is important.
When you export a file from GoldWave in text format, it adds a line
at the top of the file indicating the sample rate and the number of
samples in the file. The excerpt above is from the file that I saved
after loading the file tada.wav from the Windows\Media directory. At
the top of the file it says:
[ASCII 22050Hz, Channels: 2, Samples: 42752, Flags:
0]
This means that the file data represents audio samples at 22.05KHz
with 42752 data points in the file. Using GoldWave, you can re-
sample an audio clip if you'd like or edit it down.
Anyway, after you have the series of floating point values, you need
to convert them to byte values for use by PlaySound(). To do this,
you need to first scan the values to determine the range. Record the
largest positive value and the largest negative value you find.
Let's say that you find that the largest positive value is 0.03711
and the largest negative value is -0.03524. If you assume that the
waveform is zero-centered, this stream represents a waveform with a
peak-to-peak maximum value of 2 * 0.03711. If the absolute value of
the most negative value were larger, you'd use it instead.
You need to scale the range of these values to the BX's 0-255 range
for PlaySound(). We'll assume that 128 represents the zero level of
the waveform so each of the 128 "positive" and "negative" levels in
this case represents 0.03711 divided by 128 or about 2.9e-4.
Once you have this information, you go back through the floating
point samples and scale them to the BX levels. The sample 0.027558
gets converted by dividing it by 2.9e-4 and then adding 128 to
recenter it; the result being 223. A negative sample is handled the
same way. The sample -0.023988 yields a BX value of 45.
If you output these value to a file, one per line, you can use the
file as the initializer for a ByteVectorData element thusly:
Dim sndData as New ByteVectorData("sndFile.txt")
assuming that you saved the data as sndFile.txt.
You can get the program memory address of the sound data using the
DataAddress property of sndData thusly:
Dim sndDataAddr as Integer.
sndData = CInt(sndData.DataAddress)
Unfortunately, there isn't a similar property that tells you the
number of elements so you'll have to note the value from the original
file and hard-code it into your program.
Don
______________________________
Have a look at the new TI MCU Center on EmbeddedRelated.com!
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: PlaySound() data - Don Kinzer - Mar 29 20:25:00 2005
--- In basicx@basi..., "Don Kinzer" <dkinzer@e...> wrote:
It occurred to me after posting the earlier response that:
a) I should have changed the subject line as I did this time.
b) I should have quantized the positive and negative ranges to 127
levels not 128. 128 represents the waveform zero, 129 to 255 is the
positive range and 127 to 1 is the negative range. You would still
add 128 after scaling, though to center the wave.
Your converter should check the result and limit the positive value
to, at most, 255. A similar check should be made on the negative side
to ensure that it doesn't go "below 0" and end up wrapping to the
other end of the byte value range.
Don

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )