Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 13
106  Using Arduino / Programming Questions / Re: Fomratting numbers on: January 06, 2013, 05:52:10 pm
I did something like this for my real time clock to display a 01,02,02...
It has a lot of other junk in there but all it really does is push the number to the right and jam a zero in front if less than 0.

  char second[2];
  int tmpsecond = bcdToDec(Wire.receive());

  if(tmpsecond < 10)
  {
   second[1] = second[0];
   second[0] = '0';
  }
  uoled.TextGraphic(112,10,SMALL_FONT,0xFFFF,1,1,second,1);
107  Community / Exhibition / Gallery / Tiny custom Leonardo design on: January 05, 2013, 03:59:37 pm
I just finished a tiny Leonardo type design that has a few different sensors on board. This one has a RTC, temperature chip, accelerometer, pushbutton and a rotary encoder. It also has the Leonardo bootloader on it which allows it to be pretty small. I'm not sure what it will do since my initial goal was to see if I could get the bootloader into an Atmega. After a few revisions I thought I would fit on as many sensors as possible. All the sensors and display are i2c so routing it was really easy. I'll start on the next one for fix the problems I've found so far. The rotary encoder is way too large so I might replace it with a 5 was navigation switch. The smallest one I've found is 12.5mm square. If you have an idea of what it can be used for then let me know. Maybe a logger of some sort. I'm no good at writing code but managed to get everything barley working last night. The unpopulated bits are the switching power supply. It works but for the weekend I just have it powered by USB to get some code into it. The layout was done in Altium so if you want the files or just the schematic as a pdf then just let me know. It was really fun.






108  Using Arduino / Displays / Re: 4D Systems Screens: A Genie for Your Arduino Sketch on: December 18, 2012, 07:33:46 am
Nice! I've used the color uOLED-128 in the past and while expensive, it is by far the most beautiful screen. I wonder if the Genie software works on just LED screens or both OLED and LCD.

109  Using Arduino / Programming Questions / Re: Displaying temperature on a MAX6951 on: December 18, 2012, 07:20:54 am
I have corrected post by posting code the proper way. Thanks PaulS.

110  Using Arduino / Programming Questions / Displaying temperature on a MAX6951 on: December 17, 2012, 01:49:10 pm
I found code for driving the MAX6951 on this site that displays digits from the serial terminal. I've modified the code and attached a 1-wire temperature ic but the digits are pushed to the far left of the display with what was zeros to the right.  0x03 in the SCANLIMIT_ADDRESS will knock off the trailing zeros but I was wondering if the temperature can easily be pushed to the right. I believe that having SCANLIMIT_ADDRESS to 0x0F and putting blank digits in the first two spots will work but I have no idea how to do this.


Code:

/*
Using SPI for interfacing to MAX6951

- pin 13      SCK      SPI clock  ,DISPLAY CLK, PIN#2    
- pin 12      MISO     SPI master in, slave out  ,NOT USED
- pin 11      MOSI     SPI master out, slave in ,DISPLAY DIN, PIN#4
- pin 10      SS       SPI slave select, DISPLAY CS, PIN#3

The default SPI configuation is as follows:

- SPI Master enabled
- MSB of the data byte transmitted first
- SPI mode 0 (CPOL = 0, CPHA = 0)
- SPI clock frequency = system clock / 4

*/
#include <studio.h>
#include <OneWire.h>  //for DS18S20 temp sensor
#include <SPI.h>  // bring in SPI Library
// SPI uses hardware Chip Select vs having device address
#define DECODE_ADDRESS 0x01// 0x07, all 8 on
#define INTENSITY_ADDRESS 0x02 // 0x07 to start, half intensity 02
#define SCANLIMIT_ADDRESS 0x03 // 0x07, all 8 on  
#define CONFIG_ADDRESS 0x04
// 0000 0001 => 0 shutdown, 1 = normal mode, no fooling with blink modes & stuff
// 0000 0010 = not used
// 0000 0100 => 0  slow blink, 1 = fast blink
// 0000 1000 => 0 = global blink disabled (Plane 1 data ignored), 1  global blink enabled Plane 1 data used)
// 0001 0000 => 0 = blink unaffected during I2C acknowledge
// 0010 0000 => 0 = data unaffected during I2C ack, 1 = data cleared
// 0100 0000 => not used
// 1000 0000 => blank phase - blink status is read back

