Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
freezepops
Aug 21, 2007
witty title not included
Fun Shoe

ANIME AKBAR posted:

I found a couple dozen results on digikey. Anything from panasonic or nichicon should be good. Here's one from nichicon's HE series:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=493-1475-ND

Thanks for the help, I tried looking through their site earlier and just couldn't seem to find those.

Adbot
ADBOT LOVES YOU

Scarboy
Jan 31, 2001

Good Luck!
I've been designing a simple PCB that is pretty much a breakout for 8 CMOS4066 chips and I've run into a few little issues.

Firstly, battery power. If I have dual supply 4066 ICs can I pass the positive and negative leads from a CR2032 or 2 AAs to power them? Will -3V on the enable lines be logic low? I haven't had a chance to test this since I don't have any dual supply 4066 ICs lying around. I don't really have 0V on my board, I can get it from elsewhere but it would be nice if I could just use the negative terminal from the battery.

Next, how can I calculate how long I expect the battery to last if the battery is just feeding these 4066ICs? The enable lines will be pulled down to -3V with 10k resistors 99% of the time, I don't know if that changes anything. On most of the datasheets I look at I can only find the leakage current and quiescent current (not really sure what that is) and they are usually around 1uA for a 3V supply. To calculate battery life in hours should I just do battery capacity / (2uA (for good measure) * 8)? I don't want to put in a power switch and I just want this thing to last a long time like a remote control.

My last issue is with finding connectors. For each set of 4 ICs I have two 16 pin headers (16x2), what better options do I have for connected wires other than soldering them directly or hot gluing them into a female header? I found this on digikey http://search.digikey.com/scripts/DkSearch/dksus.dll?FullDetail&name=A28757-ND#usewithchildren but I have no idea how to use it. I suppose I need a crimper and plugs for inside? I'm also wondering if putting two of these right on top of each other will be a space issue since they are keyed.

BattleMaster
Aug 14, 2000

I know next to nothing about battery power so I'd be interested in some information on that as well.

I am under the impression that you generally want to use a boost convertor like the MAX756 because batteries don't provide a consistent voltage over the course of their life. I guess that doesn't really matter if your ICs have a wide supply range, though.

Scarboy
Jan 31, 2001

Good Luck!
The ICs I'm looking at have a range of +- 2-12V. If the batteries last long enough, the voltage drop from the battery running out over time should be negligible. I guess what I'm trying to say is that I want to be a cheap rear end and not use a DC-DC converter at all.

Mill Town
Apr 17, 2006

Scarboy posted:

I've been designing a simple PCB that is pretty much a breakout for 8 CMOS4066 chips and I've run into a few little issues.

Firstly, battery power. If I have dual supply 4066 ICs can I pass the positive and negative leads from a CR2032 or 2 AAs to power them? Will -3V on the enable lines be logic low? I haven't had a chance to test this since I don't have any dual supply 4066 ICs lying around. I don't really have 0V on my board, I can get it from elsewhere but it would be nice if I could just use the negative terminal from the battery.

Next, how can I calculate how long I expect the battery to last if the battery is just feeding these 4066ICs? The enable lines will be pulled down to -3V with 10k resistors 99% of the time, I don't know if that changes anything. On most of the datasheets I look at I can only find the leakage current and quiescent current (not really sure what that is) and they are usually around 1uA for a 3V supply. To calculate battery life in hours should I just do battery capacity / (2uA (for good measure) * 8)? I don't want to put in a power switch and I just want this thing to last a long time like a remote control.

My last issue is with finding connectors. For each set of 4 ICs I have two 16 pin headers (16x2), what better options do I have for connected wires other than soldering them directly or hot gluing them into a female header? I found this on digikey http://search.digikey.com/scripts/DkSearch/dksus.dll?FullDetail&name=A28757-ND#usewithchildren but I have no idea how to use it. I suppose I need a crimper and plugs for inside? I'm also wondering if putting two of these right on top of each other will be a space issue since they are keyed.

Is there such a thing as a dual supply 4066? Got a datasheet link? But if so, what you're proposing should work. Actually, a schematic might be helpful here. Do you need or have a virtual ground?

