Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:12 01 Aug 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 : CMM2: If you want a mouse

     Page 1 of 4    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 07:03pm 05 Oct 2020
Copy link to clipboard 
Print this post

Get one of these

The STM32H7 only supports a single USB device so I can't I/F a USB mouse. Serial and PS2 mice are getting hard to find so I/F a USB mouse. I'm sure there are other options out there but this is tested and works. Also available a a pre-programmed chip (much cheaper)
 
JoOngle
Regular Member

Joined: 25/07/2020
Location: Sweden
Posts: 82
Posted: 07:11pm 05 Oct 2020
Copy link to clipboard 
Print this post

Interesting information Peter, (takes notes), this chip could be included on a future PCB.
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 07:38pm 05 Oct 2020
Copy link to clipboard 
Print this post

Thanks for the link!  I just ordered 3.  I have been looking for something to interface with devices that have a built-in FTDI USB-Serial interface etc.
-Carl
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 07:48pm 05 Oct 2020
Copy link to clipboard 
Print this post

Interesting! Thanks, Peter!
-Bill
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 228
Posted: 07:54pm 05 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  Get one of these

The STM32H7 only supports a single USB device so I can't I/F a USB mouse. Serial and PS2 mice are getting hard to find so I/F a USB mouse. I'm sure there are other options out there but this is tested and works. Also available a a pre-programmed chip (much cheaper)


Thanks Peter, ordered.  I just need to understand where to interface it to get writing something to read it:-

https://www.hobbytronics.co.uk/usb-host-mouse
Edited 2020-10-06 06:40 by elk1984
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 871
Posted: 09:56pm 05 Oct 2020
Copy link to clipboard 
Print this post

Hi all,
Does this mean we can retain the existing USB keyboard and add a USB joystick (and/or) mouse via something like this?

Cheers,

Andrew
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 10:03pm 05 Oct 2020
Copy link to clipboard 
Print this post

This Does work for a mouse.

Bill

Edit and here
Edited 2020-10-06 08:15 by Turbo46
Keep safe. Live long and prosper.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 871
Posted: 11:49pm 05 Oct 2020
Copy link to clipboard 
Print this post

Hi Bill, et al,
I have just read the SC article and it says
  Quote  Note that most of the mouses that we tried which had mouse wheels did not report mouse wheel rotation using the basic HID protocol, so it’s unlikely that you will be able to detect rotation of the mouse wheel using this Adaptor.


I'm not sure about the one that Peter identified?

An interesting thought on this device though - the chip is programmed differently depending on whether it is to be used for a mouse or a keyboard - could a jumper, or upfront INPUT, select which variant runs?

Again I'm not sure about the one that Peter identified?


Cheers,

Andrew
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 12:47am 06 Oct 2020
Copy link to clipboard 
Print this post

  Quote  could a jumper, or upfront INPUT, select which variant runs?


You can download the C source for each variant so I would expect that they could be combined but that's way beyond me.

I posted a demo using that device on the CMM1 here.

Bill
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 05:20am 06 Oct 2020
Copy link to clipboard 
Print this post

Another USB Host adapter on Banggood site. SPI interface.
Mini USB Host Shield 2.0 ADK SLR Development Tool
Brand: LILYGO
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:59am 06 Oct 2020
Copy link to clipboard 
Print this post

  Quote  'm not sure about the one that Peter identified?


  Quote   The comma delimited output looks like the following

X,Y,LB,RB,SB,XS,YS,SS

Where
  X - X Virtual Screen Pos
  Y - Y Virtual Screen Pos
 LB - Left Button
 RB - Right Button
 SB - Scroll Wheel Button
 XS - X mouse scroll (move) value
 YS - Y Mouse Scroll (move) value
 SS - Scroll Wheel scroll value
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 10:52am 06 Oct 2020
Copy link to clipboard 
Print this post

Test code. There does seem to be an issue with the scroll wheel. It works but seems to continue counting unless the mouse moves. I've written to Hobbytronic to ask why

initmouse
sprite load "mouse.spr",1
do
 readmouse
 sprite show 1,x,y,1
 text 0,0,str$(x,6,0," ")+str$(y,6,0," ")+str$(lb,2,0," ")+str$(rb,2,0," ")+str$(sb,2,0," ")+str$(xs,4,0," ")+str$(ys,4,0," ")+str$(ss,6,0," ")
 pause 10
loop
'
sub initmouse
 i2c open 100,1000
 i2c write 41,0,3,20,int(mm.hres \ 256),int(mm.hres mod 256)
 i2c write 41,0,3,22,int(mm.vres \ 256),int(mm.vres mod 256)
 i2c write 41,0,3,24,int(mm.hres \ 512),int((mm.hres\2) mod 256)
 i2c write 41,0,3,26,int(mm.vres \ 512),int((mm.vres\2) mod 256)
 i2c write 41,0,2,28,10
end sub
'
sub readmouse
 do
   i2c write 41,1,1,0
   i2c read 41,0,10,s$
   x=str2bin(uint16,left$(s$,2),big)
   y=str2bin(uint16,mid$(s$,3,2),big)
   lb=asc(mid$(s$,5,1))
   rb=asc(mid$(s$,6,1))
   sb=asc(mid$(s$,7,1))
   xs=str2bin(int8,mid$(s$,8,1))
   ys=str2bin(int8,mid$(s$,9,1))
   ss=ss+str2bin(int8,mid$(s$,10,1))
 loop until x>=0 and x<MM.hres and y>=0 and y< mm.vres 'trap missreads
