Show Posts
Pages: [1]
1  Using Arduino / General Electronics / maximum output for TLC5940 on: March 26, 2014, 02:44:20 am
hi all,

i have a project to create 600 output on off, as i know arduino don have that much of output,
so that i come in to using TLC5940, there is alot of example i can find,
but did any one know what are the maximum output to connect TLC5940 in series?
(can reach about 600? mean 38 unit of TLC5940  connect in series.)

thank you.
2  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet lib: hang after many client.print on: January 18, 2014, 01:48:24 am
my entire sketch is very long and in difference file.

i am using arduino mega.
i just found out that the more code i write the less client it can print.
is that because of run out of ram?
i place the freememory() at the end of the client print loop, ir show the ram still have about 2000.
any idea about that???
3  Using Arduino / Networking, Protocols, and Devices / Ethernet lib: hang after many client.print on: January 17, 2014, 08:34:30 pm
hi,
i am writing a project of sending the thml code in sdcard to server.
at the begining every thing is woring good. but when the data become bigger and bigger, then ethernet hang,
it always hang at the same place. any person face the same problem also??
my code is something like this...
thank you
Code:
void sd_sendtable(EthernetClient & client,char filename[32], String token)
{
  Serial.println(filename);
   SdFile file2;
   if (!file2.open(filename, O_READ)) restart();
    int16_t data;
    int countContent = 0;
    boolean stopsend = false;
    BUFFER sendContent;
    memset(sendContent, 0, STRING_BUFFER_SIZE);
    while ((data = file2.read()) >= 0 || stopsend == false){     
      if(data <= 0){
        stopsend = true;
      }
      else{
        //250 token
        if(data == 250){
          sendContent[countContent] = token[0];
          sendContent[countContent + 1] = token[1];
          sendContent[countContent + 2] = token[2];
          sendContent[countContent + 3] = token[3];
          sendContent[countContent + 4] = token[4];
          sendContent[countContent + 5] = token[5];
          countContent = countContent + 6;
        }
        else if(data == 220 || data == 221 || data == 222 || data == 223 || data == 224){
          // remove the symbol
        }     
        else
        {
          sendContent[countContent] = data;
          countContent = countContent++;
        }
      }
      if(countContent == STRING_BUFFER_SIZE - 20 || stopsend == true){
        client.print(sendContent);
        memset(sendContent, 0, STRING_BUFFER_SIZE);
        countContent = 0;
      }
    }
    // close the file:
    file2.close();
}
4  Using Arduino / Networking, Protocols, and Devices / power link Ethernet, how to send data using power line? on: May 06, 2013, 10:02:00 pm
Halo, i have a idea that using the power line to communicate between two Arduino, and i have no idea about the logic and how it work.
any one did that before and can direct me to the right way? any module that i can use? thank you.
5  Topics / Home Automation and Networked Objects / Re: cannot combine the ethernet shield and RF24L01. on: December 20, 2012, 08:29:37 pm
sorry, will use my old post
6  Topics / Home Automation and Networked Objects / cannot combine the ethernet shield and RF24L01. on: December 20, 2012, 02:46:19 am
as i know the  Ethernet shield and RF24L01 can not combine in the same arduino uno. because they are using the same pins.
is it true?
if no any example code?
if yes any solution code?

thank you smiley-cry
7  Topics / Home Automation and Networked Objects / Re: NRF24L01 and ethernet work together problem. on: December 19, 2012, 08:49:06 pm
Normally, it is because the programmer cannot share (edit: fails to manage) the slave select pins until the individual libraries take over. That would include the uSD if you have a memory card in the ethernet shield slot.
Quote
if yes, any solution ?
Maybe. Post your code.

[/quote]
i haven start combine the code together, now what i test is i use this code to send out the data. but when i combine the arduino ethernet circuit, it not function, any extra code i need to add in?
yes, i am going to use the sd card function in my project.
Code:
#include "NRF24L01.h"

//***************************************************
#define TX_ADR_WIDTH    5   // 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH  32  // 32 unsigned chars TX payload

unsigned char TX_ADDRESS[TX_ADR_WIDTH]  =
{
  0x34,0x43,0x10,0x10,0x01
}; // Define a static TX address

