Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display using SPI on: February 03, 2010, 11:33:49 pm
Fred, try changing the spi bus freq by sending (<<SSPR0) instead of (1<<SPR1).  This will divide by 16 and not 64.

Also, check these pins (ref Arduino.cc SPI library page)

pin 13      SCK      SPI clock      
pin 12      MISO      SPI master in, slave out
pin 11      MOSI      SPI master out, slave in
pin 10      SS      SPI slave select

 Hope this helps!
2  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display using SPI on: July 21, 2009, 09:32:45 pm
Well now...after talking to myself late into the the night and with a great deal of help from fellow Arduinophile Quazar, we have this sample code for y'all to use to help get up the learning curve for this Serial LED Display from Sparkfun (COM-09230).

Hmmm, now lemme see what's cold and frosty in the fridge  smiley-wink

Wiring:
Display MOSI <--> Mini pin 11 (Across from D8) Blue
Display CSN <--> Mini pin 10 (Across from D9) Green
Display SCK <--> Mini pin 13 (Across from D6) Yellow
Display Vcc <--> Mini Vcc (Across from GND) Red
Display GND <--> Mini GND (Across from RXI) Black

Colors refer to a jpeg that I have somewhere....


Code:
// Send alphanumeric data to the Sparkfun Serial LED Display (COM-09230) using SPI
// Tested using Arduino Pro Mini w/ ATMega168 @ 5V
// July 21, 2009  - Quazar & Busaboi
// No guarantees expressed or implied just a good starting point
// Based upon the many SPI tutorials on Arduino.cc
//
// "num" specifies the number to display
// "base" specifies the base to use (2-16).
//    Use 2 for binary, 8 for octal, 10 for decimal, or 16 for hex
// "pad" indicates whether leading zeros should be replaced with spaces.
//    pad==0 means spaces ("   0"), pad==1 means zeros ("0000")
//
// Notes: The display's decimal/punctuation indicators are not changed.
// Numbers that don't fit into 4 digits show as " OF " for "Overflow".
// Assumptions: "unsigned short" is assumed to be at least 16b wide.

#define DATAOUT 11 //MOSI
#define DATAIN 12 //MISO - not used, but part of builtin SPI
#define SPICLOCK 13 //sck
#define SLAVESELECT 10 //ss

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

void setup()
{
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK, OUTPUT);
  pinMode(SLAVESELECT, OUTPUT);
  digitalWrite(SLAVESELECT, HIGH); //disable device
  // SPCR = 01010010
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/64
  SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);
  clr=SPSR;
  clr=SPDR;
  delay(10);
  write_led_numbers(0x78,0x78,0x78,0x78); //Blank display
  write_led_decimals(0x00); // All decimal points off
}

void write_led_decimals(int value)
{
   digitalWrite(SLAVESELECT, LOW);
   delay(10);
   spi_transfer(0x77);     // Decimal Point OpCode
   spi_transfer(value);    // Decimal Point Values
   digitalWrite(SLAVESELECT, HIGH); //release chip, signal end transfer
}
void write_led_numbers(int digit1, int digit2, int digit3, int digit4)
{
   digitalWrite(SLAVESELECT, LOW);
   delay(10);
   spi_transfer(digit1);    // Thousands Digit
   spi_transfer(digit2);    // Hundreds Digit
   spi_transfer(digit3);    // Tens Digit
   spi_transfer(digit4);    // Ones Digit
   digitalWrite(SLAVESELECT, HIGH); //release chip, signal end transfer
}
void write_led(unsigned short num, unsigned short base, unsigned short pad)
{
    unsigned short digit[4] = { 0, ' ', ' ', ' ' };
    unsigned short place = 0;

    if ( (base<2) || (base>16) || (num>(base*base*base*base-1)) ) {
        write_led_numbers(' ', 0x00, 0x0f, ' ');  // indicate overflow
    } else {
        while ( (num || pad) && (place<4) ) {
            if ( (num>0)  || pad )
                digit[place++] = num % base;
            num /= base;
        }
        write_led_numbers(digit[3], digit[2], digit[1], digit[0]);
    }
}

void loop()
{
 for (int i = 0; i < 9999; i++) {
     write_led (i,10,0);
     delay(100);
   }

}
3  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display using SPI on: July 18, 2009, 12:22:26 pm
Bump!
4  Forum 2005-2010 (read only) / Interfacing / 7 Segment Display using SPI on: July 13, 2009, 07:57:40 pm
Anybody have any experience with this 4 digit display using SPI?
It's from Sparkfun, item COM-09230
http://www.sparkfun.com/commerce/product_info.php?products_id=9230
I've looked at the SPI tutorials on Arduino.cc but can't quite make the jump when it comes to sending 4 byte hex packets.
5  Forum 2005-2010 (read only) / Interfacing / Re: MOSFET + H-Bridge for ultra low power on: April 27, 2009, 10:20:54 am
@AC:  So I built a proto using an STB24NF10 NPN MOSFET just to try.  It works but I can only get 2.5V into the h-bridge.  Could the current draw for the h-bridge plus the 10k resistors be dropping the voltage?  Do you think smaller resistors are worth trying?
6  Forum 2005-2010 (read only) / Interfacing / Re: MOSFET + H-Bridge for ultra low power on: April 25, 2009, 10:36:17 am
Thanks AC!  The gravitech item is slick.
I'd been doing some digging and also found the same app note.  The good thing is that I found the following after noodling about how to wire the bi-dir shifter up.

http://www.sparkfun.com/commerce/product_info.php?products_id=8745
7  Forum 2005-2010 (read only) / Interfacing / Re: MOSFET + H-Bridge for ultra low power on: April 24, 2009, 09:51:47 am
So I figured out how to use the enable pins to shut the h-bridge down.  Now my challenge is to boost the 3.3v arduino mini signals up to 5V so the logic levels on the h-bridge can be toggled.  I've tried using the MOSFET but it's NPN and inverts the signal.  I've also tried a PNP BJT but no joy.

Any ideas?

8  Forum 2005-2010 (read only) / Interfacing / MOSFET + H-Bridge for ultra low power on: April 19, 2009, 03:14:39 pm
I'm using an SN754410 to control a DC latching solenoid.  I'm sleeping the Arduino, wake on ext interrupt, pulse the solenoid open then close, then back to sleep.  The solenoid is wired like a bi-dir motor to pins 3 & 6.

All is good but the idle/standby/quiescent/leakage current of the hbridge VCC1 (pin16) is around 10mA, so too much for something I want to go at least a year b4 changing batts.

My lil noob brain thinks a MOSFET could be used to control power to VCC2 so it only draws current when pin enabled by the 'duino.  I just can't see how to wire it in.

Any help would be appreciated.

thx

sorry, i don't see an upload button to show my schematic  smiley-sad
9  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Measuring Amps out of Voltage Regulator on: April 16, 2009, 09:25:33 am
Ahhh, looks like the fuse is blown.  Thx for the help.
smiley Rob
10  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Measuring Amps out of Voltage Regulator on: April 16, 2009, 08:42:49 am
@Anachrocomputer
So what does it mean if the Arduino doesn't power up with the meter in line and set to measure current?

 :-?  
Pages: [1]