Projeto para Iniciação Científica

Para "abobrinhas" use o " Boteco"

Moderadores: andre_luis, 51, guest2003, Renie

Mensagempor fabim » 13 Out 2008 16:36

if (dado==0){faz nada}
if(dado !=0){movimenta}

compila e grava.
no byte 1 e 2, coloque valores positivos e negativos alternando.

o cursor vai ficar se movimentando..

Ja estou correndo atraz de fazer 2 hid devices, em 1 report..

só que é hitech ...

fuça nesse aí, dispois eu ja coloco o resto

Fabim
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Mensagempor fabim » 14 Out 2008 07:27

Eu estava pensand em uma coisa legal.
imagina o mouse com um inclinometro e um joystick.
E alguns botões / botãos }??rs
Seria o sequinte.
3 botões significanto simplesmente "esquerdo, centro, direito"
1 manche com valor absoluto
e alguns botões ja pré definidos.
CTRL+1
CTRL+2
CTRL+3
......
CTRL + 0

Esses comandos não existem nas definições do windows e podem ser usados como atalho para programas.
Dependendo da deficiencia da pessoa, pode ser utilizado o manche com um algoritmo de ant-shock para o cursor não ficar tremendo, tipo uma persistencia...
Dependendo da deficiencia da pessoa, pode ser utilizado o inclinometro, com o mesmo algoritmo à cima descrito.

Suponha uma pessoa que tem o movimento parcial da mão, do dedão por exemplo.
com o mesmo dedão a pessoa pode executar funções de mouse, movimento do cursor, e umas teclas bem sensiveis o cabra pode chamar por exemplo o teclado virtual, o internet explorer, o word, salvar = CTRL + S, subir ou descer pagina e etc.

Pelo que eu pude estudar este keypad/mouse hid usb, ele é reconhecido belo boot do windows, e também perfeitamente no VISTA.

Acho que essa idéia pode ser oproveitada na ajuda de alguns deficiêntes fisicos ou muitos.!!

Estou muito contente de poder te ajudar nessa tese... :)
Pode contar comigo.

E Me diciona eu no seu msn, pra módinóiz trocar figurinha.

E como sei que o LELLIS LINDO vai ler este post,!! O cabra safado purfavor, preciso doC, me manda seu msn pelo MP preazee.. :)

Fabim
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Mensagempor SoMeWhErE » 14 Out 2008 08:01

olá Fabim.

entaum vc ja tem no msn...procura ae.....safemate@hotmail.com.

porem naum posso usá-lo no serviço.....só em kza mesmo...

gostei....fico feliz por me ajudar......vamu lah tô dentro.....

Entaum...dei uma estudada no programa.....a idéia já compreendi....fiz as modificações pro 4550 porém não reconhece.....li seu post....dei um boot no windows....mas não reconheceu.....

fiz o seguinte coloquei um comando pra acender um led no inicio do while(1).....e apagar depois do delay_ms(250)......porém ele acendeu mas não apagou......modifiquei as teclas pro portb, pois na minha placa de desenvolvimento elas estão ligadas ae......

tem alguma coisa tô esquecendo....

VALEWSSS
Avatar do usuário
SoMeWhErE
Byte
 
Mensagens: 119
Registrado em: 20 Jun 2007 18:09
Localização: Charqueada

Mensagempor fabim » 14 Out 2008 08:06

me manda o esquema basico ou simplesmente me indique quais pinos estão livres para os botões.
que eu modifico e te passo.
óia, você não esta esquecendo do capacitor no Vusb não né ? de 1uF da e sobra, se não colocar este cap quando espetar no pc da pauzio.

E me diga qual o cristal que esta usando nesse pic.

FAbim
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Mensagempor SoMeWhErE » 14 Out 2008 08:18

Pinos livres para entradas RB0 até RB5
Pinos livres para saídas PORTD inteiro

o capacitor está aqui de 1uF....eu uso essa placa para testes....e nos outros projetos funciona normalmente.

