Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Development / Re: USB Host Shield Compiling Error on: October 11, 2010, 05:02:57 am
I have had the same problem.
I think you should use the library Spi.h :http:// http://www.arduino.cc/playground/Code/Spi as it's indicated here: http://www.circuitsathome.com/mcu/arduino-usb-host-part-2-classes
2  Forum 2005-2010 (read only) / Français / Re: Mega2560 et  plusieurs SPI on: November 15, 2010, 02:21:40 am
Il y a un seul port SPI:
On y accède via les i/o 50 à 53 et via le connecteur ISCP.
cf le schéma: http://arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf
Si tu as plusieurs capteurs SPI, tu mets en parallèle les lignes MISO, MOSI et SCK et tu alloues à chaque CS une pin dédiée.
3  Forum 2005-2010 (read only) / Français / Re: Chip usb sur la Uno on: October 14, 2010, 04:01:03 am
Salut,
J'ai fait un post sur la modification du firmware du 8u2:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285962838

Il y a quelques exemples fournis avec LUFA facilement adaptables.

Cependant, j'ai l'impression que le programme rempli quasiment l'intégralité de la mémoire et qu'il reste peu de place pour l'ajout de lignes de code supplémentaires.
4  Forum 2005-2010 (read only) / Français / Re: entrée analogue trop changeante on: September 01, 2010, 08:46:32 am
Slt,
le plus simple serait peut-être de mettre en place un paramètre x=10 par ex.

Si ta nouvelle valeur est supérieure à [ancienne valeur] +x ou inférieure à [ancienne valeur] - x alors tu la prends en compte et tu mets à jour [ancienne valeur],
sinon tu ne fais rien.
5  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 on: December 08, 2010, 05:52:08 pm
The problem seems to be with
Code:
sensorValue = analogRead(i);
sensorValue is a byte so its range is 0-255

then you map:
Code:
sensorValue = map(sensorValue, 0, 1024, 0, 255);
 so sensorValue=255*255/1024=63  

I hope this can help you
6  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 on: December 08, 2010, 10:10:58 am
Maybe it's because you data has to be between -100 and 100.

If your range is 0-255 you should change the descriptor:


Replace:
Code:
     0x15, 0x9c,          /*     Logical Minimum (-100)                         */
      0x25, 0x64,          /*     Logical Maximum (100)                          */
by:

Code:
     0x15, 0x00,          /*     Logical Minimum (0)                         */
      0x26, 0xff, 0x00,    /*     Logical Maximum (255)                          */
     
7  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 on: December 08, 2010, 08:25:51 am
In uno's code I define something like that:

Code:
byte start_b;
byte b1;
....

start_b=0xFF;
b1= ...
...

Serial.print(start_b);
Serial.print(b1);
....

8  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 on: December 07, 2010, 02:11:29 pm
The memory is full as 98%. To get free space you can disable all the functions that use LEDs.

I'have emulated a joystick with uno:

I send 5 byte on serial to 8u2.

You can create this data:
uint8_t tampon;
uint8_t c;
uint8_t tempi[8];

