Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Project Guidance / Re: voltage up conversion for a solenoid on: November 27, 2013, 09:47:20 pm
dc42, I will start reading up on the things you suggested. The design that I took the solenoid from must use a flyback convertor because I do see an inductor on the board. I have no idea what the resistance is, Is this something I can check easily on my own?  If you have a simple schematic that would be fantastic!

PeterH, I appreciate the idea but I am trying not to run a second 12V battery. If at all possible I want to just up-convert the voltage so I can avoid using such a big battery.
2  Using Arduino / Project Guidance / voltage up conversion for a solenoid on: November 27, 2013, 12:52:37 pm
I have a water timer that connects to the water bib on the house which is used to automatically control when my lawn is watered. I would like to add an arduino for control along with wifi so that I can control my sprinkler system remotely. I took an existing system apart in order to borrow the required mechanics and generally figured out how it works but I am struggling with how to design some of the hardware. The primary system that I will borrow is the water connection to the hose bib which is controlled by a solenoid. I probed around the original board which runs on 3V and appears to charge a 2200uF cap to 12v which then discharges to trigger the solenoid. I am not sure what the technical term is but the solenoid is two way and does not require constant power to remain in any position. Meaning that if you apply momentary power the solenoid will open and if you reverse polarity the solenoid will remain closed without constant power. I will run my Arduino at 5V but I need some suggestions on a simple way to up convert the voltage to 12V for the cap. I also need to figure out a simple way of having the Arduino control the polarity reversal in order to both open and close the solenoid. If anyone can point me to some simple schematics or something to read about up converting voltage and reversing polarity I would appreciate it.
3  Using Arduino / General Electronics / Question about how to use ADC with high impedence input on: August 02, 2013, 04:23:11 pm
I am working with a bread board ATMEGA328P that is regulated to 2.8V running the internal 8mhz oscillator. I want to measure the voltage of a lipo battery which is 4.2V when fully charged. I use a voltage divider to reduce the lipo voltage and then connect to the ADC. On the Aruino side I use the internal 1.1V reference. This project runs on a tiny battery and I have to be super careful about every micro amp. With that in mind I used very high impedence resisters for the voltage divider to limit the current consumption on the ADC. I am still kind of new so that might be a bad idea but that was my thought process. For the voltage divider I used a 330k and 100k resistor which gives me a max voltage to the ADC of 0.977V. I sample the ADC 6 times and then divide the number in order to get the ADC number. I check the battery voltage every hour and then put the unit to sleep again.The problem I have is my readings seem to be inconsistent and I am pretty sure the issue is the resistor values. My question is what is the best option on the hardware side? Can I put a small cap in between the ADC and the voltage divider? Or do I really need to reduce the values of the resistors I am using?

Here is the code I am using to poll the ADC value.

Code:
ADCSRA |= (1 << ADEN); // Enable ADC
  analogReference(2); //sets the reference to 1.1V internal. Using a voltage divider off VCC for a max of 0.997
  digitalWrite(A1, INPUT); //ADC line to lipo
  pinMode(A1, LOW);
  volts = 0; //reset the variable
  delay(2000);
  for(int i = 0; i < 6; i++){
    volts = volts + analogRead(A1);     //get analog reading 6 times and then average them
    delay(100);
  }
  volts = volts /6;
  ADCSRA &= ~(1<<ADEN); //Disable ADC for power savings on shut down
4  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: March 05, 2013, 11:37:58 pm
I was actually able to get it working, but I am not 100% sure why. What I have found is that I need to transmit the page twice in order for it to write the buffer to the memory. For example this works

Code:
  i = 0;
  while (i < 60){
    dflash.Buffer_Write_Byte(1, i, messageline[i]);  //write to buffer 1, 1 byte at a time
    i++;
  }
 
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
}

This does not work.

Code:

  i = 0;
  while (i < 60){
    dflash.Buffer_Write_Byte(1, i, messageline[i]);  //write to buffer 1, 1 byte at a time
    i++;
  }
 
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
}


Any idea why writing the page twice would work? Maybe I need to send more don't care bits?
5  Using Arduino / Programming Questions / Re: Authorized SMS using GSM SHIELD on: March 05, 2013, 11:27:05 pm
What is the output you are getting with the code you posted?
6  Using Arduino / Storage / Re: Using the writeAnything utility without struct on: February 08, 2013, 09:30:03 am
I have used it with individual variables and it works fine. You just need to make sure not to put 2 variables at the same EEPROM address and you have to space the address far enough apart to not step on each other. But otherwise it works fine.
7  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: February 08, 2013, 09:24:58 am
The library would not compile initially but I changed WProgam.h to Arduino.h and I don't get any compile errors since then.
8  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: February 07, 2013, 07:20:49 am
IDE 1.0.3
9  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: February 06, 2013, 05:33:30 pm
I misunderstood your question the first time, hopefully this answers you properly. This is the complete sketch with the interrupt handler included.

