Show Posts
Pages: [1] 2 3 ... 13
1  Using Arduino / Programming Questions / Re: What does "dht DHT;" mean on: May 06, 2013, 10:40:20 pm
Code:
dht DHT;

This line create an instance of the dht class called DHT


Nice and Easy explanation
http://en.wikipedia.org/wiki/Instance_(computer_science)
2  Using Arduino / Programming Questions / Re: Mitsubishi IR AC remote decoding Problem on: May 06, 2013, 08:16:51 am
disappeared after a while I come back here. I have a problem when trying to load the sketch with the modified libraries, I get the following error and i donĀ“t know why "expected primary-expression before ';' token"
 thanks a lot

UKHeliBob said:
Which line is the error reported to be in ?

Me to...
3  Using Arduino / Microcontrollers / Re: arduino avrdude error on: April 26, 2013, 11:23:51 pm
Quote
I put the new microcontroller in the arduino board
[/size][/size]

Does the chip have bootloader (must be correct bootloader) on it?

1.Fixing The
avrdude: stk500_getsync(): not in sync: resp=0x00
Error When Uploading a Sketch
To An Arduino Uno


avrdude: stk500_getsync(): not in sync: resp=0x00
If you get the following error message "avrdude: stk500_getsync(): not in sync: resp=0x00" that means that the Arduino is not responding. There are literally dozens of reasons this could be.

Check the following:

If you have a NG Arduino, did you press reset just before selecting Upload menu item?
Is the correct Serial Port selected?
Is the correct driver installed?
Is the chip inserted into the Arduino properly? (If you built your own arduino or have burned the bootloader on yourself)
Does the chip have the correct bootloader on it? (If you built your own arduino or have burned the bootloader on yourself)
Note that it is nearly impossible for anyone to debug this, as there are so many possible issues. Try everything.

Ref:http://www.ladyada.net/learn/arduino/help.html

In your case (new chip) most probably Bootloader issue.
4  Using Arduino / Programming Questions / Re: "if" question on: April 26, 2013, 11:04:28 pm
Useful Links:
http://arduino.cc/en/Reference/If

http://arduino.cc/en/Reference/Else

http://arduino.cc/en/Tutorial/IfStatement

http://arduino.cc/en/Reference/Break

http://arduino.cc/en/Reference/Continue
5  Using Arduino / Programming Questions / Re: What sketch is loaded? on: April 24, 2013, 10:57:21 pm
Is this how other people approach it?

I, not.

Tag them by using Sticky Tape.
6  Using Arduino / Programming Questions / Re: Ton of errors i dont understand in my code. on: April 24, 2013, 08:27:37 am
Code:
else;

what is the purpose of this line?

And } at the end of code it is also missed

And what errors?

And did your read this "How to use this forum - please read."
7  Using Arduino / Programming Questions / Re: Mitsubishi IR AC remote decoding Problem on: April 24, 2013, 08:01:10 am
@ arslankhan and diegt

On last weekend i was blackout due to office workload, thats why i start capturing of IR code of my friend Mitsubishi RC and got the same result by putting the value of rawbuf equal to 255

Code:
#define RAWBUF 255

When rawbuf equal to 400

Code:
#define RAWBUF 400

or greater than 255 i got the garbage result of IR sample. This is the starting point of story "There is some problem with RAWBUFF value". Ok, First step write/stole some code to capture the IR pulses by using interrupt.

http://ucexperiment.wordpress.com/2012/02/14/reverse-engineering-an-aim-ir-beacon-transmitter/

And by viewing the code it is clear i need the modification in two lines

Code:
/*
  IR Capture
  Copyright 2012, all rights reserved.
  James M. Eli
  1/14/2012
 
  project parts:
    (1) arduino 16MHz
    (1) 38KHz IR receiver
    (1) breadboard
    (3) wires
 
  IR - Arduino
  SIG - D2
  GND - GND
  VCC - VCC
*/

//definitions
#define IN_PIN 2
#define MAX_CAPTURE 584  // Line number 1
 
//globals
uint32_t now, start, capture[MAX_CAPTURE];
volatile bool flag_complete;
uint16_t i;    // Line number 2 uint8_t to uint16_t Key point of RAWBUF. uint8_t maximum range 255
 
