6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 10, 2024 4:59 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Thu Mar 28, 2019 4:24 pm 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
Greetings,

Recently, I've been unable to write to a 28c256 EEPROM despite my best efforts (http://forum.6502.org/viewtopic.php?f=12&t=5584). Due to this, I've began looking for alternatives and my idea right now is to use a battery to maintain an SRAM chip powered while I transfer it from my programmer to my board.

I am planning to use 2 CR2032 batteries for a total voltage of 6v (Unless 3v is enough to keep the data on the chip?) and a couple of diodes in order to keep the battery from powering other parts of the board, and to keep the power supply from overpowering the batteries.

This is my circuit diagram:
Attachment:
IMG_20190328_100539.jpg
IMG_20190328_100539.jpg [ 141.35 KiB | Viewed 1879 times ]


Would this work? This simple circuit is the first I have ever designed, so any pointers would be appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 28, 2019 6:00 pm 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1007
Location: Canada
I would use a single CR2032 and a pair of Schottky diodes like the 1N60P to ensure the battery diode turned off when the 5V is applied.

The no-load voltage of a CR2032 is about 3.3V~3.4V giving you up to 6.8V total. The Vf of a 1N4001 at very low current is under 0.8V, so you might end up draining your CR2032s pretty quickly while the RAM is active.

The standby current for a something like CY62256NLL (note the LL designation) would amount to practically no load on the CR2032.

_________________
Bill


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 28, 2019 6:53 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8538
Location: Southern California
If the SRAM has a low-power data-retention mode, it will work on just a couple of volts. You don't won't 5V on it for that, as the power requirement will be much higher. I show a simple circuit at viewtopic.php?f=4&t=573&p=32004#p32004 (although it sounds like you might not be particularly interested in long-term backing on fleapower.)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 2:21 am 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
GARTHWILSON wrote:
If the SRAM has a low-power data-retention mode, it will work on just a couple of volts. You don't won't 5V on it for that, as the power requirement will be much higher. I show a simple circuit at viewtopic.php?f=4&t=573&p=32004#p32004 (although it sounds like you might not be particularly interested in long-term backing on fleapower.)


Hello, I'm very new to everything concerning circuit analysis (Though I'm trying to learn as fast as I can). I have a few questions concerning the functionality of figure 1 in that image:

1. How do the resistors connected to RD, WR and CS prevent current from flowing when 5v is connected? Shouldn't current always flow through these resistors (Although less of it), making the input on these pins always high?
2. My intuition tells me that he higher voltage coming from the power supply prevents the current from exiting the diode near the lower voltage battery. Is this assumption correct, or does a small amount of current always flow out of the battery?
3. Why would you need to open the switches from RD, WR, and CS whenever the power supply is inactive?

Thank you.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 2:44 am 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
BillO wrote:
I would use a single CR2032 and a pair of Schottky diodes like the 1N60P to ensure the battery diode turned off when the 5V is applied.

The no-load voltage of a CR2032 is about 3.3V~3.4V giving you up to 6.8V total. The Vf of a 1N4001 at very low current is under 0.8V, so you might end up draining your CR2032s pretty quickly while the RAM is active.

The standby current for a something like CY62256NLL (note the LL designation) would amount to practically no load on the CR2032.


I have a couple of 1N5822 Schottky Diodes on hand, and from the graphs on the datasheets, as far as I can tell they have an even lower forward voltage than the 1N60P. Would they work?

Is there any reason why the Vf vs A graph of the 1N5822 looks like a logarithmic function as opposed to the 1N60P looking like an exponential function?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 2:53 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
The pull-up resistors are there to keep the control inputs in their false position when the 5v power fails. Pull-ups are generally chosen so that they can do their job quickly enough, but also so that they can be overwhelmed by an output driver. A CMOS output ideally shorts to Vcc or GND, depending on its state, and the real-world ones can approximate this fairly well.

When the 5v power is applied, the voltage across the diode is -1.4v, so the diode doesn't conduct. I would expect the battery to be under no load with the 5v power active.

I think the switches would need to be opened to prevent the battery from powering anything else. There are protection diodes on the I/O pins of most chips, and you can actually power things through those if you're not careful.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 4:17 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8538
Location: Southern California
DerTrueForce answered part of it, so I won't repeat that.

Note that the NiCd battery is charging (through the transistor base) when the power is up. I'm not fond of NiCd batteries, but the article was printed over 21 years ago. Doing it today with a lithium cell, you'd probably want a zener diode or maybe blue LED across the battery so current continues to flow after it has reached full charge, without damaging the battery. I have not taken the time to figure out the best way to do it.

Note also that Schottky diodes have a lot of reverse leakage.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 2:24 pm 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1007
Location: Canada
The 1N5822 diodes are silicon and the 1N60 diodes are germanium, that explains why their Vf vs. Af curves look so different.

Also, the !N5822 diodes, as Garth mentions, do have a fairly high reverse leakage current. The 1N60s are far better in this respect.

However, this PDF from Cypress does not recommend the method you are suggesting (with the addition of a required resistor from chip Vcc to /CE). https://www.cypress.com/file/38171/download