Code:

#include <dataflash.h>

int page = 0;
int buffer = 1;
char messageline[60] = "#This is a test string for the flash memory";
char readFlash[60];
Dataflash dflash;
int i = 0;
volatile int seconds = 0; //used to keep time


SIGNAL(TIMER2_OVF_vect){
  seconds++;
}


void setup(){
  //Setup TIMER2
  TCCR2A = 0x00;
  TCCR2B = (1<<CS22)|(1<<CS21)|(1<<CS20); //Set CLK/1024 or overflow interrupt every 8s
  ASSR = (1<<AS2); //Enable asynchronous operation, 32kHz xtal needed
  TIMSK2 = (1<<TOIE2); //Enable the timer 2 interrupt. If this is disabled the sketch works properly
 
  sei(); //Enable global interrupts
   
  pinMode(A3, OUTPUT); //Flash VCC
  digitalWrite(A3, HIGH); //powers the flash memory up
  delay(4000);
 
  Serial.begin(9600);
  Serial.println("starting the sketch now");
  dflash.init(); //initialize the memory (pins are defined in dataflash.cpp
}

void loop(){
  writeData();
  readData();
  page++;
   
  delay(1000); //keep it from running so quickly in testing
}


void writeData(){
  Serial.print("I am writing page ");
  Serial.println(page);
  i = 0;
  while (i < 60){
    dflash.Buffer_Write_Byte(1, i, messageline[i]);  //write to buffer 1, 1 byte at a time
    i++;
  }
 
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
}

void readData(){
  Serial.print("reading page ");
  Serial.println(page);
  dflash.Page_To_Buffer(page, buffer);//copy page to the buffer
 
  i = 0;
  while(i < 60){
    readFlash[i] = dflash.Buffer_Read_Byte(buffer, i); //read the buffer
    i++;
  }
  Serial.println(' ');
  Serial.println(readFlash); //print what was read from the buffer
}

10  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: February 06, 2013, 05:11:41 pm
Sorry if it came across the wrong way but I really do need help. I need to get the external flash memory working on my project and I am at a loss on how to do that. During my original post I thought the only issue was the interrupts. However, I continued to test and found additional issues with the library such as if I try to write to page 6 it appears to write to page 3. It is not clear to me if I am writing to the wrong page or reading from the wrong page (or possibly both). I do not understand enough of the library to make the modifications to get it working. I am only guessing as to where the issue is but a reasonable place to start seemed to be with how the library assigns the page to memory. My problem is that despite the simplicity of the library I don't understand it. If you have suggestions on how to get the library working for my particular application or if you can suggest some reading I would greatly appreciate it!
11  Using Arduino / Storage / Re: AT45DB dataflash library problems with timer2 interrupt on: February 06, 2013, 08:55:15 am
this enables the timer 2 interrupt.

Code:
TIMSK2 = (1<<TOIE2);

If I change that to zero the problem goes away. Until I find a better solution what I have done for the moment is to disable global interrupts at the start and enable them right after I write using cli() and sei() like this.

Code:
void writeData(){
  Serial.print("I am writing page ");
  Serial.println(page);
  cli(); //disable interrupts
  i = 0;
  while (i < 60){
    dflash.Buffer_Write_Byte(1, i, messageline[i]);  //write to buffer 1, 1 byte at a time
    i++;
  }
 
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
sei(); //enable interrupts
}



However, since this post I have found more issues. The dataflash library was created for the AT45DB041B memory which is the older 4 megabit "B" version. I am using the newer 8 megabit "D" version. The legacy B commands still work on the D, but I think I have some issues because of the memory size difference. For example when I try to store the buffer to page 6 it appears to write the data on page 3 instead. I am guessing that the library calculates the internal memory based on the 4 megabit version and that the 8 megabit version is different. I looked through the library and found the section that deals with writing the buffer to the page. I can see where it calculates the upper and lower part of the address but I don't know how to interpret it. I cant figure out where it gets "pageBits" from and what does ">>" mean?

