Autor Tema: FPGA NiosII para control de matriz (cubo) de LEDs.  (Leído 16778 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Suky

  • Moderadores
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #15 en: 09 de Abril de 2012, 15:31:04 »
Consulta rápida, que capacidad mínima debe tener un FPGA para implementar Nios II... Estaba viendo unas placas en Ebay, me acorde del tema y entré a dudar si será útil. La placa tiene un Cyclone II EP2C8, o sea 8k LEs.



Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #16 en: 10 de Abril de 2012, 22:34:11 »
Hola Suky, depende de la FPGA, pero con 8k LE estás del otro lado...

http://www.altera.com/literature/ds/ds_nios2_perf.pdf

También te piden RAM on-chip, pero el Hello World optimizado lo he corrido con solo 4k en una Cyclone y no hubo problemas.

Desconectado Suky

  • Moderadores
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #17 en: 10 de Abril de 2012, 22:38:36 »
Gracias! Ya me pedí la plaquita, así que ahora a esperar  :)


Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #18 en: 11 de Abril de 2012, 13:33:52 »
Gracias! Ya me pedí la plaquita, así que ahora a esperar  :)


Saludos!

¿Cuál fue a final de cuentas?

Desconectado pastgriot

  • PIC10
  • *
  • Mensajes: 5
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #19 en: 14 de Abril de 2012, 14:45:15 »
Estoy usando esa misma placa para mi proyecto Santiago  :mrgreen: , la verdad es que estoy sorprendido por el precio, buscando por ebay y aliexpress no encontré alguna que se le igualara en razón de calidad/precio. 

Alguien mas ha hecho algún proyecto con el nios ii??? yo hasta ahora he logrado integrarle una uart y comunicarla con un ft232 que tenia por ahí, por el momento estoy tratando de manejar el uart mediante interrupciones pero no lo he logrado, solo las interrupciones de un puerto de entrada. Cuando tenga algo de código concreto lo compartiré con ustedes.

Saludos!

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #20 en: 14 de Abril de 2012, 21:47:51 »
Lo más que he hecho con ella y Nios II es un pwm con JTAG UART jejeje

En el Cyclone I eché a andar VGA, pero en esta plaquita necesito hacer el R2R para lograrlo también  :?

Desconectado fausto0123

  • PIC10
  • *
  • Mensajes: 9
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #21 en: 16 de Abril de 2012, 00:41:29 »
amigo migsantiago claro es q con las fpga se puede hacer una infinidad de cosas, me gustaria q compartieras un pco como es el uso de nios ii para poder hacer la comunicacion serial kit  con otros componentes y poder ya mostrar ejemplos q tenemos con los cmpañeros , yo soy relativamente nuevo en esto pero con muchas gans de aprender y poder sacarle provecho al kit q tengo  y tambien en el foro mostrar ejemplos

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #22 en: 16 de Abril de 2012, 13:14:53 »
amigo migsantiago claro es q con las fpga se puede hacer una infinidad de cosas, me gustaria q compartieras un pco como es el uso de nios ii para poder hacer la comunicacion serial kit  con otros componentes y poder ya mostrar ejemplos q tenemos con los cmpañeros , yo soy relativamente nuevo en esto pero con muchas gans de aprender y poder sacarle provecho al kit q tengo  y tambien en el foro mostrar ejemplos

Hola, hay muchos tutoriales allá afuera para echar a andar Nios.

Éste te sirve para crear el módulo VHDL con Nios, RAM, JTAG UART y puertos IO...

http://www.4shared.com/office/sSMNVzLh/tut_sopc_introduction.html

Síguelo hasta la página 14.

Luego, para programar el firmware de Nios, sigue este tutorial a partir de la página 36.

http://www.4shared.com/office/Ri9M-ovB/tt_nios2_hardware_tutorial.html

Te sugiero que uses el Hello World compacto para que el código quepa en la RAM de 4kB que sugieren usar. O si quieres usa más RAM.

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #23 en: 16 de Abril de 2012, 18:08:02 »
Les dejo el archivo QSF que vincula los pines de la FPGA ya nombrados con nuestro proyecto en la DE0-Nano. Está corregido, ya no arroja el error de que confunde la terminal DCLK del EPCS y permite que Quartus sintetice correctamente.