end sub


Mouse.spr

13,1,19
7
77
7 7
7  7
7   7
7    7
7     7
7      7
7       7
7        7
7         7
7          7
7      777777
7   7  7
7  77  7
7 7  7  7
77   7  7
     7  7
     7777
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 02:47pm 06 Oct 2020
Copy link to clipboard 
Print this post

I like the Silicon Chip model from January 2019, but the unit that matherp linked to at the very top of this thread is a nice unit also.  The pre-programmed chip in SOIC or SSOP is only US$7 each, which is a pretty sweet-spot price wise.

The SSOP and PDIP packages are in stock at Microchip Direct and cost about US$3.50 each, and then you could just upload the firmware to the chip yourself if you wanted to keep the costs to an absolute minimum.  The SOIC and QFN packages are out of stock.

Very affordable device though.  Might have to add some of these to my next order from Microchip Direct.

I am particularly interested in the USB 3G Modem version of the firmware, which allows you to take a USB GSM modem stick thing, to simplify sending and receiving text messages.  The supported USB modem sticks are about US$20 on eBay or AliExpress, which is half the price of the SimCom modules I am using at the moment, and have to fight them every step of the way to make them work.  Might have to get one of those USB sticks in and play with that firmware first!
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 03:17pm 06 Oct 2020
Copy link to clipboard 
Print this post

  Quote  The SSOP and PDIP packages are in stock at Microchip Direct and cost about US$3.50 each, and then you could just upload the firmware to the chip yourself if you wanted to keep the costs to an absolute minimum.  The SOIC and QFN packages are out of stock.


No you can't. It relies on a pre-programmed bootloader which is copy protected
Edited 2020-10-07 01:18 by matherp
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 03:38pm 06 Oct 2020
Copy link to clipboard 
Print this post

Damn.

Oh well.  I just won't order from Microchip Direct then - good to know that ahead of time.

I will just get some pre-programmed chips from HT then and be done with it.  Quite keen to try out the USB GSM modem one.
Smoke makes things work. When the smoke gets out, it stops!
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 228
Posted: 07:12pm 07 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  Get one of these

The STM32H7 only supports a single USB device so I can't I/F a USB mouse. Serial and PS2 mice are getting hard to find so I/F a USB mouse. I'm sure there are other options out there but this is tested and works. Also available a a pre-programmed chip (much cheaper)


Great recommendation and Hobbytronics are really fast.  Just arrived today!

Trouble is, I'm a total wiring newbie.  I'm guessing there's different ways of wiring this depending on what protocol you want to read?  I'm assuming it doesn't need both 5V and 3.3V power simultaneously.


USB Host   - CMM2 GPIO
5V         - Pin 2 (5V Power)
0V         - Pin 6 (Ground)
3V3        - Pin 1 (3.3V Power)
SDA / SDI  - Pin 3 (I2C SDA)
SCL / SCK  - Pin 5 (I2C SCK)
A / SDO    - Pin 12 (PWM 1A) ?
SS         - ?
RX         - PIN 10 (COM1 RX)
TX         - PIN 8  (COM1 RX)
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:35pm 07 Oct 2020
Copy link to clipboard 
Print this post

You don't need both 5V and 3.3V
There is an onboard 3.3V regulator. - Check the supplied schematic.

You do need 5V to supply the 5V on the USB connector so use 5V and ignore the 3.3V
You use either I2C or Serial. You don't need both and the choice is yours.

Serial is easier to start with.

Jim
VK7JH
MMedit
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 228
Posted: 08:44pm 07 Oct 2020
Copy link to clipboard 
Print this post

  TassyJim said  You don't need both 5V and 3.3V
There is an onboard 3.3V regulator. - Check the supplied schematic.

You do need 5V to supply the 5V on the USB connector so use 5V and ignore the 3.3V
You use either I2C or Serial. You don't need both and the choice is yours.

Serial is easier to start with.

Jim


Thanks Jim.  So this one basically?   (Reading a schematic isn't something I'm up to - any electronics 101 suggestions welcome)

USB Host   - CMM2 GPIO
5V         - Pin 2 (5V Power)
0V         - Pin 6 (Ground)
RX         - PIN 10 (COM1 RX)
TX         - PIN 8  (COM1 RX)

Edited 2020-10-08 06:50 by elk1984
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:59pm 07 Oct 2020
Copy link to clipboard 
Print this post

You need to swap (cross-over) the RX and TX
One side transmits to the receiver on the other side.


USB Host   - CMM2 GPIO
5V         - Pin 2 (5V Power)
0V         - Pin 6 (Ground)
RX         - PIN 8 (COM1 TX)
TX         - PIN 10 (COM1 RX)


Jim
VK7JH
MMedit
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 228
Posted: 09:01pm 07 Oct 2020
Copy link to clipboard 
Print this post

  TassyJim said  You need to swap (cross-over) the RX and TX
One side transmits to the receiver on the other side.


USB Host   - CMM2 GPIO
5V         - Pin 2 (5V Power)
0V         - Pin 6 (Ground)
RX         - PIN 8 (COM1 TX)
TX         - PIN 10 (COM1 RX)


Jim


Thanks - doh I did say I'm a total wiring newbie  
 
     Page 1 of 4    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025