Code:
void Dataflash::Buffer_To_Page (unsigned char BufferNo, unsigned int PageAdr)
{
  DF_CS_inactive(); //make sure to toggle CS signal in order
  DF_CS_active(); //to reset Dataflash command decoder
  if (1 == BufferNo) //program flash page from buffer 1
  {
    DF_SPI_RW(Buf1ToFlashWE); //buffer 1 to flash with erase op-code
    DF_SPI_RW((unsigned char)(PageAdr >> (16 - PageBits))); //upper part of page address
    DF_SPI_RW((unsigned char)(PageAdr << (PageBits - 8))); //lower part of page address
    DF_SPI_RW(0x00); //don't cares
  }


 

12  Community / Gigs and Collaborations / paid support required for dataflash memory library on: February 05, 2013, 09:26:05 am
I am working with some AT45DB081D flash memory and I need some help which I am prepared to pay for. The issue I have is that I am using the dataflash library which you can find here.

http://playground.arduino.cc/code/dataflash

This library was developed for the AT45DB041B which has less memory and is an older version. The newer D version has more command options, although the documentation I find suggests that the legacy "B" commands are still supported. The general work flow for this memory is that if you want to write some data you first write the data to a buffer and then write that buffer to a page in memory. The problem I have is that if I specify for it to write to page 6 it will write to some other page like page 3 for example. I suspect the issue is in how the library calculates the address for the page since it was designed for a different size memory. Please PM me if you can help me update the library.
13  Using Arduino / Storage / AT45DB dataflash library problems with timer2 interrupt on: February 01, 2013, 06:24:50 pm
I am working with the dataflash library for the AT45DB series of flash memory which can be found here.
http://playground.arduino.cc/code/dataflash
I have the library working perfectly in some simple sketches but when I try to add it to my main code it becomes erratic and inconsistent. For example sometimes it wont write the page, it will fail to read pages sometimes, sometimes it will read a buffer but part of it. The errors are all over the place.

I am running a breadboard ATMEGA328P with the internal 8mhz oscillator and have a external 32.768 crystal. I use the external crystal to keep time and as an interrupt from sleep. A process of elimination has revealed that the cause of my problems is the timer2 interrupt. If I disable the timer2 interrupt my problems go away and the AT45DB works perfectly. In the sketch below I have it set to write the string from messageline into page 0. This loop will increment to the subsequent page and keep writing every page in the memory. This sketch example will consistently make it to page 3 and then hang for a a few seconds and then starts back at page 0. It does not seem to reset since I don't get the print statement from setup(), it just seems to start back from zero in the main loop which is quite strange. When I disable timer2 interrupt this sketch runs perfectly and writes/reads pages forever as it should (or at least until it runs out of pages).

My issue is that I don't want to disable timer2 even for a brief time since that will screw up my time keeping. Is there any way to keep the flash memory happy and keep my timer2 interrupt running?

Code:
#include <dataflash.h>

int page = 0;
int buffer = 1;
char messageline[60] = "#This is a test string for the flash memory";
char readFlash[60];
Dataflash dflash;
int i = 0;


void setup(){
    //Setup TIMER2
  TCCR2A = 0x00;
  TCCR2B = (1<<CS22)|(1<<CS21)|(1<<CS20); //Set CLK/1024 or overflow interrupt every 8s
  ASSR = (1<<AS2); //Enable asynchronous operation, 32kHz xtal needed
  TIMSK2 = (1<<TOIE2); //Enable the timer 2 interrupt. If this is disabled the sketch works properly
 
  sei(); //Enable global interrupts
   
  pinMode(A3, OUTPUT); //Flash VCC
  digitalWrite(A3, HIGH); //powers the flash memory up
  delay(4000);
 
  Serial.begin(9600);
  Serial.println("starting the sketch now");
  dflash.init(); //initialize the memory (pins are defined in dataflash.cpp
}

void loop(){
  writeData();
  readData();
  page++;
   
  delay(1000); //keep it from running so quickly in testing
}


void writeData(){
  Serial.print("I am writing page ");
  Serial.println(page);
  i = 0;
  while (i < 60){
    dflash.Buffer_Write_Byte(1, i, messageline[i]);  //write to buffer 1, 1 byte at a time
    i++;
  }
 
  dflash.Buffer_To_Page(1, page); //write the buffer to the memory on page: page
}

void readData(){
  Serial.print("reading page ");
  Serial.println(page);
  dflash.Page_To_Buffer(page, buffer);//copy page to the buffer
 
  i = 0;
  while(i < 60){
    readFlash[i] = dflash.Buffer_Read_Byte(buffer, i); //read the buffer
    i++;
  }
  Serial.println(' ');
  Serial.println(readFlash); //print what was read from the buffer
}
14  Using Arduino / Programming Questions / Re: Is it possible to send full $GPGGA line via GSM? on: January 27, 2013, 09:12:55 am
I would start by reviewing some of the code examples and libraries that you can find here.

Here is a GPS library. It takes most of the data from the $GPRMC string but it should have what you need. You could modify this code to use $GPGGA.
http://playground.arduino.cc/Tutorials/GPS

Or you could use a GPS library and this one works very well.
http://arduiniana.org/libraries/tinygps/

For transmitting over GSM here is a library you can try. I have never used this one but it is a place to start.
http://labs.arduino.cc/GPRS/Library
15  Using Arduino / Programming Questions / Re: Is it possible to send full $GPGGA line via GSM? on: January 27, 2013, 02:21:22 am
Yes, a full $GPGGA string is about 75 characters so you can use SMS, Email, FTP or what ever else you like.

Can you tell me a little bit more about what you are trying to do?
Pages: [1] 2 3 ... 7