Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:59 08 Sep 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 : Windows PC master and PicoMites as slaves

     Page 2 of 3    
Author Message
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 09:40am 02 Sep 2025
Copy link to clipboard 
Print this post

Hi Harm,

No, I am absolutely bare-bones; simple loopback routine, freshly nuked and flashed PicoMites, no overclock, no options. I even dropped the USB Baud to 115,200.

RP2040 and RP2350 both freeze within seconds.

Old firmware on RP2040 was bombarded for ~24hrs @ 4M Baud and it only stopped when I stopped it.

I shall persevere  
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 10:31am 02 Sep 2025
Copy link to clipboard 
Print this post

Everything points to INKEY$ getting upset  

Meh, sticking with Bluetooth and RS422. Child's play and solid reliability  
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 11:38am 02 Sep 2025
Copy link to clipboard 
Print this post

OK, I need a butt-kicking  

INKEY$ only strips a single character...needs something like:


do
   b=inkey$
loop until b = ""


My structure was allowing the KB buffer to get full and messed-up the USB comms.

In my case, this is can still work well as I only process one received character at a time.

Don't understand why the RP2040 on old FW didn't choke, though.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 11:41am 02 Sep 2025
Copy link to clipboard 
Print this post

Must have been a dream but I had it in my head that "COM0:" configured the PicoMite USB port as a regular UART.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 11:54am 02 Sep 2025
Copy link to clipboard 
Print this post

