new picaxe chip

alhoop

Member
Will Picaxe ever develop a chip with a millisecond timer and floating point math,
either as a standalone or one that can feed the timing and math (integer)results to
a very capable chip like the 20X2?
Al
 

Circuit

Senior Member
Will Picaxe ever develop a chip with a millisecond timer and floating point math,
either as a standalone or one that can feed the timing and math (integer)results to
a very capable chip like the 20X2?
Al
A standalone Floating Point Maths Chip that connects to PICAXE? Do you mean something like this? http://www.picaxestore.com/index.php/en_gb/picaxe/add-on-modules/fpu003.html
And as for precision timing, don't forget that you can add a timing crystal to X, X1 or X2 parts although they are pretty good with just a resonator. You can time milliseconds with Pause which is timed in milliseconds and pauseus which times in multiples of microseconds. Pulseout can run as fast as 0.625 microseconds. Also, see "internal timer" on page 233 of PICAXE Manual 2 (Basic Commands). What sort of timing are you seeking?
 

inglewoodpete

Senior Member
A good question. Rev Ed's bread and butter is the UK education market, so I'd imagine that future development would be largely driven by that.

On millisecond timers, the X2 series can handle timer interrupts down to about 5mS, so you can create a background timer with that order of resolution. However, smaller increments don't leave very much time for foreground tasks.
 

pxgator

Senior Member
A good question. Rev Ed's bread and butter is the UK education market, so I'd imagine that future development would be largely driven by that.
Inglewoodpete pretty much hit the nail on the head. This subject has come up many times. For fast floating point
and REAL micro/millisecond timing a compiled and not interpreted coding scheme would need to be implemented.
It's not likely to happen with the PICAXE system so my advice would be to appreciate what it can do which is much
more than some folks realize. This forum is a great resource of information if you can post code that illustrates what
you are wanting to accomplish.

Cheers to All
 

stan74

Senior Member
I searched micro controller with float and got http://uk.farnell.com/microchip/dspic33fj64gs608-i-pt/ic-mcu-16bit-64kb-80tqfp/dp/2082233?mckv=5JqcDtNx_dc|pcrid|78108376749|&gross_price=true&CATCI=pla-131222015829&CAAGID=14983511589&CMP=KNC-GUK-GEN-SHOPPING-MICROCHIP&CAGPSPN=pla&gclid=CjwKCAiAt8TUBRAKEiwAOI9pAPFKTARdB2K-V4Hmho5DBVNgv2YF2hldrPgp54Yr84J2OtjQEgznmRoCXMMQAvD_BwE&CAWELAID=120173390000213101
Theres basic that has floats but it's commercial ie money. free ones have long variables that can be used with effort.
Guessing a c prog needs converting.
They don't teach decimal point numbers any more that's why it's not supported...honest
 

bpowell

Senior Member
Can you be more specific? We poor old BASIC programmers don't really understand what you are referring to unless you spell it out. :D
I'm not sure what you're looking for. If using C, you can assign a variable of type "Float" and then do math with it.

for instance:
Code:
    fnumber1 = 1.234;
    fnumber2 = 4.321;
    floatResult = addFloat (fnumber1, fnumber2);
    inumber1 = 123;
    inumber2 = 321;
    intResult = addInt (inumber1, inumber2);
and...

Code:
    serOut ("Hello, I am a PIC 12F1840\r\n");
    serOut ("Float Result:  ");
        char * output;
        int status;
        output = ftoa(floatResult, &status);
    serOut (output);
    serOut ("\r\n");
    serOut ("Int Result:  ");
        itoa (str, intResult, 10);
    serOut (str);
    serOut ("\r\n");
will result in...

Code:
Hello, I am a PIC 12F1840
Float Result:  5.555056
Int Result:  444
So, you can see the 08M2 hardware can handle floating point math...there is a loss of precision (note the float result is NOT 5.555, but 5.555056) so you need to account for that error, this results from how floats are represented in binary...in this case, floats are stored in 24-bit variables...

If I increase the size of a float to 32-bit variables, I can get better precision, but at the cost of an additional byte of memory consumed for each float...using 32-bit Floats, the result is:

Code:
Hello, I am a PIC 12F1840
Float Result:  5.555000
Int Result:  444
Note: Storing ints and floats in variables, and adding those variables together and storing the result in another variable takes...about 10 instruction cycles for the INT and 240 instruction cycles for the float.

So, Floating point math is MUCH slower.
 
Last edited:

Flenser

Senior Member
Will Picaxe ever develop a chip with a millisecond timer
A look at the manual shows that the X2 chips can already provide a millisecond timer on both timer1 and timer3.

From the settimer command on page 233 of manual 2:
With a 4MHz resonator this means a minor tick occurs every 64us (32us at
8MHz, 16us at 16MHz, 8us at 32MHz, 4us at 64MHz).
and
We know that at 4MHz each minor tick takes 64us and 1 second is equivalent to
1000000 us. Therefore we require 15625 (1000000 / 64) minor ticks to give us a
1 second delay. Finally 65536 - 15625 = 49910, so our preload value become
49910.
If 15625 minor ticks @4MHz gives a 1 second delay then 15.625 minor ticks, rounded up to 16, @4MHz gives about a 1ms delay.

My calcuations for setting up timer1 as a 1ms timer at the clock frequencies M4, M8, M16, M32 and M64 on the 20X2:

4MHz
Major ticks for 1ms delay: 15.62
Delay calculated with rounded tick: 16 x 64us = 1.024ms
Preload value: 65520
Error: 2.4%

8MHz
Major ticks for 1ms delay: 31.25
Delay calculated with rounded tick: 31 x 32us = 0.992ms
Preload value: 65505
Error: 0.8%

16MHz
Major ticks for 1ms delay: 62.5
Delay calculated with rounded tick: 62 x 16us = 0.992ms
Preload value: 65473 or 65474
Error: 0.8%

32MHz
Major ticks for 1ms delay: 125
Delay calculated with rounded tick: 125 x 8us = 1.000ms
Preload value: 65411
Error: 0%

64Mhz
Major ticks for 1ms delay: 250
Delay calculated with rounded tick: 250 x 4us = 1.000ms
Preload value: 65286
Error: 0%

It looks like you can also setup timer3 as a 1ms timer using the tmr3setup command to setup the prescaler value and using peeksfr to setup the preload value.
 

oracacle

Senior Member
Note: Storing ints and floats in variables, and adding those variables together and storing the result in another variable takes...about 10 instruction cycles for the INT and 240 instruction cycles for the float.

So, Floating point math is MUCH slower.
I have done some work with the uM-FPU. its specified to allow 10ms for a calculation to complete. On the subject of that little device, I thought I had heard a rumour that it is no longer being produced.

I keep toying with looking through some of the floating point programmes that people have posted and seeing they can be put onto a picaxe and used as an external FPU. Although be comparison the functionality will be less
 

oracacle

Senior Member
I think that maybe the reason. I saber finding roots, expoents and fast fourier transforms take a while so the long time its to ensure you don't run into trouble trying to get out to do something before out has finished the last thing you asked it to do
 
Top