Loading...
  Show Posts
Pages: 1 [2]
16  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: AVR Bootloader burn error in Arduino 9 and 10 on: October 18, 2007, 01:40:25 pm
Things are better- I didn't realize the board had to be powered as well as the mkII, so it burned the boot loader. However, I'm using a 168 with an old NG board, and it doesn't work after burning the new bootloader. I'm going to see if I can find an old bootloader to try on it...


Dave
17  Forum 2005-2010 (read only) / Bugs & Suggestions / AVR Bootloader burn error in Arduino 9 and 10 on: October 18, 2007, 12:13:20 pm
Hi,I have an AVR ISPMKII USB dongle and when I try to burn my bootloader to my NG board with a 168 chip on it, I always get the following error:

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


Any ideas? It clearly sees my dongle,just can't do anything with it. Lights do blink...

Any and all info, much appreciated.

Dave

18  Forum 2005-2010 (read only) / Troubleshooting / Re: Ardunio, on Mac OSX Intel on: September 20, 2006, 01:48:42 pm
This may be a dumb question, but can one use a USB Arduino on a mac, or is it only possible to use the serial one on a mac? I want to buy one of these jewels and start playing with it, just want to buy one I can use!

Never mind, apparently I can use USB by using the FTDI drivers. Am I correct?

Dave
19  Forum 2005-2010 (read only) / Interfacing / Re: How to connect SCP1000 pressure sensor on: December 27, 2009, 12:25:00 pm
If you're connecting to a 5V arduino board, check out this page at Spark Fun:

http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=65

It shows how(and why!) to hook up resistors so you don't toast the 3.3V device. I used the resistor network on mine, and usedthe 3.3V on the Decimilia for the power supply for the device. It works fine.
20  Forum 2005-2010 (read only) / Interfacing / Re: n00b SPI problem on: December 31, 2009, 12:46:38 pm
Willy,

Good to hear it works for you! A true validation of my code!

Greetings from Northern California. One of these days I have to make it out to Switzerland, my father worked for CIBA-Geigy (now Novartis) for 33 years and the company calendars were always filled with pictures of the alps. I am an avid hiker and they're on my to-do list.

Cheers,
Dave
21  Forum 2005-2010 (read only) / Interfacing / Re: n00b SPI problem on: December 30, 2009, 12:18:21 pm
Hi Willy,
Here is the code I use. It prints out in Centigrade. What helped me debug this was printing out the low and high parts of the pressure reading in hex, but I have since removed that. See if this works for you. Good luck!

Dave
Code:
// define spi bus pins
#define CSB 10 //  SLAVESELECT
#define SPICLOCK 13  // SCK
#define DATAOUT 11      //MOSI
#define DATAIN 12       //MISO

#define UBLB(a,b)  ( ( (a) << 8) | (b) )
#define UBLB19(a,b) ( ( (a) << 16 ) | (b) )

//Addresses
#define REVID 0x00      //ASIC Revision Number
#define OPSTATUS 0x04   //Operation Status
#define STATUS 0x07     //ASIC Status
#define START 0x0A      //Constant Readings
#define PRESSURE 0x1F   //Pressure 3 MSB
#define PRESSURE_LSB 0x20 //Pressure 16 LSB
#define TEMP 0x21       //16 bit temp

char rev_in_byte;          
int temp_in;
unsigned long pressure_lsb;
unsigned long pressure_msb;
unsigned long temp_pressure;
unsigned long pressure;

void setup()
{
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(CSB,OUTPUT);
  digitalWrite(CSB,HIGH); //disable device  
  
  SPCR = B01010011; //MPIE=0, SPE=1 (on), DORD=0 (MSB first), MSTR=1 (master), CPOL=0 (clock idle when low), CPHA=0 (samples MOSI on rising edge), SPR1=0 & SPR0=0 (500kHz)
  clr=SPSR;
  clr=SPDR;
  delay(10);
  Serial.begin(9600);
  delay(500);

  Serial.println("Initialize High Speed Constant Reading Mode");
  write_register(0x03,0x09);
}

void loop()
{
 
  rev_in_byte = read_register(REVID);
  
  pressure_msb = read_register(PRESSURE);
  pressure_msb &= B00000111;
  pressure_lsb = read_register16(PRESSURE_LSB);
  pressure_lsb &=0xFFFF;
  pressure = UBLB19(pressure_msb, pressure_lsb);
  pressure /= 4;
  pressure +=4500;    //correction in pascals to 1250 feet elevation, which is where I am at
  
  Serial.print(" P = ");
  Serial.print(pressure, DEC);
  
  temp_in = read_register16(TEMP);
  temp_in = temp_in / 2;
  Serial.print(", T x 10 = ");
  Serial.print(temp_in , DEC);
  Serial.println(" C");

  delay(1500);
}

char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
  {
  };
  return SPDR;                    // return the received byte
}