Quiescent current is how much current the chip draws when it's not switching. The switching current (at least in the 4066 datasheet I'm looking at) is calculated as part of the total supply current, and is dependent on the switching frequency. If you're not going to be switching very fast or very often, it won't matter. It's microamps per kilohertz.

Are you already stuck with this 2x16 pin header design? You should be able to get a 2x16 header and ribbon cable although I'm having trouble finding one on digikey.

Scarboy
Jan 31, 2001

Good Luck!

Mill Town posted:

Is there such a thing as a dual supply 4066? Got a datasheet link? But if so, what you're proposing should work. Actually, a schematic might be helpful here. Do you need or have a virtual ground?

Quiescent current is how much current the chip draws when it's not switching. The switching current (at least in the 4066 datasheet I'm looking at) is calculated as part of the total supply current, and is dependent on the switching frequency. If you're not going to be switching very fast or very often, it won't matter. It's microamps per kilohertz.

Are you already stuck with this 2x16 pin header design? You should be able to get a 2x16 header and ribbon cable although I'm having trouble finding one on digikey.

This was the dual supply 4066 I was looking at

http://www.onsemi.com/pub_link/Collateral/MC74HC4066A-D.PDF

Right now I don't have a virtual ground, and if the IC works how I think it does, I don't think I need it.

Nothing is stuck for now, I'm still working on the design. I was looking through digikey/mouser for those ribbon cables and header and man is it confusing. Sometimes I think I'm looking at what I need and I have no idea what I'm getting.

Sammus
Nov 30, 2005

I have an electrical question, and this looks like the best place to ask it, so here it goes.


This is part of a power supply that was assigned for my class to work on and I've got it down to this.

I need to find the voltage going into the voltage regulator from the emitter, but I don't know how to continue.

I'm pretty sure the voltage across the resistor is 27.4 V and the zener diode clamps the voltage at B as 22, but I don't know what to do now.

The transistor's data sheet:
http://www.datasheetcatalog.org/datasheet/mospec/TIP115.pdf
The voltage regulator's (not really important):
http://www.datasheetarchive.com/pdf-datasheets/Datasheets-21/DSA-413025.pdf

Delta-Wye
Sep 29, 2005

Sammus posted:

I have an electrical question, and this looks like the best place to ask it, so here it goes.


This is part of a power supply that was assigned for my class to work on and I've got it down to this.

I need to find the voltage going into the voltage regulator from the emitter, but I don't know how to continue.

I'm pretty sure the voltage across the resistor is 27.4 V and the zener diode clamps the voltage at B as 22, but I don't know what to do now.

The transistor's data sheet:
http://www.datasheetcatalog.org/datasheet/mospec/TIP115.pdf
The voltage regulator's (not really important):
http://www.datasheetarchive.com/pdf-datasheets/Datasheets-21/DSA-413025.pdf

The easiest way to answer this is to simply assume the transistor is on, and then look at the datasheet:



You are right about the zener - it sets the base to 22V. The Vbe is approximately 2.8 V according to the datasheet, meaning that Ve should be 22 - 2.8 or about 19.2 V.

Bush Ant
Jan 4, 2009

by Fistgrrl
yeah i posted a similar circuit a few pages back, and someone was dumb enough to actually build it, you can have a look at that one

Bush Ant fucked around with this message at 12:17 on Apr 26, 2009

catbread.jpg
Feb 22, 2007

Bush Ant posted:

yeah i posted a similar circuit a few pages back, and someone was dumb enough to actually build it, you can have a look at that one

If I had built a circuit like that (god help me), I would have used a weaker input voltage divider, and tolerated a higher capacitor voltage ripple, as it's more efficient to maintain a lower quiescent current and even it out with a linear regulator.

If I was feeling particularly generous towards the power system, I'd put in a full bridge rectifier as well...

Delta-Wye
Sep 29, 2005

Bush Ant posted:

yeah i posted a similar circuit a few pages back, and someone was dumb enough to actually build it, you can have a look at that one

How embarrassing for you, I'm standing right here...

Hillridge
Aug 3, 2004

WWheeeeeee!

Bush Ant posted:

