Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:47 02 Jul 2025 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 : Quadrature multichannel decoder for PicoMite using PIO

     Page 6 of 7    
Author Message
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 08:37pm 08 Jun 2025
Copy link to clipboard 
Print this post

  phil99 said  In the old CMM2 User Manual under "Power & Serial Console Connector" are instructions on how to connect, including this:-
  Quote  On a Windows computer the Colour Maximite will appear as an additional serial port in Device Manager as illustrated on the right.
That will tell you which port to use. And this:-
  Quote  The terminal emulator and the serial port that it is using should be set to the Colour Maximite 2 standard of 115200 baud, 8 data bits and one stop bit.
I imagine the Gen2 is similar.


I searched on the web to find the old CMM2 User Manual and couldn't find it anywhere.
I couldn't find it on Geoff's web site either.
Do you know where I can find it?

Allie
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 10:46pm 08 Jun 2025
Copy link to clipboard 
Print this post

As you have the Gen 2 that is the manual you need. It's serial console looks similar to the old one.
See page 11, Power & Serial Console Connector.

The downloads are at the bottom of this page. https://geoffg.net/maximite.html
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 10:49am 26 Jun 2025
Copy link to clipboard 
Print this post

  Volhout said  Hi Allie,

The code you have from PhenixRising prints the counts to screen.
If you open a serial port on the picomite, you can send the same data to the CMM2.

This is the current main loop

'main loop
do
a$=inkey$                                     'just for control

'get the data from the fifo and print
if sm0 then print str$(read_fifo(0),12,0);    'get data from decoder
if sm1 then print str$(read_fifo(1),12,0);    'get data from decoder
if sm2 then print str$(read_fifo(2),12,0);    'get data from decoder
if sm3 then print str$(read_fifo(3),12,0);    'get data from decoder
print

'just some pause
pause 100                                     'any delay needed

'reset position (PIO X register) under control of keyboard
if a$="r" then                                'press r to zero position
  if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
  a$=""
end if

loop while a$=""  'exit when any key not r


That would convert to


'serial comms to CMM2 using GP20 and GP21
SETPIN GP21,GP20,COM2
OPEN "COM2:112500" AS #1

'main loop
do
a$=inkey$                                     'just for control

'get the data from the fifo and print
if sm0 then print #1,str$(read_fifo(0),12,0);    'get data from decoder
if sm1 then print #1,str$(read_fifo(1),12,0);    'get data from decoder
if sm2 then print #1,str$(read_fifo(2),12,0);    'get data from decoder
if sm3 then print #1,str$(read_fifo(3),12,0);    'get data from decoder
print

'just some pause
pause 100                                     'any delay needed

'reset position (PIO X register) under control of keyboard
if a$="r" then                                'press r to zero position
  if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
  a$=""
end if

loop while a$=""  'exit when any key not r


In this code you would still use the keyboard of the picomite (or console) to reset the counters. For full automation using the CMM2 you would replace the a$=inkey$ with  a$=INPUT(#1,1) or similar.
And maybe you want to replace the
loop while a$=""

with
loop


To make sure the loop on the pico never stops.

Volhout
.


I changed the program from printing to the screen to printing to the serial port with your updated version to print to the serial port but when I run the program I get the Error message :

[33] Setpin GP21,GP20,COM2

ERROR : Pin 27/GP21 IS IN USE.

 I don't have anything else hooked to this pin 27. Only SETPIN GP21
 How do I fix this?

Regards Allie

ERROR :
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5023
Posted: 12:13pm 26 Jun 2025
Copy link to clipboard 
Print this post

Hi Allie,

Please restart the pico, and type "OPTION LIST" and show it here.
Maybe you have VGA firmware programmed in the pico. In that case pin 20,21 is already assigned to VGA video.

In my writing to you I assumed you where using a pico as microcontroller. That is why I assigned GP21 and GP20.

Volhout
Edited 2025-06-26 22:20 by Volhout
PicomiteVGA PETSCII ROBOTS
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 04:27pm 26 Jun 2025
Copy link to clipboard 
Print this post

Yes, I am using Pico as micro controller and programming it by the console.

I checked the OPTION LIST and the results are.

 PicoMite MMBasic Version 5.08.00
>

This is all it showed.
 Regards allie
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1332
Posted: 04:41pm 26 Jun 2025
Copy link to clipboard 
Print this post

Works perfectly on mine.

Might be an idea to bring your firmware up to date?

Latest release
Edited 2025-06-27 02:42 by PhenixRising
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 07:14pm 26 Jun 2025
Copy link to clipboard 
Print this post

  PhenixRising said  Works perfectly on mine.

Might be an idea to bring your firmware up to date?

Latest release


I would like to upgrade to a new firmware. I have another RP2040 Pico along with the Pico 2 but I can't find a program to open the UF2 file. Do you know where a good one is that I can download?

Best Regards Allie
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5023
Posted: 08:07pm 26 Jun 2025
Copy link to clipboard 
Print this post

Hi Allie,

You do not need a program to open the uf2 file.

Hold the BOOT button on the pico while you plug it into a computer. After a second let go of the BOOT button.
On the computer (file manager) you can find a USB mass storage device is added after a few seconds. Open the mass storage device. There are 2 files already on the mass storage device.
Use the mouse to drag the picomite.uf2 file onto that mass storage device (as the 3'rd file, do not touch the other 2 files on the pico).

Wait 10 seconds.. (the pico will program).

Done...
Now you can open Teraterm/Putty and talk to the pico again. When you do a OPTION LIST the top line will show you have the new version. Note that all files you had on the pico A:/ drive will be wiped by this action.

For pico / RP2040 use PicoMiteRP2040V6.00.02.uf2
For pico-2 / RP2350 use PicoMiteRP2350V6.00.02.uf2

Volhout
Edited 2025-06-27 06:11 by Volhout
PicomiteVGA PETSCII ROBOTS
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 09:04pm 26 Jun 2025
Copy link to clipboard 
Print this post

  Volhout said  Hi Allie,

You do not need a program to open the uf2 file.

Hold the BOOT button on the pico while you plug it into a computer. After a second let go of the BOOT button.
On the computer (file manager) you can find a USB mass storage device is added after a few seconds. Open the mass storage device. There are 2 files already on the mass storage device.
Use the mouse to drag the picomite.uf2 file onto that mass storage device (as the 3'rd file, do not touch the other 2 files on the pico).

Wait 10 seconds.. (the pico will program).

Done...
Now you can open Teraterm/Putty and talk to the pico again. When you do a OPTION LIST the top line will show you have the new version. Note that all files you had on the pico A:/ drive will be wiped by this action.

For pico / RP2040 use PicoMiteRP2040V6.00.02.uf2
For pico-2 / RP2350 use PicoMiteRP2350V6.00.02.uf2

Volhout


 The pico / RP2040 which I have has a USB connector on the board. Will I use the picoMiteRP2040USBV6.00.02.uf2?

I also have 3 pico2's with a USB connector. Would I use the RP2350USBV6.00.02.uf2 on  these.

Thanks in advance.

Regards Allie
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7820
Posted: 09:22pm 26 Jun 2025
Copy link to clipboard 
Print this post

When you are updating using a uf2 file you have to connect the PC directly to the Pico's USB connector. The virtual drive that's created is done by a boot loader ROM built into the Pico's flash chip.

If you have anything else connected to the Pico's D+ and D- USB connections then it has to be disconnected or Windows will fail to find the virtual drive.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1000
Posted: 11:46pm 26 Jun 2025
Copy link to clipboard 
Print this post

  allie said  
The pico / RP2040 which I have has a USB connector on the board. Will I use the picoMiteRP2040USBV6.00.02.uf2?

I also have 3 pico2's with a USB connector. Would I use the RP2350USBV6.00.02.uf2 on  these.

No. The .uf2 firmware with  'USB' in the name are used for PICO setups that have a USB hub built in to provide multiple USB ports.
For the standard PICOs use the files suggested by @volhout
i.e.
For pico / RP2040 use PicoMiteRP2040V6.00.02.uf2
For pico-2 / RP2350 use PicoMiteRP2350V6.00.02.uf2

The USB port becomes the console after this firmware is loaded.
Latest F4 Latest H7 FotS
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 08:09am 27 Jun 2025
Copy link to clipboard 
Print this post

Thanks for all of the above posts from all of you. I'll start programming some of the Pico's today.

Best regards Allie.
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 09:06pm 29 Jun 2025
Copy link to clipboard 
Print this post

  allie said  
  Volhout said  Hi Allie,

The code you have from PhenixRising prints the counts to screen.
If you open a serial port on the picomite, you can send the same data to the CMM2.

This is the current main loop

'main loop
do
a$=inkey$                                     'just for control

'get the data from the fifo and print
if sm0 then print str$(read_fifo(0),12,0);    'get data from decoder
if sm1 then print str$(read_fifo(1),12,0);    'get data from decoder
if sm2 then print str$(read_fifo(2),12,0);    'get data from decoder
if sm3 then print str$(read_fifo(3),12,0);    'get data from decoder
print

'just some pause
pause 100                                     'any delay needed

'reset position (PIO X register) under control of keyboard
if a$="r" then                                'press r to zero position
  if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
  a$=""
end if

loop while a$=""  'exit when any key not r


That would convert to


'serial comms to CMM2 using GP20 and GP21
SETPIN GP21,GP20,COM2
OPEN "COM2:112500" AS #1

'main loop
do
a$=inkey$                                     'just for control

'get the data from the fifo and print
if sm0 then print #1,str$(read_fifo(0),12,0);    'get data from decoder
if sm1 then print #1,str$(read_fifo(1),12,0);    'get data from decoder
if sm2 then print #1,str$(read_fifo(2),12,0);    'get data from decoder
if sm3 then print #1,str$(read_fifo(3),12,0);    'get data from decoder
print

'just some pause
pause 100                                     'any delay needed

'reset position (PIO X register) under control of keyboard
if a$="r" then                                'press r to zero position
  if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
  if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
  a$=""
end if

loop while a$=""  'exit when any key not r


In this code you would still use the keyboard of the picomite (or console) to reset the counters. For full automation using the CMM2 you would replace the a$=inkey$ with  a$=INPUT(#1,1) or similar.
And maybe you want to replace the
loop while a$=""

with
loop


To make sure the loop on the pico never stops.

Volhout
.


I changed the program from printing to the screen to printing to the serial port with your updated version to print to the serial port but when I run the program I get the Error message :

[33] Setpin GP21,GP20,COM2

ERROR : Pin 27/GP21 IS IN USE.

 I don't have anything else hooked to this pin 27. Only SETPIN GP21
 How do I fix this?

Regards Allie

ERROR :


I programed a new RP2040 Pico with the MMBasic firmware version 6.00.02 and I still get the same Error msg.

 [33] Setpin GP21,GP20,COM2

ERROR : pin 27/GP21 IS IN USE.

So I tried these pins which is available on the PicoMite which is;

 SETPIN rx,tx,COM1

 Valid pins are        RX   GP1,GP13 or GP17
                       TX   GP0,GP12 or GP16
   
                             and

                       RX   GP21
                       TX   GP20    for COM2

 They all give the same ERROR MSG. about the first pin in the paired group.

Regards Allie
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 09:34pm 29 Jun 2025
Copy link to clipboard 
Print this post

  Volhout said  Please restart the pico, and type "OPTION LIST" and show it here.
Then type LIST PINS and show it here.
.
Edited 2025-06-30 07:37 by phil99
 
allie
Regular Member

Joined: 06/10/2018
Location: Canada
Posts: 80
Posted: 11:27pm 29 Jun 2025
Copy link to clipboard 
Print this post

  phil99 said  
  Volhout said  Please restart the pico, and type "OPTION LIST" and show it here.
Then type LIST PINS and show it here.
.


option list
PicoMite MMBasic RP2040 Edition V6.00.02
OPTION COLOURCODE ON
OPTION CPUSPEED 200000

GP0   1   OFF
GP1   2   OFF
GP2   4   OFF
GP3   5   OFF
GP4   6   OFF
GP5   7   OFF
GP6   9   OFF
GP7   10  OFF
GP8   11  OFF
GP9   12  OFF
GP10  14  OFF
GP11  15  OFF
GP12  16  OFF
GP13  17  OFF
GP14  19  OFF
GP15  20  OFF
GP16  21  OFF
GP17  22  OFF  
GP18  24  OFF
GP19  25  OFF
GP20  26  OFF
GP21  27  OFF
GP22  29  OFF
GP23  41  DOUT
GP24  42  DIN
GP25  43  HEARTBEAT
GP26  31  OFF
GP27  32  OFF
GP28  34  OFF
GP29  44  AIN

 REGARDS ALLIE
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 12:13am 30 Jun 2025
Copy link to clipboard 
Print this post

[Removed mistaken speculation.]
Edited 2025-06-30 10:14 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 01:34am 30 Jun 2025
Copy link to clipboard 
Print this post

That is a puzzle.
Loaded V6.00.02 on a RP2040 but can't replicate the problem.
> option list
PicoMite MMBasic RP2040 Edition V6.00.02
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 200000
>
> LIST
SetPin GP21,GP20,COM2
Open "com2:115200" As #2

For n=1 To 5
 Print #2, "The quick brown fox"
 Pause 999
Next

End
>
and the output from com2
The quick brown fox
The quick brown fox
The quick brown fox
The quick brown fox
The quick brown fox

Also works from the command line.
> SetPin GP21,GP20,COM2 :Open "com2:115200" As #2
> Print #2, "jumps over the lazy dog" :pause 9 'allow time to transmit
>

and the output from com2
jumps over the lazy dog


All I can think of is somehow SetPin GP21,GP20,COM2 is being duplicated causing the second instance to report an error.

In a program SetPin GP21,GP20,COM2 is normally only used once in the setup area. If you need to use it in a SUB precede it with ON ERROR SKIP
CLOSE #x
Edited 2025-06-30 11:52 by phil99
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 01:46am 30 Jun 2025
Copy link to clipboard 
Print this post

Is the hardware actually a WebMite flashed with PicoMite firmware?

"Note that on the WebMite version:
COM1 and COM2 are not available on GP20 to GP28"

I'm not sure that this behavior would result from this case.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 01:54am 30 Jun 2025
Copy link to clipboard 
Print this post

  allie said  option list
PicoMite MMBasic RP2040 Edition V6.00.02
OPTION COLOURCODE ON
OPTION CPUSPEED 200000

So that shouldn't be a problem, LIST PINS shows the firmware is unaware of anything connected to GP21/20.
 The firmware wont show an error but COM2 just wont work if there is a WiFi module on the pins.
.
Edited 2025-06-30 13:08 by phil99
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1332
Posted: 05:31am 30 Jun 2025
Copy link to clipboard 
Print this post

All I can think of is nuke the flash (if not already happened) and load again.
 
     Page 6 of 7    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025