Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Project Guidance / Re: ir receiver alternitive on: June 17, 2013, 03:11:41 am
i was going to actually use something a little less precise and use a small am radio chip with really good reception and make a am broadcaster sending simple commands to the radio but thats not really the problem its the translating going from ir receiver something like a attiny 85 sending commands tricking the on board processor to think its a ir receiver all of it together would weigh 1-2 grams not a big problem they would replace the weight in the front of the helicopter
2  Using Arduino / Project Guidance / Re: ir receiver alternitive on: June 16, 2013, 09:51:46 am
i was hopping i could make a translator to get it off ir and onto radio frequency
i thought about making a custom ir controller but i would like to be able to go at least 100 feet
3  Using Arduino / Project Guidance / ir receiver alternitive on: June 16, 2013, 04:07:51 am
hello first off let me explain my situation. i have a ir helicopter but i would like more range on it so i am wondering if it is possible to desolder the tsop ir receiver and replace it with some sort of pwm? or something like that basically emulate a Ir receiver.

4  Using Arduino / Programming Questions / ir proto hex code almost done need a little help though on: May 30, 2013, 05:24:01 pm
here is the code im using
Code:
/**
 ******************************************************************************
 * @file     IR_Player_ProntoCode.c
 * @author   Stephen Ong
 * @version  V1.0.0
 * @date     08/01/2011
 * @brief    Infrared Remote Control Player.
 *         
 ******************************************************************************
 *
 * Infrared Remote Control Player by Stephen Ong (http://robotics.ong.id.au).
 *
 * This infrared remote control player runs on the Arduino hardware platform.
 * It plays back IR code stored in Pronto Hex format. Useful for programming
 * learning universal remote control.
 *
 * @copy
 *
 * This work is licenced under the Creative Commons Attribution-NonCommercial
 * 3.0 Unported License. To view a copy of this licence, visit
 * http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative
 * Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
 *
 * <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/"><img alt="Creative Commons Licence" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Infrared Remote Control Player</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://robotics.ong.id.au" property="cc:attributionName" rel="cc:attributionURL">Stephen Ong</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/">Creative Commons Attribution-NonCommercial 3.0 Unported License</a>.
 */


/*
 * Changelog:
 * v1.0 - 2011/01/08 - First Release
 */


/* Includes ------------------------------------------------------------------*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>

/* Private define ------------------------------------------------------------*/
#define F_CPU           16000000        // System clock frequency
#define LED_PIN         _BV(1)          // OC1A -> PB1 = Arduino Digital Pin 9
#define DEBUG_D13       _BV(5)          // GPIO -> PB5 = Arduino Digital Pin 13

#define PRONTO_IR_SOURCE            0   // Pronto code byte 0
#define PRONTO_FREQ_CODE            1   // Pronto code byte 1
#define PRONTO_SEQUENCE1_LENGTH     2   // Pronto code byte 2
#define PRONTO_SEQUENCE2_LENGTH     3   // Pronto code byte 3
#define PRONTO_CODE_START           4   // Pronto code byte 4
//400000
#define TOTAL_CYCLES 50000             // Turns off after this number of
// cycles. About 10 seconds
/* Hardware ------------------------------------------------------------------*/

//  Platform - Arduino Deumilanove - ATMEGA328p - 16MHz

//  Connect IR LED anode to Arduino Digital Pin 9 (PB1) and connect its
//  cathode to GND.

/* Pronto Code Format---------------------------------------------------------*/

//  Reference:
//    http://www.remotecentral.com/features/irdisp1.htm
//
//  Decoding:
//  1. First number is always 0 which means leared IR pattern.
//  2. Second number: Carrier freq in Hz. Freq = 1000000/(N * .241246)
//  3. Third number: number of burst pair in non repeating burst pair #1
//  4. Fourth number: number of burst pair in repeating bust pair #2
//  5. Start of burst pairs. Burst pair #1 followed by burst pair #2
//
//  Eg Power off:
//  0000 0067 0000 000d
//  0060 0018
//  0030 0018
//  0030 0018
//  ...
//  ...
//  0018 03de
//
//  Word 1: 0x0000
//  Word 2: 0x0067 -> Carrier 40.244kHz
//  Word 3: 0x0000 -> 0 non repeating burst pair
//  word 4: 0x000d -> 13 repeating burst pair
//  Word 5, 6: Burst pair 2 -> 0x0060 0x0018 -> 96 cycles on, 24 cycles off
//  etc


/* Pronto Codes --------------------------------------------------------------*/


uint16_t ProntoCodeBroksonicPower[] = {
  0x00, 0x6c,0x00, 0x22, 0x152, 0xaa, 0x15, 0x15, 0x15, 0x40, 0x15, 0x40, 0x15, 0x15, 0x15, 0x15, 0x15,
  0x15, 0x15, 0x15, 0x15, 0x40, 0x15, 0x40, 0x15, 0x15, 0x15, 0x40, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
  0x15, 0x15, 0x15, 0x15, 0x15, 0x40, 0x15, 0x40, 0x15, 0x40, 0x15, 0x40, 0x15, 0x15, 0x15, 0x15, 0x15,
  0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x40, 0x15, 0x40, 0x15, 0x40,
  0x15, 0x40, 0x15, 0x670
};

uint16_t *ProntoCode = ProntoCodeBroksonicPower;


/* Private functions ---------------------------------------------------------*/

/**************************************************************************//**
 * Turns IR LED on and off. This is done by connecting or disconnecting OCR1A
 * to physical pin. When connected, pin is pulsed at carrier frequency. When
 * disconnected pin works as GPIO, ie off.
 * @param on: LED is on
 * @retval None
 *****************************************************************************/

uint8_t gIRLED_Power;       //True when IR led is on

void IRLED_Power(uint8_t on) {
  if (on) {
    TCCR1A |= (1<<COM1A1) + (1<<COM1A0);
    gIRLED_Power = true;
    PORTB |= DEBUG_D13; 
  }
  else {
    TCCR1A &=  ( (~(1<<COM1A1)) & (~(1<<COM1A0)) );
    gIRLED_Power = false;
    PORTB &= ~DEBUG_D13;
  }
}

/**************************************************************************//**
 * Toggles IR LED state.
 * @retval None
 *****************************************************************************/
void IRLED_Toggle() {
  if(gIRLED_Power) {
    IRLED_Power(false);
  }
  else {
    IRLED_Power(true);
  }
}

/**************************************************************************//**
 * ISR of timver1 overflow. This sequences the pronto code
 * @retval None
 *****************************************************************************/
uint16_t gCycleCount;
uint32_t gTotalCycleCount;
uint8_t gCurrentSequenceIndex;

ISR(TIMER1_OVF_vect) {
  uint16_t sequenceIndexEnd;          // Index to the last element in the
  // ProntoCode array
  uint16_t repeatSequenceIndexStart;  // Index to ProntoCode array to repeat

    gTotalCycleCount++;
  gCycleCount++;

  // End of this state, toggle led and move to the next state
  if (gCycleCount==ProntoCode[gCurrentSequenceIndex]) {
    IRLED_Toggle();
    gCycleCount = 0;
    gCurrentSequenceIndex++;
    sequenceIndexEnd = PRONTO_CODE_START +
      (ProntoCode[PRONTO_SEQUENCE1_LENGTH]<<1) +
      (ProntoCode[PRONTO_SEQUENCE2_LENGTH]<<1);

    repeatSequenceIndexStart = PRONTO_CODE_START +
      (ProntoCode[PRONTO_SEQUENCE1_LENGTH]<<1);

    // If index past last element in array, set index to repeat
    if (gCurrentSequenceIndex >= sequenceIndexEnd ) {       
      gCurrentSequenceIndex = repeatSequenceIndexStart;     

      if(gTotalCycleCount>TOTAL_CYCLES) {            // Finished
        TCCR1B &= ~(1<<CS10);                    // Stop Timer
        IRLED_Power(false);                        // Turn off LED
      }
    }
  }
}

/**************************************************************************//**
 * Main function. Setup gpio ports, timer1, then wait in infinite loop. The IR
 * code is played back for TOTAL_CYCLES cycles.
 * @retval none
 *****************************************************************************/


void loopme(){
 
   PORTB = 0x00;                       // When LED_PIN disconnected from 
  //    counter, LED will be in off state
  DDRB = LED_PIN | DEBUG_D13;         // Set LED_PIN and DEBUG_D13 for output

  // SETUP TIMER 1   
  TCCR1A = 0x00;                      // WGM=0000 for instant update of OCR1A
  TCCR1B = 0x00;

  uint16_t top = ( (F_CPU/1000000.0) *
    ProntoCode[PRONTO_FREQ_CODE]  *
    0.241246 ) - 1;

  ICR1 = top;                         // Counter counts from 0 to top
  OCR1A = top>>1;                     // PWM set to 50%, set OCR1A to top/2


  TCCR1A = (1<<WGM11);                // WGM = 1110 => Fast PWM, TOP=ICR1,
  TCCR1B = (1<<WGM13) | (1<<WGM12);   // TOV1 flag set on TOP,
  // OCR1x updated at BOTTOM

  TCNT1 = 0x0000;                     // Clear counter
  TIFR1 = 0x00;                       // Clear any pending interrupt
  TIMSK1 = 1<<TOIE1;                   // Enable Overflow Interrupt

  IRLED_Power(true);                  // IR Led starts with the ON state,
  //   this connects OCR1A out to port pin

  gCurrentSequenceIndex = PRONTO_CODE_START;   
  gCycleCount = 0;


  TCCR1B |= (1<<CS10);                // Start timer running, Clock = CLKio/1

  sei();                              // Enable global interrupt
}


int main (void){
  loopme();
  delay(5000); 
}

//---------------------------END OF IR_Player_ProntoCode.c -------------------

i want it to send the delay 5 seconds then send again but there seems to be something blocking it im not fluent in the direct port writes or timmers yet but when power is applied it only sends the code once
5  Using Arduino / Programming Questions / Re: Ir Carrier Frequency help doesnt make since on: May 30, 2013, 05:12:07 pm
thank you it was a little confusing for a little bit
6  Using Arduino / Programming Questions / Re: Ir Carrier Frequency help doesnt make since on: May 30, 2013, 05:09:38 pm
im bad at explaining things lol ok here we go again i forgot the e of the word code in the last post

i trying to build a device that you can enter the proto hex code in and it will be able to send the codes to a tv using a ir led i was trying to figure out how to calculate the frequency because not all tvs are on the same one it would have to adjust based on the code i actually have a working code now and i am using a arduino uno as the platform eventually i will be able to add sd card support for easy changeing of tvs
7  Using Arduino / Programming Questions / Re: Ir Carrier Frequency help doesnt make since on: May 30, 2013, 04:37:19 pm
sorry let me explain a little better i was on some forms but i dont have the link the people on the forums used that formula to calculate the carrier frequency for a ir  Pronto Hex Code i think the forum was http://l5remote.com/forum/viewtopic.php?f=12&t=14
8  Using Arduino / Programming Questions / Ir Carrier Frequency help doesnt make since on: May 30, 2013, 04:24:08 pm
Freq=1000000/(N*. 241246)

i ether must suck at math which may be possible or im missing something here


i have the value of N = 0x0067
in decmal thats 103
which they say the freq = Carrier 40.244kHz
when i do the math i do

1000000/(103*. 241246)
breaking this down i get
1000000/(24.848338)
1000000/(24.848338)
40244.14027207775

i cut off the trailing after the decmal and move the decmal over 3 places right
40.244

if so that means if N=108 so the freq = 38.380?
did i do that correct?



9  Using Arduino / Programming Questions / ir libary help on: May 30, 2013, 03:38:47 pm
hello i am looking for some code or a libary that can send hex over ir to a tv using these codes
http://www.remotecentral.com/cgi-bin/codes/broksonic/ctgv-4563tct/
each signal seems to look like this
Code:
0000 006c 0000 0022 0152 00aa 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0670
i have no clue were to start thank you for your help
10  Using Arduino / Programming Questions / Re: Tvout and Serial read substrings not working right and weird output on tv on: May 11, 2013, 01:04:18 pm
that part works fine it was just a quick type to see the output  its the this part thats not working

 player = readString.substring(0, 1); //get the first 1 characters
    score = readString.substring(1, 6); //get the next 6characters

with the string 1-5000
it would do stuff like this
player =1-5
score = 0
11  Using Arduino / Programming Questions / Re: Tvout and Serial read substrings not working right and weird output on tv on: May 11, 2013, 02:35:01 am
i forgot to chainge the comment when fine tunning it its suppost to capture the first number and the then the 2ed to the last number which would be like +2000 or -2000 so the entire sting would consist of something like "1-2000" or "1+2000" each of which turns into a interger for the math processing such as the starting score for player1 is  8000 + 2000 = 10000

it doesnt want to partout the string into those values with the tvout in the code
12  Using Arduino / Programming Questions / help implementing tv out with my code on: May 10, 2013, 08:08:41 pm
my previous attempts have failed now i am asking for some help heres my code i would like to figure out how to get the serial.print() to print TV.print()

in all my attempts at this the substrings wouldn't return the correct value

can someone help me get this code on my tv? with the math and substirngs working without conflict

here is my code
Code:
int startinglifepoints = 8000;
String readString, player, score;
int player_1_Lifepoints = startinglifepoints;
int player_2_Lifepoints = startinglifepoints;
int player_3_Lifepoints = startinglifepoints;
int player_4_Lifepoints = startinglifepoints;

void setup() {
  Serial.begin(9600);
  Serial.flush();
  Serial.println("Yugioh_calculator_1.3");
  Serial.println();
  Serial.print("player 1: ");
  Serial.println(player_1_Lifepoints);
  Serial.print("player 2: ");
  Serial.println(player_2_Lifepoints);
  Serial.print("player 3: ");
  Serial.println(player_3_Lifepoints);
  Serial.print("player 4: ");
  Serial.println(player_4_Lifepoints);
  Serial.println("------------------------");

}

void loop() {

  while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
  }

  if (readString.length() >0) {
    //Serial.println(readString); //see what was received

  
    player = readString.substring(0, 1); //get the first 1 characters
    score = readString.substring(1, 6); //get the next 6 characters

    int n1 = player.toInt();
    int n2 = score.toInt();
    if (n1 == 1){
      Serial.print("player 1: ");
      player_1_Lifepoints = player_1_Lifepoints + n2;
      Serial.println(player_1_Lifepoints);  

    }

    if (n1 == 2){
      Serial.print("player 2: ");  
      player_2_Lifepoints = player_2_Lifepoints + n2;
      Serial.println(player_2_Lifepoints);  

    }

    if (n1 == 3){
      Serial.print("player 3: ");  
      player_3_Lifepoints = player_3_Lifepoints + n2;
      Serial.println(player_3_Lifepoints);  

    }

    if (n1 == 4){
      Serial.print("player 4: ");  
      player_4_Lifepoints = player_4_Lifepoints + n2;
      Serial.println(player_4_Lifepoints);  

    }

    if (n1 == 9){
      Serial.println("------------------------");

      Serial.print("player 1: ");  
      Serial.println(player_1_Lifepoints);
      Serial.print("player 2: ");  
      Serial.println(player_2_Lifepoints);
      Serial.print("player 3: ");  
      Serial.println(player_3_Lifepoints);
      Serial.print("player 4: ");  
      Serial.println(player_4_Lifepoints);
      Serial.println("------------------------");  

    }

    readString="";
  }
}




13  Using Arduino / Programming Questions / Re: Tvout and Serial read substrings not working right and weird output on tv on: May 10, 2013, 07:38:38 pm
this part without the tvout works fine but when i add the tvout it wont work right
Code:
String readString, player, score;
int player_1_Lifepoints = 8000;
int player_2_Lifepoints = 8000;


void setup() {
  Serial.begin(9600);
  Serial.println("Yugioh_calculator_1.3");
  Serial.print("player 1: ");
 Serial.println(player_1_Lifepoints);
   Serial.print("player 2: ");
 Serial.println(player_2_Lifepoints);
 
 
 }

void loop() {

  while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
  }

  if (readString.length() >0) {
      //Serial.println(readString); //see what was received
      
    
      player = readString.substring(0, 1); //get the first 1 characters
      score = readString.substring(1, 6); //get the next 6 characters
      
      int n1 = player.toInt();
        int n2 = score.toInt();
      if (n1 == 1){
        Serial.print("player 1: ");
        player_1_Lifepoints = player_1_Lifepoints + n2;
        Serial.println(player_1_Lifepoints);  
        
      }
      
        if (n1 == 2){
        Serial.print("player 2: ");  
        player_2_Lifepoints = player_2_Lifepoints + n2;
        Serial.println(player_2_Lifepoints);  
        
      }
        
    readString="";
  }
}
14  Using Arduino / Programming Questions / Tvout and Serial read substrings not working right and weird output on tv on: May 10, 2013, 06:25:23 pm
hello ive been working on this program its basically a calculator for a game the problems im having are that on the tv the output is ok except it seems to be small white pixels that look like they were squashed together on the bottom of the screen the other problem is that its not grabbing the right substring values from a string captured by the serial read

i have tried to serial output the substring values but they dont show what they acturally are  
such as the serial input 1-500 the first number stats the first substring for saying player1 and the -500 is the numeral value to add to the players life points but the out put comes out like substring value 01 is always 1 and substring value 2 is always 1
heres my code if you need me to explain more i will try

Code:
#include <TVout.h>
#include <fontALL.h>

TVout TV;
int p1Score = 8000;
int p2Score = 8000;
int endgame=0;

String readString, player, score= ("","","");
int player_1_Lifepoints = 8000;
int player_2_Lifepoints = 8000;


void setup() {
  Serial.begin(9600);
  Serial.println("Yugioh_calculator_1.0");
  TV.begin(NTSC,120,96);
  TV.select_font(font6x8);
  TV.println("      Welcome\n\n   to the Yugioh \n  dual calculator");
  TV.delay(2000);
  TV.clear_screen();
  chaingeLP(player_1_Lifepoints,player_2_Lifepoints);

}

void loop() {

  while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
  }


  if (readString.length() >0) {
    Serial.println(readString); //see what was received

      
    player = readString.substring(0, 1); //get the first 1 characters
    score = readString.substring(1, 6); //get the next 6 characters
    Serial.println("=========start=========");
    Serial.println("player: " && player);//debug
    Serial.println("score: " && score);
    Serial.println("==========end==========");

    int n1 = player.toInt();
    int n2 = score.toInt();
    //  int n1 = stringToNumber(player);
    //  int n2 = stringToNumber(score);
    if (n1 == 1){
      Serial.print("player1 1 ");  
      Serial.print("Score:");  
      player_1_Lifepoints = player_1_Lifepoints + n2;
      Serial.println(player_1_Lifepoints);
      chaingeLP(player_1_Lifepoints,player_2_Lifepoints);  

    }

    if (n1 == 2){
      Serial.print("player1 2 ");  
      Serial.print("Score:");  
      player_2_Lifepoints = player_2_Lifepoints + n2;
      Serial.println(player_2_Lifepoints);  
      chaingeLP(player_1_Lifepoints,player_2_Lifepoints);        
    }

    readString="";
  }
}
void chaingeLP(int P1, int P2){

  TV.select_font(font4x6);

  TV.clear_screen();
  TV.println();
  TV.print("  ");
  TV.println("Player 1");
  TV.print("          ");
  TV.select_font(font6x8);
  TV.print(P1);
  TV.select_font(font4x6);

  TV.println("\n\n\n\n");
  TV.print("  ");
  TV.println("Player 2");


  TV.print("          ");
  TV.select_font(font6x8);
  TV.print(P2);
  TV.select_font(font4x6);


  TV.draw_rect(0,2,80,20,WHITE);
  TV.draw_rect(0,38,80,20,WHITE);

}

int stringToNumber(String thisString) {
  int i, value = 0, length;
  length = thisString.length();
  for(i=0; i<length; i++) {
    value = (10*value) + thisString.charAt(i)-(int) '0';
    ;
  }
  return value;
}

15  Using Arduino / Microcontrollers / RASPBERRY-PI Battery? on: April 29, 2013, 11:54:24 pm
I found this 5v battery pack on ebay for about 20 bucks http://www.ebay.com/itm/12000mAh-External-Portable-Emergency-Battery-Charger-Power-Bank-for-mobile-phone-/121090018244?pt=Battery_Chargers&hash=item1c31870bc4 it hs 12000mah which is good do you think this is  good buy for a RASPBERRY-Pi

is this a pretty good deal or should i keep looking around im trying to get a portable computer going with the PI and i would like the max battery time the pi will run wireless keyboard mouse and wifi as well as some peripherals like ir
Pages: [1] 2 3 ... 5