Show Posts
Pages: [1] 2 3 ... 18
1  Using Arduino / Displays / Re: OLED display with 4-wire SPI mode, but without CS on: March 10, 2014, 08:01:40 am
This thread came at the perfect time for me.  I just purchased ten 128X32 displays from a distributer on aliexpress for about $2.50 a piece.  They were advertised as SSD1306 but when I tried them out with the adafruit oled library they didn't work.  The screen was all garbled but I could see the graphics in the example sketch running at the bottom of the screen.  I thought perhaps the reason the displays were so cheap were that they were defective.  Thankfully I came across this thread and tried out the u8glib.  I changed the line:

Code:
0x000, /* set lower 4 bit of the col adr. to 4  */

to

Code:
0x004, /* set lower 4 bit of the col adr. to 4  */

(0x002 didn't quite shift the text over enough to get it on the screen)

and then ran the "Hello World!" example.  It is running like a top now!  Still doesn't work with the adafruit library but I'm sure I could dig in to it and find the line that needs to be changed.  For now I am comfortable just using the u8glib :-)

I'm curious where in the library the internal charge pump is enabled.  I found this line:

Code:
0x08d, 0x010, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */

but I notice that it doesn't make a difference whether I use 0x010 or 0x014.  It works either way.  What if I wanted to use an external supply to drive the display (not that I want to….just curious)?
2  Using Arduino / Project Guidance / Re: DS Onewire program working about 90% of the time. Shooting for 100% on: March 02, 2014, 07:57:08 am
Another option is to power the device using another port pin and connect the 4.7K resistor between it and DQ.

That's a pretty good idea!  I have lots of extra port pins.
3  Using Arduino / Project Guidance / Re: Relay options for outlet control on: March 01, 2014, 11:59:05 am
I've gotten relay boards off of ebay and they work great!

http://www.ebay.com/itm/8-Channel-5V-Relay-Module-Board-Shield-for-Arduino-PIC-AVR-MCU-DSP-ARM-US-Stock-/360717697832?pt=LH_DefaultDomain_0&hash=item53fc734328

If you are willing to wait a few weeks you can get great deals from China.

http://www.ebay.com/itm/5V-4-channel-Relay-Interface-Board-for-Microcontrollers-Arduino-PIC-AVR-MCU-DSP-/130937566565?pt=LH_DefaultDomain_0&hash=item1e7c7cb565

I know this doesn't answer your question about whether or not SSR's are cheaper, but I figured I would throw my two cents in regarding purchasing the standard relays.  I use mine for controlling my water top off and automatic water change system on my saltwater reef aquarium.



4  Using Arduino / Project Guidance / Re: DS Onewire program working about 90% of the time. Shooting for 100% on: March 01, 2014, 11:44:04 am
Quote
Seems like if it works once it should work each time.
Nope. Wishing and hoping aren't going to make it work when you've ignored the specification.

Use a 4.7k pullup resistor as is required.

Pete

I'm sure you are right :-(

I will say that I have a new piece of information though.  I unplugged the Serial LCD display that I had hooked to the MCU and all of a sudden the thing is running like a top.  Still the occasional error but it is more like 1 in 100 readings now.  Not sure what the LCD display has to do with the missed readings.  I guess I could just grab all of the bytes from the scratchpad and throw out any readings that don't match up with the CRC.  Certainly the correct course of action would be to use the 4.7k resistor but then I would need a 5V spot on the pin header to plug it in to and I am already using the only 5V spot for the LCD.  Bummer.
5  Using Arduino / Project Guidance / Re: DS Onewire program working about 90% of the time. Shooting for 100% on: March 01, 2014, 11:09:17 am
This is kind of an example of what I am getting out.  It works great for a few times…then crap….then great…..then more crap.  Seems like if it works once it should work each time.

Code:
€65.4125       
þ€526.2125       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€526.2125       
þ€65.4125       
þ€65.4125       
þ€65.5250       
þ€65.5250       
þ€65.4125       
þ€526.2125       
þ€65.4125       
þ€65.4125       
þ€65.5250       
þ€65.5250       
þ€65.4125       
þ€526.2125       
þ€65.4125       
þ€65.4125       
þ€65.5250       
þ€65.5250       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.4125       
þ€65.5250       
þ€67.3250       
þ€65.5250       
þ€987.1250       
þ€65.4125       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€67.3250       
þ€65.5250       
þ€987.1250       
þ€65.5250       
þ€65.5250       
þ€65.5250       
þ€65.4125       
þ€65.5250       
þ€65.4125       
þ€67.2125       
þ€65.4125       
þ€987.0125       
þ€67.2125       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€65.4125       
þ€987.0125       
þ€67.2125       
þ€65.4125       
þ€987.0125       
þ€67.2125       
þ€65.4125       
þ€987.0
6  Using Arduino / Project Guidance / Re: DS Onewire program working about 90% of the time. Shooting for 100% on: March 01, 2014, 11:06:10 am
Four things:
1) how long is the cable?

