Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Interfacing / Re: Split-up Serial Command on: February 26, 2008, 07:04:32 am
For the sake of anyone dealing with the same issue, this is the code I've come up with, and it works fine for me.
Code:

//
//    Arduino Serial Communication with Scriptographer!
//    #12345;65784;180;    
//


#define tagLength 6      // each tag ID contains 6 bytes
#define hash 0x23        // "#" hash
#define semicolon 0x3b   // ";" semicolon
#define dataRate 9600    // 9600kbps

int tagIndex = 0;                 // counter for number of bytes read
int allComplete = false;          // whether all tags have been read

char xVal[tagLength], yVal[tagLength], rVal[tagLength];

int xComplete = false;
int yComplete = false;
int rComplete = false;

void setup() {
  // begin serial:
  Serial.begin(dataRate);
}

void loop() {
  // read in and parse serial data:
  if (Serial.available() > 0) {
    delay(500); // wait for all data to be in
    
    readData();
        
  }

}



void readData() {
 char thisChar = Serial.read();
 
 if (thisChar == hash){
  // read all x
  while (xComplete == false && Serial.available() > 0){
      char thisChar = Serial.read();
   //   Serial.println("x-loop");
      if (thisChar == semicolon){
        xComplete = true;
        break;
      }
      else {
        xVal[tagIndex] = thisChar;
        tagIndex++;
      }  
  }
  
  tagIndex = 0;
  
 // read all y
  while (yComplete == false && Serial.available() > 0){
      char thisChar = Serial.read();
   //   Serial.println("y-loop");
      
      if (thisChar == semicolon){
        yComplete = true;
        break;  
    }
      else {
        yVal[tagIndex] = thisChar;
        tagIndex++;
      }  
  }
  
  tagIndex = 0;
 
 
 // read all r
  while (rComplete == false && Serial.available() > 0){
      char thisChar = Serial.read();
   //   Serial.println("r-loop");
      
      if (thisChar == semicolon){
        rComplete = true;
        break;
      }
      else {
        rVal[tagIndex] = thisChar;
        tagIndex++;
      }  
  }

  tagIndex = 0;

  
  if (xComplete == true && yComplete == true && rComplete == true){
 //   Serial.println("all complete");
    Serial.print("X:");
    Serial.println(xVal);
    Serial.print("Y:");
    Serial.println(yVal);
    Serial.print("R:");
    Serial.println(rVal);
    
    for (int a=0; a<atoi(xVal);a++){
      Serial.println(a);
    }
    
    xComplete = false;
    yComplete = false;
    rComplete = false;
    
    // empty arrays
    for (int i=0;i<5;i++){
    digitalWrite(5, HIGH);
    xVal[i] = 0x00;
    yVal[i] = 0x00;
    rVal[i] = 0x00;
    }
    
  }
  
 }
  
  
}


2  Forum 2005-2010 (read only) / Interfacing / Re: Split-up Serial Command on: February 22, 2008, 10:39:45 am
Maybe another important thing to add: the arduino receives ASCII characters through the serial connection, and is supposed to handle these. Hope anyone of you is able to answer my question!
3  Forum 2005-2010 (read only) / Interfacing / Split-up Serial Command on: February 20, 2008, 03:14:24 pm
Hey All,

A basic question, but I could use some assistance! I'm sending a command string to my arduino (ng) board, containing a header, an x position, a y position and a rotation value, I want the arduino to read the serial message, and be able to read these separate values. Is it useful to send it as some kind of a comma separated list of values, for instance:

ST,15400,23600,180#
Where ST is the header, 15400 is the x-position, 23600 is the y-position, and the # makes up the end of the message.

Should I try to read the serial data, store it in an array, and find a way to split the array again using the commas? Any suggestions are most welcome!

Thanks in advance!
4  Forum 2005-2010 (read only) / Development / Re: Where is the Arduino headed? on: June 03, 2008, 03:02:36 am
And Massimo, will the second surprise involve a powerful, say ARM-based, microcontroller? smiley It would be fantastic to have the ease of the arduino programming environment and the power of a more capable uC!

Can't wait for news!
5  Forum 2005-2010 (read only) / Interfacing / Arduino / CNC on: May 26, 2008, 09:30:21 am
Hey all,

I've been working on a project where I use the Arduino to drive a three axis plotter (that uses various drawing / printing tools). The plotter uses three stepper motors and I'm using stepper drivers that require a step/direction signal. Everything has been going quite well, I've got a good implementation of the Bresenham algorithm for linear interpolation (based on the one used in the RepRap project).
I would really like to have your advice on the following: when I have the plotter draw curves (which are split up in small straight line segments), the serial communication (currently at 28800kbps) can't keep up and starts to interfere with having a smooth movement. I have a kind of flow control set up between Processing and the Arduino, when the Arduino buffer runs low, it sends an ascii character through the serial connection, and processing replies with a new set of commands. But each time the arduino receives this new set of commands, it seems to slow down about 4 milliseconds.

Since hardware flow control is not available (correct me if I'm wrong), I will need another solution, what could be an option is to buffer the full sequence of commands, but since this won't fit in the RAM, some kind of external memory should be used. But using external memory requires reading data serially once again. My question is, can the Arduino read at fair speeds from an external EEPROM or CF card, and would this be a solution?

Any advice / comments / suggestions are most welcome!
6  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 13, 2009, 02:19:57 pm
that's a real nice example (the wall). that illustration you mention would come in real handy for making your own, if you ever come across it, please post it. I have another flip-dot unit for evaluation, which has a 6cm diameter. before returning it to the company i'll make some photo's of it. the technique used in this one is actually quite similar to the ones you've made yourself.
7  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 13, 2009, 09:47:11 am
yes, each dot has two coils, and the coils seem to be connected as well. Note that one of the two coils is longer on the top, the dots (while in 'rest') are always in a little angle. The dots do seem to be magnetized, if I remove some of them they do stick together or repel one another. I wouldn't be able to explain though why that is, I have little electromagnetical knowledge. what do you think?
8  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 13, 2009, 05:06:15 am
here's some more detailed photo's:





9  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 12, 2009, 05:08:18 pm
yes, that's what they cost me (note that this was some old stock), but the new ones they offer shouldn't be that far off. did you self-wind all those coils? (some insulated with black tape?). hell of a job! I haven't taken one of my dot-strips apart so far, but the principle seems pretty straightforward, i can make some photo's sometime soon and post them if you'd like, there seem to be two small coils for each dot, and I think one of them attracts the dot (which has a tiny hole punched out on one side), anyway, photo's should be more clarifying.
10  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 12, 2009, 10:27:27 am
Hi Roy,

Nice to see your selfmade flipdot(s)! I actually planned on doing this as well. Do you have some more images of your final application? And did your power supply then needed to be 64amps? (!) The units I bought cost me € 2,50 a piece.
11  Forum 2005-2010 (read only) / Interfacing / Re: flip-dot display driver on: April 11, 2009, 02:43:45 pm
yes, the ones in the image are 7 dots, the ones I have are octagonal shaped (the dots) and 8 long. i've bought them through a polish company called alfa-zeta, they sell lot's more nice electromagnetical goods. macegr, thanks for pointing me in the right direction! I'm not sure yet how much milliamps each pixel requires, I'll have to do some additional testing.
12  Forum 2005-2010 (read only) / Interfacing / flip-dot display driver on: April 11, 2009, 05:55:34 am
Hey all,

I've got a question about a circuit I want to design, I'll try to explain in short what I'm trying to accomplish.

I've acquired a nice amount of so called flip-dot strips, electromagnetic display units that contains dots with one side colored fluorescent yellow and the other side black.



You can change the state of the dots (and flip them), by applying a 6v pulse and changing the poles to do the opposite (each dot has two pins).

This technique was much applied in the past, for instance in (railway) stations and displays on buses.

Well, my question is, I want to be able to control 720 (90*smiley-cool of these dots individually with an arduino. I've read about the usage of shift-registers for controlling large arrays of led's, but in my case I would also need to be able to switch the polarity (+/-, -/+). I'm guessing this  would require some kind of h-bridge (and ofcourse I'd rather use one than 720 h-bridges smiley)

Has anyone got an idea on how to approach this? Any insights are much appreciated!
13  Forum 2005-2010 (read only) / Interfacing / Re: Arduino NG and Parallax Servo Controller on: January 26, 2008, 04:48:08 pm
How I exactly got it to work, I'm not sure, what I do know is that I noticed there was no servo movement – but I was also sending the same (1250) position over and over again, that sure did not help either in getting it to move. Next to that I still had the jumper on the board, which turned the servo channels in 16-32, instead of 1-15.

Here's the code, that works well for me:

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 6
#define txPin 7


// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(2400);
  //debug led
  digitalWrite(13, HIGH);

}


void loop() {
  
  changeServo(9, 300);
  delay(2500);
  changeServo(9,1150);
  delay(2500);
    
}



int changeServo(int chan, int posi){
  
int pw = posi;
byte lsb = pw;
byte msb =  pw >> 8;
int ramp = 0;
  
  
    mySerial.print(33, BYTE);  //!
    mySerial.print(83, BYTE);  //S
    mySerial.print(67, BYTE);  //C
    mySerial.print(chan, BYTE);  //channel
    mySerial.print(ramp, BYTE);  //rampspeed
    mySerial.print(lsb, BYTE);  //LSB
    mySerial.print(msb, BYTE);  //MSB
    mySerial.print(13, BYTE);
    
}



I did have some trouble managing to change a global var from within the loop, therefore some variable declarations are within the loop.

14  Forum 2005-2010 (read only) / Interfacing / Re: Arduino NG and Parallax Servo Controller on: January 24, 2008, 04:53:04 am
Well, I'm using the software serial for communicating through port 6 and 7, to the servo controller. But for debugging the output I temporarily used ports 0 and 1 to display the output in the serial monitor, as you suggested in your post yesterday.
15  Forum 2005-2010 (read only) / Interfacing / Re: Arduino NG and Parallax Servo Controller on: January 24, 2008, 03:36:00 am
I've got some things working now, thanks for your help!
Pages: [1] 2