Show Posts
Pages: 1 [2] 3 4 ... 20
16  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 02:25:00 pm
I can't open your flicker picture, would be better if you use Additional Options, Browse to your locally stored file, and Attach it.

I attached the file as you instructed.

Quote
You mention
Quote
why is there voltage after the P-Channel Mosfet when the gate voltage is brought high?
If the control signals to devices powered by that line are high, the voltage can leakt thru their input clamp diodes and power the device.  If you plan to cut power, you should bring their IO lines first so that doesn't occur.

This is what I thought may be happening.  So I should set all of the lines to input and low before turning everything off.  What should the lines be set to when the device is on?  This would be SPI so we have CS, MISO, MOSI, and CLK.
17  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 12:21:32 pm
You might just have a bad analog pin. Note that the signal has a pull-up resistor to 3.3vdc at the mosfet, so the signal line will be a high is the pin is open circuit internally in the chip. Have you tried your 3 second test sketch on some of the other analog pins?



The pin seems to be working fine on a different sketch that I wrote.  My problem seems to be something else now.  The video above explains the problem that I am happening.  Any insight that you can offer would be great!
18  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 09:58:51 am
I ran it with the actual intended program for this board and the gate voltage was doing what it was supposed to do.  This brings up another problem which is, why is there voltage after the P-Channel Mosfet when the gate voltage is brought high?  I made a video to help explain my problem.

19  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 09:03:31 am
Well it's not an official Arduino Pro Mini.  It's my own circuit that shares the same pin assignmens of the Arduino Pro Mini, runs at 3.3v and 8 mhz and has a bunch of other stuff on it.  Schematic is attached at the bottom.



The eagle files and code are located here and here:

https://github.com/jerseyguy1996/Leslie-GPS-Eagle-Files

https://github.com/jerseyguy1996/Leslie_GPS_1_0

Pin A5 is connected to the P-Channel Mosfet located right around the middle of the schematic, labeled U$4 (because I was too lazy to change the Eagle assigned label).  It is there to cut power to the OLED, SD card, and GPS to save on power when the micro controller is asleep.  The GPS's backup is kept connected to V+ to maintain its memory.  I noticed when testing it out that the display was not turning off when the micro controller would go to sleep.  It would however dim slightly.  That's when I started looking at the voltage at the gate of the mosfet using the blink sketch.  What I saw was that the gate voltage was staying at +3.3v and not alternating  between 3.3 and ground.  There is continuity between the mcu pin and the gate so I assume that whatever is happening at the gate is happening at the pin as well.  My voltmeter probes aren't small enough to check the actual pin voltage without bumping in to the pins next to it.  
20  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 20, 2014, 09:03:21 pm
I've always used 14 to 19 instead of A0 to A5, makes it more clear that digital is being used.
So:
Code:
byte pin19 = 19;
void setup() {               
  // initialize the digital pin as an output.
  pinMode(pin19, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(pin19, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(pin19, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);               // wait for a second
}
3000 = 3 seconds, not 1 second

I tried using '19' instead of 'A5' after I did my post but it still didn't work.  I changed it to delay 3 seconds to give my multi meter time to stabilize.  Any other ideas?  Could it be something specific to the pro mini?
21  Using Arduino / Project Guidance / Addressing analog pins on the arduino pro mini on: April 20, 2014, 08:26:01 pm
I am having trouble addressing analog pin A5 as a digitalPin on the arduino pro mini.  Using code:

Code:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(A5, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(A5, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(A5, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);               // wait for a second
}

I would expect to see the voltage on PIN A5 alternate between +3.3V and GND.  All I am seeing is plus 3.3V though.  Am I addressing the pin incorrectly?
22  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)?
23  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.
24  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.



25  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.
26  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
27  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!
28  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;
}
29  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!
30  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
Pages: 1 [2] 3 4 ... 20