Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:59 24 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 : PicoMiteHDMIUSB motherboard reference design

     Page 5 of 7    
Author Message
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 09:54am 23 Oct 2024
Copy link to clipboard 
Print this post

More info on my mouse/USB power issue.

I switched to a different power source, a desktop muti-charger that I am sure is providing more power and cleaner.  It now has stoped boot looping.

The second issue though is that the detection of devices is messed up. I am using a bog standard USB keyboard but the Fantom generic USB gamepad shows up every time. On that, I initially used a Logitec wireless KB/mouse but have switched to the test KB.  Could using that Logitec have messed it up?  

second some mice DO NOT WORK AT ALL. My generic E-wast mouse is not be detected at all. my MS USB/PS2 one does so I don't care as long as one of them does.

Sometimes the mouse gets lost after it is working and is used in a test program and you have to reset it to get it to detect.

Another issue is that the assigning of channels seems a bit random.  The mouse floats a lot to different channels on boot but after a reset it generally goes to the highest channel. So my KB take Channel 1 and 2 for that fantom gamepad and the actual gamepad get 3(or I think so. I have nothing to test which one is the real gamepad yet). Is this all expected behavior and how do we deal with it in our programs if it is.  Is there a way to detect the channels of devices in a program and conditional assign the proper channels for basic commands?

I hope this helps.  Thanks.

EDIT: I have a concern about using Consol into the PICO because the boot loop issue remains if I have it connected to my PC for power and for and Consol access for MMEDIT or terminal access.  I had it connected to my PC when I first tried the mouse then switched to a different discreet power supply and still had the boot loops.  Now I have it on that better power source now and it is stable but now I can't get consol access without the boot looping.  Would it be best to remove the R60, and will that fix this as well.
Edited 2024-10-23 20:12 by mclout999
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 10:00am 23 Oct 2024
Copy link to clipboard 
Print this post

Hi Peter,

If I read your "fixes" for the USB problem right, the problem is a result of 5V becomming low under heavy load. And since the AMS1117 has a dropout voltage of 1V (worst case 1.3V) there is a dip in the 3.3V that reset's the pico.

A solution could be a linear regulator that has a lower dropout voltage (but alas I have not found a pin compatible option). An alternative could be to remove the linear regulator and used the on board SMPS on the pico2. This will increase audio noise, but will definitely fix the issue.
This could be a reason why RP put a switcher on the pico's, and not a (cheaper) linear regulator like the chineese dudes.

Regards,

Volhout

P.S. I have seen instances where USB power sources (i.e. phone chargers) really drop the output voltage far before they reach their specified output current (i.e 500mA or 1A). This is not cable, but power source related. Maybe that is why RP ship their own PSU's with their PI3/4/5's.
Edited 2024-10-23 20:07 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 10:26am 23 Oct 2024
Copy link to clipboard 
Print this post

MM.INFO(USB n)
Returns the device code for any device connected to channel ‘n’ which is a number from 1 to 4.  The returned device code can be:
0=not in use, 1=keyboard, 2=mouse, 128=ps4, 129=ps3, 130=SNES/Generic

Please try the attached


PicoMiteHDMIUSB.zip


Please then plug in the gamepad and report

mm.info(USB vid n) and mm.info(usb pid n)

For both the real gamepad and the spurious one. If your gamepad is the same as mine I'll then assume it is general and can block the spurious one

  Quote  EDIT: I have a concern about using Consol into the PICO because the boot loop issue remains if I have it connected to my PC for power and for and Consol access for MMEDIT or terminal access.  I had it connected to my PC when I first tried the mouse then switched to a different discreet power supply and still had the boot loops.  Now I have it on that better power source now and it is stable but now I can't get consol access without the boot looping.  Would it be best to remove the R60, and will that fix this as well.


Removing R60 will solve it but this shouldn't be necessary. I'm connecting to my computer which is supplying the power and don't get a boot loop unless I select a deliberately poor cable
Edited 2024-10-23 20:28 by matherp
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 896
Posted: 11:46am 23 Oct 2024
Copy link to clipboard 
Print this post

My generic gamepad returns
VID 2079
PID 58369

I have test 5 USB keyboards, all return a phantom Generic Gamepad with various PIDs and VIDs, only two identical ones return the same.

A wireless logitech K400+ with mouse pad returns the Keyboard,Mouse and a phantom Gamepad.Not sure if the mouse works because I don't know what it should do at this stage.
Latest F4 Latest H7
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 11:58am 23 Oct 2024
Copy link to clipboard 
Print this post

Can you do any sort of search on the phantom pids and vids and see it you can find anything?

I use a lenovo KU-0225 keyboard and don't get any phantoms

