Show Posts
Pages: [1] 2 3 ... 5
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: LCD Library on: May 18, 2008, 05:14:54 pm
Quote
will this work with serial-enabled LCDs?


I have a library for an LCD driven by Software Serial. The command codes are for a PH Anderon controller chip, but they would be trivially easy to edit.


http://www.wulfden.org/downloads/code/arduino/SWSerialLCDPHA_Lib.zip

cheers ... BBR
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino 0011 and <stdio.h> on: June 19, 2008, 12:01:09 am
Thanks guys, mungbean's suggestion cleaned things up nicely.

 cheers ... BBR
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Arduino 0011 and <stdio.h> on: June 18, 2008, 01:50:24 pm
I was doing some coding to make use a printf and a test sample of code I had that compiled clean 0010, blew up in stdio.h under 0011. I gutted the code to bare bones:
Code:
#include <stdio.h>
// char _str[32]; // 32 chars max! increase if required to avoid overflow
// #define writeln(...) sprintf(_str, __VA_ARGS__); Serial.println(_str)

void setup() {
}

void loop() {
}

 and it produced these errors. Anyone know what's going on here?

Cheers ... BBR

Quote
/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected unqualified-id before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected unqualified-id before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__put' was not declared in this scope

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'char'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__get' was not declared in this scope

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'

/Applications/arduino-0011/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: initializer expression list treated as compound expression

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



4  Forum 2005-2010 (read only) / Bugs & Suggestions / Arduino-0009 and avrdude for uploading on: August 07, 2007, 09:17:21 am
I downloaded 0009 last night and used it to burn bootloaders via avrisp mkii, it works fine, I also used it to load sketches and that worked fine also ...

However, I am, for lack of a better phrase, a 'touchy feely' kind of guy. I like feedback. in 0008 and earlier after the final lione from gcc with sketch size we got a couple of lines from uisp about the download. But, avrdude is silent (running under OSX 10.4.10 on a MacBook Pro) on loading sketches and burning bootloaders.

Is there  anyway in 0009 to use my avrisp mkii to burn sketches sans bootloader? If so, what are teh setups/commands?

cheers ... BBR
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: rfid compare tag code on: August 29, 2007, 08:05:36 pm
Quote
String functions are not appropriate, as you are working with chinks of binary data, not strings.  

The Parallax RFID Reader from Grand Designs sends a start byte of 0x0A, then ten hexadecimal digits in ASCII, then a stop byte 0x0D. Its all 'printable ASCII' so string functions are appropriate. Tie off the ID string by replacing the stop byte with 0x00, then use strcmp() to match to your array of valid IDs.


cheers ... BBR
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: How to Reset milli() function? on: May 24, 2008, 09:34:48 am
The Arduino IDE does not send a 'reset' when the serial monitor port is opened. However in the Arduino 0009 and later compatible hardware DTR (or RTS on boards made for the FTDI TTL-232R cable) gets asserted when the serial port is opened and a hardware reset is generated.

So, on the one hand, you are right in that a reset IS generated, BUT, on the other hand, you are wrong, because it IS NOT generated by the Arduino IDE.

I hope this helps make it clear.

 cheers ... BBR
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Unexpected behavior – what am I missing? on: May 24, 2008, 09:22:06 am
Quote
HIGH and LOW are #defines in wiring.h, so the compiler replaces them by 1 and 0 when you compile:

#define HIGH 0x1
#define LOW  0x0

The same is true for INPUT and OUTPUT.

As far as I know, the Arduino software is not compiling your code, the GCC C/C++ compiler is.

- Ben

 Quite correct. The Ardino IDE is, essentially,  a "pre-processor" which takes the various Arduino 'defines' and command directives and builds a .cpp file which then gets fed to the gcc compiler.

cheers ... BBR
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Unexpected behavior – what am I missing? on: May 18, 2008, 07:45:23 pm
A small point here ... in so much as  "random(2)" can produce on the values 0 and 1 why not eliminate a lot of code by simply  writing this instead:

Code:
R1 = random(2);
 digitalWrite(L1, R1);

 R2 = random(2);
 digitalWrite(L2, R2);

 R3 = random(2);
 digitalWrite(L3, R3);

 if ((R1 + R2 + R3) > 0)
       delay(random(250,001));


  just a thought ... cheers ... BBR