// for this use: 0000 0101 => normal operation, fast blink
#define DISPLAYTEST_ADDRESS 0x07 // 0x01, on, 0x00 off 07
#define DIGIT0_ADDRESS 0x20 // write Plane 0 20
#define DIGIT1_ADDRESS 0x21 // write Plane 0 21
#define DIGIT2_ADDRESS 0x22 // write Plane 0
#define DIGIT3_ADDRESS 0x23 // write Plane 0
#define DIGIT4_ADDRESS 0x24 // write Plane 0
#define DIGIT5_ADDRESS 0x25 // write Plane 0
#define DIGIT6_ADDRESS 0x26 // write Plane 0
#define DIGIT7_ADDRESS 0x27 // write Plane 0

int DS18S20_Pin = 0; //DS18S20 Signal pin on digital 0
int ColonLED=3;
const int slaveSelectPin = 10;

int led = 3;
//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 2

void setup()
{
 Serial.begin(9600); //monitor Temp
 // define pins used - 13,12,11,10 defined by SPI
 pinMode(ColonLED, OUTPUT);
 //pinMode(SS, OUTPUT);
 pinMode (slaveSelectPin, OUTPUT);
 
 pinMode(led, OUTPUT);

 // start up SPI
 SPI.begin(); // nothing in () because we are the master

 //  write config register  
 digitalWrite(slaveSelectPin,LOW);
 SPI.transfer(CONFIG_ADDRESS);  // select the Address,
 SPI.transfer(0x05);      // select the data 5
 digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
 

 //  write intensity register
 digitalWrite(slaveSelectPin,LOW);
 SPI.transfer(INTENSITY_ADDRESS);  // select the Address,
 SPI.transfer(0x00);  //DIM Display  ,0x0E is full brightness
 
 
 digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
 //Serial.println("intensity register");

 // write scanlimit register
 digitalWrite(slaveSelectPin,LOW); // take the SS pin low to select the chip:
 SPI.transfer(SCANLIMIT_ADDRESS);  // select the Address,
 SPI.transfer(0x0F);      // select the data //Was 0F
 digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
 
 // write decode register
 digitalWrite(slaveSelectPin,LOW); // take the SS pin low to select the chip:
 SPI.transfer(DECODE_ADDRESS);  // select the Address,
 SPI.transfer(0xFF);      // select the data, FF
 //digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
 digitalWrite(slaveSelectPin,HIGH);
 //Serial.println("decode register");

 //display test  
 digitalWrite(slaveSelectPin,LOW); // take the SS pin low to select the chip:
 SPI.transfer(DISPLAYTEST_ADDRESS);  // select the Address,
 SPI.transfer(0x00);      // select the data,01
 digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
 delay (1000);
}


void loop()
{  
  float temperature = getTemp();
  int t = temperature*100;  //get rid of decimel point

  int ones = t%10;
  int tens = (t/10)%10;
  int hundreds = (t/100)%10;
  int thousands = (t/1000)%10;
  write_digits(0x00,0x00,ones,tens,hundreds+0x80,thousands); //0x80 is the decimal
}

static void write_digits(int u, int v,int w,int x, int y, int z)
{
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT5_ADDRESS);
   SPI.transfer(u);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT4_ADDRESS);
   SPI.transfer(v);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT3_ADDRESS);
   SPI.transfer(w);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT2_ADDRESS);  // select the Address,
   SPI.transfer(x);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT1_ADDRESS);  // select the Address,
   SPI.transfer(y);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
  
   digitalWrite(slaveSelectPin,LOW);
   SPI.transfer(DIGIT0_ADDRESS);  // select the Address,
   SPI.transfer(z);      // select the data
   digitalWrite(slaveSelectPin,HIGH);
}

float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE); // Read Scratchpad

  
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
  
  ds.reset_search();
  
  byte MSB = data[1];
  byte LSB = data[0];
 
  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  
  float test = ((MSB << 8) | LSB);
  return TemperatureSum;
}


111  Community / Gigs and Collaborations / Re: Customized Arduino designs offered on: December 15, 2012, 07:37:33 am
I use OSHPark for my board manufacturing. 13 mil drill via holes and 6 mil width tracks. A 2"x2" two layer board is around $15 + $5 shipping and a 4 layer board that size is around $20 + $5 shipping. The only problem is that the turn around time is a month.
112  Community / Gigs and Collaborations / Re: Customized Arduino designs offered on: December 14, 2012, 07:03:39 pm
Great idea. I have also embedded my Solidworks 3d models into my Altium footprints. Ill be in touch soon.

Mike
113  Community / Gigs and Collaborations / Re: Customized Arduino designs offered on: December 14, 2012, 09:42:26 am
I use Altium Designer.
114  Community / Gigs and Collaborations / Customized Arduino designs offered on: December 14, 2012, 09:01:52 am
My full time job is PCB design work and 3D modeling so as a hobby I've made a few customized arduino boards. Over the past few months I've built up a good size schematic and footprint library using the 328P and 23U4 with TQFP and the smaller MLF footprints. So far the cheapest manufacturer I've found is OSHPark which has done a fine job. If you have a project on a breadboard and would like it much smaller on a custom board then I can possibly help.
A few examples are:
h**ps://sites.google.com/site/0miker0/Designing-your-custom-Arduino-Board

Mike
115  Using Arduino / Programming Questions / How do I create a new makefile? on: November 27, 2012, 12:15:19 pm
I would like to edit the 16Mhz frequency on the Caterina makefile to be 8Mhz. How do I actually create the new makefile after editing this line? All I have is Arduino 1.0.2 now installed. Nothing else programming related.

Mike
116  Using Arduino / Programming Questions / Get units, 10ths and 100ths of a value on: November 21, 2012, 01:47:37 pm
How can I get break up and integer to get the 100ths or 1000value?

int t= 1234

int a = t % 10;  //get units
//I see a value on the serial monitor of 4

 x = x/10;
 int b = t % 10; // get tens value
//I see a value on the serial monitor of 3

How can I see the 2 and the 1?

Mike
117  Using Arduino / Programming Questions / Re: Float to array? on: November 20, 2012, 07:36:31 pm
It works! Thanks to all for the help. I'm trying to figure it now since I stick to hardware design and rarely write code. I have no idea what the line t /= 10; is yet but i'll figure it out. I think I have the rest of it in my head.

Mike
118  Using Arduino / Programming Questions / Float to array? on: November 20, 2012, 03:25:30 pm
I have a few seven segment leds and I want the temperature ic float displayed. The code is set up so an integer is assigned to each digit.
(working test code)
 int a=1;
 int b=2;
 int c=3;
write_digits(a,b,c);

Is there an easy way to have a float to array? Then my temperature ic could do something like:
float temperature = getTemp();
somehow put the float into an array
write_digits(temp[0],temp[1],temp[2],temp[3]);
119  Using Arduino / Microcontrollers / Atmega32u4 from 5V to 3.3V on: November 17, 2012, 01:52:18 pm
If I have a custom board that has the Atmega32u4 using the Leonardo bootloader and I want to convert from 5V to 3.3V I believe I just modify the USB circuitry so it is no longer on the same power supply as the micro. Someone I was talking to mentioned that the crystal will have to be dropped from 16Mhz to 8Mhz as well. Can the same exact bootloader for the 5V, 16Mhz board work fine on the same board at 8Mhz 3.3V or will it have to me modified in some way? I know nothing about the bootloader or how it works.
120  Using Arduino / Project Guidance / Parts selection for a prototype board on: November 01, 2012, 06:30:38 am
I'm working on a prototype board that will monitor a few sensors. It's just a fun hobby project so I was thinking a clean design might be a switching power supply, micro and maybe three sensors all using the same bus. Just the two i2C lines could out and three sensors could all be side by side. My coding is not the best so i'm looking for parts that have a fair amount of example code to help me get each part working. My components so far are:
Temperature: TMP75
Possibly a LM75A or a TMP102
Accelerometer: ADXL345
Real Time Clock: DS1307 sounds like the best one to go with.

Mike
Pages: 1 ... 6 7 [8] 9 10 ... 13