Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Use of Serial in a Library on: September 26, 2012, 10:36:26 pm
I'm writing a library that writes to a VFD (vacuum fluorescent display), and would like to take advantage of  Print. I looked at the LiquidCrystal library as an example, except the VFD uses a serial interface. However, the Serial functions, in a library, does not seem to work - no rx or tx leds during usage. After searching, found this read-only topic: http://arduino.cc/forum/index.php?topic=38072.0

It suggests: "This code allows you to use any library that inherits the Print object. [ethernet serial softwareserial etc etx]" and proceeds to add a MyLibrary class that inherits the Print object.

I'm not sure this is the way to go for writing a shared library, and after all, none of the LiquidCrystal examples have this. Is there a good solution to creating a library that uses Serial and a member of the Print class? Thanks!
2  Using Arduino / Microcontrollers / Re: ATTiny85 and 84, and the timer(s), porting code from ATMega328. on: August 27, 2012, 11:31:49 pm
Were you ever able to get interrupts to work with the ATTiny84? I'm running into the exact same problem- I can't get a simple CTC interrupt to trigger (for a clock-like application). The blink sketch works on the ATTiny84, but switching to interrupts with a similar sketch to yours compiles, but the ISR routine never fires.  smiley-sad-blue

I'm unsure if this is a problem with the Arudino IDE, or the damellis-attiny-6bff522 hardware files, but the datasheet seems to suggest the same registers as the AtMega328p, except with different register addresses.

I feel bad that I'll have to use a practically under used AT328p for this project when the AtTiny84 has the right amount of resources I need.

Thanks.

----= UPDATE =----
I got it to work by reading this related thread: http://arduino.cc/forum/index.php/topic,97048.0.html
Note the ISR vector- it's different. TIM1_COMPA_vect  vs TIMER1_COMPA_vect

NON-WORKING CODE: (from http://letsmakerobots.com/node/28278, which works on Arduino, but not the ATTiny84 as mentioned above)
/* Arduino 101: timer and interrupts
   1: Timer1 compare match interrupt example
   more infos: http://www.letmakerobots.com/node/28278
   created by RobotFreak
*/

#define ledPin 0

void setup()
{
  pinMode(ledPin, OUTPUT);
  
  // initialize timer1
  noInterrupts();           // disable all interrupts
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;

  OCR1A = 31250;            // compare match register 16MHz/256/2Hz
  TCCR1B |= (1 << WGM12);   // CTC mode
  TCCR1B |= (1 << CS12);    // 256 prescaler
  TIMSK1 |= (1 << OCIE1A);  // enable timer compare interrupt
  interrupts();             // enable all interrupts
}

ISR(TIMER1_COMPA_vect)          // timer compare interrupt service routine
{
  digitalWrite(ledPin, digitalRead(ledPin) ^ 1);   // toggle LED pin
}

void loop()
{
  // your program here...
}


WORKING CODE:
#define ledPin 0

void setup()
{
  DDRA  = 0xDF;
  PORTA = 0x20;
  DDRB  = 0xFF;
  PORTB = 0xFF;
 
  noInterrupts();        
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;
  OCR1A = 11250;            
  TCCR1B |= (1 << WGM12);  
  TCCR1B |= (1 << CS12);  
  TIMSK1 |= (1 << OCIE1A);  
  interrupts();
}

ISR(TIM1_COMPA_vect) // timer interrupt
{
  digitalWrite(ledPin, digitalRead(ledPin) ^ 1);
}

void loop()
{
  // main code
}
3  Using Arduino / Displays / Re: GLCD library version 3 on: August 26, 2012, 11:48:28 am
Hi Bill. An engineer at my work gave me this 160X160 display that I'd like to play around with at home with my AVR chips. I'd like to get your feedback on whether its worth pursuing using the glcd-v3 library on this display for basic text and graphics. i.e. "Yeah, it's easy- just create a new glcd\device, but don't worry about that single CS pin.." or "..better to roll your own here...".  smiley-lol

Model: Sunlike SG160160B    http://gecw.co.kr/data/sunlike/sg160160b.pdf
Controller: SED1330F series    http://www.lcd-module.de/eng/pdf/zubehoer/sed1330.pdf

I'm reading up on gLCD info at the moment, but there are clues to me to indicate that the glcd-v3 lib may not work for this display. Digging in a little further after looking at the datasheets (comparing SED1520 vs SED1330F)...
1) only 1 CS pin, where as the library suggests requiring 2 or even 3 CS pins. Not sure how this is used- perhaps memory banks? Maybe the SED1330F has enough memory so that it can reference the entire 160X160 space?
2) Extensive graphic layers and memory descriptions on the 1330F i.e. 3 layered graphics on the SED1330F. Again, I'll be happy if I can just do basic functionality on it (initialize, clear, display text, draw some lines and such), but I'm unsure if the commands, memory, etc are compatible between the two.
3) Inverted A0 levels between data and command. Not sure if this is "auto detected", or specified, or hard-coded in the glcd-v3 library.
4) Different duty cycles (1/160 vs 1/16 or 1/32) [I'm unsure what this characteristic defines, or even how it relates to the library]
5) The SED1330F pdf has 150 pages (granted, a few pages account for the TV version) where as the SED1520 only has 50 pages, suggesting the display was designed for different purposes (i.e. perhaps for involved graphics for the SED1330F vs perhaps a simplified\industrial standard\KS0108 compatibility for the SED 1520)

Again, I'd like to get your feedback on whether its worth pursuing using the glcd-v3 library on this display for basic text and graphics as I continue to read up on the specs for this display.

Thanks for your time.
Andy
Pages: [1]