yeah i posted a similar circuit a few pages back, and someone was dumb awesome enough to actually build it, you can have a look at that one

Fixed.

Hillridge
Aug 3, 2004

WWheeeeeee!
This may be a bit of a long shot, but do any of you know how gamma correction is done on a TFT/LCD at at very low hardware level? I know what gamma correction is for, but not quite how it's implemented in hardware. I have a raw LCD panel that needs 14 gamma voltage levels between GND and AVDD, all set by a big chain of resistors. I'm pretty sure the resistors are set by trial and error to iron out the idiosyncrasies in the gamma correction of that particular panel model, but I haven't been able to find any references as to how these voltages are used by the panel. I hope that makes sense.

catbread.jpg
Feb 22, 2007
Those voltages will be used by a gamma buffer, a multi-channel controllable output voltage buffer. I think that level goes to set the total output in each section in combination with the RGB control.

If it's just a chain of 14 levels, does that make it an older LCD? I think newer/flasher ones use a digital gamma map.

Hillridge
Aug 3, 2004

WWheeeeeee!
It's not a full size LCD, it's a 800x480 7" display.

ANIME AKBAR
Jan 25, 2007

afu~
I'm finally doing some real professional consulting/design so I'm finally learning to program AVRs in C using AVR GCC.

it's loving waaayy harder than I thought. Sucks when example source code doesn't even work. Does anyone here know their way around AVR GCC?

catbread.jpg
Feb 22, 2007
Yes. Mostly.

edit: what's your setup? cygwin, linux?

catbread.jpg fucked around with this message at 09:27 on Apr 28, 2009

Snaily
Mar 5, 2006
Sluggish. Wee!
Only worked with it for a little while, but I find it generally easy to work with. A bunch of annoyances with non-standardized #defines, but nothing major.

ANIME AKBAR
Jan 25, 2007

afu~
I'm using AVRstudio (or winavr I suppose), since I already have experience with it and most tutorials I'm finding use it as an example.

So far I'm running into two things. First, changes to variables done in interrupt routines are not being kept upon returning to the main control, even though the variables are declared outside the interrupt routine. Second, in a lot of the code examples I'm messing with, the code just operates in an infinite for or while loop with maybe one instruction in it (most of the functions are interrupt driven). However, when I go to simulate it, the simulator will never actually step into the code inside the for loop, but rather only step into the interrupt routines.

here's some example code where both of these issues occur:
code:
#include <avr\io.h>

#include <avr\iom8.h>

#include <avr\interrupt.h>

#define outp(a, b) b = a


uint8_t led;

/* signal handler for timer interrupt TOV0 */

ISR(TIMER0_OVF_vect) {

led++;

}

int main(void) {

/* use PortB for output (LED) */

outp(0xFF, DDRB);

/*enable timer overflow interrupt*/

outp((1<<TOV0), TIMSK);

/*set timer counter initial value*/

TCNT0=0x00;

/*start timer without presscaler*/

outp((1<<CS00), TCCR0);

/* enable interrupts */

sei();

/*Initial led value*/

led = 0x00;

for (;;) {

/* loop forever timer interupts will

change the led value*/

outp(led, PORTB);

}

} 
so when I run this, once it gets to the for loop, the compiler does not step into the outp(led,portB) line, but it will go to the interrupt vector appropriately upon timer overflow. However, what I see is that after led has been incremented and the routine finishes, led's value returns to zero, and the status of portB never changes.

Snaily
Mar 5, 2006
Sluggish. Wee!
The first issue I know the solution to.

The compiler does not know about the interrupt handler, and just sees led as a loop invariant that can be optimized away. You want to declare it as volatile uint8_t which makes any optimizing away access to it forbidden (or compile without optimization, but that is just a workaround).

catbread.jpg
Feb 22, 2007
Yep, it just needs a volatile declaration. Standard for anything that gets changed in an ISR. This is also where you might want to start thinking about atomic operations, for example multi-cycle instructions on larger integers. cli() + sei() are your friends.

The other issue is probably caused by the simulation of the timer.

Once the first problem is fixed, try going 'run to' for a line in the main loop. Step through and look at the simulated timer register value. You could insert some dummy operations on dummy variables if you want to pad it out a little.

