Show Posts
Pages: 1 ... 3 4 [5]
61  Forum 2005-2010 (read only) / Interfacing / Re: messenger library and processing on: October 04, 2009, 04:49:10 pm
I think the Arduino doesn't reboot. At least, mine doesn't reboot the same.

I solved it by removing the while loop :
Code:
while (port.available() == 0 ) {}; // Wait till Arduino boots

Don't forget to print a carriage return to when you reply from Arduino.
Code:
void messageReady() {
  // Loop through all the available elements of the message
  while ( message.available() ) {
    Serial.print(message.readChar() );
  }
  //added
  Serial.print(13,BYTE);

}


That made it work for me.
Still I'm having some errors, so I'm figuring out some things too.
But at least this might got you started on the good road.
62  Forum 2005-2010 (read only) / Interfacing / Re: Firmata 2.1 (version C) on: September 24, 2009, 07:57:03 am
Seems to work ok. The only problem is that 2.1 in Arduino has a serial speed of 57600 Baud and this 2.1 version has a higher speed ( 115200 ).
63  Forum 2005-2010 (read only) / Interfacing / Re: receiving a byte from Flash on: April 01, 2007, 06:06:37 pm
Thank you for that answer.
I've programmed the following solution :
With flash I send this string : I0,000,000,000,0,0
Or this with maximum pwm values : I1,255,255,255,1,1

Arduino code :
Code:
digseq=17;    // extra indexes for pwm
p=8;

if (serInString[0]==73)  // I
{ for (int i=1; i <= digseq; i++)
  { if (serInString[i]==',')
      { p++;
      i++;
      }    
    char valchar=serInString[i];
      if(p==8 || p==12 || p==13)                        // digital outputs
      { if(valchar=='1') digitalWrite(p, HIGH);
      if(valchar=='0') digitalWrite(p, LOW);            
      }
      else                                           // PWM outputs
      { valpwm = 0;
      valpwm = (serInString[i]-48)*100;
      valpwm = valpwm + (serInString[i+1]-48)*10;
      valpwm = valpwm + (serInString[i+2]-48);
      
        i=i+2;
                                    
        analogWrite(p,valpwm);                   
      }
  }  
}


Well, this works almost perfect.

Sometimes I see the other pwm outputs going on for a short time. When changing another pwm output.
Any idea what is the cause of that ? To much serial data ( I'm also sending a string with all the inputs to Flash ) or someting ?

IntervalTimer in Flash : 100ms
Arduino : delay(40); Serial.begin(57600);






64  Forum 2005-2010 (read only) / Interfacing / receiving a byte from Flash on: March 31, 2007, 01:14:19 pm
I've some trouble receiving bytes from Flash.
I want to sent an 8bit value to a PWM output. I use the serial examples from Beltran Berrocal http://www.progetto25zero1.com/b/tools/Arduino/

The problem is that character above 127 ( so 8bit values instead of 7 ) seems to occupie two index values in the serInString array instead of one.  

Code:

char serInString[100];
char valchar;

if (serInString[0]==73)  // I
    { for (int i=1; i <= digseq; i++)
     { p = i+digout-1;       // output to the right pins
        char valchar=serInString[i];   // what is the letter
        Serial.print(valchar, BYTE);
      }  
      Serial.println();
    }

This code works perfect when sending 7bit characters.

Here a copy from my Flash output window. The 1st, 3rd etc. row is the string I send to the Arduino.  
Code:
Iÿ00000
Arduino says -- ÿ0000
Iÿÿ0000
Arduino says -- ÿÿ00
Iÿÿÿ000
Arduino says -- ÿÿÿ
Iÿÿÿÿ00
Arduino says -- ÿÿÿ

The ÿ character is 255 or FF in hexadecimal ( maybe this is the reason? ). The zero's are ascii zero's, but I couldn't display them in the forum (its translated in a breakingrule ).
h
When reading indexnumbers higher than 6 ( since I walk through 1,2,3,4,5,6 with the loop ), I get the other characters.

Why is this happening ?


65  Forum 2005-2010 (read only) / Troubleshooting / Re: avrdude: write to file '/../sketch.hex' failed on: April 15, 2009, 06:18:37 am
Its seems that its arduino 015 related. Because I get the error directly while compiling for an Arduino NG too.
66  Forum 2005-2010 (read only) / Troubleshooting / Re: avrdude: write to file '/../sketch.hex' failed on: April 15, 2009, 02:20:20 am
I've made a Arduino-Flash communication script ( ) and it seems that users that use the Duemilanove ATMEGA 328 and Arduino 15 have the same problem as above.

What a user send to me :

C:\DOCUME~1\Bob\LOCALS~1\Temp\build6597.tmp\core.a(wiring_serial.c.o): In function `__vector_18':

C:\Documents and Settings\Bob\Bureaublad\arduino\arduino-0015-win\arduino-0015\hardware\cores\arduino/wiring_serial.c:112: multiple definition of `__vector_18'


C:\DOCUME~1\Bob\LOCALS~1\Temp\build6597.tmp\core.a(HardwareSerial.cpp.o):C:\Documents and Settings\Bob\Bureaublad\arduino\arduino-0015-win\arduino-0015\hardware\cores\arduino/HardwareSerial.cpp:95: first defined here

Couldn't determine program size: C:\Documents and Settings\Bob\Bureaublad\arduino\arduino-0015-win\arduino-0015\hardware/tools/avr/bin/avr-size: 'C:\DOCUME~1\Bob\LOCALS~1\Temp\build6597.tmp\arduino_flash.hex': No such file
67  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino 15 hardwareserial on: April 15, 2009, 04:45:51 pm
Deleting wiring_serial.c didn't help, but it did track the error.

In the script based on the code by beltran berrocal ( SERIAL COM - HANDELING MULTIPLE BYTES inside ARDUINO - 04_function development
).

The functions serialAvailable() and serialRead() were used. Probably they were replaced by Serial.available() and Serial.read() later ( because this script is from 2006 ).

Changing this part of the code in the script solves the issue.

Code:
void readSerialString (char *strArray)
{
  int i = 0;                        
  if(Serial.available()){                
    while (Serial.available()) {        
      strArray[i] = Serial.read();                                              
      i++;                          
    }
  }
  serInStringLength=i;      
}
68  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino 15 hardwareserial on: April 15, 2009, 10:31:48 am
I'm running osx 10.5.

The buildlog ( well, i suppose it is, because this information turns up extra when I set the build verbose to true ) :

Code:
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/pins_arduino.c -o/tmp/build26535.tmp/pins_arduino.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/WInterrupts.c -o/tmp/build26535.tmp/WInterrupts.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring.c -o/tmp/build26535.tmp/wiring.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring_analog.c -o/tmp/build26535.tmp/wiring_analog.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring_digital.c -o/tmp/build26535.tmp/wiring_digital.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring_pulse.c -o/tmp/build26535.tmp/wiring_pulse.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring_serial.c -o/tmp/build26535.tmp/wiring_serial.c.o
hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/wiring_shift.c -o/tmp/build26535.tmp/wiring_shift.c.o
hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /tmp/build26535.tmp/Temporary_8018_3780.cpp -o/tmp/build26535.tmp/Temporary_8018_3780.cpp.o
hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/HardwareSerial.cpp -o/tmp/build26535.tmp/HardwareSerial.cpp.o
hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/Print.cpp -o/tmp/build26535.tmp/Print.cpp.o
hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=16000000L -I/Applications/arduino-0015/hardware/cores/arduino /Applications/arduino-0015/hardware/cores/arduino/WMath.cpp -o/tmp/build26535.tmp/WMath.cpp.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/HardwareSerial.cpp.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/pins_arduino.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/Print.cpp.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/WInterrupts.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring_analog.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring_digital.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring_pulse.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring_serial.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/wiring_shift.c.o
hardware/tools/avr/bin/avr-ar rcs /tmp/build26535.tmp/core.a /tmp/build26535.tmp/WMath.cpp.o
hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega168 -o /tmp/build26535.tmp/arduino_flash.elf /tmp/build26535.tmp/Temporary_8018_3780.cpp.o /tmp/build26535.tmp/core.a -L/tmp/build26535.tmp -lm

Has someone any idea about workarounds ?
Maybe I can change something in the script so its compatible with 0015 ?
69  Forum 2005-2010 (read only) / Bugs & Suggestions / Arduino 15 hardwareserial on: April 15, 2009, 06:40:19 am
When compiling my Flash-Arduino script http://www.arduino.cc/playground/Interfacing/Flash with Arduino 0015 I get an error that I didn't get when I compiled with former versions.

Two other people reacted that they had this problem with the new atmega 328 board, but with the NG this seems to happen as well ( so I think it is something in the 0015 version ).

I think the error in this topic is related :
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239771130/2#2

The error :
Code:
/tmp/build59819.tmp/core.a(wiring_serial.c.o): In function `__vector_18':

/Applications/arduino-0015/hardware/cores/arduino/wiring_serial.c:112: multiple definition of `__vector_18'

/tmp/build59819.tmp/core.a(HardwareSerial.cpp.o):/Applications/arduino-0015/hardware/cores/arduino/HardwareSerial.cpp:95: first defined here

Couldn't determine program size: hardware/tools/avr/bin/avr-size: '/tmp/build59819.tmp/arduino_flash.hex': No such file

The script
Code:
/* Arduino communication with Flash
 * Use Arduino as an interfaceboard for Flash applications.
 *
 * This code should be used with the following flash files :
 * Flash_arduino.fla
 * ArduinoFO.as
 * ArduinoXML.as
 *
 * More information in the readme.txt
 *
 * Art & Technology - Saxion University of Applied Sciences
 * copyleft Kasper Kamperman / Rene Heijnen, Enschede - The Netherlands - september 2008
 * http://www.kasperkamperman.com
 *
 * code based on :
 * -------------------------------------------------------------------------------  
 * General Purpose computer serial IO
 * copyleft Stephen Wilson  <http://userwww.sfsu.edu/~swilson/>
 * Created October, 2006
 *
 * SERIAL COM - HANDELING MULTIPLE BYTES inside ARDUINO - 04_function development
 * by beltran berrocal  created 16 Decembre 2005;
 * copyleft 2005 Progetto25zero1  <http://www.progetto25zero1.com>
 * -------------------------------------------------------------------------------
 *
 * Make sure that the pinConfig Array in this file is exactly the same as in the flash fla file.
 */

// variabels
char serInString[40];  // the received string with output information max 40 characters
char tempString[4];    // temp string for reading the pwm & output values
int tempVal;           // temp int for reading pwm values
int val;               // temp int for reading analog en digital inputs
int stringLength = 1;  // expected length of string received from Flash
int serInStringLength; // length of string received by Flash.
int digOut = 0;        // Number of digital outputs
int digIn = 0;         // Number of digital inputs
int digInputs[12];     // array that stores which pins are used as digital inputs max 12.
int digOutputs[12];    // array that stores which pins are used as digital outputs max 12.
int digOutLastValues[12]; // array that stores the last values, an output only updates when there is a change

char pinConfig[] =  {  
  // array with the pin configuration of Arduino. Don't forget to change in Flash.
  // pin 0 and 1 are not used because they are used by the Serialport (RX/TX)

  // COPY-PASTE PIN CONFIGURATION BELOW ALSO TO FLASH --

  'i',  // Pin 2  'i' for in 'o' for out
  'i',  // Pin 3  'i' for in 'o' for out or 'p' for pwm
  'i',  // Pin 4  'i' for in 'o' for out
  'i',  // Pin 5  'i' for in 'o' for out or 'p' for pwm
  'i',  // Pin 6  'i' for in 'o' for out or 'p' for pwm
  'i',  // Pin 7  'i' for in 'o' for out
  'o',  // Pin 8  'i' for in 'o' for out
  'p',  // Pin 9  'i' for in 'o' for out or 'p' for pwm
  'p',  // Pin 10 'i' for in 'o' for out or 'p' for pwm
  'p',  // Pin 11 'i' for in 'o' for out or 'p' for pwm
  'o',  // Pin 12 'i' for in 'o' for out
  'o'   // Pin 13 LedPin 'i' for in 'o' for out

  // ----------------------------------------------------
};

void setup() {
  Serial.begin(57600);       // start serial port

  // set pinconfiguration according to the pinConfig array
  for (int i =0; i < 12; i++) {
    //Serial.print(pinConfig[i]);
    if (pinConfig[i] == 'i') { // input
      pinMode(i+2, INPUT);
      digInputs[digIn] = i+2;
      digIn++;
    }  
    if (pinConfig[i] == 'o') { // output
      pinMode(i+2, OUTPUT);
      digOutputs[digOut] = i+2;
      stringLength +=2; // output string part will have 2 characters
      digOut++;
    }
    if (pinConfig[i] == 'p') { // pwm output
      pinMode(i+2, OUTPUT);
      digOutputs[digOut] = i+2;
      stringLength +=4; // pwm string part will have 4 characters
      digOut++;
    }
  }
}

// Function to read a string from the serialport and store it in an array
void readSerialString (char *strArray)
{
  int i = 0;                        
  if(serialAvailable()){                
    while (serialAvailable()) {        
      strArray[i] = serialRead();                                              
      i++;                          
    }
  }
  serInStringLength=i;      
}

// Function to find out wether the array is empty or not
boolean isStringEmpty(char *strArray)
{
  if (strArray[0] == 0) return true;
  else                   return false;
}


void sendInputsToFlash(boolean error)
{
  if(error) {  
    Serial.print("e,");
    Serial.print(stringLength);
    Serial.print(",");
    Serial.print(serInStringLength);
    Serial.print(",");
  }
  else  Serial.print("i,");

  // read the defined digital inputs
  for (int i=0; i < digIn; i++) {    
    val = digitalRead(digInputs[i]);
    if (val == HIGH) {
      Serial.print(val,BIN);
    }
    if (val == LOW) {
      Serial.print(val,BIN);
    }
    Serial.print(",");
  }

  // read the 6 analog inputs    
  for (int i=0; i < 6; i++) {      
    val = analogRead(i);
    Serial.print(val,DEC);
    Serial.print(",");
  }

  Serial.println(0, BYTE); // close with a zero byte for XML Flash  
}

void updateArduinoOutputs()
{ // position of the current character in the serInstring
  int serInStringPosition = 1;       

  // set the defined outputs

  for (int i=0; i < digOut; i++) {

    // check if next character is ',' then it is a digital output
    // because a pwm value has three characters

    if (serInString[serInStringPosition + 1]==',' ) {
      tempString[0] = serInString[serInStringPosition];
      tempString[1] = 0;
      tempString[2] = 0;
      tempVal = atoi(tempString);

      // check if this output has changed
      // this prevents outputs to "flicker"
      if(digOutLastValues[i]!=tempVal)
      {
        if(tempVal==1) digitalWrite(digOutputs[i], HIGH);
        if(tempVal==0) digitalWrite(digOutputs[i], LOW);
        digOutLastValues[i]=tempVal;
      }
      serInStringPosition += 2;
    }

    // next pin is not ',' so its a pwm value
    else {
      tempString[0] = serInString[serInStringPosition];
      tempString[1] = serInString[serInStringPosition+1];
      tempString[2] = serInString[serInStringPosition+2];
      tempVal = atoi(tempString);

      if(digOutLastValues[i]!=tempVal)
      {
        analogWrite(digOutputs[i],tempVal);
        digOutLastValues[i]=tempVal;
      }
      serInStringPosition +=4;
    }
  }

}

void eraseStrings()
{ // erase contents in the serInString array
  for (int i=0; i < 40; i++) {  
    serInString[i]=0;    
  }
  // erase contents in the tempString array
  for (int i=0; i < 4; i++) {
    tempString[i]=0;
  }
}

void loop () {
  // Serial.println("Arduino is alive !!!");
  // read the serial port and create a string out of what you read
  readSerialString(serInString);

  // check if there data is received if isStringEmpty is true do nothing.
  if(isStringEmpty(serInString) == false) {

    /* check if the received string starts with an o            
     check if string length is the same as expected length (defined outputs)
     if true : return I (input), send input info to flash and update the Arduino outputs
     if false: return E (error) and the part of the string that is received (to debug)
    
     check if the received string start with an n
     send only input information ( no new info from Flash )      
     */

    if(serInString[0]==111) //o
    {
      if(serInStringLength>=stringLength)
      { //the received information is complete
        updateArduinoOutputs();
        sendInputsToFlash(false);      
      }    
      // receive info incomplete error is true
      else sendInputsToFlash(true);  
    }
    else if(serInString[0]==110) //n
    {
      sendInputsToFlash(false);
    }
    // no o or n as start character, start with error info
    else sendInputsToFlash(true);

    eraseStrings();    
  }
  // short delay before making sure serial.read is not called to soon again
  delay(20);    
}
70  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: August 10, 2006, 12:31:31 pm
Thank you for your usefull tips! Sometimes its hard to find a good starting point to learn something. Your example posts and explanation posts are excellent. Very inspirational to see some examples that go deeper into possibility's of Arduino. A blinking led is nice, but sometimes you want more of course. Nice to see that this is actually possible.

Well, I'll have to start reading then smiley

Kasper



71  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: August 09, 2006, 06:02:11 am
Thank you for the explanation. I can understand a little bit French, but I have viewed the link in French thru Babelfish. Do I understand it right that you use the assembly code from the Atmel processor ? Is this because of speed issues or is this the only way ( I'm a beginner ) to do this in Aduino ?

Why do you define so much variables ( especially in the "French post" ), it seems to my that you don't use all those variables.

Do you have some good resources (links, books) we're you can learn programming the Atmel processor ? Or is reading the whole datasheet the best option ?

72  Forum 2005-2010 (read only) / Interfacing / Re: reading rpm signal from cpu fan on: August 08, 2006, 04:56:59 pm
Do you have a link were the source code is explained ? I'm trying to understand the code. It seems I can't find all the info in the arduino reference. Are there any other resources we're I can find this information ?

Especially the void initInt0() function is hard to understand.

hope you can give me some hints.
73  Forum 2005-2010 (read only) / News / Re: Messenger library on: May 13, 2010, 05:13:41 pm
Hi, just for your information.

I've made a description in how to send serial data from and to Flash with the Messenger library. The file can be used with the basic_communication sketch in the Messenger library examples folder.
http://www.kasperkamperman.com/blog/arduino-flash-communication-as3-messenger/.

74  Forum 2005-2010 (read only) / Uno Punto Zero / Re: UNO firmata as3glue on: January 04, 2011, 03:58:35 am
Seems that its was an issue with the Firmata included in Arduino 0021. The version included in Arduino 0022 seems to work fine.

By the way an nice tool to test and monitor Firmata without Serialproxy is Firmata_test :
http://www.firmata.org/
75  Forum 2005-2010 (read only) / Uno Punto Zero / UNO firmata as3glue on: December 08, 2010, 11:34:04 am
Hi,

I was testing the As3Glue library with the Arduino UNO, however I notice that the connection is not very stable. Sometimes ports are updated and sometimes not, same goes for analog inputs.

With the older Arduino boards (diecimilla, duemilanove) everything works flawless.

I use Serproxy (actually TinkerProxy) to translate the serial data to XMLsocket.

I now the Arduino UNO has a new USB chip, does that cause the errors.

I use Flash Arduino communication a lot in my classes and it would be a pity if thats not possible anymore with the new board.

Someone noticed the same issue's?
http://code.google.com/p/as3glue/
I used the bundle 1.5.

Kasper

Pages: 1 ... 3 4 [5]