Reply by ybernikov December 12, 20052005-12-12
[]

Thank you for the detailed explanation. I agree that the problem of
speed is rather complicated - quite often it resembles comparing
apples to oranges. May be I used too strong language when I talked
about "marketing tricks" :)

-Yuri


Reply by Don Kinzer December 12, 20052005-12-12
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
> This means that the "real life" speed of BX-24 is more than 10 times
> slower than the "best case" speed for the specific instructions like
> b = b + 1. I understand, that this is not Netmedia's guilt - all
> manufacturers do the same trick for the marketing purposes.

Part of the problem is that attempting to convey an accurate and
complete idea of processor speed is a difficult proposition. In
particular, what consititutes an instruction? Given that the mapping
from a line of source code (one perception of an instruction) to pcode
instructions (another perception of an instruction) varies widely, no
one metric is going to adequately describe the processor speed.

This problem is not unique to the BX-24, Basic Stamp or ZX-24, of
course. With the AVR chips themselves, Atmel describes them as
executing as fast as 1 MIP per megahertz of clock speed. Of course,
that only applies to instructions that execute in 1 clock cycle.
Although a fair number of the instructions do, many don't.

In my opinion, the NetMedia claim of a best case speed of 83,000 is
accurate but incomplete. That is why I describe the ZX-24 speed
as "up to 172,000 instructions per second".

Don
http://www.zbasic.net


Reply by arhodes19044 December 12, 20052005-12-12
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:

> This means that the "real life" speed of BX-24 is more than 10 times
> slower than the "best case" speed

Well, I did not calculate the number of instructions involved in each
cycle of the I2C clock, but there are quite a few. I am not surprised
that the clock rate is going to be WELL below the rated speed of a
single instruction.

It would be interesting to see what the average instruction duration
is for this sort of operation. One would have to look hard at the
code and figure out the number of instructions, on average, per clock
cycle, then get a good measurement of the I2C clock rate. Not a hard
task, just a little tedious. Possibly informative regarding
bottlenecks and optimizing techniques.

-Tony


Reply by ybernikov December 12, 20052005-12-12
>
> I think I remember measuring the BX bit-banged I2C clock at somewhere
> around 3000 Hz.
>
> -Tony
>

This means that the "real life" speed of BX-24 is more than 10 times
slower than the "best case" speed for the specific instructions like b
= b + 1. I understand, that this is not Netmedia's guilt - all
manufacturers do the same trick for the marketing purposes.


Reply by Don Kinzer December 10, 20052005-12-10
--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> Too bad that the ZX hardware SPI is not all that fast. ...

SPI on both the BX-24 and the ZX-24 can be very fast; the top speed is
1.84MHz on the BX and 7.37MHz on the ZX. The issue to keep in mind is
that your SPI device will have its chip select asserted only during
the execution of each SPICmd(). Chip select has to be de-asserted
when SPICmd() is done because the CPU needs to use the SPI channel to
fetch instructions. The other limitation that might come into play is
the 255 byte data length limit for SPICmd().

It is possible to implement a bit-bang SPI interface in the ZX
firmware. I suspect that the top speed would be in the range of
500KHz to 1MHz.

Don


Reply by arhodes19044 December 10, 20052005-12-10
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
> 83000 / 20 = 4150 bytes/sec


I think I remember measuring the BX bit-banged I2C clock at somewhere
around 3000 Hz.

-Tony



Reply by arhodes19044 December 10, 20052005-12-10
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
>
> I did not try the I2C capabilities of ZBasic, but it must be much
> faster.
>
> -Yuri
>

I did. It is actually just about the actual speed which you have set
as the clock frequency. So at a clock setting of 400KHz, you do
approach that speed.

This is just the RAW speed of the data array that you are sending.
Filling the array and figuring out what to fill it with does take
longer, but the actual speed of the I2C driver is very fast.

Too bad that the ZX hardware SPI is not all that fast. I had to drop
down to the bit-banged SPI functions because the SD/MMC card does not
like sharing its bus (All transactions must be atomic). SPI FRAM,
OTOH, AFAIK, does not mind sharing, and transactions need not be
atomic. When the chip select is released, Ramtron FRAM pauses its
transaction, and it can be resumed. Not so for SD/MMC.


Reply by Don Kinzer December 9, 20052005-12-09
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
> Netmedia claims that the speed of BX24 is 83,000 Basic
> instructions per second.

I have confirmed the accuracy of this claim. However, it should be
noted that this is a "best case" speed that is obtainable only with
a few specific instructions (e.g. incrementing an Integer variable).

A possibly more representative speed measurement can be obtained by
using the following program:

Sub Main()
Register.DDRC = &H01
Do
Register.PortC = Register.PortC Xor &H01
Loop
End Sub

This program generates a square wave on pin 12 having a period
equal to twice the loop execution time. With an oscilloscope or
logic analyzer you can measure the period and calculate the
execution time for one pass through the loop. For the BX-24, the
loop execution time is a little over 90uS; for the BX-24P it is a
little over 66uS.

It should be noted that more complicated instructions, like those
involving expressions with multiple operators or array indexing, are
going to take much longer. A single BasicX instruction can produce
dozens (or in some extreme cases, hundreds) of pcode instructions
for the processor to execute.

By way of comparison, the ZX-24 has a maximum execution speed of
172,000 instructions per second under the same conditions as the BX-
24's top speed. Its loop execution time for the program above is
about 32uS. More comparative data can be found at the site below.

Don
http://www.zbasic.net


Reply by ybernikov December 9, 20052005-12-09

> That IS rather speedy. Of course that does not help us here much
> because the bit-banged I2C interface of the BX-24 is rather slow.
I
> am Not sure what its speed is, but I'd bet it is rather lower than
> 100KHz.
>

Let's do some calculations:

Netmedia claims that the speed of BX24 is 83,000 Basic instructions
per second. In order to send one byte via I2C, a sequence of at least
20 instructions has to be executed. Let's assume for the simplicity
sake, that all instructions have the same execution time. This gives
us VERY ROUGHLY:

83000 / 20 = 4150 bytes/sec

or

4150 * 8 / 1000 = 33.2 kbit/s,

but I believe the real speed is much lover.

I did not try the I2C capabilities of ZBasic, but it must be much
faster.

-Yuri


Reply by arhodes19044 December 9, 20052005-12-09
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
the Version 2
> of I2C bus specification allows an increase in the bit rate up to
3.4 Mbit/s That IS rather speedy. Of course that does not help us here much
because the bit-banged I2C interface of the BX-24 is rather slow. I
am Not sure what its speed is, but I'd bet it is rather lower than
100KHz.

Even the full hardware I2C on an ATMega128 running at 16MHz can only
get to 409KHz or so. I have some FRAM that is capable of 1MHz, but I
am only able to run it at 40% of its maximum under the best
circumstances.

-Tony