Código: [Seleccionar]
Error (169187): Following feature(s) of I/O pin ~ALTERA_DCLK~ has invalid setting(s) in the configuration scheme ACTIVE_SERIAL when the pin is placed at pin location H1 Info (169189): I/O feature 'Current Strength' has an invalid setting. The setting should be Default.

Desconectado fausto0123

  • PIC10
  • *
  • Mensajes: 9
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #24 en: 16 de Abril de 2012, 21:57:38 »
gracias por los link voy a mirarlos, en la SD encontre ejemplos para nios II
http://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=56&No=372  esta es el kit  q tenemos

este es un ejemplo
falta es mirar como pasarlo lo q tenemos  a la SD

*****************************************************************************
 *  File: sd_card.c
 *
 *  This file contains functions for performing general tasks associated
 *  with the sd card.
 *
 ****************************************************************************/

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "includes.h"
#include "elca_fat.h"
#include "sd_card.h"
#include "os_utils.h"


// Message boxes for communication with the SD Card task.
OS_EVENT* As_SDCardComMbox;
OS_EVENT* As_SDCardRespMbox;

/*****************************************************************************
 *  Function: SDChdirLongName
 *
 *  Purpose: Changes directories in the SD Card to a directory with the long
 *           filename "dirname[]"
 *
 *  Returns: 0 - Success
 *          -1 - Failure
 ****************************************************************************/
int SDChdirLongName( char dirname[] )
{
  int found_dir = 0;
  int ret_code = 0;
  char fixed_shortname[16];

  // Clear the shortname and longname since the elca_findx functions dont do it for us.
  memset( ffblk.ff_longname, 0x0, _MAX_NAME );
  memset( ffblk.ff_name, 0x0, 12 );

  // Look for any directories who's long or short names match ours
  if( elca_findfirst() != 0 ) //Find first file
  {
    do
    {
       // Reformat the short filename from the weird way El Camino does it.
       SDStringToLower( ffblk.ff_name, fixed_shortname );
       if( memchr( fixed_shortname, '.', strlen( fixed_shortname ) ))
       {
         *((char*)strrchr( fixed_shortname, '.' )) = '\0';
       }
     
      if (( ffblk.ff_attr == ATTR_DIRECTORY ) && ( ffblk.ff_name[0] != '.' ))
      {
        if(( !strcmp( fixed_shortname, dirname )) ||
           ( !strcmp( ffblk.ff_longname, dirname )))
        {
          found_dir = 1;
          break;
        }
      }
      // Clear the shortname and longname since the elca_findx functions dont do it for us.
      memset( ffblk.ff_longname, 0x0, _MAX_NAME );
      memset( ffblk.ff_name, 0x0, 12 );
    } while( elca_findnext() != 0 ); //Find next file or directory
  }

  if( found_dir )
  {
    ret_code = elca_chdir( ffblk.ff_name );
  }
  else
  {
    ret_code = -1;
  }

  return( ret_code );
}


/*****************************************************************************
 *  Function: SDOpenLongName
 *
 *  Purpose: Opens a file on the SD Card with the long
 *           filename "filename[]"
 *
 *  Returns: file_handle > 0 - Success
 *          -1               - Failure
 ****************************************************************************/
char SDOpenLongName( char filename[], unsigned char attr )
{
  int found_file = 0;
  char ret_code;
  char fixed_shortname[16];

  // Look for any directories who's long or short names match ours
  if( elca_findfirst() != 0 ) //Find first file
  {
    do
    {
      // Reformat the short filename from the weird way El Camino does it.
      SDStringToLower( ffblk.ff_name, fixed_shortname );
     
      if (( ffblk.ff_attr == ATTR_FILE ) && ( ffblk.ff_name[0] != '.' ))
      {
        if(( !strcmp( fixed_shortname, filename )) ||
           ( !strcmp( ffblk.ff_longname, filename )))
        {
          found_file = 1;
          break;
        }
      }
    } while( elca_findnext() != 0 ); //Find next file or directory
  }

  if( found_file )
  {
    ret_code = elca_fopen( ffblk.ff_name, attr );
  }
  else
  {
    ret_code = -1;
  }

  return( ret_code );
}

/*****************************************************************************
 *  Function: SDStringToLower
 *
 *  Purpose: Converts a string to lower case, and removes any spaces from it.
 *           The space-removal is neccessary because the El Camino FAT
 *           fat filesystem code returns short filenames with spaces between
 *           the filename and the "." if the filename is fewer than 8
 *           characters
 *
 *  Returns: 0
 ****************************************************************************/
int SDStringToLower( char src_string[], char dest_string[] )
{
  int src_index = 0;
  int dest_index = 0;
 
  while( src_string[src_index] != '\0' )
  {
    if( src_string[src_index] != ' ' )
    {
      if(( src_string[src_index] >= 'A' ) &&
         ( src_string[src_index] <= 'Z' ))
      {
        dest_string[dest_index] = src_string[src_index] + 32;
      }
      else
      {
        dest_string[dest_index] = src_string[src_index];
      }
      dest_index++;
    }
    src_index++;
  }
  dest_string[dest_index] = '\0';
 
  return( 0 );
}


/*****************************************************************************
 *  Function: SDls
 *
 *  Purpose: Parses the contents of the SD directory dir_listing->dirpath
 *           and returns it in the structure "dir_listing"
 *
 *  Returns: 0 - success
 *          -1 - failure
 ****************************************************************************/
int SDls( sdcard_dir_listing* dir_listing )
{
 
  sdcard_com_message sdcard_com_message;
  sdcard_resp_message* sdcard_resp_message;
  INT8U err;
   
  sdcard_com_message.command = SDCARD_LISTING;
  strcpy( sdcard_com_message.filepath, dir_listing->dirpath );
  sdcard_com_message.data = (void*)dir_listing;
  while( OSMboxPost( As_SDCardComMbox, &sdcard_com_message ) != OS_NO_ERR );
  sdcard_resp_message = OSMboxPend( As_SDCardRespMbox, 0, &err );
 
  if( err || sdcard_resp_message->error || dir_listing->error )
  {
    return( -1 );
  }
  else
  {
    return( 0 );
  }
}
 

/*****************************************************************************
 *  Function: SDChdirAbsPath
 *
 *  Purpose: Changes to an absolute path directory.  Supports both long
 *           and short names.  Can also put a filename on the end of the path
 *           However if you pass in a directory only (no file on end), the
 *           path must end with a /.
 *
 *  Returns: Number of directory levels descended to reach target directory
 *
 ****************************************************************************/
int SDChdirAbsPath( char abspath[] )
{
  int num_levels;
  char temppathstaticarray[256];
  char* temppath = &(temppathstaticarray[0]);
  char tempdir[256];
  char* slashptr;
 
  strcpy( temppath, abspath );
 
  for( num_levels = 0; ; num_levels++ )
  {
    slashptr = strchr( temppath, '/' );
    if( !slashptr )
    {
      // There was no slash in the remaining path, so lets make sure what remains
      // is a directory by trying to cd to it.
      if( SDChdirLongName( temppath ) == ELCA_F_OK )
      {
        num_levels++;
      }
      // If what's left is not a directory, we should return 0 to indicate failure
      // But first, we need to walk back up whatever directories we've descended.
      else
      {
        while( num_levels > 0 )
        {
          elca_chdir( ".." );
          num_levels--;
        }
      }
      break;
    }
    else
    {
      // Clear tempdir before we copy anything into it since it may contain
      // stale data
      memset( tempdir, 0x0, 256 );
      strncpy( tempdir, temppath, slashptr - temppath );
      if( SDChdirLongName( tempdir ) != ELCA_F_OK )
        break;
      temppath = slashptr + 1;
    }
  }
 
  return( num_levels );
}


void SDCardTask( void* pdata )
{
  int num_levels;
  int i;
  INT8U err;
 
  char* filename; 
  char* slashptr;
  char tempname[256];
 
  sdcard_com_message* sdcard_com_message;
  sdcard_resp_message sdcard_resp_message;

  As_SDCardComMbox = OSMboxCreate((void *)0); 
  As_SDCardRespMbox = OSMboxCreate((void *)0); 


  // Mount the SD Card.  Make 100 attempts before giving up.
  for( i = 0; i < 100; i++ )
  {
    if( elca_fat_mount( PERIPHERAL_SUBSYSTEM_EL_CAMINO_SD_CARD_CONTROLLER_NAME ) >= 0 )
      break;
  }

  if( i == 100 )
  {
//    OSPrintf("ERROR: Failed to mount %s\n", PERIPHERAL_SUBSYSTEM_EL_CAMINO_SD_CARD_CONTROLLER_NAME );
  }
   
  while (1)
  {
    // Wait for a message asking for SD Card action
    sdcard_com_message = OSMboxPend( As_SDCardComMbox, 0, &err );
    if ( err == OS_NO_ERR )
    {
      // Task implementation of elca_fopen
      if( sdcard_com_message->command == SDCARD_OPEN )
      {
        slashptr = strrchr( sdcard_com_message->filepath, '/' );
        filename = slashptr + 1;
        *slashptr = 0x0;
        num_levels = SDChdirAbsPath( sdcard_com_message->filepath );

        sdcard_resp_message.file_handle = (char) SDOpenLongName( filename, sdcard_com_message->flag );
        if( sdcard_resp_message.file_handle < 0 )
        {
          sdcard_resp_message.error = SDCARD_ERROR;
        }
        else
        {
          sdcard_resp_message.error = 0;
        }

        // Walk back down the dir tree for next time since el camino doesnt let you
        // change back to the root.
        for( ; num_levels > 0; num_levels-- )
        {
          elca_chdir( ".." );
        }
      }
      // Task implementation of elca_filelength
      else if( sdcard_com_message->command == SDCARD_FILELENGTH )
      {
        if( sdcard_com_message->file_handle >= 0 )
        {
          sdcard_resp_message.num_bytes = elca_filelength( sdcard_com_message->file_handle );
          sdcard_resp_message.error = 0;
        }
        else
        {
          sdcard_resp_message.error = SDCARD_ERROR;
        }
      }
      // Task implementation of elca_fread
      else if( sdcard_com_message->command == SDCARD_READ )
      {
        if( sdcard_com_message->file_handle >= 0 )
        {
          sdcard_resp_message.num_bytes = elca_fread( sdcard_com_message->data,
                                                      sdcard_com_message->num_bytes,
                                                      sdcard_com_message->file_handle );
          sdcard_resp_message.error = 0;
        }
        else
        {
          sdcard_resp_message.error = SDCARD_ERROR;
        }
      }
      // Task implementation of elca_fclose
      else if( sdcard_com_message->command == SDCARD_CLOSE )
      {
        // El Camino provides no error detection capability for closing a file, so
        // we'll just do it blindly.
        elca_fclose( sdcard_com_message->file_handle );
      }
      else if( sdcard_com_message->command == SDCARD_LISTING )
      {
        sdcard_dir_listing* dir_listing = (sdcard_dir_listing*)sdcard_com_message->data;
        dir_listing->num_found = 0;
        num_levels = SDChdirAbsPath( sdcard_com_message->filepath );
        if( num_levels > 0 )
        {
          // El Camino does not clean the name fields between "finds", so we do it manually.
          memset( ffblk.ff_longname, 0x0, _MAX_NAME );
          // Find all the sub-dirs in the app root dir
          if( elca_findfirst() != 0 ) //Find first file
          {
            i = 0;
            do
            {
              // Save off our directory name, because it gets overwritten when we
              // look at the files contained within it.
              if( ffblk.ff_longname[0] != 0 )
              {
                strcpy( tempname, ffblk.ff_longname );
              }
              // If the name was a short filename only, El Camino does not copy it to the
              // longname structure element, so we need to go get the short name and format
              // it properly.
              else
              {
                // Deal with the strange way El Camino formats the short filename.
                SDStringToLower( ffblk.ff_name, tempname );
                // Remove the '.' from the end of the name if it's a dir.
                if(( memchr( tempname, '.', _MAX_NAME )) &&
                   ( ffblk.ff_attr == ATTR_DIRECTORY ))
                {
                  *((char*)strrchr( tempname, '.' )) = '\0';
                }
              }
              strcpy( dir_listing->filenames, tempname );
              i++;
             
              // El Camino does not clean the name fields between "finds", so we do it manually.
              memset( ffblk.ff_longname, 0x0, _MAX_NAME );
            } while ( elca_findnext() != 0 ); //Find next file or directory
          }
         
          // Walk back down the dir tree for next time since el camino doesnt let you
          // change back to the root.
          for( ; num_levels > 0; num_levels-- )
          {
            elca_chdir( ".." );
          }
         
          dir_listing->num_found = i;
          dir_listing->error = 0;
          sdcard_resp_message.error = 0;
        }
        else
        {
          sdcard_resp_message.error = SDCARD_ERROR;         
        }
      }
     
      while( OSMboxPost( As_SDCardRespMbox, &sdcard_resp_message ) != OS_NO_ERR );
    }
  }
}

char SDOpen( char fullfilename[], unsigned char flag )
{
 
  sdcard_com_message sdcard_com_message;
  sdcard_resp_message* sdcard_resp_message;
  INT8U err;
   
  sdcard_com_message.command = SDCARD_OPEN;
  sdcard_com_message.flag = flag;
  strcpy( sdcard_com_message.filepath, fullfilename );
  while( OSMboxPost( As_SDCardComMbox, &sdcard_com_message ) != OS_NO_ERR );
  sdcard_resp_message = OSMboxPend( As_SDCardRespMbox, 0, &err );
 
  if( err || sdcard_resp_message->error )
  {
    return( -1 );
  }
  else
  {
    return( sdcard_resp_message->file_handle );
  }
}

int SDFilelength( char filehandle )
{
 
  sdcard_com_message sdcard_com_message;
  sdcard_resp_message* sdcard_resp_message;
  INT8U err;

  sdcard_com_message.command = SDCARD_FILELENGTH;
  sdcard_com_message.file_handle = filehandle;
  while( OSMboxPost( As_SDCardComMbox, &sdcard_com_message ) != OS_NO_ERR );
  sdcard_resp_message = OSMboxPend( As_SDCardRespMbox, 0, &err );
 
  if( err || sdcard_resp_message->error )
  {
    return( -1 );
  }
  else
  {
    return( sdcard_resp_message->num_bytes );
  }
}


unsigned int SDRead( char* buffer, unsigned int bytecount, char filehandle )
{
 
  sdcard_com_message sdcard_com_message;
  sdcard_resp_message* sdcard_resp_message;
  INT8U err;

  sdcard_com_message.command = SDCARD_READ;
  sdcard_com_message.file_handle = filehandle;
  sdcard_com_message.data = buffer;
  sdcard_com_message.num_bytes = bytecount;
  while( OSMboxPost( As_SDCardComMbox, &sdcard_com_message ) != OS_NO_ERR );
  sdcard_resp_message = OSMboxPend( As_SDCardRespMbox, 0, &err );
 
  if( err || sdcard_resp_message->error )
  {
    return( 0 );
  }
  else
  {
    return( sdcard_resp_message->num_bytes );
  }
}

void SDClose( char filehandle )
{
 
  sdcard_com_message sdcard_com_message;
  sdcard_resp_message* sdcard_resp_message;
  INT8U err;

  sdcard_com_message.command = SDCARD_CLOSE;
  sdcard_com_message.file_handle = filehandle;
  while( OSMboxPost( As_SDCardComMbox, &sdcard_com_message ) != OS_NO_ERR );
  sdcard_resp_message = OSMboxPend( As_SDCardRespMbox, 0, &err );
 
  // There is no error detection for closing a file, so we do nothing here. 
}

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #25 en: 17 de Abril de 2012, 00:03:27 »
gracias por los link voy a mirarlos, en la SD encontre ejemplos para nios II
http://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=56&No=372  esta es el kit  q tenemos


Ah ese kit lo teníamos en mi anterior trabajo, pero mi jefe nunca lo usó, siempre lo tuvo arrumbado...  :x

Desconectado fausto0123

  • PIC10
  • *
  • Mensajes: 9
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #26 en: 17 de Abril de 2012, 13:20:37 »
si, hombre una pregunta se debe sacar las licencias ps por el quartus II y por la librerias
me imagino es q aca tenemos uno el de prueba que dura 30 dias y en su concepto personal q tal es el kit

Desconectado migsantiago

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8257
    • Sitio de MigSantiago
Re: FPGA NiosII para control de matriz (cubo) de LEDs.
« Respuesta #27 en: 03 de Mayo de 2012, 11:58:08 »
Yo uso Quartus II 11.1 y no hace falta licencia para compilar para Cyclone IV.

Para los que sí hace falta licencia es para la Cyclone I por ejemplo. También si se usa Quartus II 8.0, pero la licencia es gratis dándose de alta en altera.com.

El kit DE0-Nano es muy bueno, sobre todo para los principiantes que queremos entender las cosas desde cero.