BattleMaster
Aug 14, 2000

The volatile keyword is also handy for memory-mapped I/O which can get messed up by optimization as well. I don't think that will come up very often with AVRs, though, but I have had to use it for USB RAM on PICs.

ANIME AKBAR
Jan 25, 2007

afu~
yeah I was assuming it had to do with how I was declaring the variable... but is volatile really what I want? I had assumed volatile meant that the value is not kept between routines (based on what the definition of the word volatile actually is). Are volatile variables the same as global variables?

As for the thing with the for loops, I did try putting dummy code in there but it still didn't step into it. I'm pretty sure the code gets executed, but it won't let me see it. And putting breakpoints inside should work, but when I go to run it, the simulator tells me that that "the break point can not be set."

BattleMaster
Aug 14, 2000

You're thinking of local variables which are declared in functions, allocated onto the stack when the function is called, and deallocated when the function returns. Global variables are declared outside of functions and should retain their value throughout the program's execution. The variable led in your program is global whether you make it volatile or not.

Volatile has nothing to do with scope, just with the way the compiler optimizes your program. You usually want it for things that can change outside the regular flow of your program such as during interrupt routines or if you're using memory-mapped I/O. Let's say you have something like this that reads two bytes from a serial port or something:

code:
temp1 = rx;
temp2 = rx;
If rx is not declared volatile, the program will read rx once and write the same value to temp1 and temp2. If rx is declared volatile, the program reads it and writes the value to temp1, then reads it again and writes the value to temp2. The first option uses fewer instructions and so uses less memory and eats a little less CPU time, but isn't desirable in this case.

Your case is fairly similar. The compiler sees led initialized to 0 but then it never changes later in the function, so to optimize the code it just assumes that led will always be 0. It has no way of knowing that an interrupt routine will increment led at regular intervals, so you need to declare it as volatile to tell the compiler that it may be different every time it loops.

Edited for a tiny bit of clarity

BattleMaster fucked around with this message at 02:14 on Apr 29, 2009

ANIME AKBAR
Jan 25, 2007

afu~
Declaring the variable as volatile did the trick, though I still can't really understand why.

BattleMaster posted:

You're thinking of local variables which are declared in functions, allocated onto the stack when the function is called, and deallocated when the function returns. Global variables are declared outside of functions and should retain their value throughout the program's execution. The variable led in your program is global whether you make it volatile or not.
Right, so if led is global then why is its value not being conserved between functions?

Now that I think about it, I really don't know if I'm observing its value correctly. I've been looking at the memory space and I've seen that when it's incremented in the subroutine, it happens in a working register, but after that, it could be storing it in SRAM (perhaps the stack?). Is there a way to keep track of variables the way the compiler keeps track of them, or do I just have to track it down in the memory space?

quote:

Volatile has nothing to do with scope, just with the way the compiler optimizes your program. You usually want it for things that can change outside the regular flow of your program such as during interrupt routines or if you're using memory-mapped I/O. Let's say you have something like this that reads two bytes from a serial port or something:

code:
temp1 = rx;
temp2 = rx;
If rx is not declared volatile, the program will read rx once and write the same value to temp1 and temp2. If rx is declared volatile, the program reads it and writes the value to temp1, then reads it again and writes the value to temp2. The first option uses fewer instructions and so uses less memory and eats a little less CPU time, but isn't desirable in this case.
So in the case that it's not volatile, it sees those two lines of code and turns it into temp1=temp2=rx, which is somehow more efficient? But for your example, volatility doesn't ultimately change the result of the code (just perhaps how fast it executes).

quote:

Your case is fairly similar. The compiler sees led initialized to 0 but then it never changes later in the function, so to optimize the code it just assumes that led will always be 0. It has no way of knowing that an interrupt routine will increment led at regular intervals, so you need to declare it as volatile to tell the compiler that it may be different every time it loops.
Strange, this seems extremely important, but I've never come across anything about volatility in any of my reading. But it seems to have been the issue all along. The code examples I've been using have all been from WinAVR's tutorials, so I'd expect them to be solid, but I guess not.

Now on to something else. A lot of people told me I was underestimating C compilers when I assumed that I could always write assembly to be more efficient (in terms of execution time). Now I'm convinced more than ever that I was correct. I'm looking at my cycle counter and seeing things requiring 15 cycles that I could do in two or three. Later on I'm going to have to code my own asynchronous serial interface which will require a lot of bit banging. I'm afraid that if I write it in C, its execution time will be huge. Is there any way I can make it so my compiler biases itself more towards optimizing execution speed instead of program memory?

Thanks for the help so far, I don't know what I would have done if you guys hadn't pointed out the volatility thing.

ANIME AKBAR fucked around with this message at 16:14 on Apr 29, 2009

SnoPuppy
Jun 15, 2005

ANIME AKBAR posted:

Now that I think about it, I really don't know if I'm observing its value correctly. I've been looking at the memory space and I've seen that when it's incremented in the subroutine, it happens in a working register, but after that, it could be storing it in SRAM (perhaps the stack?). Is there a way to keep track of variables the way the compiler keeps track of them, or do I just have to track it down in the memory space?
Not sure about micros, but normally each variable has a location in memory where it is stored. Obviously, to act on a variable it must be loaded into the appropriate register. Now, with micros, there may be optimizations to keep variables in registers instead of continually reading/writing out of memory, so YMMV.

Remember, the idea of a "stack" is just a logical construct made out of memory.

ANIME AKBAR posted:

So in the case that it's not volatile, it sees those two lines of code and turns it into temp1=temp2=rx, which is somehow more efficient? But for your example, volatility doesn't ultimately change the result of the code (just perhaps how fast it executes).

The volatile keyword doesn't mean "don't optimize", although that is its effect. What it means is that the memory/register where that variable is "stored" could be changed by some other process or action at any time, and the compiler would have no idea. Thus it could change between accesses.

This is often true in cases when you aren't pointing to memory, but to an I/O port. In the example, rx might be returning a byte from a serial port. Each "read" from rx would return the next byte that has been received, so setting temp1=temp2 would be wrong!

BattleMaster
Aug 14, 2000

ANIME AKBAR posted:

Declaring the variable as volatile did the trick, though I still can't really understand why.

Let's take a look at your code:

code:
    led = 0x00;

    for (;;)
    {
        outp(led, PORTB);
    }
You initialize it at 0x00, but it never changes during the loop. A lot of C compilers do optimizations in situations like this. It can save some CPU time and program memory by assuming that led will never, ever be anything but 0x00. So in essence it becomes this:

code:
    for (;;)
    {
        outp(0x00, PORTB);
    }
By declaring it volatile, the compiler knows that it could potentially change outside the normal flow of the program (in the interrupt service routine in this case) and so the compiler knows it needs to actually read the value every time the variable is accessed rather than trying to be smart about it.

The lesson is that if you use variables in both interrupts and main code, they need to be volatile or they will likely not work correctly.

quote:

Right, so if led is global then why is its value not being conserved between functions?

Now that I think about it, I really don't know if I'm observing its value correctly. I've been looking at the memory space and I've seen that when it's incremented in the subroutine, it happens in a working register, but after that, it could be storing it in SRAM (perhaps the stack?). Is there a way to keep track of variables the way the compiler keeps track of them, or do I just have to track it down in the memory space?

Calling/returning from functions shouldn't affect the value of led becuase globals don't care about that. Only locals are affected by that. They pop into existence when the function is called and disappear when it returns. The Wikipedia article on call stacks actually does a good job of explaining how that works.

Global variables are stored in constant RAM locations that are fixed at compile time. I have little experience with AVR development tools but you should be able to find out where the variable led is being kept if you look at the disassembly for the line led = 0x00;. Maybe there's an easier way?

quote:

So in the case that it's not volatile, it sees those two lines of code and turns it into temp1=temp2=rx, which is somehow more efficient? But for your example, volatility doesn't ultimately change the result of the code (just perhaps how fast it executes).

Sorry if I confused you with that example, I thought it was a good example but it's something that probably won't come up a whole lot. The variable rx was supposed to show the usefulness of volatile in memory mapped I/O. That is, rx doesn't point to RAM but rather a hardware-based buffer for a serial port or somesuch that gives you the next value in the buffer every time you read it.

SnoPuppy did a great job of explaining why you want it to be volatile!

quote:

Now on to something else. A lot of people told me I was underestimating C compilers when I assumed that I could always write assembly to be more efficient (in terms of execution time). Now I'm convinced more than ever that I was correct. I'm looking at my cycle counter and seeing things requiring 15 cycles that I could do in two or three. Later on I'm going to have to code my own asynchronous serial interface which will require a lot of bit banging. I'm afraid that if I write it in C, its execution time will be huge. Is there any way I can make it so my compiler biases itself more towards optimizing execution speed instead of program memory?

C compilers are good enough at optimization that it's almost never worth your time to hand-optimize something. And that's coming from someone who learns assembly languages for fun!

There are a few things to watch out for, though. Depending on the architecture used, function calls with arguments and local variables can be more inefficient than you'd like. Read about call stacks to find out why - accessing local variables and arguments requires calculating offsets because the dynamic nature of function calling makes it impossible to use an absolute address.

You probably don't want to be using that outp() function for time-sensitive bit banging. If the compiler gives you access to I/O ports as if they were variables (no clue about AVRs, but everything else I've ever used lets you) then the results shouldn't be much different than if you had written it in assembly.

BattleMaster fucked around with this message at 19:24 on Apr 29, 2009

CptAJ
Sep 15, 2007
El Capitanisimo
Hello again guys. Well, you'll be glad to hear that I'm still broke and bored. This time my 1st gen 2gb ipod nano seems to have died on me. Since its fairly old I figure its the common problem with these things, the battery finally gave up. I opened it up and I'm ready to change it. Thing is, I don't have an actual replacement battery. They don't sell them in my country. Some technicians fix them but they're assholes and won't sell me the battery alone (presumably so they can charge me exhorbitant fees for their godlike labour). :doom:

I do have a ton of cellphone batteries though. :science:

These are the specs for the original ipod battery according to this site.

quote:

# Capacity: 330mAh
# Voltage: 3.70V

This is my candidate battery:

quote:

# Capacity: 670mAh
# Nominal Voltage: 3.70V
# Charge Up Voltage: 4.20V

So my questions are probably obvious at this point. First of all, will the battery work?
And second, whats this charge up voltage thing? I can't find the "charge up voltage" for the ipod battery. I need to know if and what kind of problems that will cause when I plug the thing into the USB cable.

More info on ipod battery specs.

Thanks for any help you can provide

Nerobro
Nov 4, 2005

Rider now with 100% more titanium!
Yeah, it'll work.

Southern Heel
Jul 2, 2004

Crossposted from wiring thread:

I have a few low voltage questions:

For 14v AC @ 1amp - what size wire can I get away with for a run of 30' without a drop in power?

I'm familiar with AWG, but my supplier uses a format of 24/0.2 , 7/0.2, 1/0.6 - as far as I can tell this translates to 24 strands at 0.2mm each. Is there a chart on how these compare with AWG figures?

Delta-Wye
Sep 29, 2005

Jagtpanther posted:

Crossposted from wiring thread:

I have a few low voltage questions:

For 14v AC @ 1amp - what size wire can I get away with for a run of 30' without a drop in power?

I'm familiar with AWG, but my supplier uses a format of 24/0.2 , 7/0.2, 1/0.6 - as far as I can tell this translates to 24 strands at 0.2mm each. Is there a chart on how these compare with AWG figures?

Infinite :v: How much drop is too much?

CptAJ
Sep 15, 2007
El Capitanisimo
Didn't work. I soldered the cellphone battery (BL-6C model from nokia) onto the ipod. It lit up when I plugged the USB cable into it but its giving me a "very low battery, please wait" message and its not being recognized by the PC. I'm guessing this is because they're both smart batteries, right? They both have 3 pins and I'm not exactly sure which one is the data pin, if someone could help me find out I'd really appreciate it. I've done a fair bit of googling but maybe I'm just not looking in the right places.

Also, do the two smart batteries even speak the same language? or is the ipod simply dumping me into a default error message because it doesn't know if the battery is charged? And if so, is there a way around it?

Here's what I did:


It should be noted that I removed the thing and plugged the ipod in without any battery and I got the same message so maybe I just got the pins wrong? (Also, I was getting no message at all when it had the original (presumably faulty) battery in place)

Halp?

Delta-Wye
Sep 29, 2005

CptAJ posted:

Didn't work. I soldered the cellphone battery (BL-6C model from nokia) onto the ipod. It lit up when I plugged the USB cable into it but its giving me a "very low battery, please wait" message and its not being recognized by the PC. I'm guessing this is because they're both smart batteries, right? They both have 3 pins and I'm not exactly sure which one is the data pin, if someone could help me find out I'd really appreciate it. I've done a fair bit of googling but maybe I'm just not looking in the right places.

Also, do the two smart batteries even speak the same language? or is the ipod simply dumping me into a default error message because it doesn't know if the battery is charged? And if so, is there a way around it?

Here's what I did:


It should be noted that I removed the thing and plugged the ipod in without any battery and I got the same message so maybe I just got the pins wrong? (Also, I was getting no message at all when it had the original (presumably faulty) battery in place)

Halp?

Can you take a better picture of the ipod battery? It looks like a run of the mill (as I call it) flatpack lithium ion polymer battery, which is most probably not a smart battery. If that is the case, there is a chance that the extra wire is a thermister or something.

http://www.stagarms.com/product_info.php?cPath=13_22&products_id=209

CptAJ
Sep 15, 2007
El Capitanisimo


Maybe you're right? If so, then I must've gotten the pins wrong? Suggestions? (I'm guessing switch white and red)

catbread.jpg
Feb 22, 2007
I've got one tip with optimising bit operations:

Where possible, do all operations as native n-bit integers. For example, use a whole byte to represent each bit of a bitfield when you're doing operations on it, then reconvert to a bitfield at the end.

Same thing goes for boolean flags, bytes for everything.

Delta-Wye
Sep 29, 2005

CptAJ posted:



Maybe you're right? If so, then I must've gotten the pins wrong? Suggestions? (I'm guessing switch white and red)

it would appear the circuitry on the left turns it into a smart battery. If I were you, I would try and find a replacement li-ion cell, and just unsolder the smart battery circuitry (carefully) and resolder it on the new cell. I don't THINK that will hurt anything, at least - I think battery controllers keep cell health info, but it should gradually change to match the new cell, I would think.

Keep in mind what I would do is less of an expert's opinion and more of a hobbyist's inklings.

csammis
Aug 26, 2003

Mental Institution

catbread.jpg posted:

I've got one tip with optimising bit operations:

Where possible, do all operations as native n-bit integers. For example, use a whole byte to represent each bit of a bitfield when you're doing operations on it, then reconvert to a bitfield at the end.

Same thing goes for boolean flags, bytes for everything.

Are you seriously recommending something like this:

code:
unsigned char bitfield = /*whatever*/;
unsigned char b[8];
unsigned char mask;

for (i = 0, mask = 0xFF; i < 8; i++)
{
  b[i] = (bitfield & mask) >> (8 - i);
  mask >>= 1;
}

/* manipulate 'bits' in b */

for (i = 0, bitfield = 0; i < 8; i++)
{
  bitfield |= (b[i] & 0x01);
  bitfield <<= 1;
}

catbread.jpg
Feb 22, 2007
No, I'm saying if you have seperate data bits originally (serial input or similar), AND you want to do bit operations on them before the final output, save the conversion to the bitfield till the end.

catbread.jpg
Feb 22, 2007
Quote is not edit!

Adbot
ADBOT LOVES YOU

catbread.jpg
Feb 22, 2007
That second algorithm is doing unnecessary operations if bitfield is initialised to zero.

Either:

code:
for (i = 0, bitfield = 0; i < 8; i++)
{
  bitfield += (b[i] << i);
}
Or

code:
for (i = 7, bitfield = 0; i >= 0; i--)
{
  bitfield += (b[i] << i);
}
Depending on how you organise the bitfield.

I won't comment on the first algorithm because there should be no need to do that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply