Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Control Player''s movement using 4 switches via USB

Status
Not open for further replies.

Eshal

Advanced Member level 1
Joined
Aug 29, 2012
Messages
470
Helped
16
Reputation
32
Reaction score
15
Trophy points
1,298
Location
Nowhere :)
Activity points
5,149
I have a simple project which title is defined the Thread's title.

I don't have even a tiny idea about how to do it.

What I have and what I need to do is in the below paragraph:
" Let say I have a very simple game in which player can only move left, right, up and down. I have made this game (assume). Now I need to control its position using simple four micro-switches. Let say I have solder those micro-switches on the strip board. But how to connection them with the USB? Means what IC or circuit I need to use in order to control the character's movement? "

Thanks

PS: Without Micro-controller
 

PS: Without Micro-controller

PS: Good luck.

Why USB? What are you connecting the switches to? USB is a fairly complex protocol; if you're not using a microcontroller, how do you expect to interpret the USB data stream?
 

Actually, I have seen "Quickshot QS-160 joystick" circuit board. It has no micro-controller and it is used for Sega Genesis Drive. I hope you know this Drive.

Well, if you think that I should use a micro-controller then can you tell me whether 8051 can be used or not?
 

That joystick is not USB. Again, why do you think you need USB, and what are you connecting to?
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
I would assume their "game" project is on a PC, therefore they are stuck with USB as the HID interface.

Unless the project involves developing a joystick HID, I would suggest not developing that and just and concentrate on the actual project, the joystick controlled game.
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
@berry
I have a game on PC. I need to make a simple USB based character movement controller pad. So that player in the game should move in the all 4 directions. This is my task.

@ads-ee
Yes my game project is on PC. No, I need to make it myself. But don't know how to start it.
 

1. You should make a board, where will be a 4 buttons, microcontroller and usb socket. Let's say with PIC18F14K50 it will be enought. Possible, some capacitor for +5 will be recomended.
2. You should prepare the HID descriptor for simple joystick with 4 buttons only. You can use "HID Desc TOOL" found by google.
3. In MikroC there is an USB HID library that works fine (yes, I said this! Some MikroC libraries works! Realy!). Attach your new descriptor, read the buttons data and send it to PC.
I can do all of this in 20 minutes. You can spend a day without expirience. Good luck.
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
You said to use PIC. Can't we use 8051 family?
What is HID descriptor? Is it any lookup table?
I have no experience :(
 

You want a micro that has built in USB device functionality, many PICs do, some 8051 variants may, but I have not used those parts for many years.

Further, USB is somewhat complicated, so it is really helpful to have a library available that already contains the state machine to run the USB transactions.

A HID descriptor is a block of data that describes a human interface device to the PC, see chapter 9 of the USB specification. Getting the various descriptors correct is a big part making USB enumeration work (Top tip, linux gives more useful error messages here then windows does, and lsusb -v is most helpful).

Pretty much any USB device contains a micro of some sort, it may be mask programmed but it will be there, as it is by far the easiest way to implement the required state machine.

Regards, Dan.
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
hello Dan Mills
Thanks for your great reply.

Can you tell me what should I do further , I have soldered four micro-switches and a USB socket. I have decided to use PIC but which controller in PIC family, can you suggest please?

I want to do all programming in assembly. Also provide the link of HID descriptor because it is very new to me, I have never heard about it, so that I could learn it before implementing.

Thanks.
 

I was searching about 8051 USB interfacing and I found this link https://www.electro-tech-online.com/threads/interfacing-usb-to-8051-microcontroller.95100/
In this link someone asked the question:
I was suggested the topic 'interfacing USB to 8051 microcontroller' as my final year project...i would like to know whether it is actually possible to do so...and the time required for completing the project..(we are required to complete it in about 6 months)...i would also be grateful if you share any information regarding the topic with me.

And 2 persons gave these answers:
1) I'll suggest the obvious of using a serial-USB bridge (e.g. FT232BM). This offloads all USB related management from the uC - the PC and 8051 communicate via a super simple serial interface (virtual serial over USB driver on PC and physical serial interface between the 8051 and FTDI chip).

This, of course, may not fulfill your assignment requirements.


2) Hello Mr Sam

Pavius gave U a G8 Idea of Using FT232,
I have also used the same and its very easy to use that. Otherwise U have to write a USB driver program in Microcontroller, thats not an easy task.

NaveenCali


Can anyone tell me what if I want to use 8051 family microcontroller then I need to use FT232, right?

- - - Updated - - -

such a big difference in both languages programming. OK.
It will be my first experience with PIC family so PIC18F is OK for starting. Is it? And ok I will use C-language.
 

If you will use FT232 in bitbang mode, you will don't need MCU at all.
But... you want to make a HID class device or you will have to emulate joystick with uart in operation system... and also will have to install a driver for FT232. I told you the correct way - PIC18 -> USB. Why PIC18F14K50? It is a cheapest pic with USB.
Also, you can use some different mcu. STM8/STM32 or Mega. It is your choice. Just because MikroC has USB HID library and my opinion it is a easiest way to do it with this library. I will provide an example if you wish.
STM8/STM32 will be much more difficult for you. I spend a week to start usb working with STM32F103. That was realy hard.
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
yes, i need starting point and tutorial .
 

This is a sample project for Proteus 7.8/8.1 + MikroC. Check that virtual USB driver installed. After start simulation, windows will find a new device - mouse. You cursor will move and paint a sqare. In project files you will find USB descriptor for mouse. It is just a tutorial. No real schematic, just a simmulation.
View attachment USB_HID_TEST.rar
You can use this project as a starting point. It is done on 90% for your needs.
 
  • Like
Reactions: Eshal

    Eshal

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top