PICAXE 08M2 w/ Ext. Clock Frequency: Can It Be Done?

laserhawk64

Senior Member
Hello, all! I'm new here, so please be gentle.

I had an idea, the other day, for something like this: http://www.linusakesson.net/scene/bitbanger/index.php

I want to use a PICAXE 08M2. The idea is to run it at 25.175MHz using the input-only lead C.3, and have it output random 8bit strings from three IO leads (C.1, C.2, C.4) which would be converted to raw VGA via a trio of 74xx595 ICs paired with R-2R ladders. I can scan the (hand-drawn) schematic and post it, but I will warn you that my chickenscratch is not the most readable -- and this particular schematic is not my neatest!

My primary question relates to the clock issue: is it possible to drive the 08M2 from an external clock at all? If so, would non-integer values be supported?

My secondary question is: OK, if I can do the clock input, how would I implement that in software? I can probably figure out the rest of it (I program occasionally) but this clock issue has me just boggled.
 

nick12ab

Senior Member
Welcome to the forum

I want to use a PICAXE 08M2. The idea is to run it at 25.175MHz using the input-only lead C.3, and
Using the external resonator can only be done if the configuration fuses set by Rev-Ed allow it and the SETFREQ command would boast about support for it if you could do it but you can't.

have it output random 8bit strings from three IO leads (C.1, C.2, C.4) which would be converted to raw VGA via a trio of 74xx595 ICs paired with R-2R ladders.
Random 8-bit strings? To create a random pattern? In the video, a raw microcontroller is used without the slow PICAXE interpreter so even to create random patterns you might be able to do it with serout but I can't guarantee that that will work.

My primary question relates to the clock issue: is it possible to drive the 08M2 from an external clock at all? If so, would non-integer values be supported?
Any clock frequency up to the maximum is guaranteed to work with a PICAXE that has external resonator capability.
 

laserhawk64

Senior Member
Note that his ATtiny was running at ~1.6MHz. He also was getting video AND sound out of it.

I'm looking for just the video, at something like 15x the speed... and the chip's too slow? <kaos> I find that very hard to believe. </kaos>

EDIT: want to make it clear that I'm not trying to argue, I'm just, well, blown away by the apparent limitations of this chip vs. the ATtiny.
 
Last edited:

Goeytex

Senior Member
I would think that the short answer is NO....since the 08M2 has no clock input pin(s) and nothing in the data sheets even hint at
support for external clocking.

Comparing the ATtiny and the Picaxe08M2 is comparing apples and oranges. Completely different target markets.

The 08M2 target market is mostly educational where blazing speed and 2 clock instruction execution is not needed. Teaching kids how to get started programming microprocessors beginning with BASIC. The limitations are a tradeoff between simplicity and speed and are related to using an on chip basic interpreter. With the Picaxe, no special external libraries needed for stuff like Serial Coms, PWM, I2C, SPI, touch sensing etc. One line of Picaxe Basic code can do what 20 - 50 lines of C does. The tradeoff for this ease of use and simplicity is a performance hit in code execution speed.

The Picaxe is not the right platform for every application , but it was not intended to be.
 
Last edited:

laserhawk64

Senior Member
OK, then, what chip would ya'll recommend for this? Keep in mind that it's better if it's easy to program... most of my knowledge of such things is in an old version of the BASIC language, called QBASIC/QuickBASIC (it's by MS, for DOS).
 

westaust55

Moderator
You need to ensure that you are comparing "apples with apples".

While the ATtiny15main clock was only 1.6 MHz, note the comment also:
"The ATtiny15 luckily has a PWM output that runs on a separate peripheral clock at a staggering 25.6 MHz"

The program to achieve that was written in machine code/assembler which is the native language of such microcontrollers and in the OP's own words "
Here's an excerpt from the source code, so you get an idea of what I was up against:
Some folks do program microcontrollers in assembler and this methods results in much faster performance to the extent that the program may need to introduce delays so the user can see some actions.

