![]() |
Forum Index : Microcontroller and PC projects : Windows PC master and PicoMites as slaves
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
Oh shoot I need: 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 KingdomPosts: 1516 |
Perfect ![]() 4M Baud is really nice. ![]() |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1516 |
Three instances of SmallBASIC talking to PicoMites: ![]() |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5217 |
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 KingdomPosts: 1516 |
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. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5217 |
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 KingdomPosts: 1516 |
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 StatesPosts: 3404 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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 StatesPosts: 3404 |
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 KingdomPosts: 1516 |
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 KingdomPosts: 1516 |
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: AustraliaPosts: 6300 |
From the manual 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 KingdomPosts: 1516 |
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 ![]() |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |