Loading...
  Show Posts
Pages: [1] 2 3 ... 17
1  Using Arduino / Programming Questions / Re: start code from the begining .How? on: May 06, 2013, 04:41:41 pm
there is a function that checks if there is "OFF" signal from IR remote control (lets name this function IR_CHECK). if user presses off button then it stores "1" to a temp variables. if user press  "ON" button it stores "0" to that temp variable

on my project there are many other functions (displaying graphic efe,showing scrolling text and other)
all these functions are calling IR_CHECK function to check if there is "OFF" or "ON" signal. and they works like this:

if (temp==0){
  task_0();
  task_1();
  task_2();
 //...
 //...
}
if (temp==1){
  task_temperature();//show only temperature
}

so when user presses OFF button the only fanction that runs is task_temperature. the only problem is that it needs to wait to finish the current task (some of them are spending some seconds)
2  Using Arduino / Programming Questions / Re: start code from the begining .How? on: May 06, 2013, 04:10:50 pm
well this is what i have made using arduino code:


the code is really complicated and big. user can program it via IR remote control.

each loop takes about 1-3 minutes. I want the add a new feauture now. "night mode"
when user presses "off" button on remote control, the cross display need to show only temperature. (this is night mode).
i succed to do that with a flag, but the functions are spending a lot of time and it needs to finish one of them and then go to night mode.
for example when it scrolling the time, when user presses "off" button it waits to finish this fuction (maybe about 5-10 seconds) and then it goes to night mode.. and this is not what i want from that. i want to turning on night mode in real time


edit.

i found this
void(* resetFunc) (void) = 0; //declare reset function @ address 0
...
resetFunc();  //call reset

is it safe to use it?
3  Using Arduino / Programming Questions / Re: start code from the begining .How? on: May 06, 2013, 03:23:32 pm
yes. function
4  Using Arduino / Programming Questions / Re: start code from the begining .How? on: May 06, 2013, 03:08:06 pm
you are right. my original scetch is really big so i decided to give you an example on what i want to do.

so check again my code.
it runs many task and in all these tasks it checks for IR.
all i need is to start from begining when a IR signal is coming
5  Using Arduino / Programming Questions / start code from the begining .How? on: May 06, 2013, 02:52:45 pm
I have a program that makes some tasks and it checks for infrared signals.

all i want is every time it checks for IR signals i want the scetch to start from begining. I tried with goto but it only works inside their void

Code:
byte incoming_IR_data;
void setup() {                

  pinMode(13, OUTPUT);    
}

void loop() {
  start:
  task_0();
  task_1();
  task_2(); 
}

void task_0(){
  
  //some code here
   check_IR();
}
void task_1(){
  
  //some code here
   check_IR();
}
void task_2(){
  
  //some code here
   check_IR();
}
void check_IR(){
 //Some code that checks IR and stores data from Infrared to incoming_IR_data variable
 
     if (incoming_IR_data==12524){
       goto start;  
     }
  
  
}
6  Using Arduino / Programming Questions / Re: Help On reading SD card like EEPROM on: February 07, 2013, 05:21:41 pm
i need to store many data that arduino will read and store them to variables arrays. data are integers with values 0-255.

how could i do that with files?
7  Using Arduino / Programming Questions / Help On reading SD card like EEPROM on: February 07, 2013, 04:56:28 pm
Hi. i need big storage and SD card is more than enough for me.

But i need to be able to read/write on address like an eeprom.
So i dont want to use files. Only read/write bytes on any address of that.

Is it posible to do that? and if yes how?
also i would like to know about the speed of SD cards. Are they faster than eeprom?
8  Using Arduino / Programming Questions / Re: Communication with 2 x DS18B20 on: January 09, 2013, 01:25:04 pm
forgot to mention that i have no problem with any other code (just to be sure is not buggy, some codes doesnt gives negative values)
9  Using Arduino / Programming Questions / Communication with 2 x DS18B20 on: January 09, 2013, 01:03:59 pm
Hi i have 2 DS18B20 sensors and i want to recieve temperature values from both sensors. (one by one)
Each DS18B20 is connected to different pin. (for example pin 10 and pin 11).
How could i do that on code please??

here is the code i am using


Code:
#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

OneWire  ds(10);  // on pin 10

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

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
 
  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
 
  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }
  Serial.println();
 
  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
 
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("  Data = ");
  Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print(OneWire::crc8(data, 8), HEX);
  Serial.println();

  // convert the data to actual temperature

  unsigned int raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // count remain gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    if (cfg == 0x00) raw = raw << 3;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
    // default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
}
10  Using Arduino / Programming Questions / Re: declare 1 pin on 2 names on: July 11, 2012, 01:45:22 pm
actually i created my own PCB board with PIC32MX795F512 with many components (FRAM,RAM,EEPROM) and i have common pins on some components (CY62148EV30,DS1744W)
i am using arduino code so i prefer to not have common names (variables) on both components. It will be easier to program them
11  Using Arduino / Programming Questions / declare 1 pin on 2 names on: July 11, 2012, 01:32:53 pm
HI. i would like to know if i can declare 2 integer on 1 pin
example

  int CY62148EV30_A0=35;
  int DS1744W_A0=35;

  pinMode(CY62148EV30_A0,OUTPUT); 
  pinMode(DS1744W_A0,OUTPUT);

if i do that can i use (digitalread,digitalWrite) any of them without problem?
12  Using Arduino / Networking, Protocols, and Devices / Re: shift register with SRAM. speed? on: May 29, 2012, 03:24:49 pm
these are F-RAM like this? http://www.ramtron.com/files/datasheets/FM25L04B-GA_ds.pdf

i am worring about SPI inteface.

is there any documentary on that?

EDIT:
does this tutorial works the same with FRAM?
http://arduino.cc/en/Tutorial/SPIEEPROM
13  Using Arduino / Networking, Protocols, and Devices / shift register with SRAM. speed? on: May 29, 2012, 03:01:39 pm
Hi all!
I am working on led displays and i'm out of RAM. i tried to use EEPROM and i saw that it is really slow...
I'm gonna use 512KB SRAM (http://www.alliancememory.com/pdf/AS6C4008.pdf) with arduino.

becouse it needs too many pins i was thinking to use shift registers for Address Inputs.

Will i loose much speed?
14  Using Arduino / Programming Questions / Re: Need help on IR remote on: April 09, 2012, 05:20:12 pm
i succed to make my own code without library(thanks to an old code of some on this forum). i modified so it works on external function when someone need to read if there is IR signal.

this works on SONY remotes

Code:
int getIRKey() {
  int total_length=10000;
  int header_length=7000;
  int check_on_high=3000;
  int check_on_low=1000;
  int ir_data[12];
  int ir_result[12];
  long pulselow;

  for (int i=0;i<total_length;i++){//give time to check all pulses. becouse we dont know where the header low bit is  
        delayMicroseconds(1);
        if (digitalRead(ir_pin)==LOW){ //if you found low signal        
            pulselow=pulseIn(ir_pin,LOW);//then store in pulselow the length of pulse
            if (pulselow>header_length){ //if this is the header pulse
                    pulselow=0;
                    for (int j=0;j<12;j++){
                       ir_data[j] = pulseIn(ir_pin, LOW);      //Start measuring bits, I only want low pulses
                    }
                    for(int i=0;i<12;i++) {  //Parse them
                        if(ir_data[i]>check_on_high) {  //is it a 1?
                     ir_result[i] = 1;
                        }  else {
                         if(ir_data[i]>check_on_low) { //is it a 0?
                            ir_result[i] = 0;
                         } else {
                           ir_result[i] = 2;  //Flag the data as invalid; I don't know what it is!
                         }
                        }
                    }
                    for(int i=0;i<12;i++) {  //Pre-check data for errors
                        if(ir_result[i] > 1) {
                         return -1;     //Return -1 on invalid data
                        }
                   }
                   int result = 0;
                   int seed = 1;
                   for(int i=0;i<12;i++) {  //Convert bits to integer
                        if(ir_result[i] == 1) {
                      result += seed;
                        }
                        seed = seed * 2;
                   }
                   return result;
            }
    }
    }
}


Moderator edit: [code] [/code] tags added.
15  Using Arduino / Programming Questions / Re: Need help on IR remote on: April 09, 2012, 09:58:29 am
I told you again
//other tasks here

it contains there 80kb code.  i think it was not necessary to paste all code....

delay was an example to understand that my code needs to read the ir pulses when i need
Pages: [1] 2 3 ... 17