unsigned char rx_buf[TX_PLOAD_WIDTH] = {0}; // initialize value
unsigned char tx_buf[TX_PLOAD_WIDTH] = {0};
//***************************************************
void setup()
{
  SPI_DIR = ( CE + SCK + CSN + MOSI);
  SPI_DIR &=~ ( IRQ + MISO);
  //  attachInterrupt(1, _ISR, LOW);// interrupt enable
  Serial.begin(9600);
  init_io();                        // Initialize IO port
  unsigned char status=SPI_Read(STATUS);
  Serial.print("status = ");   
  Serial.println(status,HEX);     // There is read the mode鈥檚 status register, the default value should be 鈥楨鈥? 

Serial.println("*******************TX_Mode Start****************************");
  TX_Mode();                       // set TX mode
}
void loop()
{
  int k = 0;
  for(;;)
  {
    for(int i=0; i<32; i++)
        tx_buf[i] = k++;       
    unsigned char status = SPI_Read(STATUS);                   // read register STATUS's value
    if(status&TX_DS)                                           // if receive data ready (TX_DS) interrupt
    {
      SPI_RW_Reg(FLUSH_TX,0);                                 
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);       // write playload to TX_FIFO
    }
    if(status&MAX_RT)                                         // if receive data ready (MAX_RT) interrupt, this is retransmit than  SETUP_RETR                         
    {
      SPI_RW_Reg(FLUSH_TX,0);
      SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);      // disable standy-mode
    }
    SPI_RW_Reg(WRITE_REG+STATUS,status);                     // clear RX_DR or TX_DS or MAX_RT interrupt flag
    delay(1000);
  }
}

//**************************************************
// Function: init_io();
// Description:
// flash led one time,chip enable(ready to TX or RX Mode),
// Spi disable,Spi clock line init high
//**************************************************
void init_io(void)
{
  SPI_PORT&=~CE; // chip enable
  SPI_PORT|=CSN; // Spi disable
  SPI_PORT&=~SCK; // Spi clock line init high
}

/**************************************************
 * Function: SPI_RW();
 *
 * Description:
 * Writes one unsigned char to nRF24L01, and return the unsigned char read
 * from nRF24L01 during write, according to SPI protocol
 **************************************************/
unsigned char SPI_RW(unsigned char Byte)
{
  unsigned char i;
  for(i=0;i<8;i++)                      // output 8-bit
  {
    if(Byte&0x80)
    {
      SPI_PORT |=MOSI;    // output 'unsigned char', MSB to MOSI
    }
    else
    {
      SPI_PORT &=~MOSI;
    }
    SPI_PORT|=SCK;                      // Set SCK high..
    Byte <<= 1;                         // shift next bit into MSB..
    if(SPI_IN & MISO)
    {
      Byte |= 1;                // capture current MISO bit
    }
    SPI_PORT&=~SCK;                    // ..then set SCK low again
  }
  return(Byte);                    // return read unsigned char
}
/**************************************************/

