fast RCTIME
Archiver
Posts: 46,084
Hello all,
I am working on a project that requires the measurement of around
20 potentiometers. What makes things worse is that I would like it to
be somewhere around realtime, say 40 potentiometer reads per second.
I have looked back about a year's worth of posts concerning RCTIME,
and people seem to agree that the best way of doing this is reducing
either the capacitor or potentiometer values, but that will of course
reduce precicion, which isn't really a big deal. So my question is
this: If I want to keep 6-7 bits of precision, what is the smallest
resistor/capacitor combination I can use which doesn't pose an
operational threat to my BS2p40. Barring that, if I have to test
various combinations myself (which is completely fine by me) what
should the lower bounds of my tests be so that I don't burn out my
chip. Any input would be appreciated. Thanks.
Stefan Dorsett
I am working on a project that requires the measurement of around
20 potentiometers. What makes things worse is that I would like it to
be somewhere around realtime, say 40 potentiometer reads per second.
I have looked back about a year's worth of posts concerning RCTIME,
and people seem to agree that the best way of doing this is reducing
either the capacitor or potentiometer values, but that will of course
reduce precicion, which isn't really a big deal. So my question is
this: If I want to keep 6-7 bits of precision, what is the smallest
resistor/capacitor combination I can use which doesn't pose an
operational threat to my BS2p40. Barring that, if I have to test
various combinations myself (which is completely fine by me) what
should the lower bounds of my tests be so that I don't burn out my
chip. Any input would be appreciated. Thanks.
Stefan Dorsett
Comments
> I am working on a project that requires the measurement of around
>20 potentiometers. What makes things worse is that I would like it to
>be somewhere around realtime, say 40 potentiometer reads per second.
>I have looked back about a year's worth of posts concerning RCTIME,
>and people seem to agree that the best way of doing this is reducing
>either the capacitor or potentiometer values, but that will of course
>reduce precicion, which isn't really a big deal. So my question is
>this: If I want to keep 6-7 bits of precision, what is the smallest
>resistor/capacitor combination I can use which doesn't pose an
>operational threat to my BS2p40. Barring that, if I have to test
>various combinations myself (which is completely fine by me) what
>should the lower bounds of my tests be so that I don't burn out my
>chip. Any input would be appreciated. Thanks.
> Stefan Dorsett
Okay, a BS2p40 with enough pins. If you put a protection resistor in
series with the Stamp input pin there is nothing to worry about wrt
burning it out.
potentiometer
R1 ;---;
Vss --/\/\--/\/\---o
|
P0
/\/\----o pin protection resistor
330 |
===== capacitor
| film
Vss
'
In one second, with 40 potentiometers, you can allow over 25000
microseconds for each RCtime command. Take away 2 milliseconds for
the interpreter, that leaves 23000 microseconds for the result.
Since the BS2p gives units of 0.9 microseconds, the resolution is
still theoretically about 1 part in 25000. That is better than 14
bits. The practical limit on the RCtime command is around 10 bits.
Choose the capacitor, the potentiometer and the resistor so that the
minimum time will be around 200 microseconds and the maximum time
will be around 1000 microseconds. That will meet your required
precision. In the circuit shown, the capacitor is initially charged
high and discharges thru the potentiometer+R1 circuit. The time to
discharge to the Stamp switching threshold is about:
tm = 1.347 * R * C
do
RCtime 0,1,mytime
high 0
loop
More RCtime info at:
http://www.emesystems.com/BS2rct.htm
-- best regards
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...
> >Hello all,
> > I am working on a project that requires the measurement of
around
> >20 potentiometers. What makes things worse is that I would like it
to
> >be somewhere around realtime, say 40 potentiometer reads per
second.
> >I have looked back about a year's worth of posts concerning RCTIME,
> >and people seem to agree that the best way of doing this is
reducing
> >either the capacitor or potentiometer values, but that will of
course
> >reduce precicion, which isn't really a big deal. So my question is
> >this: If I want to keep 6-7 bits of precision, what is the smallest
> >resistor/capacitor combination I can use which doesn't pose an
> >operational threat to my BS2p40. Barring that, if I have to test
> >various combinations myself (which is completely fine by me) what
> >should the lower bounds of my tests be so that I don't burn out my
> >chip. Any input would be appreciated. Thanks.
> > Stefan Dorsett
>
>
> Okay, a BS2p40 with enough pins. If you put a protection resistor
in
> series with the Stamp input pin there is nothing to worry about wrt
> burning it out.
>
> potentiometer
> R1 ;---;
> Vss --/\/\--/\/\---o
> |
> P0
/\/\----o pin protection resistor
> 330 |
> ===== capacitor
> | film
> Vss
'
>
> In one second, with 40 potentiometers, you can allow over 25000
> microseconds for each RCtime command. Take away 2 milliseconds
for
> the interpreter, that leaves 23000 microseconds for the result.
> Since the BS2p gives units of 0.9 microseconds, the resolution is
> still theoretically about 1 part in 25000. That is better than 14
> bits. The practical limit on the RCtime command is around 10 bits.
> Choose the capacitor, the potentiometer and the resistor so that
the
> minimum time will be around 200 microseconds and the maximum time
> will be around 1000 microseconds. That will meet your required
> precision. In the circuit shown, the capacitor is initially
charged
> high and discharges thru the potentiometer+R1 circuit. The time to
> discharge to the Stamp switching threshold is about:
> tm = 1.347 * R * C
>
> do
> RCtime 0,1,mytime
> high 0
> loop
>
>
> More RCtime info at:
>
> http://www.emesystems.com/BS2rct.htm
>
> -- best regards
> Tracy Allen
> electronically monitored ecosystems
> http://www.emesystems.com
> mailto:tracy@e...
Wow, thanks. The part about me not burning out my chip helps a lot,
as I imagine I'll be tweaking various potentiometer/resistor values
far past the time it is healthy for me to be doing so. However,
another thought on this subject came to me last night in bed: Since
most of the time in the RCTIME command is essentially executing nops,
waiting for the pin to reach logic low, I'm wondering if it would be
possible to execute, say, four RCTIME commands at once, and check
every fourth cycle. This would reduce precision, but to a very small
level, only up to three cycles in this case. I doubt the RCTIME
command has anything like this, but is it possible to reconstruct the
RCTIME command so that it enables this. In short, is RCTIME hardware
implemented or software. And if it is software, are there any
resources available to me to be able to recode it? Any thoughts would
be appreciated. Thanks again.
Stefan Dorsett
It does one thing at a time. Interleaving is not possible.
2. The RCTime expects you to have charged a capacitor on
the pin, and then when you execute the RCTime instruction
itself, it runs a counter until the pin changes state.
It is NOT doing 'NOP's, it's incrementing a counter
and monitoring the pin. You can't do that to 4 at
once.
Having said that, the Basic Atom can be convinced to do
a FORM of Basic Interrupts, and it has timers, so you
in theory could do the same thing yourself.
In practice, the resolution and accuracy you're looking
for make even the Atom's pseudo interrupts chancy.
The BS2p40 looks like the best bet.
--- In basicstamps@yahoogroups.com, "Stefan Dorsett"
<tebukuro42@y...> wrote:
> --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
> > >Hello all,
> > > I am working on a project that requires the measurement of
> around
> > >20 potentiometers. What makes things worse is that I would like
it
> to
> > >be somewhere around realtime, say 40 potentiometer reads per
> second.
> > >I have looked back about a year's worth of posts concerning
RCTIME,
> > >and people seem to agree that the best way of doing this is
> reducing
> > >either the capacitor or potentiometer values, but that will of
> course
> > >reduce precicion, which isn't really a big deal. So my question
is
> > >this: If I want to keep 6-7 bits of precision, what is the
smallest
> > >resistor/capacitor combination I can use which doesn't pose an
> > >operational threat to my BS2p40. Barring that, if I have to test
> > >various combinations myself (which is completely fine by me) what
> > >should the lower bounds of my tests be so that I don't burn out
my
> > >chip. Any input would be appreciated. Thanks.
> > > Stefan Dorsett
> >
> >
> > Okay, a BS2p40 with enough pins. If you put a protection
resistor
> in
> > series with the Stamp input pin there is nothing to worry about
wrt
> > burning it out.
> >
> > potentiometer
> > R1 ;---;
> > Vss --/\/\--/\/\---o
> > |
> > P0
/\/\----o pin protection resistor
> > 330 |
> > ===== capacitor
> > | film
> > Vss
'
> >
> > In one second, with 40 potentiometers, you can allow over 25000
> > microseconds for each RCtime command. Take away 2 milliseconds
> for
> > the interpreter, that leaves 23000 microseconds for the result.
> > Since the BS2p gives units of 0.9 microseconds, the resolution is
> > still theoretically about 1 part in 25000. That is better than
14
> > bits. The practical limit on the RCtime command is around 10
bits.
> > Choose the capacitor, the potentiometer and the resistor so that
> the
> > minimum time will be around 200 microseconds and the maximum time
> > will be around 1000 microseconds. That will meet your
required
> > precision. In the circuit shown, the capacitor is initially
> charged
> > high and discharges thru the potentiometer+R1 circuit. The time
to
> > discharge to the Stamp switching threshold is about:
> > tm = 1.347 * R * C
> >
> > do
> > RCtime 0,1,mytime
> > high 0
> > loop
> >
> >
> > More RCtime info at:
> >
> > http://www.emesystems.com/BS2rct.htm
> >
> > -- best regards
> > Tracy Allen
> > electronically monitored ecosystems
> > http://www.emesystems.com
> > mailto:tracy@e...
>
> Wow, thanks. The part about me not burning out my chip helps a lot,
> as I imagine I'll be tweaking various potentiometer/resistor values
> far past the time it is healthy for me to be doing so. However,
> another thought on this subject came to me last night in bed: Since
> most of the time in the RCTIME command is essentially executing
nops,
> waiting for the pin to reach logic low, I'm wondering if it would
be
> possible to execute, say, four RCTIME commands at once, and check
> every fourth cycle. This would reduce precision, but to a very
small
> level, only up to three cycles in this case. I doubt the RCTIME
> command has anything like this, but is it possible to reconstruct
the
> RCTIME command so that it enables this. In short, is RCTIME
hardware
> implemented or software. And if it is software, are there any
> resources available to me to be able to recode it? Any thoughts
would
> be appreciated. Thanks again.
> Stefan Dorsett
better grasp of what the basic stamp can do. However, there are a few
things I have found out from the documentation that make me wonder if
it is possible. First, I require the 32 I/O pins on the BS2p40, so I
am going to work around this model. the BS2p, unlike the earlier
models, have polling functions which look like they would be able to
support a sort of parallelism:
Capacitors and potentiometers work in parallel, so why should we
wait for each to discharge in turn when we can discharge all of them
at once? My solution is to charge and POLLIN all of the pins we would
have used RCTIME on, set POLLMODE, increment a counter until one of
the pins polls, break to a list of IF statements to figure out which
pin polled, save the counter as an index to that pin, and continue
from polling the other pins from there. I realize this will introduce
extra cycles into the total count, but if I only need 6-7 bits of
precision and RCTIME is accurate up to 10, this shouldn't be an
issue. I don't know if this code will work, as I have yet to get my
stamp, and this is just speculation, but I like to start early on
theory. My only other concern at this point would be just how many
pins POLLIN can reasonably poll inbetween instructions, and the
constant overhead for figuring out which pin polled. If this works,
hopefully I can go from 2 refreshes per second to maybe 4 or 5,
depending. Well, what do you think? Any input is appreciated. Thanks.
Stefan Dorsett
--- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
wrote:
> 1. The Basic Stamp is NOT a multi-processing beast.
> It does one thing at a time. Interleaving is not possible.
>
> 2. The RCTime expects you to have charged a capacitor on
> the pin, and then when you execute the RCTime instruction
> itself, it runs a counter until the pin changes state.
> It is NOT doing 'NOP's, it's incrementing a counter
> and monitoring the pin. You can't do that to 4 at
> once.
>
> Having said that, the Basic Atom can be convinced to do
> a FORM of Basic Interrupts, and it has timers, so you
> in theory could do the same thing yourself.
>
> In practice, the resolution and accuracy you're looking
> for make even the Atom's pseudo interrupts chancy.
> The BS2p40 looks like the best bet.
>
> --- In basicstamps@yahoogroups.com, "Stefan Dorsett"
> <tebukuro42@y...> wrote:
> > --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...>
wrote:
> > > >Hello all,
> > > > I am working on a project that requires the measurement of
> > around
> > > >20 potentiometers. What makes things worse is that I would
like
> it
> > to
> > > >be somewhere around realtime, say 40 potentiometer reads per
> > second.
> > > >I have looked back about a year's worth of posts concerning
> RCTIME,
> > > >and people seem to agree that the best way of doing this is
> > reducing
> > > >either the capacitor or potentiometer values, but that will of
> > course
> > > >reduce precicion, which isn't really a big deal. So my
question
> is
> > > >this: If I want to keep 6-7 bits of precision, what is the
> smallest
> > > >resistor/capacitor combination I can use which doesn't pose an
> > > >operational threat to my BS2p40. Barring that, if I have to
test
> > > >various combinations myself (which is completely fine by me)
what
> > > >should the lower bounds of my tests be so that I don't burn
out
> my
> > > >chip. Any input would be appreciated. Thanks.
> > > > Stefan Dorsett
> > >
> > >
> > > Okay, a BS2p40 with enough pins. If you put a protection
> resistor
> > in
> > > series with the Stamp input pin there is nothing to worry about
> wrt
> > > burning it out.
> > >
> > > potentiometer
> > > R1 ;---;
> > > Vss --/\/\--/\/\---o
> > > |
> > > P0
/\/\----o pin protection resistor
> > > 330 |
> > > ===== capacitor
> > > | film
> > > Vss
'
> > >
> > > In one second, with 40 potentiometers, you can allow over 25000
> > > microseconds for each RCtime command. Take away 2
milliseconds
> > for
> > > the interpreter, that leaves 23000 microseconds for the result.
> > > Since the BS2p gives units of 0.9 microseconds, the resolution
is
> > > still theoretically about 1 part in 25000. That is better than
> 14
> > > bits. The practical limit on the RCtime command is around 10
> bits.
> > > Choose the capacitor, the potentiometer and the resistor so
that
> > the
> > > minimum time will be around 200 microseconds and the maximum
time
> > > will be around 1000 microseconds. That will meet your
> required
> > > precision. In the circuit shown, the capacitor is initially
> > charged
> > > high and discharges thru the potentiometer+R1 circuit. The
time
> to
> > > discharge to the Stamp switching threshold is about:
> > > tm = 1.347 * R * C
> > >
> > > do
> > > RCtime 0,1,mytime
> > > high 0
> > > loop
> > >
> > >
> > > More RCtime info at:
> > >
> > > http://www.emesystems.com/BS2rct.htm
> > >
> > > -- best regards
> > > Tracy Allen
> > > electronically monitored ecosystems
> > > http://www.emesystems.com
> > > mailto:tracy@e...
> >
> > Wow, thanks. The part about me not burning out my chip helps a
lot,
> > as I imagine I'll be tweaking various potentiometer/resistor
values
> > far past the time it is healthy for me to be doing so. However,
> > another thought on this subject came to me last night in bed:
Since
> > most of the time in the RCTIME command is essentially executing
> nops,
> > waiting for the pin to reach logic low, I'm wondering if it would
> be
> > possible to execute, say, four RCTIME commands at once, and check
> > every fourth cycle. This would reduce precision, but to a very
> small
> > level, only up to three cycles in this case. I doubt the RCTIME
> > command has anything like this, but is it possible to reconstruct
> the
> > RCTIME command so that it enables this. In short, is RCTIME
> hardware
> > implemented or software. And if it is software, are there any
> > resources available to me to be able to recode it? Any thoughts
> would
> > be appreciated. Thanks again.
> > Stefan Dorsett
If each RCtime reads from 0.1 to 1 millisecond, and the overhead for
each one is 1 millisecond, then you could read all 20 potentiometers
in something less than 50 milliseconds. That would be fast enough
for 20 updates per second
By the way, be careful for your circuit layout, to minimize stray
capacitance and long leads.
The scheme using pollmode might work too (DIY parallelism), but I
don't guess it would enable faster scanning. The counting done by
the interpreter is going to be on the time scale of milliseconds,
whereas the RCtime command counts on the time scale of microseconds.
To count up to 64 (6 bits accuracy) will take on the order of 64
milliseconds, which is no better than the straight RCtime scheme.
-- Tracy
>Ok, true. Both points 1 and 2 make sense, and they help me get a
>better grasp of what the basic stamp can do. However, there are a few
>things I have found out from the documentation that make me wonder if
>it is possible. First, I require the 32 I/O pins on the BS2p40, so I
>am going to work around this model. the BS2p, unlike the earlier
>models, have polling functions which look like they would be able to
>support a sort of parallelism:
> Capacitors and potentiometers work in parallel, so why should we
>wait for each to discharge in turn when we can discharge all of them
>at once? My solution is to charge and POLLIN all of the pins we would
>have used RCTIME on, set POLLMODE, increment a counter until one of
>the pins polls, break to a list of IF statements to figure out which
>pin polled, save the counter as an index to that pin, and continue
>from polling the other pins from there. I realize this will introduce
>extra cycles into the total count, but if I only need 6-7 bits of
>precision and RCTIME is accurate up to 10, this shouldn't be an
>issue. I don't know if this code will work, as I have yet to get my
>stamp, and this is just speculation, but I like to start early on
>theory. My only other concern at this point would be just how many
>pins POLLIN can reasonably poll inbetween instructions, and the
>constant overhead for figuring out which pin polled. If this works,
>hopefully I can go from 2 refreshes per second to maybe 4 or 5,
>depending. Well, what do you think? Any input is appreciated. Thanks.
> Stefan Dorsett
to a hardware implementation than software, or the commands given in
PBASIC aren't at the assembly level. I'm thinking it is more the
hardware part, but I would be curious as to how they implement it.
I'll try to let you guys know how the project goes, or in the likely
event that I need more help, I'll post again. Thanks all.
Stefan Dorsett
--- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
> Hi Stefan,
>
> If each RCtime reads from 0.1 to 1 millisecond, and the overhead
for
> each one is 1 millisecond, then you could read all 20
potentiometers
> in something less than 50 milliseconds. That would be fast enough
> for 20 updates per second
>
> By the way, be careful for your circuit layout, to minimize stray
> capacitance and long leads.
>
> The scheme using pollmode might work too (DIY parallelism), but I
> don't guess it would enable faster scanning. The counting done by
> the interpreter is going to be on the time scale of milliseconds,
> whereas the RCtime command counts on the time scale of
microseconds.
> To count up to 64 (6 bits accuracy) will take on the order of 64
> milliseconds, which is no better than the straight RCtime scheme.
>
> -- Tracy
>
>
> >Ok, true. Both points 1 and 2 make sense, and they help me get a
> >better grasp of what the basic stamp can do. However, there are a
few
> >things I have found out from the documentation that make me wonder
if
> >it is possible. First, I require the 32 I/O pins on the BS2p40, so
I
> >am going to work around this model. the BS2p, unlike the earlier
> >models, have polling functions which look like they would be able
to
> >support a sort of parallelism:
> > Capacitors and potentiometers work in parallel, so why should we
> >wait for each to discharge in turn when we can discharge all of
them
> >at once? My solution is to charge and POLLIN all of the pins we
would
> >have used RCTIME on, set POLLMODE, increment a counter until one of
> >the pins polls, break to a list of IF statements to figure out
which
> >pin polled, save the counter as an index to that pin, and continue
> >from polling the other pins from there. I realize this will
introduce
> >extra cycles into the total count, but if I only need 6-7 bits of
> >precision and RCTIME is accurate up to 10, this shouldn't be an
> >issue. I don't know if this code will work, as I have yet to get my
> >stamp, and this is just speculation, but I like to start early on
> >theory. My only other concern at this point would be just how many
> >pins POLLIN can reasonably poll inbetween instructions, and the
> >constant overhead for figuring out which pin polled. If this works,
> >hopefully I can go from 2 refreshes per second to maybe 4 or 5,
> >depending. Well, what do you think? Any input is appreciated.
Thanks.
> > Stefan Dorsett