The PICAXE chips (same applies to other microcontroller based systems such as the BASIC Stamp by Parallax) use an interpreted programming method just like the old Commodore 64 and many home computers back in the 1980's and 1990's did. The PICAXE and similar were originally aimed at the educational market and have also had an amazing hobbyist uptake as well.
When the Interpreter system is used, the program listing you type in is not converted directly to machine code/assembler but stored much as the program listing but with the keywords reduced to a single byte or some other smaller "token" to save programming space.
The inbuilt interpreter then reads a line of the tokenised program and inbuilt routines must execute many native machine code commands to achieve the function of that one program command. This takes time for the interpreter to retrieve a BASIC command token, then perform the instruction and finally save any results in memory or set IO etc. The result is that any Interpreted system will be far slower than a program stored in assembler/machine code.
However, for the vat majority of PICAXE users the reduced speed is not a significant issue and usually the speed is ample to achieve the desired task in a good speed &#8211; in fact we still have to add delays (PAUSE command) to give users time to see some actions.

Rather than being critical of the PICAXE speed/capabilities, it is a case of ensuring you are using the right tools for the job. Take the same PIC upon which the PICAXE is based and learn to program in Assembler (which many find harder to achieve) and you may find the results are more equal.
 

laserhawk64

Senior Member
I'm quite familiar with interpreted languages. QBASIC is one of them. I've also done (a little) assembly programming on a C64. Assembly is so simple-minded that it's painful.

Here's what I'm looking for, in pseudocode.

start
>set clock to C.3, ext. 25.175MHz osc
>DO
>>random (8bits, binary) to VAR_RED
>>random (8bits, binary) to VAR_GRN
>>random (8bits, binary) to VAR_BLU
>>output VAR_RED on C.1
>>output VAR_GRN on C.2
>>output VAR_BLU on C.4
>LOOP
end

Now tell me exactly how hard it would be for the 08M2 to keep up with the timing. IIRC I didn't mention this, but the HSYNC and VSYNC are manually generated (elsewhere) at 31.5kHz (a little off, but not much) and ~60Hz. The 08M2 does not take care of that part at all.

EDIT: also, not being critical, being confused. I still don't see, even with the overhead, a 4-30MHz chip not being able to compete with a 1.6MHz chip. I realize it's apples and oranges, but they're both still fruit.

EDIT2: OK, if the 08M2 can't take an external clock, what about the 20X2? I can't tell which pin from the diagram because each pin (with few exceptions) is capable of like 20 different things...
 
Last edited:

Goeytex

Senior Member
What interface do you plan on using to output the data ?

Rather than remaining confused as to why the Picaxe takes 50 - 200us to execute a command why not seek to understand?
Saying "I still don't see" after only 4 posts, and seemingly little investigation & research suggests to me that you may not be trying
very hard. Not being critical.

How long does it take a compiler on a PC running at 2 gigahertz to compile 40 lines of C code?. Consider that this is
similar to what a Picaxe does on the fly for each command while running at only 4 to 32 Mhz. To get this done and then execute
in 50 - 250us is fairly reasonable wouldn't you say?
 
Last edited:

laserhawk64

Senior Member
I see what you mean. I just needed it spelled out a little more vividly. I will look at other, more responsive chips.

Thank you all for your time; I'm sorry that I ended up wasting it.
 

srnet

Senior Member
I still don't see, even with the overhead, a 4-30MHz chip not being able to compete with a 1.6MHz chip
The Native chip the 08M2 is made of almost certainly can, it can run 20 times faster, has 8 times the RAM and ROM, and does support an external clock up to 32Mhz.

Teach yourself 'simple-minded' assembler (can't be hard can it?) and away you go.
 

westaust55

Moderator
OK, if the 08M2 can't take an external clock, what about the 20X2? I can't tell which pin from the diagram because each pin (with few exceptions) is capable of like 20 different things...
If you have a read of the PICAXE manual 2 (currently V7.7) for the SETFREQ command - see page 221, you will see which PICAXE chips can use what frequencies and which are defined to use an external resonator.
The 20X2 cannot use an external resonator whereas all other X1 and X2 parts can use an external resonator.

PICAXE manual 1 page 11 shows clearly the 28X2 and 40X2 chips with dedicated RESONATOR pins.
 
Top