Cristal de 8MHz.

VALEWS
Avatar do usuário
SoMeWhErE
Byte
 
Mensagens: 119
Registrado em: 20 Jun 2007 18:09
Localização: Charqueada

Mensagempor fabim » 14 Out 2008 10:38

Ó meu rei..
http://www.proenergysafety.com.br/arqui ... /mouse.rar

PIC18F4550...

Configuradim, procezim, prontim,

Só gravar o hex, e bizoiar o ruwindows dizendo que tem um rato no conector usb.

Observe como eu configurei os fuses ..

Fabim
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Mensagempor fabim » 14 Out 2008 21:03

ó ó.. óia...
Como meu inglês é interpretativo, e de preferencia inglês técnico.
Isso aqui fundiu meus miólos...

Tenha a caridade de traduzir para o português, mineireis de preferência..

Código: Selecionar todos
  Still continues

b) Composite device
We are going to combine "USB Device - HID - Keyboard" and "USB Device - HID - mouse"

b-0) Preparation before union of two devices
Unfortunately, this USB implementation doesn't suppose such a composite device of the same class. The 'namespaces' (#define, variables, arrays and subroutine name) overlap on the two interfaces of the same class. Then, split the namespace on a working copy first.

Copy the entire code of "USB Device - HID - mouse" to a working folder.
Copy usb_function_hid.c and usb_function_hid.h to the working folder, too, and rename these two files. Of course, replace these two files on the IDE work space after renaming them.
usb_function_hid.c ---> usb_function_hid_m.c
usb_function_hid.h ---> usb_function_hid_m.h

In this stage, build and run the project once to check this modification.
You may see the error of include file name - fix it


On usb_function_hid_m.c and usb_function_hid_m.h,
rename the variables and subroutines defined in these files, like

BYTE idle_rate; ---> idle_rate_m
BYTE active_protocol; ---> active_protocol_m
BYTE hid_rpt_rx_len; ---> hid_rpt_rx_len_m

- USBCheckHIDRequest() ---> USBCheckHIDRequest_m()
- HIDGetReportHandler() ---> HIDGetReportHandler_m()
- HIDSetReportHandler() ---> HIDSetReportHandler_m()

Build the project, and you'll see errors that the original variables and subroutines are not found. Using this error, rename the references, too. Run and test again.

Next, move the address of the endpoint.
On usb_config.h,
- Increase USB_MAX_EP_NUMBER from 1 to 2
- Rename #define's on the ENDPOINTS ALLOCATION section
- Change the HID_EP_M from 1 to 2 (endpoint address)

usb_config.h

/** DEFINITIONS ****************************************************/
...
#define USB_MAX_NUM_INT         1   // change this number afterward
#define USB_MAX_EP_NUMBER       2   // <---- to move the endpoint

/** ENDPOINTS ALLOCATION *******************************************/
/* HID */
#define HID_INTF_ID_M           0x00   // change the IF number afterward
#define HID_EP_M                2      // <--- end point address
#define HID_INT_OUT_EP_SIZE_M   3
#define HID_INT_IN_EP_SIZE_M    3
#define HID_NUM_OF_DSC_M        1
#define HID_RPT01_SIZE_M        50


- Add arrays to the USB RAM space on usb_function_hid_m.c
- Replace ALL hid_report_in to hid_report_in_m on mouse.c

usb_function_hid_m.c
// Add these arrays
#pragma udata USB_MOUSE_BUF = 0x500
volatile unsigned char hid_report_out_m[HID_INT_OUT_EP_SIZE_M];
volatile unsigned char hid_report_in_m[HID_INT_IN_EP_SIZE_M];
#pragma udata

usb_function_hid_m.h
extern volatile unsigned char hid_report_out_m[HID_INT_OUT_EP_SIZE_M];
extern volatile unsigned char hid_report_in_m[HID_INT_IN_EP_SIZE_M];


- Rename hid_rpt01 to hid_rpt01_m on usb_descriptors.c
ROM struct{BYTE report[HID_RPT01_SIZE_M];}hid_rpt01_m={

Build the project, check errors, rename the references and test run.


Now, solid code with separated namespace is established.
At last, these two devices are combined into a composite device.
We use a merge utility to work out this step, for example,

WinMerge http://www.winmerge.org/

Comparing the files of the same name from the two project, merge the two devices into composite one. Merge utility highlights the difference we made on above step. It helps us to find the part to be merged, or modified.
On the next steps, modified mouse example is merged to the keyboard example.

b-1) Descriptor work

VID/PID
Change VID/PID to your custom one, as usual

Descriptors

usb_descriptors.c
- Copy Interface, HID class and endpoint descriptors from mouse example
- Append it after the endpoint descriptor of the keyboard

- Tune the descriptors,
Configuration Descriptor - Total length (0x0022 * 2 - 9)
Configuration Descriptor - Number of interfaces (2)
mouse Interface Descriptor - Interface Number (1)

- Copy the report descriptor from the mouse example.

In usb_config.h
- USB_MAX_NUM_INT: from 1 to 2
- USB_MAX_EP_NUMBER: from 1 to 2
- Copy all #define's of HID section from mouse example
- change HID_INTF_ID_M to 1

usb_config.h
/** DEFINITIONS ****************************************************/
// change the values
#define USB_MAX_NUM_INT         2   // number of interfaces
#define USB_MAX_EP_NUMBER       2   // number of endpoints pairs (IN/OUT)

/** ENDPOINTS ALLOCATION *******************************************/
/* HID */
#define HID_INTF_ID_M           0x01   // <---- change to 1
#define HID_EP_M                2
#define HID_INT_OUT_EP_SIZE_M   3
#define HID_INT_IN_EP_SIZE_M    3
#define HID_NUM_OF_DSC_M        1
#define HID_RPT01_SIZE_M        50



b-2) Request support

Class specific request

- Copy usb_function_hid_m.c and usb_function_hid_m.h to the keyboard project.
- Rewrite USBCBCheckOtherReq() (keyboard.c) to support mouse interface

keyboard.c

void USBCBCheckOtherReq(void)
{
    // dispatch request to specified interface by wIndex
    switch ( SetupPkt.wIndex ) {
        case HID_INTF_ID:    USBCheckHIDRequest();    break;
        case HID_INTF_ID_M:  USBCheckHIDRequest_m();  break;
        default:                                      break;
    }
}//end



b-3) Interrupt endpoints support

- Join ProcessIO() (keyboard.c)
- Drag mouse-specific routines into keyboard.c

keyboard.c

void ProcessIO(void)
{   
    //Blink the LEDs according to the USB device status
    BlinkUSBStatus();

    // User Application USB tasks
    if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;

    //Call the function that behaves like a keyboard   
    Keyboard();       


    // imported from mouse example
    if(Switch3IsPressed())              //Note: Switch3IsPressed() implements only the
    {                                   //.....
                                        //is not implemented in this example.
        emulate_mode = !emulate_mode;
    }
   
    //Call the function that emulates the mouse
    Emulate_Mouse();

}//end ProcessIO



I think I list up most of the modification here, but please compare the files well and check the difference.


As above modification shows, multiple top-level collections share the requests and the interrupt endpoint. The addition of another HID device(s) doesn't change the basic stack structure so much. It is implemented at the each subroutine level. The report ID identifies the devices. As the result, modification is simpler. Instead, as the bandwidth of the single interrupt endpoint is also shared, the response decreases along with the number of implemented devices.

For composite device, on the other hand, devices are independent at the interface level. Each device has its own interface and endpoint, its own request and endpoint handlers. Then, we have to duplicate these stuffs to implement it. The structure of the stack are modified so much. But the performance on the interrupt endpoint is the same as the original devices.

Tsuneo
 
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Anterior

Voltar para Assuntos Gerais

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x