/**************************************************
 * Function: SPI_RW_Reg();
 *
 * Description:
 * Writes value 'value' to register 'reg'
/**************************************************/
unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
{
  unsigned char status;

  SPI_PORT&=~CSN;                   // CSN low, init SPI transaction
  status = SPI_RW(reg);             // select register
  SPI_RW(value);                    // ..and write value to it..
  SPI_PORT|=CSN;                    // CSN high again

  return(status);                   // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: SPI_Read();
 *
 * Description:
 * Read one unsigned char from nRF24L01 register, 'reg'
/**************************************************/
unsigned char SPI_Read(unsigned char reg)
{
  unsigned char reg_val;

  SPI_PORT&=~CSN;                // CSN low, initialize SPI communication...
  SPI_RW(reg);                   // Select register to read from..
  reg_val = SPI_RW(0);           // ..then read register value
  SPI_PORT|=CSN;                 // CSN high, terminate SPI communication

  return(reg_val);               // return register value
}
/**************************************************/

/**************************************************
 * Function: SPI_Read_Buf();
 *
 * Description:
 * Reads 'unsigned chars' #of unsigned chars from register 'reg'
 * Typically used to read RX payload, Rx/Tx address
/**************************************************/
unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
{
  unsigned char status,i;

  SPI_PORT&=~CSN;                   // Set CSN low, init SPI tranaction
  status = SPI_RW(reg);            // Select register to write to and read status unsigned char

  for(i=0;i<bytes;i++)
  {
    pBuf[i] = SPI_RW(0);    // Perform SPI_RW to read unsigned char from nRF24L01
  }

  SPI_PORT|=CSN;                   // Set CSN high again

  return(status);                  // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: SPI_Write_Buf();
 *
 * Description:
 * Writes contents of buffer '*pBuf' to nRF24L01
 * Typically used to write TX payload, Rx/Tx address
/**************************************************/
unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
{
  unsigned char status,i;

  SPI_PORT&=~CSN;                   // Set CSN low, init SPI tranaction
  status = SPI_RW(reg);             // Select register to write to and read status unsigned char
  for(i=0;i<bytes; i++)             // then write all unsigned char in buffer(*pBuf)
  {
    SPI_RW(*pBuf++);
  }
  SPI_PORT|=CSN;                   // Set CSN high again
  return(status);                  // return nRF24L01 status unsigned char
}
/**************************************************/

/**************************************************
 * Function: TX_Mode();
 *
 * Description:
 * This function initializes one nRF24L01 device to
 * TX mode, set TX address, set RX address for auto.ack,
 * fill TX payload, select RF channel, datarate & TX pwr.
 * PWR_UP is set, CRC(2 unsigned chars) is enabled, & PRIM:TX.
 *
 * ToDo: One high pulse(>10us) on CE will now send this
 * packet and expext an acknowledgment from the RX device.
 **************************************************/
void TX_Mode(void)
{
  SPI_PORT&=~CE;

  SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);    // Writes TX_Address to nRF24L01
  SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack

  SPI_RW_Reg(WRITE_REG + EN_AA, 0x01);      // Enable Auto.Ack:Pipe0
  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  // Enable Pipe0
  SPI_RW_Reg(WRITE_REG + SETUP_RETR, 0x1a); // 500us + 86us, 10 retrans...
  SPI_RW_Reg(WRITE_REG + RF_CH, 40);        // Select RF channel 40
  SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);   // TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR
  SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);     // Set PWR_UP bit, enable CRC(2 unsigned chars) & Prim:TX. MAX_RT & TX_DS enabled..
  SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH);

  SPI_PORT|=CE;
}
8  Topics / Home Automation and Networked Objects / Re: NRF24L01 and ethernet work together problem. on: December 19, 2012, 09:26:05 am
is that because of the arduino cannot share the ICSP pin?
if yes, any solution ?
9  Topics / Home Automation and Networked Objects / Re: upload picture using web server to sd card. on: December 19, 2012, 09:24:54 am
hallo hong, how about the arduino code?
do you mean that i can use myFile.println("pic in text");
to write my pic to the sd card?
10  Topics / Home Automation and Networked Objects / NRF24L01 and ethernet work together problem. on: December 19, 2012, 01:32:59 am
http://www.elecfreaks.com/203.html
http://www.homebrew-tech.com/arduino/brewing-arduino-announcement/arduinor3testingethernetshieldr3
hallo my project is using the ie to control the LED at another arduino using NRF24L01.
did any one have an example? now i am able to create a web server and NRF24L01 send data. but when i combine them together, the NRF24L01  not working at all. anyone can help??? please and thank
11  Topics / Home Automation and Networked Objects / upload picture using web server to sd card. on: December 16, 2012, 01:10:39 am
hello, i am using a arduino. to created a web server, so far so good. but when i want to create a new function that can upload the picture in my computer to the sd card that located in the arduina, i found out that there is no example and there is no any code that can copy a picture. can anyone help me???

thank u.
12  Topics / Robotics / Re: Arduino + nRF24L01 on: December 03, 2012, 03:07:36 am
hi, i am just started using nRF24L01,
i just want know can Arduino use this device communicated with pic16fXXX?
any one have the example?
Pages: [1]