char read_register(char register_name)
{
    char in_byte;
    register_name <<= 2;
    register_name &= B11111100; //Read command
  
    digitalWrite(CSB,LOW); //Select SPI Device
    spi_transfer(register_name); //Write byte to device
    in_byte = spi_transfer(0x00); //Send nothing, but we should get back the register value
    digitalWrite(CSB,HIGH);
    delay(10);
    return(in_byte);
  
}

unsigned long read_register16(char register_name)
{
    byte in_byte1;
    byte in_byte2;
    unsigned long in_word;
    
    register_name <<= 2;
    register_name &= B11111100; //Read command

    digitalWrite(CSB,LOW); //Select SPI Device
    spi_transfer(register_name); //Write byte to device
    in_byte1 = spi_transfer(0x00);    
    in_byte2 = spi_transfer(0x00);
    digitalWrite(CSB,HIGH);
    in_word = UBLB(in_byte1,in_byte2);
    return(in_word);
}

void write_register(char register_name, char register_value)
{
    register_name <<= 2;
    register_name |= B00000010; //Write command

    digitalWrite(CSB,LOW); //Select SPI device
    spi_transfer(register_name); //Send register location
    spi_transfer(register_value); //Send value to record into register
    digitalWrite(CSB,HIGH);
}

22  Forum 2005-2010 (read only) / Interfacing / Re: n00b SPI problem on: December 29, 2009, 11:58:21 am
Willy,
read my post, just before yours. Change the read_register16 function to a unsigned long from a float. That helped me.


unsigned long read_register16(char register_name)
23  Forum 2005-2010 (read only) / Interfacing / Re: n00b SPI problem on: December 27, 2009, 12:27:56 pm
Hi folks,
The posted code works fine except that you want to change the type of return value for the read_register16 from a float to an unsigned long, same as the variable it's acting on. I had some funny business until I changed this.

unsigned long read_register16(char register_name)

Also, if you want to run this on a 5V board, check out this page on Spark Fun for how to do it. I used the resistor method and everything is working fine.

whoops, how about a link?  smiley-wink

http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=65
24  Forum 2005-2010 (read only) / Interfacing / Re: analog in to 4 bit LCD driver on: October 17, 2006, 09:42:51 am
Hey Neill,
I haven't tried your 4 bit library yet. The newer init code I posted above works fine for either a 2 or 4 line display. A quick glance at the excellent links you have on the LCD's processor's internal init functions leads me to believe that it probably isn't necessary to do a hard init of an LCD unless you want it to do a mode other than its native format (ie getting a 2 line display to only do 1 line). I don't have a 1 line display so I can't check that configuration. Thanks for the tip on the integer to string function. One thing I do enjoy about the Arduino is actually having to worry about keeping code lean and mean! Reminds me of the "good" old days with my Timex Sinclair smiley-wink

I could see people either using the "clear screen" or "reset to home" commands depending on what they want to do. "reset to home" sometimes looks nicer because it doesn't have the slight flicker that the "clear screen" function has.

Another interesting thing I found this weekend, after writing a little mac app to talk to the Arduino and set stuff on the LCD (if anyone's interested I'd be happy to post it) is that the serial(USB) port only seems to take in 65 bytes max at any one time? Is this a limitation of the hardware or the serial library?

At this rate, I might not get a chance to mess around with this until the weekend, but I've got plenty of stuff to read and try, thanks to you. Good show.

Dave
25  Forum 2005-2010 (read only) / Interfacing / Re: analog in to 4 bit LCD driver on: October 16, 2006, 10:50:25 pm
Hey Neill,


I'll give your code a look and see if we can't get the best of both of ours together (it might end up being all your's!) smiley-wink
26  Forum 2005-2010 (read only) / Interfacing / Re: analog in to 4 bit LCD driver on: October 16, 2006, 10:48:36 pm
Hey Neill,

I was playing around this weekend, trying to get everything to work well on a cold power up, and the following seems to work every time- works on a 20x4 LCD screen, and should also work on 1 and 2 line screens, although a 16x2 screen starts the second line at the 40th character. a 20x4 display does the first line, then the third, then the second, then the 4th...fyi.

the following does best in the setup function.

 int i;
 for (i=Enable; i <= DI; i++)
   pinMode(i,OUTPUT);

delay(200);

  LcdCommandWrite(2);  // set cursor to home
                        
 delay(200);                      
 LcdCommandWrite(2);  // do it again for good measure
                        
 delay(33);                      
 LcdCommandWrite(14);  // flat cursor, no blinking
 
 delay(50);                    
 
LcdCommandWrite(1);  // erase screen (if desired)
                      
 delay(20);    
27  Forum 2005-2010 (read only) / Interfacing / analog in to 4 bit LCD driver on: October 11, 2006, 12:13:20 pm
Hi all,
I combined and modified some of the tutorials to allow driving an LCD display in 4 bit mode, to save digital pins. The result is a program that can display temperature on an LCD and turn a digital pin on and off, to control a heater or other device. I'd post it in the playground but I haven't figured out how to create a new page.

Enjoy!

Dave

/* Analog in to LCD 4 bits
 * ---------
 * Adapted from the "analog_read_send" and "lcd_8bits" tutorials.
 * This example uses 4 less pins on the Arduino than the 8 bit example.
 * It will take a reading from a 'K' Type thermocouple ice point reference chip
 * on Analog Input 2 and display the temperature in degrees Centigrade on the LCD.
 * One can also set a target temperature for turning a relay off, say for a heater,
 * at a given setpoint temperature. This is done on digital pin 4.
 *
 * These are the pins used on the LCD:
 *
 * - DI(register select), RW, DB4..DB7, Enable (7 in total)
 *
 * the pinout for LCD displays is standard and there is plenty
 * of documentation to be found on the internet.
 *
 * 2006, Dave Sopchak  glasspusher at outofoptions dot net
 *
 */
 
int DI = 12; // register select
int RW = 11;
int DB[] = {7, 8, 9, 10};
int Enable = 6;

int temperaturePin = 2;    // select the input pin for the temperature
int ledPin = 13;           // pin for the LED

void tickleEnable()
{
 // send a pulse to enable
 digitalWrite(Enable,HIGH);
 delayMicroseconds(1);  // pause 1 ms according to datasheet
 digitalWrite(Enable,LOW);
 delayMicroseconds(1);  // pause 1 ms according to datasheet
}

void cmdWriteSet()
{
 digitalWrite(Enable,LOW);
 delayMicroseconds(1);  // pause 1 ms according to datasheet
  digitalWrite(DI,0);
  digitalWrite(RW,0);
}
void LcdCommandWrite(int value)
{
 int i = 0;

  for (i=DB[3]; i >= DB[0]; i--) // high nybble first
  {
    digitalWrite(i, value & 128);
    value <<= 1;
  }
    cmdWriteSet();
    tickleEnable();

  for (i=DB[3]; i >= DB[0]; i--) // low nybble next
  {
    digitalWrite(i, value & 128);
    value <<= 1;
  }
    cmdWriteSet();
    tickleEnable();
}

void LcdDataWrite(int value)
{
 int i = 0;
 
 digitalWrite(DI, HIGH);
 digitalWrite(RW, LOW);
  
  for (i=DB[3]; i >= DB[0]; i--) // high nybble first
  {
    digitalWrite(i, value & 128);
    value <<= 1;
  }
    tickleEnable();

  for (i=DB[3]; i >= DB[0]; i--) // low nybble next
  {
    digitalWrite(i, value & 128);
    value <<= 1;
  }
    tickleEnable();
}

void setup (void)
{
 int i;
 for (i=Enable; i <= DI; i++)
   pinMode(i,OUTPUT);

 delay(100);
 // initiatize lcd after a short pause
 // needed by the LCDs controller
 LcdCommandWrite(0x28);  // function set:
  delay(64);             // 4-bit interface, 2 display lines, 5x7 font
                         // other interaces:
                         // 0x20 = 4 bit, 1 display line

 LcdCommandWrite(0x28);  // function set:
  delay(64);             // 4-bit interface, 2 display lines, 5x7 font
 
  LcdCommandWrite(0x06);  // entry mode set:
                         // increment automatically, no display shift
 delay(20);                      
 LcdCommandWrite(0x0E);  // display control:
                         // turn display on, cursor on, no blinking
 delay(20);                      
 LcdCommandWrite(0x01);  // clear display, set cursor position to zero  
 delay(100);                      
 LcdCommandWrite(0x80);  // display control:
                         // turn display on, cursor on, no blinking
 delay(20);      
}

void loop (void)
{
  int i, val = 0;
  
  for(i = 0; i < 20; ++i)
  {
        val += analogRead(temperaturePin);    // read the value from the sensor
        delay(50);
  }
  
  val /= 4.06;      // conversion value to millivolts
  
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(500);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  
  if(val > 175 * 10)   // temperature in deg C times 10, since we're measuring to tenths of a degree
      digitalWrite(4,LOW);
   else
     digitalWrite(4,HIGH);

    LcdCommandWrite(0x02);  // set cursor position to zero  
  delay(10);                    
  firstDisplay(val);
}

void firstDisplay(int value)
{
  int first,second, third, fourth;
  
  first = value / 1000;    //
  second = (value - 1000 * first)/ 100;
  third = (value - 1000 * first - 100 * second)/ 10;
  fourth = (value - 1000 * first - 100 * second - 10 * third);
 
      LcdDataWrite('T');
      LcdDataWrite('e');
      LcdDataWrite('m');
      LcdDataWrite('p');
      LcdDataWrite(' ');
      LcdDataWrite('=');
      LcdDataWrite(' ');

      LcdDataWrite(value > 999 ? first + 48 :  ' ');  // begin onscreen
      LcdDataWrite(value > 99 ? second + 48 : ' ');
      LcdDataWrite(third + 48);
      LcdDataWrite('.');
      LcdDataWrite(fourth + 48);

      LcdDataWrite(' ');
      LcdDataWrite('C');
      LcdDataWrite(' ');
      LcdDataWrite(' ');
}
Pages: 1 [2]