Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:34 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : What is everybody body building these days.

     Page 2 of 2    
Author Message
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3800
Posted: 11:41am 19 Jun 2024
Copy link to clipboard 
Print this post

Is there a PicoBasic? Is it a name for MMBasic on a Pico or was PiccoloBasic meant?

And... then there's the ever-thorny question of faster doing what (and is it a useful what)?

John
Edited 2024-06-19 21:42 by JohnS
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 01:17pm 19 Jun 2024
Copy link to clipboard 
Print this post

  asknik2022 said  I haven't done a comparison but if you would like to let me a PicoBasic test file then I will convert to uPython and do a comparison test between the two


I don't know if "PicoBasic" is meant to refer to MMBasic, but for starters, there's the frequently done MMBasic benchmark code.

Main Benchmark Thread

Latest full update chart

Code:
Print "Maximite Benchmark tests"
Print " "

Print "Benchmark 1"
Timer = 0
For j = 1 To 1000
Next j
Print Timer / 1000
Print " "

Print "Benchmark 2"
Timer = 0
j =j0
BM2:
j = j+1
If j < 1000 GoTo BM2
Print Timer / 1000
Print " "

Print "Benchmark 3"
Timer = 0
j = 0
BM3:
j = j+1
a = j/j*j+j-j
If j < 1000 GoTo BM3
Print Timer / 1000
Print " "

Print "Benchmark 4"
Timer = 0
j = 0
BM4:
j = j+1
a = j/2*3+4-5
If j < 1000 GoTo BM4
Print Timer / 1000
Print " "

Print "Benchmark 5"
Timer = 0
j = 0
BM5:
j = j+1
m = j/2*3+4-5
Gosub 4000
If j < 1000 GoTo BM5
Print Timer / 1000
Print " "

Print "Benchmark 6"
Timer = 0
j = 0
dim ray(5)
BM6:
j = j+1
m = j/2*3+4-5
Gosub 4000
For q = 1 TO 5
Next q
If j < 1000 GoTo BM6
Print Timer / 1000
Print " "

Print "Benchmark 7"
Timer = 0
j = 0
dim ray2(5)
BM7:
j = j+1
m = j/2*3+4-5
Gosub 4000
For q = 1 TO 5
ray2(q) = m
Next q
If j < 1000 GoTo BM7
Print Timer / 1000
Print " "

Print "Benchmark 8"
Timer = 0
j = 0
BM8:
j = j+1
m = j^2
blog = LOG(j)
csin = SIN(j)
If j < 1000 GoTo BM8
Print Timer / 1000

End

4000 RETURN


(With all the caveats about how benchmarks may not accurately show the difference between the performances for two microprocessors for any given particular application.)

~
Edited 2024-06-19 23:21 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
asknik2022
Regular Member

Joined: 26/03/2022
Location: United Kingdom
Posts: 92
Posted: 05:10pm 19 Jun 2024
Copy link to clipboard 
Print this post

PhenixRising Called it Picobasic but I am asssuming that he meant mmbasic on the pico.

I will try this test after I have converted it to uPython etc...
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 05:22pm 19 Jun 2024
Copy link to clipboard 
Print this post

When you need speed, go C.
All interpreters are slower. And honestly MMBasic is not one of the faster basic interpreters(*). But it has a huge feature set(funtions and commands).
You do not decide on sheer speed if python does not provide support libraries for your project.

Volhout
(*)
My tinybasic interpreter on arduino uno was faster than MM2 on 48Mhz. But only integer math....
PicomiteVGA PETSCII ROBOTS
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2127
Posted: 05:46pm 19 Jun 2024
Copy link to clipboard 
Print this post

I posted earlier about converting gcbasic as7262 spectral to mmbasic. it's difficult for me.
I found a python version, can anyone please help me.
https://github.com/pimoroni/as7262-python/tree/main/as7262
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 07:06am 20 Jun 2024
Copy link to clipboard 
Print this post

Hi Stan,

In this case it is not simple port. The I2C reading is not the problem. As mentioned before, the floating point format is not the same as the one used by the pico mite.
This means that you have to convert the values (extract mantissa and exponent) and re-combine them. To do this without an actual chip, this is prone for errors, that is why I am not volunteering.

In this case, I personally would work from the datasheet (ignore the python code) and work from there. Step by step. I did the same for the thermal camera. And it simply takes time.

First you start communicating (I2C) with the chip.

Then read the calibration registers, and convert them to values you need in the math.
Then reaf the sensor values (I think there are 8, there green and orange are double).
Then do the math....

Step by step... It may take a week, 2 weeks (it took me 4-5 weeks for the thermal camera) but you will get there eventually.

Volhout
Edited 2024-06-20 17:07 by Volhout
PicomiteVGA PETSCII ROBOTS
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2075
Posted: 09:17am 20 Jun 2024
Copy link to clipboard 
Print this post

Hi Stan