It's about 12 inches.


Quote
2) IIRC the internal pull up is way bigger than the 4K7  -  50K ? -
so the signal is pulled to 5V much slower possibly causing read errors as the signal isn't stable

I was worried about this but then when I started to get valid data out after sending a read rom command, I figured it should work out.

Quote
3) furthermore in your communication you have function call overhead e.g. for writeOne() and writeZero().
you could make them inline (just adding inline for function definition) or adjust timing.

What do you mean by "inline"?  Is that just putting the pin changes in the routine rather than calling another function to do it?

Quote
4) constructs like this   
Code:
  pinLow();
  delayMicroseconds(3);
  pinHigh();
are quite critical as function calls can take a few miliseconds.

so advise: have a really good look at the timing!

I assume you mean microseconds for the function calls.  It there a way to determine how many microseconds the function call is eating up?

Thanks for your help with this.  I really appreciate it!
7  Using Arduino / Project Guidance / DS Onewire program working about 90% of the time. Shooting for 100% on: March 01, 2014, 10:23:11 am
I am trying to roll my own DS Onewire program (not using the library) to read a DS18B20.  I notice that most of the code online assumes a 4.7K pull-up resistor on the DQ line but I wanted to use the internal pull-ups on the arduino.  It is actually working quite well except that every 10 readings or so my arduino just receives junk from the onewire device.  This happens more frequently the cooler the temperature gets.  At roughly freezing temperatures, it starts happening about every 5 readings or so.  I couldn't find anything in the data sheet that suggests that the communication timings should be different at different temperatures so I am a bit confused.  I tried playing with different delays in my receive_bit() function but nothing seemed to help.  Any insight that people can give me would be great.  The whole sketch is below.

Code:
#define datapin 2


void setup()
{
  Serial.begin(9600);
  Serial.write(254);
  Serial.write(0x01);
  pinMode(datapin, INPUT);
  digitalWrite(datapin, HIGH);
}

void loop()
{
 
  Serial.write(254);
  Serial.write(128);
 
  long HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
 
  reset_onewire();
  send_byte(0xCC);  //skip ROM
  //for(int i = 0; i<8; i++)
  {
    //Serial.print(receive_byte(), HEX);
    //Serial.print(" ");
  }
 
  //Serial.println();
  //Serial.println(reset_onewire());
  //send_byte(0xCC);
  send_byte(0x44); //take a temperature reading
  strong_pullup(); //active high for at least 750ms
  reset_onewire();
  send_byte(0xCC);
  send_byte(0xBE);
 
 
 
  LowByte = receive_byte();
  HighByte = receive_byte();
  //Serial.print(LowByte,BIN);
  //Serial.println(HighByte, BIN);
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
    TReading *= -1;
  }
  //Serial.println(TReading);
  Tc_100 = (((TReading * 625)*18)/10)+320000;    // multiply by (100 * 0.0625) or 6.25
  //Serial.println(Tc_100);
  //Tc_100 = ((Tc_100*900)/500) + 3200;
 
  Whole = Tc_100 / 10000;  // separate off the whole and fractional portions
  Fract = Tc_100 % 10000;
  if(SignBit) Tc_100 = 10000 - Tc_100;

  if (Whole < 0) // If its negative
  {
     Serial.print("-");
  }
  Serial.print(Whole);
  Serial.print(".");
  if (Fract < 1000)
  {
     Serial.print("0");
  }
  Serial.print(Fract);

  Serial.println("        ");
  delay(1000);
}

//drive the data pin active low
void pinLow()
{
  digitalWrite(datapin, LOW);
  pinMode(datapin, OUTPUT);
}

//let the pin float back up to VCC
//through the internal pullup resistor
void pinHigh()
{
  pinMode(datapin, INPUT);
  digitalWrite(datapin, HIGH);
}

void strong_pullup()
{
  pinMode(datapin, OUTPUT);
  digitalWrite(datapin, HIGH);
  delay(1000);
  pinMode(datapin, INPUT);
  digitalWrite(datapin, HIGH);
}

//send reset pulse and listen for presence pulse
boolean reset_onewire()
{
  boolean b;
  pinLow();
  delayMicroseconds(500);
  pinHigh();
  delayMicroseconds(90);
  b = digitalRead(datapin);
  delayMicroseconds(500);
  return !b;  //return true if we get a low pulse
}

//send a one bit
void writeOne()
{
  pinLow();
  delayMicroseconds(10);
  pinHigh();
  delayMicroseconds(50);
}

//send a zero bit
void writeZero()
{
  pinLow();
  delayMicroseconds(60);
  pinHigh();
  delayMicroseconds(3);
}

//shift out a single bit
void send_bit(boolean b)
{
  if(b)
  {
    writeOne();
  }
  else
  {
    writeZero();
  }
}

//receive a single bit
boolean receive_bit()
{
  boolean b;
  pinLow();
  delayMicroseconds(3);
  pinHigh();
  delayMicroseconds(7);
  b = digitalRead(datapin);
  delayMicroseconds(45);
  //Serial.print(b);
  return b;
}

//shift out a full byte
void send_byte(byte v)
{
  byte mask;
  for(mask = 1; mask; mask<<=1)
  {
    send_bit(mask & v);

  }
  //Serial.println();
 
}

//receive a full byte
//00000000
//
byte receive_byte()
{
  byte data = 0;
  byte mask = 0;
 
  for(mask = 1; mask; mask <<= 1)
  {
    if(receive_bit()) data |= mask;
  }
 
  return data;
}
8  Using Arduino / Programming Questions / Re: shifting out data one bit at a time isn't working on: February 24, 2014, 06:15:01 pm
Fantastic!  All good to go now.  Thanks!
9  Using Arduino / Programming Questions / shifting out data one bit at a time isn't working on: February 23, 2014, 09:53:17 pm
I'm trying to roll my own onewire functions and I am getting hung up pretty early.

This is the snippet that is having problems.

Code:
void loop()
{
  //Serial.println(reset());
  send_byte(10110110);
  delay(1000);
}

void send_byte(byte v)
{
  byte mask;
  for(mask = 1; mask; mask<<=1)
  {
    //send_bit(mask & v);
    if(mask & v)
    {
    Serial.print(1);
    }
    else
    {
      Serial.print(0);
    }
  }
  Serial.println();
 
}

This is what I get as output from the Serial.print:

Code:
01111001
0
01111001
0
01111001
0
01111001
0


Why is it not shifting out:

Code:
10110110
0
10110110
0
10110110
10  Using Arduino / Programming Questions / Re: SoftwareSerial - using transmit only and use the RX pin for something else on: December 22, 2013, 11:58:59 am

Oh wow……It's like it was made just for me:-)  Thanks for your help!!!
11  Using Arduino / Programming Questions / SoftwareSerial - using transmit only and use the RX pin for something else on: December 22, 2013, 09:31:12 am
Hello!  I want to use an attiny85 for a project but I need to use all of the available pins.  I will have an lcd display with a uart backpack and it only needs one pin for communication.  My understanding (although it could be wrong) is that since the attiny85 doesn't have UART, I have to use the softwareserial library to implement that type of functionality.  I would like to use one pin for TX and I don't need a RX pin.  I would like to use the RX pin for something else such as a button input.  Is this easy to do?
12  Using Arduino / Project Guidance / Re: Is a DC-DC boost IC worthwhile for a very low power board? on: July 21, 2013, 07:13:31 pm
+1 for Nick Gammon's link.  I am using a single liPo cell on a breadboarded atmega328 and when I put it to sleep using Nick's fantastic instructions, I can go days without the battery voltage dropping by even a tenth of a volt.
13  Using Arduino / Project Guidance / Re: Temperature Probe DS18B20 on: July 21, 2013, 07:09:08 pm
Make sure you incorporate some hysteresis in the sketch or else the fans will be cycling on and off very rapidly.
14  Using Arduino / Project Guidance / Re: I'm out of memory? Is the next thing up the Mega644P? on: July 05, 2013, 05:22:04 pm
I plan to order the PDIP version of the 1284P on my next mouser purchase so that I can breadboard my project and hopefully I can try out some of these fixes.
15  Using Arduino / Project Guidance / Re: I'm out of memory? Is the next thing up the Mega644P? on: July 04, 2013, 09:57:40 pm
I think most of those items will still be applicable, except possibly the RX0
problem. Depends on whether the RX0 pin is located adjacent to the
Oscillator-in pin on the chip you use. Also, maniac bug still hasn't fixed
the Bobuino variant file. And you will still need to check all of the
library files for proper 1284 support.

Excellent!  Thanks!
Pages: [1] 2 3 ... 18