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.
Joined: 18/02/2023 Location: United StatesPosts: 118
Posted: 09:06pm 10 Sep 2023
Copy link to clipboard
Print this post
The classic Amazing.Bas program modified to run on MMBasic. And also modified to print the maze's solution:
Mixtel90
Guru
Joined: 05/10/2019 Location: United KingdomPosts: 6798
Posted: 09:50pm 10 Sep 2023
Copy link to clipboard
Print this post
Very good Ednedn. :) Welcome to the forum!
How do you like working in MMBasic?
If you want to set yourself a challenge, go over it again doing it without line numbers, GOTO or GOSUB and using SUB / END SUB and FUNCTION / END FUNCTION. It can be quite an eye-opener as you really have to understand how the program is working.Mick
Joined: 18/02/2023 Location: United StatesPosts: 118
Posted: 10:42pm 10 Sep 2023
Copy link to clipboard
Print this post
I converted Amazing.bas to MMBasic just to see how well the Pico version would run. And to get familiar with the tools and such. Mostly I used the embedded Edit command connected to a Tera-Terminal. But now I'm mostly using the Maximite Control program paired with MMEdit.
I kind of did what you suggest with ditching the line numbers. I needed a signal generator to send pulse trains at different frequencies to calibrate an electronic tachometer for an old car that is getting restored. The code is below:
MMBasic on a Raspberry Pi RP2040 is impressive. The speed is good and provides a reliable platform for whatever the user has in mind. In the signal generator case, I was able to turn a $3 Raspberry Pi Zero into a precision calibration tool.
Edited 2023-09-11 08:43 by EDNEDN
phil99
Guru
Joined: 11/02/2018 Location: AustraliaPosts: 2136
Posted: 11:52pm 10 Sep 2023
Copy link to clipboard
Print this post
You may be able to shorten your signal generator a little. The PicoMite has a lot of useful features to do that. This method doesn't even need a program, just the command prompt will do. eg.
> option cpuspeed 64000 'reduce the CPU speed to use PWM at low frequencies PicoMite MMBasic Version 5.07.08b15 Copyright 2011-2023 Geoff Graham Copyright 2016-2023 Peter Mather
> setpin gp17,pwm 'GP17 is PWM channel 0B > rpm = 1000 'engine speed > cyls = 8 'number of cylinders > pps = rpm * cyls / 2 / 60 'pulses per second > pw = rpm / 500 'pulse width, change 500 to get the right pulse width > pwm 0,pps,,pw 'the extra coma skips channel A to output on B
Using PULSE in a SETTICK interrupt subroutine is another way.
EDNEDN Senior Member
Joined: 18/02/2023 Location: United StatesPosts: 118
Posted: 11:57pm 10 Sep 2023
Copy link to clipboard
Print this post
Wow!
That is impressive! MMBasic on a Pico is definitely a good foundation for home projects!
phil99
Guru
Joined: 11/02/2018 Location: AustraliaPosts: 2136
Posted: 12:23am 11 Sep 2023
Copy link to clipboard
Print this post
The command prompt has a line editor so to change the RPM use the up arrow to get to that line and change the value. Then re-run the other lines. CYLS won't change so that doesn't need to be repeated. Even that can be simplified, putting the lot on one line.
Joined: 18/02/2023 Location: United StatesPosts: 118
Posted: 02:06am 11 Sep 2023
Copy link to clipboard
Print this post
While that would work... Maybe it can be optimized a little bit:
(I think you might have fat fingered the keyboard and got an extra calculation for the pulses/sec in there....)
THANKS!!!!! Edited 2023-09-11 12:21 by EDNEDN
Mixtel90
Guru
Joined: 05/10/2019 Location: United KingdomPosts: 6798
Posted: 06:27am 11 Sep 2023
Copy link to clipboard
Print this post
The PicoMite has a command, BITSTREAM PULSEOUT that will produce custom pulse trains with very high precision. It's not relevant to this application as it's way too fast, but it gives an example of the sort of things that can be done.
Triggering a PULSE command from a SETTICK interrupt is another way, but most of the interrupts in MMBasic are not precision as they are scanned at the end of each line. It's still a useful technique though, especially for short pulses with long periods between them.
You usually find that there are several ways to skin a cat in MMBasic. :)Mick
Joined: 18/02/2023 Location: United StatesPosts: 118
Posted: 01:20pm 11 Sep 2023
Copy link to clipboard
Print this post
I appreciate the pointers to different ways to accomplish the task.
I need to understand the Chanel A and Chanel B thing on the pwm command. I haven't pulled up the documentation or code yet to check it out, but I'm guessing there are only two pins that can be put under control with the pwm command and that is why there is a Chanel A and a Chanel B. I'll get that fully understood first.
Then I'll learn about the BITSTREAM PULSEOUT command. And see what can be done with that as well as how it is implemented in the firmware. If it is utilizing hardware timer support in the chip it is very possible only certain pins can be controlled. I'll get that understood next.
And then I'll check out the SETTICK interrupt stuff. It will be interesting to see how that is implemented in the firmware.
Thanks again people for help getting up the learning curve!
phil99
Guru
Joined: 11/02/2018 Location: AustraliaPosts: 2136
Posted: 01:48pm 11 Sep 2023
Copy link to clipboard
Print this post
Page 9 of the latest PicoMite manual has a pin diagram showing what functions can be assigned to each pin. There are 8 PWM channels (0 to 7) that can each have a unique frequency. Each of those can drive 2 pins with different mark-space ratios (A and B). A full description is on page 121.