9  Forum 2005-2010 (read only) / Development / Re: Morse library on: March 01, 2008, 08:42:27 pm
This is good work. I like what you have done, but I take one exception. The call to Morsee use a variable "intervail" which passes the dot time to the routine. Thus setting the words per minute rate. This number is rather obscure. I would propose that you do the math for the user. As long as you writing the library to make this easy for the user, do the whole job ... This is an output routine, we start up a serial routine by issuing a command like  "Serial.begin(9600)" so I would suggest you do the following;

(1) make "intervail" private , initialized to 0

(2) create begin() that gets called in a fashion like "myMorse.begin(wpm)" where wpm is a variable or an actual number of the Morse sending speed in words per minute. Then you do the math and set "intervail"

cheers ... BBR (n1bq)
10  Forum 2005-2010 (read only) / Development / Re: 3-line printf-style hack on: June 18, 2008, 01:58:36 pm
There now seems to be a proble in Arduino 0011 invoking stdio.h ... see this  thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213815025

cheers ... BBR

11  Forum 2005-2010 (read only) / Development / Re: 3-line printf-style hack on: April 30, 2008, 09:27:02 am
Good show, just one small comment ....

You call it "writeln()" and use  "Serial.println()", wouldn't it be more appropriate to call "Serial.print()" and put in the '\n' yourself ... if, where, and when you want it????

Buffer overflow considerations aside, I want it for formating stuff to LCD displays, where a 20-40 byte buffer is all I need and if I ain't payin attenshun to my line size I deserve whatever I get!!!!!

Thanks for a good idea ...

cheers ... BBR

12  Forum 2005-2010 (read only) / Development / Re: Arduino bundle for TextMate on: August 25, 2007, 07:19:27 pm
I would vote for a command line script that can be invoked from BBEdit ... on the Mac

 cheers ... BBR
13  Forum 2005-2010 (read only) / Development / Re: Servo Libraries - Arduino 0010 on: April 19, 2008, 11:52:07 pm
Mellis and I put our heads together on this at the Boston Arduino Users Group Meeting  Saturday and pounded it out, the  TICIE1 reference in the copy I had should have been deleted ... all is now well in  Mudville! At this point I am not sure which library I had  the patched one from Lady Ada or what ... but it now works and my test program compiles clean, now that I am back from Beantown (3.5 hours each way) and get some sleep ... tomorrow,  I will dig my servos back out of the drawer and check them out. Thanks for the help ...

p.s The Boston Arduino meeting was fun ... Mellis, Paul Badger (Modern Devices, the BBB), and I (Wulfden Freeduino) and about 15-- others had several hours of playing with Arduino toys and software/hardware discussions and show and tell!

 There's a great Burrito shop with its own free WiFi,  two doors down from where  they held  the meeting, PB and I went and gorged for dinner!

cheers ... BBR

14  Forum 2005-2010 (read only) / Development / Re: Servo Libraries - Arduino 0010 on: April 18, 2008, 10:44:04 pm
That Library also has the same problem ...
Quote
ServoTimer1.cpp: In static member function 'static void ServoTimer1::seizeTimer1()':
ServoTimer1.cpp:43: error: 'TICIE1' was not declared in this scope

15  Forum 2005-2010 (read only) / Development / Servo Libraries - Arduino 0010 on: April 14, 2008, 07:58:27 pm
I am playing with the the Servo and ServoTimer1 libraries from  the playground and using the sample code given and both libraries give the same error at compile time on Arduino 0010