Depending on your circuit, it may or may not work very well. They suggest using a supervisory chip to look after the RAM and give examples.

There are non-volatile static rams available. Have you looked into them?

_________________
Bill


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 4:22 pm 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
BillO wrote:
The 1N5822 diodes are silicon and the 1N60 diodes are germanium, that explains why their Vf vs. Af curves look so different.

Also, the !N5822 diodes, as Garth mentions, do have a fairly high reverse leakage current. The 1N60s are far better in this respect.

However, this PDF from Cypress does not recommend the method you are suggesting (with the addition of a required resistor from chip Vcc to /CE). https://www.cypress.com/file/38171/download

Depending on your circuit, it may or may not work very well. They suggest using a supervisory chip to look after the RAM and give examples.

There are non-volatile static rams available. Have you looked into them?


Thank you! That PDF from Cypress was very useful. I read through it, and it says that this type of design is not recommended because the diodes inside of the microprocessor might draw too much current and drain the battery. This is not a problem, though, since I only need to have the battery active for a very small amount of time while I swap out the chip. I might also have to use the pull-up resistor shown there as well, since I didn't know floating pins could be a problem (Could floating pins cause an inadvertent write?)

I also looked at the nvSRAM and it looks like it would do exactly what I need! However, it doesn't come in DIP and it is very expensive. Since my whole purpose of doing this was avoiding the cost of an EEPROM programmer, it wouldn't be very good for my purposes.

I will also follow your advice and use the diode type you recommend.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 4:26 pm 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
DerTrueForce wrote:
The pull-up resistors are there to keep the control inputs in their false position when the 5v power fails. Pull-ups are generally chosen so that they can do their job quickly enough, but also so that they can be overwhelmed by an output driver. A CMOS output ideally shorts to Vcc or GND, depending on its state, and the real-world ones can approximate this fairly well.

When the 5v power is applied, the voltage across the diode is -1.4v, so the diode doesn't conduct. I would expect the battery to be under no load with the 5v power active.

I think the switches would need to be opened to prevent the battery from powering anything else. There are protection diodes on the I/O pins of most chips, and you can actually power things through those if you're not careful.


I understand what pull-up resistors do now, but I am having trouble understanding what is happening from a conceptual standpoint. I read elsewhere that the resistor used should have a lower impedance than the IC output. Does voltage always equal what is being output by the higher impedance output?

Perhaps you could point me to some readings?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 5:01 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10975
Location: England
If I can jump in... if you can understand how two resistances in series act as a voltage divider, you're almost there. When a driving chip pulls low, it has a finite drive, so if there's something pulling up at the same time, the supply voltage gets divided. You can approximate the driving chip as a relatively small resistor to ground. So, if the pullup resistor is nine times that, you'd get 9/10 of the supply voltage dropping across the pullup and the remaining 1/10 dropping across the internals of the driving chip. For a 5V supply, that would take the driven pin down to 0.5V, which although it's not zero volts, is low enough to count as a logic zero.

In practice the ratio will be more extreme than that, so the driven-down pin will go to a lower voltage which is even more solidly a logic zero.

Digital electronics is robust in part because the inputs will interpret a range of voltages as valid zero or one, and the outputs will drive further towards the rails than those ranges, which gives some immunity from noise.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 29, 2019 9:25 pm 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
BigEd wrote:
If I can jump in... if you can understand how two resistances in series act as a voltage divider, you're almost there. When a driving chip pulls low, it has a finite drive, so if there's something pulling up at the same time, the supply voltage gets divided. You can approximate the driving chip as a relatively small resistor to ground. So, if the pullup resistor is nine times that, you'd get 9/10 of the supply voltage dropping across the pullup and the remaining 1/10 dropping across the internals of the driving chip. For a 5V supply, that would take the driven pin down to 0.5V, which although it's not zero volts, is low enough to count as a logic zero.

In practice the ratio will be more extreme than that, so the driven-down pin will go to a lower voltage which is even more solidly a logic zero.

Digital electronics is robust in part because the inputs will interpret a range of voltages as valid zero or one, and the outputs will drive further towards the rails than those ranges, which gives some immunity from noise.


That was a very good explanation, thank you! I understand it now.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 03, 2019 1:55 am 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
So I've been implementing the design:
Attachment:
IMG_20190402_193444.jpg
IMG_20190402_193444.jpg [ 332.15 KiB | Viewed 1674 times ]


As you can see, I used a couple of paperclips and some electrical tape as the battery terminal, and I connected an 18k resistor to the CE/ pin as a pull-up resistor.

I can't get it to work, all information is lost when I disable the external power. While disconnected, if I measure the Vcc pin with a DMM, I do get a constant 2.7 volts. If I measure the CE/ pin, however, I get only about 1.3 volts.

I've reasoned that what might be wrong may be any of these things:
I've shorted out the battery with my paperclip connectors a couple of times now, so it might be nearly dead.
I got some pretty crazy resistance values when measuring from the paperclip to Vcc (50k ohms), which may be limiting the current.
Maybe the pull-up resistor value is too high.


At this point, I think my best option is to cut my losses and change the way I connect the battery to the IC. I could buy a terminal, but I have been unable to find one for these coin batteries around here. I was thinking of using a large clip with something that insulates better than electrical tape and also a couple of metal plates. But I don't know what type of metal plate I could use, any ideas? Also, can I simply solder some wires directly to the batteries, or will that expose the acid?

EDIT:
I just checked all of my diodes, and they all seem to have about a 35k resistance. Is that normal, or is that a side-effect of my cheap DMM (It is pretty cheap, both of the probe tips just fell out today, within a few hours of each other. Had to expose the wires in order to keep using it).

Also, I found a place that stocks actual CR battery sockets near where I live, so I should be able to get some within a couple of days.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 06, 2019 8:02 pm 
Offline

Joined: Sun Mar 24, 2019 8:00 pm
Posts: 20
I finally got it to work! I redid the whole assembly, but it looks like the problem was not in the assembly itself. Here is what it looks like now (Note that the ZIF is not part of the assembly and only used here to keep the IC upright for the photo):
Attachment:
IMG_20190406_134818.jpg
IMG_20190406_134818.jpg [ 4.06 MiB | Viewed 1621 times ]

It looks like when powering up the arduino and setting some of the pins to outputs it sets them to low by default. This was solved by setting the CE and WE pins to high before setting the pins on the arduino to output.

Here is my code in case it helps anyone in the future:
Code:
#include "Arduino.h"

#define SHIFT_DATA 2
#define SHIFT_CLOCK 3
#define SHIFT_LATCH 4
#define DATA_PIN 5 // first data pin, 7 others will follow afterwards
#define WRITE_ENABLE 13
#define CHIP_ENABLE A0
#define OUTPUT_ENABLE A1

void high_pulse(int pin) {
  digitalWrite(pin, LOW);
  digitalWrite(pin, HIGH);
  digitalWrite(pin, LOW);
}

void low_pulse(int pin) {
  digitalWrite(pin, HIGH);
  digitalWrite(pin, LOW);
  digitalWrite(pin, HIGH);
}

void set_address(int address) {
  shiftOut(SHIFT_DATA, SHIFT_CLOCK, MSBFIRST, address >> 8);
  shiftOut(SHIFT_DATA, SHIFT_CLOCK, MSBFIRST, address);

  high_pulse(SHIFT_LATCH);
}

void data_read_mode() {
  for (int i = DATA_PIN; i <= DATA_PIN + 7; i++) {
    pinMode(i, INPUT);
  }
}

void data_write_mode() {
  for (int i = DATA_PIN; i <= DATA_PIN + 7; i++) {
    pinMode(i, OUTPUT);
  }
}

int read_byte() {
  int number = 0;
  int temp;
  for (int i = 0; i < 8; i++) {
    temp = (int)digitalRead(DATA_PIN + i);
    temp = temp << i;
    number = number | temp;
  }
  return number;
}

int read(int address) {
  data_read_mode();
  set_address(address);
  digitalWrite(WRITE_ENABLE, HIGH);
  digitalWrite(CHIP_ENABLE, LOW);
  digitalWrite(OUTPUT_ENABLE, LOW);
  delayMicroseconds(2); // address to output delay(tACC)

  int read = read_byte();
  digitalWrite(CHIP_ENABLE, HIGH);
  return read;
}

void write_byte(int address, int byte) {
  set_address(address);

  int temp;
  for (int i = 0; i < 8; i++) {
    temp = byte >> i;
    temp = temp & 1;
    digitalWrite(DATA_PIN + i, (bool)temp);
  }

  digitalWrite(CHIP_ENABLE, LOW);
  digitalWrite(WRITE_ENABLE, LOW);

  delayMicroseconds(1); // write pulse width(TWP)
  digitalWrite(WRITE_ENABLE, HIGH);
  digitalWrite(CHIP_ENABLE, HIGH);
  delayMicroseconds(1);
}

void write_prepare() {
  data_write_mode();
  digitalWrite(OUTPUT_ENABLE, HIGH);
  digitalWrite(CHIP_ENABLE, HIGH);
  digitalWrite(WRITE_ENABLE, HIGH);
}

void write(int address, int byte) {
  write_prepare();

  write_byte(address, byte);
}

void setup() {

  digitalWrite(CHIP_ENABLE, HIGH);
  digitalWrite(WRITE_ENABLE,
               HIGH); // need to set these pins to high beforehand, otherwise
                      // they will be pulsed low when the arduino is powered on
  pinMode(SHIFT_DATA, OUTPUT);
  pinMode(SHIFT_CLOCK, OUTPUT);
  pinMode(SHIFT_LATCH, OUTPUT);
  pinMode(WRITE_ENABLE, OUTPUT);
  pinMode(CHIP_ENABLE, OUTPUT);
  pinMode(OUTPUT_ENABLE, OUTPUT);

  digitalWrite(CHIP_ENABLE, HIGH);

  Serial.begin(9600);
}

void loop() {
  for (int i = 0; i <= 0x7FFF; i++) {
    write(i, i % 255);
    Serial.println(read(i));
  }
}



Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: