Show Posts
Pages: 1 2 3 [4] 5 6
46  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 01:27:08 pm
And I don't have any extra port here as I'm using UNO R3. would it work if I use two different ports for servo & RAdar.Would it help me if I go for a mega?
47  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 01:25:03 pm
So how this shall be solved? Is there any way? Sorry but, I'm needing a solution here as I'm not much of into hardcore micro-controller stuffs.
And the parseInt link that's been forwarded to me, doesn't have any example code.
48  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 01:22:39 pm
comments are comments right? those are meant to check the speed results in the serial monitor.  
Now I'm just porting the frequency data to the port from the arduino & TRYING TO ACCEPept slider value from the port to the arduino.
I'm not that much High end with timers though. I explained my aim also that why i need those timer interrupts as then the radar won't work.
49  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 01:15:45 pm
It may be due to the timers or the bi directional communication. I tried to drive the servo from an simple UI of just slider & it worked.

--------------arduino code------------

#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(9);
  Serial.begin(115200);
}


void loop()
{
  while(Serial.available() == 0);
  {
  int pos = Serial.read() - '0';
  myservo.write(pos);
  Serial.flush();
  }
  }

------------processing code-------------

import processing.serial.*;
import controlP5.*;

Serial port;
ControlP5 cp5;

int tilt = 0;

void setup()
{
size(500, 500);

port = new Serial(this, "COM14", 115200);
//port.bufferUntil('\n');

cp5 = new ControlP5(this);
cp5.addSlider("tilt")
     .setPosition(320, 0)
     .setSize(20,240)
     .setRange(0,180)
     .setValue(90)
     ;
}

void draw()
  {
    background(0);
    port.write(tilt);
  }

.
50  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 01:01:38 pm
So is there any solution here? smiley-sad
51  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 12:59:26 pm
this is the code:
----------------new sketch-----------------

#include <Servo.h>

Servo myservo;

const uint16_t TICK_CNT = 3; // 255-(16MHz/1024/62Hz) 
static uint16_t freq = 0;
double sped = 0; //"speed" seems to be a reserved term


void setup()
{
  myservo.attach(9);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
 
  Serial.begin(115200);

  noInterrupts();                     // disable all interrupts while we configure 
  // init Timer1 - 16-bit timer/counter
  TCNT1   = 0;                                  // start count at zero.       
  TCCR1B  |= _BV(CS12) | _BV(CS11) | _BV(CS10); // Increment T1 input on each positive edge
                                                // using an external source. Table 16-5, pg 139.
 
  // init Timer2 - 8-bit timer/counter
  TCNT2   = TICK_CNT;                 // preload Timer2 to interrupt every 250 msec
  TIMSK2  = _BV(TOIE2);               // enable the Timer2 overflow interrupt
  TCCR2B  |= _BV(CS22) |_BV(CS21) | _BV(CS20);   // init clock prescaler to 1024. Table 18-9, page 164.
  interrupts();                       // enable all interrupts
 
  //Serial.println("Ready...");
}

ISR(TIMER1_OVF_vect) {
  // do nothing. this is just a dummy ISR in case it actually overflows.
  //Serial.println("Inside Timer1 Overflow Interrupt.");
}

ISR(TIMER2_OVF_vect) {
  //Serial.print("TCNT1: ");
  //Serial.println(TCNT1);
  freq = TCNT1;
  //Serial.println(freq);
  TCNT1 = 0;
  TCNT2 = TICK_CNT;
}

void loop()
{
  while(Serial.available() == 0);
  {
  int pos = Serial.read() - '0';
  myservo.write(pos);
  Serial.flush();
  }

  if (freq != 0)
  {
      freq = freq * 62;      // multiple the frequency * 4 (using leftshift 2 places). 250ms*4 = 1 sec.
      //sped = freq * .03225;  // multiplying freq * 0.03225 will give speed in mph. 31Hz == 1 mph.
                             // see: http://www.microwave-solutions.com/contents/en-uk/d13_System_Design.html
     // Serial.print("Freq: ");
      Serial.println(freq, DEC);
      //Serial.print(" Hz, Speed: ");
      //Serial.print(sped, 0);
      //Serial.println(" mph");
      freq = 0;
  }
}
52  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 12:54:31 pm
surely I even tried to do it by simply servo.write(the serial value).
it didn't work.
53  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 12:52:34 pm
i'm sorry for that.
Servo's not responding. even though when I ran an exemplary  "sweep" code just to check whether the servo's ok or not, it worked just fine.
54  Using Arduino / Programming Questions / Re: Serial communication querry on: February 11, 2013, 12:39:12 pm
umm smiley-confuse facing problem here!!

I've been playing with an X-Band radar & I've copy pasted a code from the forum only .

http://arduino.cc/forum/index.php?topic=91793.new;topicseen#new

My aim is to get the serial data (the change in frequency data) to the processing app through serial communication where I'll visualize it in cool graphics. Along with it I would implant a webcam(To snap the pics of those passing by). Now I want to control the tilting of the webcam through a slider from the app. The whole communication goes at 115200 bps(Can't change it for timer concerns).

-----------------Arduino code------------------------
Code:
#include <Servo.h>

Servo myservo;

const uint16_t TICK_CNT = 3; // 255-(16MHz/1024/62Hz)  
static uint16_t freq = 0;
double sped = 0; //"speed" seems to be a reserved term


void setup()
{
  myservo.attach(9);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  
  Serial.begin(115200);

  noInterrupts();                     // disable all interrupts while we configure  
  // init Timer1 - 16-bit timer/counter
  TCNT1   = 0;                                  // start count at zero.        
  TCCR1B  |= _BV(CS12) | _BV(CS11) | _BV(CS10); // Increment T1 input on each positive edge
                                                // using an external source. Table 16-5, pg 139.
  
  // init Timer2 - 8-bit timer/counter
  TCNT2   = TICK_CNT;                 // preload Timer2 to interrupt every 250 msec
  TIMSK2  = _BV(TOIE2);               // enable the Timer2 overflow interrupt
  TCCR2B  |= _BV(CS22) |_BV(CS21) | _BV(CS20);   // init clock prescaler to 1024. Table 18-9, page 164.
  interrupts();                       // enable all interrupts
  
  //Serial.println("Ready...");
}

ISR(TIMER1_OVF_vect) {
  // do nothing. this is just a dummy ISR in case it actually overflows.
  //Serial.println("Inside Timer1 Overflow Interrupt.");
}

ISR(TIMER2_OVF_vect) {
  //Serial.print("TCNT1: ");
  //Serial.println(TCNT1);
  freq = TCNT1;
  //Serial.println(freq);
  TCNT1 = 0;
  TCNT2 = TICK_CNT;
}

void loop()
{
  while(Serial.available() == 0);
  {
  int data = Serial.read() - '0';
  int pos = map(data, 0, 180, 0, 180);
  pos = constrain(pos, 0, 180);
  myservo.write(pos);
  Serial.flush();
  }
  if (freq != 0)
  {
      freq = freq * 62;      // multiple the frequency * 4 (using leftshift 2 places). 250ms*4 = 1 sec.
      //sped = freq * .03225;  // multiplying freq * 0.03225 will give speed in mph. 31Hz == 1 mph.
                             // see: http://www.microwave-solutions.com/contents/en-uk/d13_System_Design.html
     // Serial.print("Freq: ");
      Serial.println(freq, DEC);
      //Serial.print(" Hz, Speed: ");
      //Serial.print(sped, 0);
      //Serial.println(" mph");
      freq = 0;
  }
}

------------------processing code----------------------------
Code:
import processing.serial.*;
import codeanticode.gsvideo.*;
import controlP5.*;

PFont fontB;

GSCapture cam;
Serial port;
ControlP5 cp5;

int id = 1;
int freq = 0;
float velocity = 0.00;
int tilt = 0;

void setup()
{
size(680, 420);

port = new Serial(this, "COM14", 115200);
port.bufferUntil('\n');

String[] cameras = GSCapture.list();

fontB = loadFont("ArialMT-48.vlw");
textFont(fontB, 48);

if (cameras.length == 0)
  {
    println("There are no cameras available for capture.");
    exit();
  }
  else
  {
    println("Available cameras:");
    
    for (int i = 0; i < cameras.length; i++)
    {
      println(cameras[i]);
    }
    
    cam = new GSCapture(this, 320, 240, cameras[0]);
    cam.start();  
    }
  
cp5 = new ControlP5(this);

cp5.addSlider("tilt")
     .setPosition(320, 0)
     .setSize(20,240)
     .setRange(0,180)
     .setValue(90)
     ;
}

void draw()
  {
    if (cam.available() == true)
    {
    background(0);
    
    cam.read();
    image(cam, 0, 0);
    
    fill(255);
    text(velocity, 350, 350);
    text("mph", 500, 350);
    println(tilt);
    port.write(tilt);
    
    }
  }

void serialEvent (Serial port)
{
  String inString = port.readStringUntil('\n');//reading from serial data until new line
  
   if (inString != null)
 {
  //conversion of the string into integer
  inString = trim(inString);
  freq = int(inString);
  velocity = (freq * .03225)-1.9994999;
  
  if(velocity == 1.9994999)
    {
      velocity = 0.00;
    }
  }
}

help!!! smiley-cry


Moderator edit: [code] [/code] tags added.
55  Using Arduino / Project Guidance / Re: TV + Arduino on: February 11, 2013, 06:45:44 am
So is this a way of saying that If I follow the earlier schematic that I've uploaded & put the RCA cable at it's jack at my TV's back & then sent the TV to feed from the composit (Which is a way of setting when we plug in DVD players with TV), It won't work?.

I'd really admire this if you just step wise tell me what to follow.

Also I found some PIN change setting over another picture I got over google.

Confused which one to follow. smiley-confuse
56  Using Arduino / Project Guidance / Re: TV + Arduino on: February 11, 2013, 06:40:27 am
I found this article (http://en.wikipedia.org/wiki/SCART) on wikipedia & that seems not present in TVs I've seen so far.
57  Using Arduino / Project Guidance / Re: TV + Arduino on: February 11, 2013, 05:19:24 am
I checked it earlier only & it's not available in India. & where would I get an Sony LCD now. Any ways let me change the settings to feed the video through the composit in & let you know about the results.
58  Using Arduino / Project Guidance / Re: TV + Arduino on: February 10, 2013, 02:56:35 pm
I'll try it tomorrow & let you know. I don't have a TV around at my place.
59  Using Arduino / Project Guidance / Re: TV + Arduino on: February 10, 2013, 12:26:58 pm
Sorry but what do you mean by "changing the inputs here" ?
60  Using Arduino / Project Guidance / TV + Arduino on: February 10, 2013, 11:31:07 am
I recently tried to use my Arduino Uno R3 to publish data on a TV.
I connected the GND cable of my RCA jack to the ground of Arduino & followed these schematic
,

Used this "TVout" LIB(R5.91 ver):-
http://code.google.com/p/arduino-tvout/

& this piece of code :

--------------------//code//----------------------
#include <TVout.h>

TVout TV;
unsigned char x, y;

void setup ( )
{
  TV.start_render( _NTSC );
}

void loop ( )
{
  TV.clear_screen ( );
  TV.print_str ( 10, 10, "TVout FTW!!!" );
  TV.delay ( 60 );
}

Nothing happened when I attached the RCA cable to video in composit.
I'm not sure whether every thing here I/m doing is on the right way.
Is there any setting change that I need to do over the TV. I tried with the TV's cable service once plugged in & another time plugged out.
Also changed it in the code from NTSC to PAL as I recede in India.
Pages: 1 2 3 [4] 5 6