Quote
: In function `setup':
undefined reference to `ServoTimer1::attach(int)'o: In function `loop':
o: In function `__static_initialization_and_destruction_0':


The IDE always highlights the last line before the first call to the 'attach' command as the error whether its a comment or code. I know its something simple that I am overlooking ... but I am just drawing a blank.

cheers ... BBR

Code:
//Example code for using ServoTimer1 library
// hardware control of up to two servos, on Arduino pins 9 & 10

#include <ServoTimer1.h>

ServoTimer1 servo1;
ServoTimer1 servo2;

void setup()
{
  pinMode(1,OUTPUT);
  servo1.attach(9);
  servo2.attach(10);
  Serial.begin(19200);
  Serial.print("Ready");
}

void loop()
{
  static int v = 0;

  if ( Serial.available()) {
    char ch = Serial.read();

    switch(ch) {
      case '0'...'9':
        v = v * 10 + ch - '0';
        break;
      case 's':
        servo1.write(v);
        v = 0;
        break;
      case 'w':
        servo2.write(v);
        v = 0;
        break;
      case 'd':
        servo2.detach();
        break;
      case 'a':
        servo2.attach(10);
        break;
    }
  }
        // Notice that no ServoTimer1::refresh() is needed.
}


The library code is here
Code:
#include <ServoTimer1.h>
#include <avr/interrupt.h>

/*
  ServoTimer1.h - Hardware Servo Timer Library
  Author: Jim Studt, jim@federated.com
  Copyright (c) 2007 David A. Mellis.  All right reserved.

  --boiler plate removed--
*/

uint8_t ServoTimer1::attached9 = 0;
uint8_t ServoTimer1::attached10 = 0;

void ServoTimer1::seizeTimer1()
{
    uint8_t oldSREG = SREG;

    cli();
    TCCR1A = _BV(WGM11); /* Fast PWM, ICR1 is top */
    TCCR1B = _BV(WGM13) | _BV(WGM12) /* Fast PWM, ICR1 is top */
      | _BV(CS11) /* div 8 clock prescaler */
      ;
    OCR1A = 3000;
    OCR1B = 3000;
    ICR1 = clockCyclesPerMicrosecond()*(20000L/8);  // 20000 uS is a bit fast for the refresh, 20ms, but
                                                    // it keeps us from overflowing ICR1 at 20MHz clocks
                                                    // That "/8" at the end is the prescaler.
#if defined(__AVR_ATmega168__)
    TIMSK0 &= ~(_BV(TICIE1) | _BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) );
#else
    TIMSK &= ~(_BV(TICIE1) | _BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) );
#endif
    SREG = oldSREG;  // undo cli()    
}

void ServoTimer1::releaseTimer1()
{;}


#define NO_ANGLE (0xff)

ServoTimer1::ServoTimer1() : pin(0),angle(NO_ANGLE),min16(34),max16(150)
{}

void ServoTimer1::setMinimumPulse(uint16_t t)
{
    min16 = t/16;
}

void ServoTimer1::setMaximumPulse(uint16_t t)
{
    max16 = t/16;
}

uint8_t ServoTimer1::attach(int pinArg)
{
    if ( pinArg != 9 && pinArg != 10) return 0;

    pin = pinArg;
    angle = NO_ANGLE;
    digitalWrite(pin,0);
    pinMode(pin,OUTPUT);

    if ( !attached9 && !attached10) seizeTimer1();

    // muck with timer flags
    if ( pin == 9) {
      attached9 = 1;
      TCCR1A = TCCR1A & ~_BV(COM1A0) | _BV(COM1A1);
    } else {
      attached10 = 1;
      TCCR1A = TCCR1A & ~_BV(COM1B0) | _BV(COM1B1);
    }
    return 1;
}

void ServoTimer1::detach()
{
    // muck with timer flags
    if ( pin == 9) {
      attached9 = 0;
      TCCR1A = TCCR1A & ~_BV(COM1A0) & ~_BV(COM1A1);
    } else {
      attached10 = 0;
      TCCR1A = TCCR1A & ~_BV(COM1B0) & ~_BV(COM1B1);
    }
    pinMode(pin,INPUT);

    if ( !attached9 && !attached10) releaseTimer1();
}

void ServoTimer1::write(int angleArg)
{
    uint16_t p;

    if ( angleArg < 0) angleArg = 0;
    if ( angleArg > 180) angleArg = 180;
    angle = angleArg;

    // bleh, have to use longs to prevent overflow, could be tricky if always a 16MHz clock, but not true
    // That 8L on the end is the TCNT1 prescaler, it will need to change if the clock's prescaler changes,
    // but then there will likely be an overflow problem, so it will have to be handled by a human.
    p = (min16*16L*clockCyclesPerMicrosecond() + (max16-min16)*(16L*clockCyclesPerMicrosecond())*angle/180L)/8L;
    if ( pin == 9) OCR1A = p;
    else OCR1B = p;
}

uint8_t ServoTimer1::read()
{
    return angle;
}

uint8_t ServoTimer1::attached()
{
    if ( pin == 9 && attached9) return 1;
    if ( pin == 10 && attached10) return 1;
    return 0;
}

void ServoTimer1::refresh()
{
    ;
}



Pages: [1] 2 3 ... 5