//interrupt fires on ir event (rise/fall)
void IRInterrupt(void) {
  now = micros();
  capture[i++] = now - start;
  start = now;
  if (i >= MAX_CAPTURE) {
    detachInterrupt(0);
    flag_complete = true;
  }
}
 
void setup(void) {
  flag_complete = false;
  start = 0;
  now = 0;
  i = 0;
  Serial.begin(9600);
  attachInterrupt(0, IRInterrupt, CHANGE);
  Serial.println("Ready to capture.");
}
 
void loop(void) {
  while (1) {
    if (flag_complete) {
      for (i=0; i < MAX_CAPTURE; i++) {        
        Serial.println(capture[i]);
        //Serial.print(",");
        flag_complete = false;
      }
    }
  }
}

Quote
uint16_t i;    // Line number 2 uint8_t to uint16_t Key point of RAWBUF. uint8_t maximum range 255

Quote
#define MAX_CAPTURE 584  // Line number 1, Value selected after hit and trial base experiments.

Hurray smiley-cool here is the full IR sample values = 584 samples

Quote
3548,1640,492,1188,492,1192,492,348,492,344,492,348,492,1192,492,348,492,344,492,1192,492,1192,492,344,492,1192,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,488,348,492,1192,492,348,492,348,492,1188,492,348,492,348,492,348,488,348,492,348,492,348,492,348,492,348,488,348,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,1192,492,348,492,344,496,344,492,348,492,348,492,1188,492,1192,492,348,492,348,492,348,488,1192,492,1192,492,1188,492,1192,492,348,492,344,492,348,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,1192,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,1188,492,348,492,348,492,1192,492,348,492,1188,492,1192,492,12916,3544,1640,492,1188,492,1192,492,348,492,348,492,344,496,1188,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,492,344,496,1188,492,348,492,348,492,1188,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,1188,492,348,492,348,492,344,496,344,492,348,492,1192,492,1188,492,348,492,348,492,348,492,1188,492,1192,492,1188,492,1192,492,348,492,348,492,344,492,348,492,348,492,1192,488,1192,492,348,492,1192,488,1192,492,348,492,348,492,344,496,344,496,344,492,348,492,348,492,348,492,1188,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,496,344,492,344,492,348,492,1192,492,348,492,344,492,1192,492,348,492,1188,492,1192,492,

what is happening in IR code expalned in attached excel file.

Second step finding the issue of IR remote library.

Code:
typedef struct {
  uint8_t recvpin;           // pin for IR data from detector
  uint8_t rcvstate;          // state machine
  uint8_t blinkflag;         // TRUE to enable blinking of pin 13 on IR processing
  unsigned int timer;     // state timer, counts 50uS ticks.
  unsigned int rawbuf[RAWBUF]; // raw data
  uint8_t rawlen;         // counter of entries in rawbuf
}
irparams_t;

Here it is
Quote
uint8_t rawlen;  maximum range 255

Solution:

Code:
typedef struct {
  uint8_t recvpin;           // pin for IR data from detector
  uint8_t rcvstate;          // state machine
  uint8_t blinkflag;         // TRUE to enable blinking of pin 13 on IR processing
  unsigned int timer;     // state timer, counts 50uS ticks.
  unsigned int rawbuf[RAWBUF]; // raw data
  uint16_t rawlen;         // counter of entries in rawbuf
}
irparams_t;

And hurray 292 samples

Quote
4718 3550 -1600 500 -1200 500 -1150 500 -350 550 -300 500 -350 500 -1150 500 -350 500 -350 500 -1200 450 -1200 500 -350 500 -1150 500 -350 550 -300 500 -1200 450 -1200 500 -350 500 -1200 450 -1200 500 -350 500 -350 500 -1150 500 -350 500 -350 500 -1150 500 -350 550 -300 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -1150 500 -350 500 -350 500 -350 450 -350 500 -350 500 -1200 500 -1150 500 -350 500 -350 500 -350 450 -1200 550 -1150 500 -1150 500 -1200 500 -350 500 -350 500 -300 500 -350 500 -350 500 -1200 450 -1200 500 -350 500 -1150 500 -1200 500 -350 500 -350 500 -1150 500 -1200 500 -350 500 -300 500 -350 500 -350 500 -1150 500 -350 550 -300 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 500 -1150 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -1150 500 -350 500 -1200 500 -350 500 -1150 500 -1200 500 -1150 500 -1200 500

why 292 not 584?
reason is, same IR code sent twice with space of 12ms b/w them.

Now it is clear and it will take 10 min to write the code of sendMit of both of you.

Goodluck.

Edit: If you get the raw code after the above modification and send it in raw it will work.
8  Using Arduino / Programming Questions / Re: 8-bit timer or 16-bit timer on: April 17, 2013, 05:48:29 am
There are 8-bit timers and 16-bit timer in AVR MCUs. May I know under what conditions should I use 16-bit timer? Are the only difference between the two a matter of resolution only?

Google [16 bit vs 8 bit timer]

first page
http://www.scriptoriumdesigns.com/embedded/timers.php

Quote
May I know under what conditions should I use 16-bit timer?

where you want to set the 0xFFFF to timer register for desire time.

Quote
Are the only difference between the two a matter of resolution only?

Depend
9  Using Arduino / Programming Questions / Re: Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 08:39:00 am
This seems me what i am excepting to study BTW at this time i am considering the C99 only.

Thanks pYro_65.
10  Using Arduino / Programming Questions / Re: Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 05:36:41 am
But the real reason?

By using union lots of (heavy)function replaced by few lines of code e.g. conversion steps ,extracting different parameter, error-detecting, and performing action on them.

In short, I just wanted to make sure that use of union is not harmful for embedded systems in this case.
11  Using Arduino / Programming Questions / Re: Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 05:08:07 am
Why do you want the union?

Because it is the part of K&R and i am trying to feel(practice) it.


You are posting a snippet. Show the rest of your code.

It's too long...

Thanks.
12  Using Arduino / Programming Questions / Re: Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 04:45:03 am
Suggestion required (anything need to keep in mind?).

Don't use a union. It doesn't give you anything here.

It's mean i am doing some thing wrong?
13  Using Arduino / Programming Questions / Re: Issue with variable declaration on: April 15, 2013, 03:08:03 am
Quote
issue

What issue?
14  Using Arduino / Programming Questions / Re: Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 02:44:37 am
One suggestion:

A union is used if data is used in different ways in the same sketch.

If you transmit and receive data, you often don't have to use an union.
A transmit function is typical: transmit( char * buffer, int size);
You can call that function with the structure: transmit( (char *) myStruct, sizeof( myStrut));

Thanks. Actually this is the simplest form of (testing)message. In actual application union contain multiple stuctures for specific purpose. e.g. [header][ver][Application][][]...
15  Using Arduino / Programming Questions / Communication "Packet" design by using "union" (Suggestion required) on: April 15, 2013, 01:53:40 am
Hello Everyone,

Story start from this thread ref:http://arduino.cc/forum/index.php/topic,159519.0.html.

To feel "union in c" I tested it in real (not only for Arduino base system) Wireless Sensor Network application. This is the format of packet

Code:
union uPacket{
  struct packet{
    char sDelimeter; //To mantian Backward Compatibilty
    uint8_t id;
    uint8_t payload[10];
    char mDelimeter; //To mantian Backward Compatibilty
    uint16_t msgId;
    char eDelimeter; //To mantian Backward Compatibilty
  }
  sPac;
  uint8_t asBytes[16];
}
uRx, uTx;

Quote
Cycle of Communication

                            NODE 1                                                    NODE 2
Fill(struct) -->Send(uTx.asBytes) -... ...- Recv(&buffer) -->copy(uRx.asBytes) -->extract(struct)

Suggestion required (anything need to keep in mind?).
Thanks in advance.

Literature Links:
http://forums.codeguru.com/showthread.php?306399-Visual-C-Network-How-do-I-transfer-structure

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=115140&postdays=0&postorder=asc

http://lxr.linux.no/linux+v3.1.5/+search

http://nrqm.ca/nrf24l01/driver/

Edit: Sorry for last time posting in wrong section
Pages: [1] 2 3 ... 13