the double <--> single conversion is going to be a pain point.

If you are building a spectrometer, I am guessing that speed is not an issue - you present the sample light source and get a reading of its spectral make-up - you are working in "human timeframes". Maybe not(?)

For me, this wouldn't present a problem as the AS7262 seems easy enough to talk-to and the MicroMite Mk2 (my chip of choice) will speak natively to the FP registers in it. The MM is a powerful little beast but slower than the PicoMite in raw performance. Clever programming can hide this and make for a very responsive system "even at" 48MHz. Bear with me... there is a reason I have gone off on this particular tangent...

If you are committed to the PicoMite and don't want to leave MMBasic, perhaps consider a MicroMite slaved to the Pico to act as an extra layer to your interface. You could talk across the serial as "text" very quickly (230Kb?) convert from strings to FP on each platform very easily and the MicroMite would not be stretched in the slightest - this might sound complicated, but the prog for the MM would be quite straight forward - develop a simple protocol along the lines of:
PUTBYTE,n,register
PUTFLOAT,n,register
GETBYTE,register
GETFLOAT,register

and a typical command from your Pico would be

PUTFLOAT,78.332,27
GETFLOAT,12

etc.

The MM puts "n" in either a Float or Integer variable and then talks to the AS7262. This is largely what the MM prog needs to be, just runs in a loop monitoring the serial port (I would use the console port) for commands and responds accordingly. Sure it's an extra bit of work, but it is a single chip solution and would do the job. Any time critical stuff you'll have to cater for, but consider off-loading the AS7262 tasks to the MM. This leaves you to do all the pretty stuff on the Pico. This is going back to the (P)rogrammabe (I)nterface (C)ontroller's roots - I love it!

In the absence of anyone else's solution, I don't know what to suggest to get around the precision conversion. Ideally there would be additions as I first posited but I don't want to make work for others - nothing is impossible for the man who doesn't have to do the work right? This is genuinely how I would approach your problem.

MMs make great slave modules - I have a friend with a Harley Davidson that has two on his bike and they chatter back and forth quite happily. There are various small MM modules available and I can provide a 32mm square PCB for you - drop me a PM if you are interested.

h
Edited 2024-06-20 19:39 by CaptainBoing
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 10:50am 20 Jun 2024
Copy link to clipboard 
Print this post

deleted

Volhout
Edited 2024-06-20 21:22 by Volhout
PicomiteVGA PETSCII ROBOTS
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2127
Posted: 12:31pm 20 Jun 2024
Copy link to clipboard 
Print this post

The great cow basic library for as7262 uses gcb "still under development" floats but the author says you can use integers. In the as7262 data sheet it shows float values or 0-255.
I will re-read the data sheet and the gcb code, which I haven't used since using picomite.
I suppose I could use a LGT328 and gcbasic then a serial to a picomite but gcb supports ili9341 so dunno. cheers, stan
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2075
Posted: 12:36pm 20 Jun 2024
Copy link to clipboard 
Print this post

Hi Stan, you need to see this post

then you can just work from the datasheet for the chip
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2127
Posted: 02:22pm 20 Jun 2024
Copy link to clipboard 
Print this post

  CaptainBoing said  Hi Stan, you need to see this post

then you can just work from the datasheet for the chip

yes sir,saw it, I'm not good at math though so don't understand float bits.
never sorted a library from a data sheet either but how many do, apart from developers?
well it's back to data sheet and mmedit and the manual on 2 displays.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2075
Posted: 02:35pm 20 Jun 2024
Copy link to clipboard 
Print this post

Me neither, but you don't need to.

Pete has done the heavy lift, just pick the bones out of his example code and that will translate the single precision (4 byte) FP numbers from that chip, to the double precision (8 byte) FP number of the Pico (and others)

h
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2127
Posted: 05:41pm 20 Jun 2024
Copy link to clipboard 
Print this post

@Captainboing - the data sheet says you can read 2 byte values, hi then low so result would be hi*256+low? I'm reading the mmb manual, can't remember everything :)
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2075
Posted: 08:25pm 20 Jun 2024
Copy link to clipboard 
Print this post

many ways to skin a cat, but that is as good as any
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 482
Posted: 12:34am 21 Jun 2024
Copy link to clipboard 
Print this post

It does looks nifty .. [ though I wouldn't try to make a serious spectrometer with it, not nearly enough wavelengths ]

Maybe the try the Arduino project / code as a guide

colour sensor
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3800
Posted: 07:28am 21 Jun 2024
Copy link to clipboard 
Print this post

  stanleyella said  @Captainboing - the data sheet says you can read 2 byte values, hi then low so result would be hi*256+low?

Often, yes.

A lot of ADC-type things provide integers on the understanding that they represent (say) 0-3.3V so to get the actual oltage you'd use the formula
value*3.3/range
where value is the reading and range is the max value the reading can be (1024 or whatever).

John
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024