The mousepad should work try the DEVICE(MOUSE function to interrogate it.
Edited 2024-10-23 21:59 by matherp
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 02:30pm 23 Oct 2024
Copy link to clipboard 
Print this post

OK, here are my findings

                     VID                   PID
KB=1                  10874                 27160

PAD=2                 10874                 27160

PAD=3                 2079                  58369

MOUSE=4               1118                  132

From this I can see the best way to deal with generic gamepads is compare the KB PID or VID numbers to finger out witch is the real pad in your code to find the right channel for the pad and assign it to a variable to use with any gamepad reading. Of course there is no need for the other gamepad types as they have unique mm.info( USB n) results. I am going to go through my keyboard PILES to see if I can find one that does not give the ghosted gamepad but many may not have that option.

Is there any way to force the KB and MOUSE to be KB=1 and Mouse=2 on reset? That would make it easier but if not that cool the above method should be enough. I may try to write a little sub routine to use with every gamepad program that dose that.

EDIT: the first NAME BRAND(an ancient DEL) KB works fine with no ghost mouse but it should be noted that I got random assignments of channel numbers on power on but a reset got me to

KB=1 gamepad=2 and Mouse=3 very consistently, so maybe always hit reset after powering on to get to the most stable channel assignments. I still think it best for users to adopt some standardized sub-routines to find and assign channel numbers in programs so a game of app will just work with whatever channels are assigned by the system.
Edited 2024-10-24 00:47 by mclout999
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 03:14pm 23 Oct 2024
Copy link to clipboard 
Print this post

Please try this version.

PicoMiteHDMIUSB.zip

This will always try and allocate slot 1 to the keyboard and slot 2 to a mouse.
It will always try to allocate slot 3, if free, to the first game controller and slot 4 to the second.

In the event that you are trying to use three of more game controllers or two or more keyboards or mice then this of course will break down and the extra ones will be allocated to the highest available slot.

In addition this version now assumes that generic gamepads use either 2079/58369 or
2064/58625 so you shouldn't see the phantom (NB: Sony ds3/ds4 are already handled separately)
Hopefully this change doesn't exclude any of the available generics but if anyone does find a gamepad is no longer found then please run the previous posted version and report the VID/PID to me so I can special case it as well.
Edited 2024-10-24 01:18 by matherp
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 03:28pm 23 Oct 2024
Copy link to clipboard 
Print this post

  matherp said  Please try this version.

PicoMiteHDMIUSB.zip

This will always try and allocate slot 1 to the keyboard and slot 2 to a mouse.
It will always try to allocate slot 3, if free, to the first game controller and slot 4 to the second.

In the event that you are trying to use three of more game controllers or two or more keyboards or mice then this of course will break down and the extra ones will be allocated to the highest available slot.

In addition, this version now assumes that generic gamepads use either 2079/58369 or
2064/58625 so you shouldn't see the phantom (NB: Sony ds3/ds4 are already handled separately)
Hopefully, this change doesn't exclude any of the available generics but if anyone does find a gamepad is no longer found then please run the previous posted version and report the VID/PID to me so I can special case it as well.


thank you for your unbelievable efforts. You are right about that cable as well.  I connected to my PC with a better cable and it works without a hitch, no boot looping. I will test this new build.
EDIT: This build very consistently assigns the devices even on Power on.
Edited 2024-10-24 02:00 by mclout999
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 04:15pm 23 Oct 2024
Copy link to clipboard 
Print this post

Does anyone have a program to test the inputs of a game controller?  I also am not sure how to program it yet. What manual is there at this time that would be best. Can I use any of the info in my CMM2 manual? Thanks.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 04:25pm 23 Oct 2024
Copy link to clipboard 
Print this post

' save this as redmouse.spr on the A: drive
13,1,19
4
44
4 4
4  4
4   4
4    4
4     4
4      4
4       4
4        4
4         4
4          4
4      444444
4   4  4
4  44  4
4 4  4  4
44   4  4
     4  4
     4444


Const ps4=128
Const ps3=129
Const snes=130
Const mouse=2
MODE 2
FRAMEBUFFER layer
Sprite load "redmouse"
CLS
For i=1 To 4
If MM.Info(usb i)=mouse Then
  mousechannel=i
  Print "Mouse found on channel ",mousechannel
EndIf
If MM.Info(usb i)=ps3 Then
  PS3channel=i
  Print "PS3 controller found on channel ",PS3channel
EndIf
If MM.Info(usb i)=ps4 Then
  PS4channel=i
  Print "PS4 controller found on channel ",PS4channel
EndIf
If MM.Info(usb i)=130 Then
  SNESchannel=i
  Print "SNES controler found on channel ",SNESchannel
EndIf
Next
FRAMEBUFFER write l
Sprite show 1,MM.HRes\2,MM.VRes\2,1

If mousechannel Then Device mouse interrupt enable mousechannel,mouseint
If PS4channel Then Device gamepad interrupt enable PS4channel,ps4int
If PS3channel Then Device gamepad interrupt enable PS3channel,ps3int
If SNESchannel Then Device gamepad interrupt enable SNESchannel,genericint
Device mouse set mousechannel,MM.HRes\2,MM.VRes\2,0
Pause 1000
Do
If mousechannel Then
Sprite show 1,DEVICE(MOUSE mousechannel,x),DEVICE(mouse mousechannel,y),1
Pause 20
EndIf
Loop

Sub mouseint
Static int L,R,M
FRAMEBUFFER write n
Print "Mouse Interrupt: ";
If L<> DEVICE(mouse mousechannel,L) And L Then Print "L_UP"
If R<> DEVICE(mouse mousechannel,R) And R Then Print "R_UP"
If M<> DEVICE(mouse mousechannel,M) And M Then Print "M_UP"
If L<> DEVICE(mouse mousechannel,L) And L=0 Then Print "L_DOWN"
If R<> DEVICE(mouse mousechannel,R) And R=0 Then Print "R_DOWN"
If M<> DEVICE(mouse mousechannel,M) And M=0 Then Print "M_DOWN"
If DEVICE(MOUSE mousechannel,D) Then Print "double click"
L=DEVICE(mouse mousechannel,L)
R=DEVICE(mouse mousechannel,R)
M=DEVICE(mouse mousechannel,M)
FRAMEBUFFER write l
End Sub

Sub ps3int
FRAMEBUFFER write n
Print "PS3 interrupt: ";
myint ps3channel
FRAMEBUFFER write L
End Sub

Sub ps4int
FRAMEBUFFER write n
Print "PS4 interrupt: ";
myint ps4channel
FRAMEBUFFER write l
End Sub

Sub genericint
FRAMEBUFFER write n
Print "Generic interrupt: ";
myint SNESchannel
FRAMEBUFFER write l
End Sub

Sub myint(USBchan)
Print DEVICE(gamepad USBchan, lx);
Print DEVICE(gamepad USBchan, ly);
Print DEVICE(gamepad USBchan, rx);
Print DEVICE(gamepad USBchan, ry);
Print DEVICE(gamepad USBchan, l);
Print DEVICE(gamepad USBchan, r)
Static integer l%=0
m%=1
a%=DEVICE(gamepad USBchan, b)
t%=l% Xor a%
If t% And m% Then
If a% And m% Then : Print "R_ON":Else : Print "R_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "Start_ON":Else : Print "Start_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "Home_ON":Else : Print "Home_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "Select_ON":Else : Print "Select_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "L_ON":Else : Print "L_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "DOWN_ON":Else : Print "DOWN_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "RIGHT_ON":Else : Print "RIGHT_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "UP_ON":Else : Print "UP_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "LEFT_ON":Else : Print "LEFT_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "ZR_ON":Else : Print "ZR_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "X_ON":Else : Print "X_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "A_ON":Else : Print "A_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "Y_ON":Else : Print "Y_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "B_ON":Else : Print "B_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "ZL_ON":Else : Print "ZL_OFF":EndIf
EndIf
Inc m%,m%
If t% And m% Then
If a% And m% Then : Print "TPAD_ON":Else : Print "TPAD_OFF":EndIf
EndIf
l%=a%
End Sub
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 07:04pm 23 Oct 2024
Copy link to clipboard 
Print this post

Now I know I'm being a nuge but I decided to try out a few PS3 controllers I have and a PS4. All of my 3rd party PS3 USB controllers cause a boot loop and my original PS3 wireless on a USB cable causes a boot loop until I turn it on and shows as a PS3 on channel 3 but will not work in that test program.  No input is detected. My PS4 controller is 3rd party and is wireless and on a USB cable it causes boot looping. Do I need an original PS3 or PS4 USB version?  Thank goodness I got that Ali Express cheap generic SNES controller. Second question, are the analog sticks on the PS3 and PS4 readable by the PICO if I can find one that works?

maybe some of you can list some PS3 and PS4 controllers you have found that work on this board.  Thank.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 896
Posted: 10:22pm 23 Oct 2024
Copy link to clipboard 
Print this post

Peter,
I think the phantom GamePads can be identified by them having the same VID and PID as the keyboard that they identify with. In all cases I have seen the phantom connects to the USB no directly following the keyboard,no matter how they are plugged in, re-powered or reset. So a gamepad with same VID and PID as the preceding keyboard can be ignored. A mouse with the same VID PID should be kept.

Here s a list of USB VIDs and PIDs I found.
List of USB VID and PIDs

This is a summary of my keyboards with VID/PID in hex to allow a lookup in the list.
This uses the first test binary you posted.

> list
Print " type    VID  PID"
For x=1 To 4
Print MM.Info(USB x),Hex$(MM.Info(USB VID x),4),Hex$(MM.Info(USB PID x),4)
Next


Logitech Wireless K400+ with track pad mouse
046d = Logitech, Inc. c52b = Unifying Receiver
081f  Manta  e401  gamepad
type    VID  PID
130    081F    E401
1      046D    C52B            
2      046D    C52B            
130    046D    C52B     Phantom


Keyboard Mini usb/ps2
type    VID  PID
130    081F    E401
1      1A2C    0E24
130    1A2C    0E24    Phantom
0      0000    0000

Keyboard Mini usb/ps2
0A81  Chesen Electronics Corp.0101  Keyboard
type    VID  PID
130    081F    E401
1      0A81    0101
130    0A81    0101        Phantom
0      0000    0000

Full size wired generic keyboard
type    VID  PID
130    081F    E401
1      2A7A    6A23
130    2A7A    6A23        Phantom
0      0000    0000

Full size wired generic keyboard
04D9  Holtek Semiconductor, Inc. 1503  Keyboard
type    VID  PID
130    081F    E401
1      04D9    1503
130    04D9    1503       Phantom
0      0000    0000
Latest F4 Latest H7
 
javavi

Senior Member

Joined: 01/10/2023
Location: Ukraine
Posts: 206
Posted: 07:49am 24 Oct 2024
Copy link to clipboard 
Print this post

  matherp said  Please try this version.
This will always try and allocate slot 1 to the keyboard and slot 2 to a mouse.
It will always try to allocate slot 3, if free, to the first game controller and slot 4 to the second.

GitHub user Fruit-Bat has a library for parsing USB HID devices (keyboard, mouse, joystick, gamepad) which he uses in his Spectrum emulator on Pico.
And in it, these USB HID devices are always correctly identified in their places. + there is support for gamepads from XBOX.
https://github.com/fruit-bat/pico-hid-host
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 469
Posted: 01:21pm 25 Oct 2024
Copy link to clipboard 
Print this post

I was wondering if anyone had some feedback on my previous post about getting boot loops with PS3 and PS4 controllers.  None of them work at all but the original PS3 wireless one that will stop boot looping if I force it on and it is detected but it will not work with the Test program matherp posted recently.  Thank for any help you can render.  Also as above has anyone got either a PS3 or PS4 controller to work on this board?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 02:18pm 25 Oct 2024
Copy link to clipboard 
Print this post

  Quote  Also as above has anyone got either a PS3 or PS4 controller to work on this board?


Yes - both. If you are bootlooping you still have a power problem.
NB: the code I posted shows how to read the joysticks



Edited 2024-10-26 00:30 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 02:37pm 25 Oct 2024
Copy link to clipboard 
Print this post

@mclout999,

Please try a Raspberry Pi power supply. One of those that are used for a Pi3/3b/4/4b.
They have a USB-C connector, and can supply sufficient power for the pico platform. And they are like 10 dollar (not overly expensive).This is the EURO version, but a US version will also exist.




Volhout
Edited 2024-10-26 00:39 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 03:24pm 25 Oct 2024
Copy link to clipboard 
Print this post

I just use the USB-C output on my computer but it works equally well with the PSU as suggested above
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3800
Posted: 03:50pm 25 Oct 2024
Copy link to clipboard 
Print this post

Could be the USB cable used for power - some have far too thin wires and so cause a voltage drop when loaded.

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6776
Posted: 04:34pm 25 Oct 2024
Copy link to clipboard 
Print this post

The thing to do is to measure the 3V3 rail at the Pico's pin 36. It's being fed from a linear regulator and *must* be a stable 3V3. If it isn't then check the 5V into the regulator (U21 pin 3). That *must be over 4V6 to be within spec. If it isn't then there is a problem with the supply or the power lead. In theory it could drop as low as 4V4 but there's no guarantee that all regulators will work at that.
Mick

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 9104
Posted: 06:32pm 25 Oct 2024
Copy link to clipboard 
Print this post

  Quote  The thing to do is to measure the 3V3 rail at the Pico's pin 36. It's being fed from a linear regulator and *must* be a stable 3V3. If it isn't then check the 5V into the regulator (U21 pin 3).


Not easy to do in a useful way. You are looking for a transient when the Hub controller enables its power output which will be a short time after it sees power
 
     Page 5 of 7    
Print this page
© JAQ Software 2024