Oh shoot I need:

  Quote  INPUT$(nbr, [#]fnbr)
Will return a string composed of ‘nbr’ characters read from a file or serial
communications port opened as 'fnbr'. This function will return as many
characters as are in the file or receive buffer up to ‘nbr’. If there are no
characters available it will immediately return with an empty string.
#0 can be used which refers to the console's input buffer.
The # is optional. Also see the OPEN command.


I Knew that I'd see something about #0  

Edit: You guys just like to see me struggle  
Edited 2025-09-02 21:55 by PhenixRising
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 12:07pm 02 Sep 2025
Copy link to clipboard 
Print this post

Perfect  

4M Baud is really nice.  
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 12:42pm 02 Sep 2025
Copy link to clipboard 
Print this post

Three instances of SmallBASIC talking to PicoMites:


 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5217
Posted: 01:04pm 02 Sep 2025
Copy link to clipboard 
Print this post

Hi Phenix,

Help is provided at Hogwards for those who ask for it.. Dumbledoor quote.

analogy

You just needed to show your code, and ask for advise. Always willing to help...
This is a terminal program I sometimes use (work with lines terminated with <CR>).

'Communication terminal to set up HC-15
'disconnect KEY, and reboot HC-15

 ' open COM port pico
 SetPin gp17,gp16,COM1
 Open "COM1:9600" As #1

 'interactive terminal function
 Print "<ESC> to stop"
 Do
   'input command
   Input "command";k$
   Print #1,UCase$(k$)'; 'send upper case commands

   'wait for response and read + print response
   Pause 100

   Line Input #1,b$
   Print b$

   'empty rx buffer
   Do : b$=Input$(1,#1) : Loop Until Loc(1)=0

 Loop Until k$=Chr$(27)
End


Volhout
Edited 2025-09-02 23:10 by Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 01:11pm 02 Sep 2025
Copy link to clipboard 
Print this post

I did....but I missed that INKEY$ only strips a single character. Buffer got choked and messed-up the USB. I had to unplug the PicoMite to get comm's back.


  PhenixRising said  
RP2040 has continued to run without a problem. I need to investigate further with the RP2350 and firmware revisions, etc.

The Windows app simply increments a variable and sends it via USB to the PicoMite which then prepends "Pico: " to the value and sends it back.

dim as string chars
do  
 chars=inkey$
 if chars<>"" then
     print "Pico: "+ chars;
 end if
loop
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5217
Posted: 01:20pm 02 Sep 2025
Copy link to clipboard 
Print this post

Phenix,

When you send data at 4Mbps to the pico, it will not be able to handle that in a routine like the one you showed. Buffers will overrun.
The DO-LOOP is 6 commands. When the pico runs at 300MHz, it may execute 100000 instructions per second. 6 instructions is 16666 loops per second. And you process 8+3=11 bits. Your maximum baudrate will be around 190kbps.
Of coarse this is very rough calculation, and it may be 50% off, but you are not achieving 20x speed (4Mbps/190kbps). The estimation is not that far of.

For higher speeds you need to process more data in 1 loop (more bytes).

Regards,

Volhout
P.S. a CMM2 with near 500000 basic instructions per second, also can not sustain 4Mbps using single character acquisitiom.
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 01:21pm 02 Sep 2025
Copy link to clipboard 
Print this post

This works perfectly


dim as integer a
dim as string b

do
 do
   b=input$(250,0)    'reads up to 250 characters from console buffer (#0)
 loop until b = ""

 pause 100

 inc a
 print a        'sends to Windows app via USB
loop
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3404
Posted: 01:54pm 02 Sep 2025
Copy link to clipboard 
Print this post

Works perfectly to do exactly what?

b is always empty when the loop exits, and nothing in the loop saves what has been returned when b is not empty.

When I tested a CMM2 at 1M with a buffer of more than 1MB, by far the biggest time delay was saving what had been received so that MMBasic could do something with it (and then doing it would be another issue).

FYI, here's a PC sending 10+ megabytes to a CMM2 at "baud%=1843200" with a 2MB buffer using XON/XOFF flow control: 1.8Mb/sec

CRC checked OK. 20% of the time to completion was transmission, 80% was saving the data.

~
Edited 2025-09-03 00:11 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 02:26pm 02 Sep 2025
Copy link to clipboard 
Print this post

  lizby said  Works perfectly to do exactly what?


Just communicating reliably.

A large packet for me is <30 characters. I am using the USB console port in lieu of the COM1/COM2 UARTS.

The idea is that; the Master Controller (Windows PC) can also directly edit the PicoMites programs and the PicoMites still have two free UARTS.

I have always used Android via Bluetooth for the HMI but now I am toying with the idea of also offering Windows.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 04:11pm 02 Sep 2025
Copy link to clipboard 
Print this post

  Volhout said  Phenix,

When you send data at 4Mbps to the pico, it will not be able to handle that in a routine like the one you showed. Buffers will overrun.
The DO-LOOP is 6 commands. When the pico runs at 300MHz, it may execute 100000 instructions per second. 6 instructions is 16666 loops per second. And you process 8+3=11 bits. Your maximum baudrate will be around 190kbps.
Of coarse this is very rough calculation, and it may be 50% off, but you are not achieving 20x speed (4Mbps/190kbps). The estimation is not that far of.

For higher speeds you need to process more data in 1 loop (more bytes).

Regards,

Volhout
P.S. a CMM2 with near 500000 basic instructions per second, also can not sustain 4Mbps using single character acquisitiom.


The Benefit of the high baud rate, is that; my small packets are there instantly.

I see lots of examples where LOC() is checked for TRUE and then a PAUSE is used to ensure that all the data has arrived before reading. I don't like blocks (PAUSE) in my programs.

My programs receive a message, process the message and then reply.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 04:18pm 02 Sep 2025
Copy link to clipboard 
Print this post

So everything was much improved but I would still experience a USB freeze, sometimes the RP2040 and sometimes the RP2350.

Looking at my Windows code (SmallBASIC), I realized that I had missed the semicolon:

print #1,str(d)


I don't know why because I automatically use it between MCUs

I added it

print #1,str(d);

print #2,str(d);


And now it hasn't failed in the longest time.
Fingers crossed. Let's see how it goes.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3404
Posted: 05:25pm 02 Sep 2025
Copy link to clipboard 
Print this post

  PhenixRising said  
  lizby said  Works perfectly to do exactly what?


Just communicating reliably.


Since the code as presented never checks to see if b<>"", it looks to me like it would continually increment a and print it even if nothing was ever sent.

Why not something like sending "ABCDEFGHIJKLMNIPQRSTUVWXYZ" continually (with a pause), and on the receiving end

do
 do until LOC(#0) > 0 ' you know something has been received
   pause 50 ' or however long it takes to send your message at your baud rate
   b$=input$(250,0)
 loop
 if mid$(b$,1,26)="ABCDEFGHIJKLMNIPQRSTUVWXYZ" then
   inc a
   print a
 else
   print "ERROR: "+b$+" Received"
 endif
loop


Or for varying data, use a CRC.

~
Edited 2025-09-03 03:43 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 05:47pm 02 Sep 2025
Copy link to clipboard 
Print this post

Well it loops until b is null.

This is what's currently running:

PicoMite:


dim as integer a,c
dim as string b

do
 do
   b=input$(50,0)
   if len(b) then c = 1
 loop until len(b) = 0

 if c = 1 then
   c = 0
   inc a
   print a
 end if  
loop


SmallBASIC on Windows:

print "step 1"
open "COM5:4000000" as # 2    ' Open COM5 @4M BAUD
open "COM11:4000000" as # 1    ' Open COM11 @4M BAUD
print "step 2"
showpage
c=1
a=0
d=1
print #1,str(d);
print #2,str(d);
repeat
 d++
 delay 20
 
   l = lof(1)   ' Query how much data is in the queue
   if l then
       s$ = INPUT(l,1)    ' get all data
       at 50,50
       print "RP2350"+s$
       print #1,str(d);
       showpage
  fi
   l = lof(2)   ' Query how much data is in the queue
   if l then
       s$ = INPUT(l,2)    ' get all data
       at 50,100
       print "RP2040"+s$
       print #2,str(d);
       showpage
  fi

until inkey="s"

close #1
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 06:13pm 02 Sep 2025
Copy link to clipboard 
Print this post

  Quote  Why not something like sending "ABCDEFGHIJKLMNIPQRSTUVWXYZ" continually (with a pause), and on the receiving end


Oh sure, the data integrity etc., is yet to come. My problem has been with freezing comm's to the point where I would have to unplug the Mites.

The semi-colon appears to have solved the problem; running nicely ever since.
I'll leave it running overnight (excuse for a beverage or 4)  
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6300
Posted: 09:44pm 02 Sep 2025
Copy link to clipboard 
Print this post

From the manual
  Quote  The PicoMite firmware will ignore the baud rate setting so it can
be set to any speed (other than 1200 baud which puts the Pico
into firmware upgrade mode).


If you don't include some sort of speed control sending to the pico, the USB buffer will overrun regardless of the baud rate you have set.

Linux users will also have trouble with the USB buffer overflowing when sending from the Pico.
VK7JH
MMedit
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1516
Posted: 04:14am 03 Sep 2025
Copy link to clipboard 
Print this post

A long packet for me:

-header byte
-address byte (for multidrop RS422)
-control byte (upper nibble = type of operation, lower nibble = number of data bytes to follow)
-data byte
-data byte
-data byte
-data byte etc.
-checksum byte.

Send a packet similar to the above (bin2str) and await response.
I have no need to be throwing lots of data around.
I only use the high baud rate so I don't need to sit around waiting for the rx buffer to fill.


Ran all night and still running, thanks to the semi-colon  
 
     Page 2 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025