Show Posts
Pages: 1 [2]
16  Using Arduino / Sensors / Re: How to use RAW data from IR detector on: May 25, 2011, 08:50:32 am
Here is the sketch. I have very little knowledge of what is actually happening behind the scenes, this code is straight from Ken Shirrif. All I know is the last couple of lines is what toggles the relay.
What does this mean "result->value?" I'm not familiar with the symbol between the words.

Quote
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;
int RELAY_PIN = 4;

IRrecv irrecv(RECV_PIN);
decode_results results;

// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
//  decode_results *results = (decode_results *)v
void dump(decode_results *results) {
  int count = results->rawlen;
  if (results->decode_type == UNKNOWN) {
    Serial.println("Could not decode message");
  } 
  else {
    if (results->decode_type == NEC) {
      Serial.print("Decoded NEC: ");
    } 
    else if (results->decode_type == SONY) {
      Serial.print("Decoded SONY: ");
    } 
    else if (results->decode_type == RC5) {
      Serial.print("Decoded RC5: ");
    } 
    else if (results->decode_type == RC6) {
      Serial.print("Decoded RC6: ");
    }
    Serial.print(results->value, HEX);
    Serial.print(" (");
    Serial.print(results->bits, DEC);
    Serial.println(" bits)");
  }
  Serial.print("Raw (");
  Serial.print(count, DEC);
  Serial.print("): ");

  for (int i = 0; i < count; i++) {
    if ((i % 2) == 1) {
      Serial.print(results->rawbuf*USECPERTICK, DEC);
    } 
    else {
      Serial.print(-(int)results->rawbuf*USECPERTICK, DEC);
    }
    Serial.print(" ");
  }
  Serial.println("");
}

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(13, OUTPUT);
    Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

int on = 0;
unsigned long last = millis();

void loop() {
  if (irrecv.decode(&results)) {
    // If it's been at least 1/4 second since the last
    // IR received, toggle the relay
    if (millis() - last > 250) {
      on = !on;
      digitalWrite(RELAY_PIN, on ? HIGH : LOW);
      digitalWrite(13, on ? HIGH : LOW);
      dump(&results);
    }
    last = millis();     
    irrecv.resume(); // Receive the next value
  }
}

17  Using Arduino / Sensors / How to use RAW data from IR detector on: May 25, 2011, 07:00:09 am
I have used code from Ken Shirriff to read the raw dump from an IR remote.

He also have a simple sketch to toggle a relay, but the relay toggles no matter what button I press on the remote. How can I use the raw dump received from a specific button only to toggle the relay, or make other things happen? Basically I want to read data from a remote, and that data must be able to control a gadget. I do get HEX dumps from the different remote buttons. I could'nt really care if it decodes the correct remote, all I want is if say I receive FFE21D, then toggle the relay.
Below is a typical output from the relay toggling code.

Code:
Decoded NEC: FF42BD (32 bits)
Raw (68): 25830 9050 -4450 600 -550 550 -600 550 -550 600 -500 600 -550 600 -550 550 -550 550 -550 600 -1700 500 -1700 600 -1700 550 -1650 550 -1750 550 -1700 550 -1600 600 -1750 550 -550 550 -1700 550 -600 500 -550 600 -550 600 -550 500 -1750 550 -550 550 -1650 600 -550 550 -1750 550 -1700 550 -1650 550 -1700 600 -550 500 -1700 600


18  Using Arduino / Sensors / Re: Tilt only sensor for telescope. on: May 25, 2011, 06:14:01 am
Been offline a bit.

Thanks for info to try and fix the scope, Lefty. As I said before, no cure in hot glue. The mirror on Maks is adjusted up and down to focus. The play comes from that adjusting bit. It seems even high end Maks suffer from it. A common cure is to fix the mirror in place and use a Crayford external focuser.

Accellerometers is too expensive for me (even the cheap ones I can find locally) and overkill.

The "bearing in a can" tilt sensor is is not quite what I want, although a couple of them could do the trick. At a guess I would need to adjust the focus for every 15 deg or so of tilt. I have no hope to get it perfectly accurate in any case. What I thought of is the kind of tilt sensor thingy you get in digital level meters. I used them over the years to check downtilt on GSM antennas. But I discovered it uses the expensive X-Y accellerometers...

Willnue's idea is great, and I did not explore that one, simply because I can't find any ball mouse anywhere, so I chucked out the idea of a mouse. I simply never considered the wheel have the same principle.

The output shaft of the telescope mount have notches I can use with a switch or sensor, but I have no idea how such a sensor will be able to tell which direction the shaft is turning.
19  Using Arduino / Sensors / Re: Tilt only sensor for telescope. on: May 23, 2011, 09:26:30 am
Ah, fresh ideas I never thought of myself.

There is unfortunately no "fix" for mirror flop. The mirror is mounted on a base plate that is in turn geared to the focusing knob, so the whole mirror moves up and down. I think a faster focusing-mechanism should help!  smiley  It takes about 30 second for one revolution...

I am also toying with adding a wheel to a pot that can run on the shaft, but a mechanical connection like this may make it too much of a hassle, especially when the dew builds up...

Speaking of which. I have build a PWM dew controller, which I plan to hook up so the Arduino reads temp sensors and control the amount of power automatically. Then do some focusing control etc. and when I grew up, I will try and build a wireless (infrared) controller to focus my scope with. When I glue the Arduino to my scope, I don't want it just to blink and LED!  smiley It should work for a living. There is a GPS module in the scope mount... wonder if I can access that...

Keep the ideas coming!
20  Using Arduino / Sensors / Tilt only sensor for telescope. on: May 23, 2011, 07:17:10 am
My first post, so please don't be to harsh! smiley

I want to build a tilt sensor for a telescope. I have Maksutov Cassegrain and it suffers from "mirror flop." I.e. when you look at something low in the sky, the focus changes when you swing it to something higher in the sky. Thus a constant need to refocus arise when you change the angle of the scope.

I have fa-dangled a home made focuser from and old servo motor, and some flatbed scanner gears. To focus, I have a simple toggle switch to go in whatever direction I choose to focus, it focus sharp, but is slooooow. So I want to save time while the telescope is swinging around by having the focuser change focus a bit. No need to focus sharp, but at least give the focus a nudge in the right direction for a couple of seconds. (Yes, its that slow.  smiley-wink ) Now the plan is to add a tilt sensor and roughly calibrate it to the tilt.

Summing up: If the scope goes up by "x degrees", the focuser run clockwise for "x time."

I know that x - y tilt sensors is available, (not in South Africa though, and very expensive.) But maybe there is something simpler and cheaper and at least a bit more accurate than a "ball bearing in a can." I thought a slotted wheel with a weight will do, but it messes up the scope since its too big and awkward, and not much more accurate than two canned ball bearings. I want something small and simple... Or am I asking too much? Any ideas? It only has to go through 90deg.
Pages: 1 [2]