And  modify the code:
Code:
for (;;)
      {
            HID_Device_USBTask(&Joystick_HID_Interface);
            USB_USBTask();

            if (c==8)
                  c=0;
            if (Serial_IsCharReceived())
        {
                  tampon=Serial_RxByte();
                  if (tampon==0xFF)
                        c=0;
                  tempi[c]=tampon;
                  c+=1;
            }      
            

And add that in the call back function

Code:
     JoystickReport->X=tempi[1];
      JoystickReport->Y=tempi[2];
      JoystickReport->Z=tempi[3];      
      JoystickReport->Rz=tempi[4];
      JoystickReport->Button1 =tempi[5];
      JoystickReport->Button2 =tempi[6];
      JoystickReport->Button3 =tempi[7];


The arduino has to send only bytes.
You have to use print function, not println that is sending others bytes after your data.
You can use a logic analyser to follow the data that are exchanged.

In this example, Uno has to send 0xFF as first byte (tempi[0]). However you can't send 0xFF as a data value or it will reset the c value.
9  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 on: December 03, 2010, 11:46:54 am
PS2 has 2 more axes: Z and Rz
So Descriptors.c has to be modified:

Replace
Code:
     0x09, 0x30,          /*     Usage (X)                                      */
      0x09, 0x31,          /*     Usage (Y)                                      */
      0x15, 0x9c,          /*     Logical Minimum (-100)                         */
      0x25, 0x64,          /*     Logical Maximum (100)                          */
      0x75, 0x08,          /*     Report Size (8)                                */
      0x95, 0x02,          /*     Report Count (2)                               */

by

Code:
     0x09, 0x30,          /*     Usage (X)                                      */
      0x09, 0x31,          /*     Usage (Y)                                      */
      0x09, 0x32,          /*     Usage (Z)                                      */
      0x09, 0x35,          /*     Usage (Rz)                                      */
      0x15, 0x9c,          /*     Logical Minimum (-100)                         */
      0x25, 0x64,          /*     Logical Maximum (100)                          */
      0x75, 0x08,          /*     Report Size (8)                                */
      0x95, 0x04,          /*     Report Count (4)                               */

And change the data structure:
in Joystick.h

Replace

Code:
typedef struct
            {
                  int8_t  X; /**< Current absolute joystick X position, as a signed 8-bit integer */
                  int8_t  Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */
                  uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */
            } USB_JoystickReport_Data_t;

by:

Code:
           typedef struct
            {
                  int8_t  X; /**< Current absolute joystick X position, as a signed 8-bit integer */
                  int8_t  Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */
                  int8_t  Z; /**< Current absolute joystick Z position, as a signed 8-bit integer */                  
                  int8_t  Rz; /**< Current absolute joystick Rz position, as a signed 8-bit integer */
                  uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */
            } USB_JoystickReport_Data_t;

I think it's the only thing to modify to see the 8u2 as a 4 axes joystick.
The code that is used to manage serial communication between 8u2 and arduino has to be updated to.
10  Forum 2005-2010 (read only) / Uno Punto Zero / Re: Tutorial - How to change firmware on 8u2 / UPDATED on: October 06, 2010, 05:15:47 pm
Hi,
This is the next step : how to make a joytick emulator with the arduino-uno.

First step
Be sure to be able to upload the initial firwmare arduino-serial: we need this firmware to upload the Atmega328.

How it works
The Atmega328 sends to 8u2 a byte on serial communication that represents the state of the joystick.

Point of attention
It's important to load first the atmega328 program and then the 8u2 firmware.
Once the firmware of 8u2 is upload with joystick program, atmega328 can't be loaded.
In order to modify atmega328 program, the original firmware of 8u2 need to be re-loaded.

Atmega328 program
Code:
/*
Program test for arduino uno
8u2 firmware-> Usb Joystick
ant.b
6 oct 2010
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285962838
 */

void setup()
{
  Serial.begin(9600);
}

void loop()
{
send_byte(0,0,0,0,0,0);
send_byte(1,0,0,0,0,0);
send_byte(0,1,0,0,0,0);
send_byte(0,0,1,0,0,0);
send_byte(0,0,0,1,0,0);
send_byte(0,0,0,0,1,0);
send_byte(0,0,0,0,0,1);
}

void send_byte(boolean JOY_UP, boolean JOY_DOWN,
                boolean JOY_LEFT, boolean JOY_RIGHT,
                boolean JOY_PRESS, boolean BUTTONS_BUTTON1)
{
  byte byte_to_send;// use a 'byte' not a 'int'-> a int will send 3 bytes via serial
  byte_to_send= JOY_UP*32 + JOY_DOWN *16  +
                JOY_LEFT*8 + JOY_RIGHT*4 +
                JOY_PRESS*2 +  BUTTONS_BUTTON1*1;
  Serial.print(byte_to_send);  
  delay(1000);//delay 1s before send another byte
}

8u2 program
  • copy  the folder LUFA_100807\Demos\Device\ClassDriver\Joystick to LUFA_100807\Projects\Arduino-Joystick
  • copy the following files from arduino-0021\hardware\arduino\firmwares\arduino-usbserial\ to LUFA_100807\Projects\Arduino-Joystick
    • folder 'Lib'
    • folder 'Board'
    • file makefile
Changes to make
      In makefile
             Set TARGET = Joystick
      In Joystick.h
             Delete #include <LUFA/Drivers/Board/Joystick.h>
             Delete #include <LUFA/Drivers/Board/Buttons.h>
     In Joystick.c
             Add this on the begining:
Code:
#include <LUFA/Drivers/Peripheral/Serial.c>
uint8_t temp;
const uint8_t JOY_UP= 0b100000;
const uint8_t JOY_DOWN = 0b010000;
const uint8_t JOY_LEFT= 0b001000;
const uint8_t JOY_RIGHT= 0b000100;
const uint8_t JOY_PRESS= 0b000010;
const uint8_t BUTTONS_BUTTON1= 0b000001;
            Add this in void SetupHardware(void)
                
Code:
 Serial_Init(9600, false);

             I delete clock_prescale_set(clock_div_1); because this line can't compile. I don't know if it is usefull ??
             I also delete
               Joystick_Init();
                    Buttons_Init();

            I add this in  for( ;;; )
            
Code:
while (Serial_IsCharReceived())
                {
            temp=Serial_RxByte();
            Serial_TxByte(temp);// Sendback the same byte juste for information
            }

                 And finally replace the content of CALLBACK_HID_Device_CreateHIDReport by that
Code:
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;

uint8_t JoyStatus_LCL    =temp; //Joystick_GetStatus();

      if (JoyStatus_LCL & JOY_UP)
             JoystickReport->Y = -100;
        else if (JoyStatus_LCL & JOY_DOWN)
              JoystickReport->Y =  100;

       if (JoyStatus_LCL & JOY_LEFT)
              JoystickReport->X = -100;
       else if (JoyStatus_LCL & JOY_RIGHT)
              JoystickReport->X =  100;

       if (JoyStatus_LCL & JOY_PRESS)
              JoystickReport->Button  = (1 << 1);

       if (JoyStatus_LCL & BUTTONS_BUTTON1)
               JoystickReport->Button |= (1 << 0);

      *ReportSize = sizeof(USB_JoystickReport_Data_t);
        return false;

Then compile and upload this program on 8u2

Verify
You can verify that it is working by unplug and replug the usb connection.

The joystick is visible in configuration pannel / gamepad.

Comment : I have had some difficulties with Flip : I often had the error 'Address is out of range'. I don't really now why?? Does someone have an idea?
11  Forum 2005-2010 (read only) / Uno Punto Zero / Tutorial - How to change firmware on 8u2 on: October 01, 2010, 02:53:58 pm
Hi
I've just received my arduino uno.
I try to upload a new firmware on the 8u2
I share here the steps I follow.
I use Windows.

Source
I use the following sources:
http://arduino.cc/en/Main/ArduinoBoardUno
http://arduino.cc/blog/2010/09/27/arduino-0020-released-for-windows-and-mac-supports-uno-and-mega-2560/
http://www.ladyada.net/library/arduino/unofaq.html
http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf

Software
I need those software:After install, copy folder arduino-0020\hardware\arduino\firmwares\arduino-usbserial on LUFA_100807\Projects\

Hardware:
There are two modifications to do:
Solder 2 jumpers: one on the HWB line and one between pin 5 & 6 on ISP1 for RESET



How to put the Uno on DFU mode:
      4. put the 8U2 into USB DFU mode:
      4.a. assert and hold the 8U2's RESET line
      4.b. assert and hold the 8U2's HWB line
      4.c. release the 8U2's RESET line
      4.d. release the 8U2's HWB line
      The device became USB DFU

Hardware, drivers installation:
  • Arduino Uno: drivers are on arduino-0020\drivers
  • Arduino Uno DFU: drivers are on Atmel\Flip 3.4.2\usb
Verify the board
Upload blink program on your uno to check that the board is working fine.

Compile firmware
  • To be sure that's working i change a line in Descriptors.c:
UnicodeString          = L"Arduino Uno"  by UnicodeString          = L"ArduINo UNO"
  • Open WinAvr/Programmer Notepad
  • Load makefile
  • I modify LUFA_PATH => LUFA_PATH = ../../
  • You should have to modify ARDUINO_MODEL_PID if you use MEGA
  • Do Tools[ch8594]Make clean
  • Do Tools[ch8594]Make all
Upload Arduino-usbserial.hex on the board
  • make sure the board is in DFU mode
  • Start Flip
  • Select the device AT90USB82  (not the ATmega8u2!!)
  • Open usb communication
  • Select Load Hex file
  • Program target device memory
Test
Unplug the board and re-plug
The Name of the board should have changed : it becomes “ArduINo UNO”

Verify the board
Upload blink program on your uno to check that the board is still working fine.

That's all!
12  Forum 2005-2010 (read only) / Uno Punto Zero / Re: UNO Help Changing USB Device on: October 07, 2010, 12:45:00 am
I have updated my last post with an example of an usb-joystick for arduino uno.
You can easily adapt this to get a mouse (use LUFA_100807\Demos\Device\ClassDriver\Mouse)

13  Forum 2005-2010 (read only) / Uno Punto Zero / Re: UNO Help Changing USB Device on: October 01, 2010, 03:33:20 pm
I open a post for the beginning:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285962838
Pages: [1]