text
stringlengths 83
79.5k
|
---|
H: Loop is executing infinite times
I am working with an ATmega32-A microcontroller. Using USART communication, I am displaying data on monitor and am using switch case to select different commands. In one of the commands I have written the following code:
case(DATA):
init_io();
statusreg = AD7798_8(0x40, 0xFF);
printf("status register %02x\r\n", statusreg);
if (statusreg != 0x80)
printf("unexpected power on status %02x\r\n", statusreg);
while(1){
while ((statusreg & 0x80) != 0); // wait till ADC is ready
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %04x\r\n", adc);
}
Command=0;
break;
But the above code is printing the ADC value infinite times. I have changed the while loop to the following
while(1){
while ((statusreg & 0x80) != 0); // wait till ADC is ready
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %04x\r\n", adc);
}
After that it is printing only once, but does not accept any more commands. I have to re-build if I want to enter any other command. Any help appreciated.
AI: A while(1){} loop never exits, (unless you have a break inside) so it will always stick there. Why do you need the while(1) anyway? It looks like you are only reading once from the ADC.
If you do want to loop more than once, you need to add a condition to equal 0 when whatever it is you want to do inside has finished. |
H: For a lower voltage drop one could use Schottky diodes, but what are the disadvantages of Schottky's?
In other words, why don't we always use Schottky diodes if they are so much better? What diode properties do Schottky diodes have that makes them unfit for certain applications?
AI: They cost more, have higher reverse leakage current, and are physically larger according to a quick search. Of course they're much faster though :)
Looks like in a same size comparison they can't dissipate as much power as a typical power diode. Also with larger currents you lose that Vfw advantage. Oh and wiki says they normally have lower reverse voltage rating on the order of 50V. |
H: Designing Pick-and-Place-friendly CAD library parts
I'm working on a PCB design with surface mount components to be manufactured by a PCB assembly shop. I'm using CADSTAR, and I had to populate the library with some components, from scratch. I'm new to this, and I want to make sure I'm defining component outlines and origins in such a way that the pick and place machine will match the leads up correctly to the land area.
Consider a specific component, a humidity sensor from Honeywell. As I've defined the component in the CADSTAR library, the placement and silkscreen outlines are identical, while the assembly outline is smaller and is offset (lower) in the y-axis with respect to the other two outlines:
Should my component origin be defined at the center of the placement outline, of the assembly outline, or isn't it critical?
I have only the vaguest idea of how the P&P machine works. I understand that there's a camera that detects fiducial marks on the PCB, and so can match coordinates in the design with physical locations on the real PCB. But I'm a little fuzzy on how coordinates in the part definition are matched to a physical point on the part. For example, does the camera detect the outline of the physical package and try to correlate that with one of the outlines (assembly outline? placement outline?) in the part library definition? Does the placement of the component on the reel tape have something to do with it?
AI: The IPC-7351 standard defines a coordinate system origin for surface mount parts, as well as a standard orientation. There is a summary of the orientations on the last page of this document: http://landpatterns.ipc.org/IPC-7351BNamingConvention.pdf [Update: archived link], and illustrations in the full standard.
For most surface mount parts:
The origin is at the centroid of the part's body
The standard orientation is with pin 1 at upper left, except:
two-leaded components, where it's to the left
components where pin 1 is in the middle of an edge, where it's at top center
The reason for the origin being at the centroid of the part body is that pick and place machines use a suction cup to pick up the part at that point. Orientation on the reel can vary, so you have to tell the machine which way they are rotated when you load the reel. |
H: hierarchy of op-amps choice for class use
I saw mentioned in another question that a 741 is one of the worst designs. An LM324 is also pretty low-end.
Is there a better low-end operational amplifier for the money?
I would just appreciate knowing a hierarchy of people's favorites.
Obviously, if I can get LM324 for 0.18, it's not comparable to a higher end opamp costing $4.
I think the fact that the LM324 is a quad is very useful for class because we can use one chip to build a positive feedback amp, then a negative feedback with a source follower front end, and finally a differential amplifier, all with a single chip. So all things being equal I guess I would tend to prefer quad packages over others for that reason.
So I'm looking for the best opamp/$ in 3 categories:
classroom use
low noise/higher speed (say, in the 10Mhz range rather than 1Mhz)
Power (10W or thereabouts)
In addition, after reading a question here about differential amplifiers I looked on Avnet to see what I could get in a single package. I found some really nice ones, but only in surface mount packages. Is there anyone selling differential amplifiers in PDIP format so they can be used in class? They are pricier as well, of course.
AI: Some of my favorites:
general purpose - TL084
higher speed - AD817 (GBW of 50MHz)
instrumentation - AD620 (not the best anymore, but a $4 part) |
H: Oscilloscope reading not what I expect
I had my first very exciting and successful go at an oscilloscope today. The question which arose at the end of my first experience has to do with the accuracy I was expecting. My microcontroller was programmed to output signals such as a HIGH signal for 80us, LOW for 50us, HIGH for 25ms, etc. I used a 16MHz crystal with my ATMega8.
When I recorded the output with the scope, I noticed that the measurements were not exact. For example, when I'd expect a 80us HIGH signal on the scope, it would look something like 77us. The signals which lasted longer times (i.e. 25ms) seemed more accurate.
My question is simply: is this what I should expect? I mean, the device I hooked up to my microcontroller requires specific signals for specific amounts of time, and I programmed my microcontroller to deliver it those signals for the lengths of time it requires. Everything works great, I just can't seem to understand why this discrepancy exists. For reference, the sensor is the DHT-11 temperature sensor. If the microcontroller is actually not delivering the precise signals, why is my sensor responding correctly?
Here are some of my guesses:
The sensor can tolerate some amount of error, which is why it works. I can't seem to identify and put that error into perspective based on the data sheet.
The crystal is not perfectly accurate. We are dealing with microsecond resolution here, so it is possible.
Other components like resistors and capacitors introduce error.
The clock on the oscilloscope is not perfect either - albeit much better than the crystal used for my microcontroller
Perhaps there is something else going on which I am not aware of.
Note that the timings I used above are just examples, and may differ from the data sheet and what I actually used in my code.
AI: It's hard to be specific without seeing your code, but I'll take a stab at it.
Your guess #1 is definitely true; any one-wire bus protocol has to have a lot of tolerance for timing variations, since it partly depends on the resistive pullup of a wire with unpredictable capacitance.
Your guesses #2 - #4 are unlikely; the crystals on both the microcontroller and the oscilloscope are fine.
What's probably happening is that the pulses you're generating with your firmware are not exactly the widths that you intended. An offset of a few instruction cycles could easily amount to 3 µs. And this error would not scale with the timing interval, so longer intervals will seem more accurate, as you observed.
If you post the code you're using to generate the pulses, we could give more specific advice. |
H: How can I get this button to be more reliable for my arduino program?
I have been working on this program for a simple controller. I have a prototype all wired up and working however the momentary push button is not very reliable. Sometimes it reads and other times it ignors it.
Here is my code.
/*
* Valve Purge Control/heater control
*/
#include <math.h>
int feedValve = 12; // feed valve is connected to pin 12
int returnValve = 11; // return valve is connected to pin 11
int heater = 10; // heater is connected to pin 10
//int loopValves = 9 // loop valves are connected to pin 9
//int pump = 8 // pump is connected to pin 8
int button = 2; // button is connected to pin 2
int val; // variable for reading the pin status
int val2; // variable for reading the delayed/debounced status
int buttonState; // variable to hold the button state
int buttonMode = 0; // Is valve on or off?
void setup() {
pinMode(feedValve, OUTPUT); // Set the Feed Valve pin as output
pinMode(returnValve, OUTPUT); // Set the Return Valve pin as output
pinMode(heater, OUTPUT); // Set the Heater Valve pin as output
//pinMode(loopValves, OUTPUT); // Set the Loop Valves pin as output
//pinMode(pump, OUTPUT): // Set Pump pin as output
pinMode(button, INPUT); // Set the switch pin as input
Serial.begin(9600); // Set up serial communication at 9600bps
buttonState = digitalRead(button); // read the initial state
}
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celcius
Temp = (Temp * 1.8) + 32.0; // Convert to F
return Temp;
}
void loop(){
val = digitalRead(button); // read input value and store it in val
delay(10);
val2 = digitalRead(button); // read the input again to check for bounces
if (val == val2) { // make sure we got 2 consistant readings!
if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
if (buttonMode == 0) { // is the button off?
buttonMode = 1; // turn buttonMode to 1
} else {
if (buttonMode == 1){
buttonMode = 0; // turn buttonMode to 0
}
}
}
buttonState = val;
}
if (buttonMode == 1) {
double Temp = Thermister(analogRead(0)); // read Thermistor
//Serial.println(Temp);
if (Temp > 90){
digitalWrite(feedValve, HIGH); // turn on feed valve
delay(5000);
digitalWrite(returnValve, HIGH); // turn on return valve
}
if (Temp < 100)digitalWrite(heater, HIGH); // turn heater on
else if (Temp > 105)digitalWrite(heater, LOW); // turn heater off
}
if (buttonMode == 0) {
digitalWrite(heater, LOW); // turn heater off
digitalWrite(feedValve, LOW); // turn feed valve off
delay(5000);
digitalWrite(returnValve, LOW); // turn return valve off
}
}
}
AI: EDIT: Button is connected like this:
If there was no pull-up, one would put the following in setup()
pinMode(button, INPUT);
digitalWrite(button, HIGH);
An interrupt is an event that 'pauses' the main program, runs a function (called an interrupt service routine or ISR for short), then returns to the main program where it left. Pins 2 and 3 have level and edge triggered interrupts. You can use them to set a flag that indicates the button has been pressed. e.g. adding this code to setup()
attachInterrupt(0, pin2_isr, FALLING);
will run the pin2_isr function when the button brings pin 2 low. Add a flag variable to the start,
volatile boolean pin2_flag = 0;
then the isr function,
void pin2_isr() {
pin2_flag = 1;
}
EDIT - add a valve state variable so that you don't keep turning them on when they are already on.
boolean valve_state = 0;
Your main loop could then become
void loop()
{
if(pin2_flag == 1)
{
detachInterrupt(0); //Interrupt received, turn ISR off
pin2_flag = 0; //Interrupt received, clear flag
//Debounce
delay(250);
//Check button still down
if(digitalRead(2) == 0) {
if (buttonMode == 0) buttonMode = 1; //Change mode
else buttonMode = 0;
Serial.println("button press");
}
//Little delay for debounce
digitalWrite(13,LOW);
attachInterrupt(0,pin2_isr,FALLING); //Re-enable interrupt
}
if (buttonMode == 1) {
double Temp = Thermister(analogRead(0)); // read Thermistor
//Serial.println(Temp);
if (Temp > 90 && valve_state == 0) {
digitalWrite(feedValve, HIGH); // turn on feed valve
delay(5000);
digitalWrite(returnValve, HIGH); // turn on return valve
valve_state = 1;
}
if (Temp < 100) digitalWrite(heater, HIGH); // turn heater on
else if (Temp > 105) digitalWrite(heater, LOW); // turn heater off
}
else if (buttonMode == 0) {
digitalWrite(heater, LOW); // turn heater off
if (valve_state == 1) {
digitalWrite(feedValve, LOW); // turn feed valve off
delay(5000);
digitalWrite(returnValve, LOW); // turn return valve off
valve_state = 0;
}
}
}
Note the change of the second 'if' to an 'else if' and the addition of the buttonMode lines.
By the way, what you have now is a state machine. Add more buttonModes to do more things!
edit: changed interrupt to falling to avoid flag being set when button is held down for too long.
edit 2: changed as per daves suggestion
edit 3: added better debounce
edit 4: interrupt number should be 0 not 2 |
H: What is the physical representation of the heap and the stack?
I can easily understand how .bss and the code have physical representations in the processor which has a memory bank for the instructions that a program counter can count up and the bss (block starting symbol) is just global data. But then there is the stack for local variables and the heap for dynamic memory. How are these things put on the circuit physically?
AI: Note: I refer mostly to x86 as I'm most familiar with it and it's widely documented:
On x86 (and most other architectures) the stack is just resident in memory like everything else. The processor manipulates the stack through a pointer, which is usually stored in a register (the stack pointer). Push and pop instructions will change the value of the stack pointer, changing where the top of the stack is.
The heap is a software abstraction. Like the name implies, it's just a lump of RAM which an allocator slices up and hands out pointers to. In physical terms, the heap doesn't look any different to any other part of RAM.
Paging and segmentation are tangentially related to the heap, however. They're mostly to do with multi-tasking, where processes can't be allowed to modify RAM they don't explicitly own. |
H: Driving a LED with an open drain digital output
I need to drive an LED from an STM32F217ZG.
So I was thinking about a classic circuit with a BJT.
But then I saw that GPIO outputs of the microcontroller are configurable as open drain.
Would this circuit work?
The LED has a 20mA forward current and a 2V forward voltage. Considering \$R=(3.3-2)/0.02\$ it should be on, if GPIO is Hi-Z and off, if it is GND, right?
I don't see why this circuit would not work but I've never seen it before, so I just want to be sure before designing it.
Edit:
Then you mean it is better to do this:
Edit 2:
Finally here is the schematic I'll be using (the output GPIO LED6FAIL is 3.3V and it's a push-pull):
AI: This circuit will work, but not be efficient, power-wise. If the output is high the LED is on and you'll have 20 mA current through LED and resistor.
But with the output low, the LED is short-circuited and therefore off, but the resistor current will be even higher: 50 mA!, which is not only bad for your wallet and the environment, but also for the output pin; most I/Os will only allow 25 mA.
Place the LED in series with the resistor. Then a high output won't light the LED because the output FET is switched off. A low output will draw the 20 mA through LED, resistor and open-drain output.
Note that this will invert the logic: in your first schematic the LED will be off when the output is active, in the second circuit it will be on with active output.
edit
If the output can't sink enough current you'll need an external transistor to increase that.
If the output is active (low) there will flow a 1.5 mA from +3.3 V through Q2's emitter-base junction, R2 and Q1. That 1.5 mA will allow Q2 to source more than 100 mA for a typical general-purpose transistor. You will only get about 22 mA, though, because R1 won't allow more.
If Q1 is off there won't be any base current through Q1, so the LED will remain off. Q1 will have a small leakage current, and to avoid that this would get amplified by Q2 I added R3. As long as the leakage current is less than 0.7 V / 15 kΩ = 50 µA all the leakage current will flow through R3, so that will ensure Q2 will be completely off. |
H: How do the lights on stairs work?
I remember that there's a very simple circuit diagram that explains how there can be 2 light switches for 1 light and that regardless of which switch you turn 'on/off' the light is toggled on/off.
This, as I recall, is the same circuit that is used for the light on a staircase where there is a switch at both the top and the bottom of the stairs.
I've been trying to draw this circuit diagram but I just can't get it... could someone explain or provide a circuit diagram to help please.
AI: In the drawn position the lamp will be on. Switching any switch will turn it off, and again any switch will turn it on again.
If you need more than two switching points you have to add "cross-switches", like this:
You have two A-type switches (for A and B) and the others are C-type.
edit
Any manufacturer of residential switching material has those cross-type switches, but in case you would ever need them in a DIY circuit with rocker switches, you can emulate them with DPDT switches. I'll leave it as an exercise for the interested reader to find out how to wire them. :-) |
H: Developing for an FPGA using Impulse C
I am considering using Impulse C to write C code that will compile down to HDL for my FPGA. I'm curious as to what experiences people have had with Impulse C, to better understand the advantages and disadvantages, and in what cases it makes the most sense to use Impulse C as opposed to raw Verilog or VHDL.
In the pros I expect:
Faster development time
Cross platform FPGA programming
Possibility for writing very complex algorithms take will run in an FPGA
In the cons I expect:
Added layer of complexity with the Impulse C framework
License fees for using Impulse C
Less control over the behaviour of the FPGA
Longer compilation cycles
Are these assumptions correct?
I also have specific questions:
Does using Impulse C for one part of the project impose using Impulse C for the whole project?
Is using Impulse C more or less bug prone than using an HDL?
AI: Do you have c code already for the function? If so it may make some sense...
To answer your specific questions (disclaimer - I haven't used Impulse C, but I have "read-the-book")
You don't have to use impulse for the whole project, it spits out a netlist that you can use as a block within a larger system.
"more or less bug-prone" is a tricky one. I'd expect it to be easier to test in C than VHDL, so good coverage should be easier to get too.
Here's another thought:
For a complex function most of your time is spent writing verification code, so choose a language which makes that easy and then interface it to your low-level synthesisable code.
One option for this is MyHDL - you still write the FPGA part at the "behavioural RTL" level, but your testing can take advantage of the whole Python infrastructure. So:
You get test management for free - just use one of the existing test frameworks
You have a random library already for generating test data
If you are creating an implementation of a standard algorithm (eg SHA) you can generate the expected answers for your random input data using (assumed-)good library code, rather than figuring it out yourself (possibly on paper)
If you want to use images or audio as input data, you can just call the libraries to do it.
Dealing with Ethernet packets? there's a library for creating those too
... etc!
Using C as your input language, tends to mean then using C (or C++) as your testing language - similar benefits can be had, but they are not "just there" you have to go installing and managing various libraries. |
H: Should I use a parallel or serial connection?
I need to split one power cord from the wall socket to power three 20w lamps.
Should I use a parallel, or a serial connection?
Follow up question: In which ever case, where can I find some guidelines for how to proceed?
AI: As long as the 20W lamps are designed to operate at the wall socket voltage then you will want to wire the lamps in parallel connection.
Some guidelines.
Make sure you appreciate that messing with AC wall power can be dangerous.
Make sure the power cord is not plugged in when you are wiring the circuit.
Make sure all the connections are properly insulated and secured before attempting to power up the circuit.
Do use the proper type of socket for the 20W lamps that have proper terminals to take the attachment of the wires. |
H: Will an opening fuse cause an inductive kick, or not?
I'm looking at designing a high-current crowbar circuit. We need to blow a 1400A fuse on demand. One question that has arisen is, what about inductive kick? If you short a large capacitor through a fuse, like so:
the current in the fuse path may well reach 50kA before the fuse opens. That's a lot of energy built up in the inductance of the path between the cap and the fuse. So where does that energy go? Does it get burned off in the fuse as it opens? Or do you get an inductive kick on that node, potentially damaging anything else connected to it? Some of each?
AI: The inductive kick can't increase the current. It will tend to maintain the existing current and thereby possibly cause high voltage someplace, but it doesn't ever increase the current.
In this case it will keep the current flowing a little longer than it would if there were no inductance. The 50 kA will melt or vaporise the fuse element, which eventually opens the circuit. The inductance will force the current to change more slowly, which causes the arc accross the dead fuse to be sustained a little longer. Most of the voltage will be accross the fuse at that point, which puts a reverse voltage on the inductance, which allows the current to ramp down to 0.
The energy stored in the inductance will mostly be dissipated in the arc as the fuse opens. Fuses are designed for some amount of inductance and should be able to take it. |
H: Using GPIO in PC
I've got a simple project on host device that should drive 2 pins with high logic level (voltage 3.3V, 5V or 12V - doesn't matter) and wait for 2 others pins become driven high level by the peripheral device.
Can I implement such host device with a standard PC and what hardware (built-in or extra) should I use?
AI: It's not clear what you want the PC to do and what the device is supposed to do ("host device" makes no sense), but it seems you want basic digital I/O from a PC.
PC's are not really designed for direct digital I/O to external devices. But, you can buy digital I/O modules that connect to the PC via USB, which then allow you to read and write individual digital signals. You can do this yourself most easily by having a microcontroller communicate with the PC via a COM port.
However if this is really just a simple control problem, why do you need a PC at all? Have a small microcontroller do the whole task itself. That's exactly what micronctrollers are for. They are small computers with digital and other I/O lines coming out that are intended to connect directly to external hardware. |
H: stepper motor overheating
I'm using an Arduino to control[1] 2 stepper motors [2][3] (both obtained from scraped printers and I can't seem to find datasheets for them). First I used a 12V 0.5Amp power supply, that worked for each motor separately (although [3] lacked some torque), but when connecting them together the motors stalled. I then connected a 14V 1Amp power supply and both the motors ran fine, apart from the fact that motor [2] got extremely hot, I understand that due to it's lower resistance it takes the grater share of the current while it is probably rated for lower current in the first place. As you might have gathered I'm working with a nearly non-existent budget, and my knowledge of electronics is rudimentary at best, I don't have a variable power supply, I'm basically working off scraps...
My question is how do I divert more current to motor [3]?
I thought of placing a resistor (something like 30-40ohm) on the motor [2] circuit, but that resistor would have to have a very high power rating, and, wouldn't it create a voltage drop? I think [2] is rated for 24v, and I'm already providing it with only 14v...
Another option I read about is using PWM to control the current, the problem I have with this is that it would cast me 2 extra PWM pins on the Arduino and I'd rather save them for other things (I have an Uno, so only 6 PWMs).
[1] Using L293D quad half-bridge.
[2] Mitsumi m35sp-9t resistance 10ohm
[3] Malaysia 42sin-15k8na 28ohm
p.s. I expect many people here would wince at my messy, inaccurate, quick and dirty, trail and error approach to electronics, being a programmer, I understand how you feel, but I'm not building a control system for the mars rover, I'm just trying to learn electronics by doing electronics.
Thanks.
AI: A properly designed chopper PWM current regulator will let you run the motors much faster while maintaining torque than other other solution.
As the rotation speed and thus commutation frequency of a stepper motor increases, the winding inductance begins to present a larger and larger reactance, and limit the current which will flow at rated voltage. The solution is to use a power supply much above the rated voltage, but use a chopper current regulator to prevent overheating the motor or damaging its permanent magnets from excessive field strength.
The power resistor and higher voltage supply method has enough advantage over "nothing" as to have been used in some large stepper motor systems before choppers became affordable, but is a far inferior solution to active current regulation.
In terms of available pins, remember that once you start putting any ICs on a board, putting an additional ATMEGA xx8 on a board becomes fairly economical, too - you don't need a whole Arduino, and the prices for what you do need range from about $2-$4. It's not uncommon if someone is going to the trouble of marketing a stepper power amplifier module for hobby/robots use to put a microcontroller on it and give it a serial command interface instead of raw step/direction per motor. |
H: Analog to digital conversion
I am using an Atmega32-A microcontroller and an AD7798 external ADC. I am able to set the ADC registers and read back ADC values. I have written the following code:
statusreg = AD7798_8(0x40, 0xFF); // read STATUS register default value
Id = AD7798_8(0x60, 0xFF); // read ID register default value
mode = AD7798_16(0x48, 0xFFFF); // read MODE register default value
conf = AD7798_16(0x50, 0xFFFF); // read conf register default value
AD7798_16(0x10, 0x0010); // write Configuration reg = 0x0010. 2.5V range
value = AD7798_16(0x50, 0xFFFF); // read Configration register
if (value != 0x0010)
printf("unexpected conf setting %04x\r\n", value);
while ((statusreg & 0x80) != 0); // wait till ADC is ready
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %04d\r\n", adc);
From the above code, I am reading the ADC values. According to the AD7798 datasheet and according to my configuration register setup, I have to find out the analog input voltage using following formula:
When the ADC is configured for bipolar operation, the output code is
offset binary, with a negative full-scale voltage resulting in a code
of 000...000, a zero differential input voltage resulting in a code
of 100...000, and a positive full-scale input voltage resulting in a
code of 111...111. The output code for any analog input voltage can
be represented as
Code = 2N – 1 × [(AIN × GAIN / VREF) + 1]
where:
AIN is the analog input voltage.
N = 16 for the AD7798, and N = 24 for the AD7799.
I am getting an ADC value of 1EF2(hex) for 0.6V analog input. I have measured using an oscilloscope. I have calculated the analog input voltage using the above formula and I am getting 0.15V. Here GAIN is 1, VREF = 2.5V. Which is wrong because I have to get 0.6V. I have converted resultant hex ADC value into decimal 7922 and also binary 0001111011110010. My analog input voltage is varying from 0V to 0.6V. According to my analog input voltage my ADC output is also changing from 0002 to 1EF2.
If I change the configuration register setup to any other setup like bipolar to unipolar (from 0x0010 to 0x1010), at that time I am getting an ADC value of 0000 always. It is giving an ADC value of 0000 for any configuration other than 0x0010 in the configuration register.
More over, I am not able to understand what the following sentence means:
with a negative full-scale voltage resulting in a code of 000...000,
a zero differential input voltage resulting in a code of 100...000,
and a positive full-scale input voltage resulting in a code of
111...111.
How do I properly convert resultant digital signal to an analog voltage?
Are my ADC readings right or wrong?
Why does my code not work for any other configuration?
AI: The AD7798 is a differential ADC.
It has a negative input and a positive input. When configured for bipolar operation:
When the voltage between in+ and in- is positive (in+ > in-) at full
scale the output will be all one.
When the voltage between in+ and in- is 0 (in+ == in-) the output
will be 1000...0000.
And When the voltage between in+ and in- is negative (in+ < in-) at
full scale the output will be all zero. |
H: Can pins (breadboard friendly) be added to non-drilled pads?
Some PCBA's have pads along the edge, where I believe some kind of headers could be soldered (or may be not), but don't have the pads drilled. I guess manufacturers save a little cost on drilling, and is not a problem when these are breakout boards used in production settings. To turn them into something that is breadboard friendly, apart from drilling holes, is there any alternative option -- s.a. a novel way of soldering pins ?
PS> Aversion to drilling is that these are FR4 boards, and I do not have drill-press or access to one.
AI: No holes drilled makes me think SMT.
Are these what you're looking for?
http://www.digikey.com/product-detail/en/0015916102/WM3699TR-ND/2421395 |
H: (Bad) counting digital pulses with Arduino using interrupts and a 4 pin switch
I have to write an Arduino sketch to accomplish some tasks with the number of digital pulses detected by a pin. For this purpose I chose to use interrupts in order not to miss any pulse and perform the rest of the algorithm virtually at the same time.
In order to make a quick test, I put on this circuit:
and I loaded this sketch (based on the example in the attachInterrupt documentation):
volatile unsigned int pulses=0;
void setup() {
attachInterrupt(0, countpulses, FALLING); // interrupt 0 = pin 2
Serial.begin(9600);
}
void loop() {
Serial.println(pulses);
delay(500);
}
void countpulses() {
pulses++;
}
What I expected here is that whenever I press and release the switch (and the red led turns on and off), it should read one pulse. The weird thing is that it counts two pulses instead, that is, it counts a pulse for each state change instead of just for the "falling" one.
Is this a matter of code or it's due to the switch? Will I have the same issue handling direct digital signals on pin 2?
AI: Mechanical switches experience "contact bounce", which means that one press (or release) of the switch might cause the electical contact to make/break contact several times in rapid succession. This is what you are seeing with your code as it stands currently. The Arduino is fast enough to respond to each of the interrupts caused by this bouncing, even though you can't see it on the LED. |
H: Automatic Rotating Platform
I would like to build a very simple, circular wooden platform that rotates automatically - no stopping. The torque is not very important, as it doesn't need to support much weight. As far as rpm, not too fast, but not incredibly slow - about the pace of a fast escalator? That's the only comparison I can make. It's for an art project. I know this is probably an easy one for most people, but I am starting from square one. Thanks for any help.
AI: Why not just buy a record turntable? Stick a 3 foot platform on it. It's kind of fast, and doesn't support much weight.
Or get a small motor off eBay, and make your own.
You just need some bearings to hold the turntable, and a belt to connect the small wheel on the motor to the big wheel on the turntable. |
H: Electronically controlled pneumatic lift, or something similar
Need to be able to firmly lift about 110Lbs (~50Kgs) weight, through a distance of upto 12 inches. The weight can be considered to be a flat & square wooden board, hinged to a flat platform, with the lifting action applied to the free end, s.t. the wooden board slopes at an angle, when a signal is applied.
Also, I need that the lift should be proportional to signal duration or strength (voltage), ideally not be jerky (or be minimally be so), and it should be possible to reduce the lifted height as well.
Would like to understand the potential options available for the required mechanical action, on application to electrical current. Few things on my mind are electronically-controlled pneumatic lifts, gear-and-pully with stepper motor. An indication of the relative costs (amongst alternatives), would be of great value.
AI: It's going to be difficult to get a pneumatic system to stop exactly where you want it to. Hydraulics could be used, but would be complex. The simplest concept I can think of that can be moved to specific positions would be an electrical actuator, perhaps with an encoder if you needed that level of precision. Basically it's a leadscrew with a lead nut and a shaft driven by an electric motor. The screw provides significant gearing, so the mechanical advantage of the motor is increased. They're used a lot for garden tractors and riding mowers. Surplus Center is a good place to look if you're not planning on going into production with these.
This 107 lb actuator looks like it may be close to what you want |
H: Current measurement in component level of an embedded system
I have an embedded system with a MCU, GPS module, GSM module and TI module. The project is largely depend on the total battery consumption. In order to characterize battery consumption, I have to measure current with respect to each module from the embedded PCB.
Does anyone know how to perform current measurements from the PCB with respect to the above mentioned modules?
AI: Can you break the power connection to each module somehow? Generally current measurement will involve either inserting an ammeter (like the current mode on a multi meter) into the circuit between the source and the module power. Or if you can put a very low resistor between the source and the load you can measure the voltage and calculate the current.
Otherwise you could use a current probe for a scope but in that case you still need to break the connection and insert a little wire loop so you can put the probe around it. This is a nice way to see what your current profile really looks like. Same with the power resistor approach.
Usually you design in the ability to break the power connection to measure power. Also some new regulator controller parts from Linear will actually measure current for you and report it over a serial bus.
If you don't have the ability to break the current path you'll only be able to measure total system power.
----- Update to answer your questions below -------
Digital Mutli-Meter
Well first you don't have a DMM do you? Because just to start off that's going to be easier for you. Something like this:
With that all you'll have to do is put it in series between your battery and your circuit board.
Scope
If you want to go the scope route you can but you'll need to order a 0.1 Ohm resistor. Make sure you get one that's the right Wattage, as in P = i^2 * R. So if you got yourself a 0.5 Watt 0.1 Ohm resistor you could run about 2 amps through it.
Now place that resistor in your circuit like so (ignore that I drew 0.01, I did that before I thought about how small your currents might be!):
Notice how you hook up the scope probes, you need to take a differential measurement, because you are trying to measure the voltage drop across the resistor. Normally I'd say use a differential probe but I'm guessing you don't have one. Instead you can clip the two GND leads together and then tie them to GND. Then place the first probe on one side of the resistor and the second on the other side. When you go to your scope you want to subtract those signals from each other. On an older scope that might mean you have to add and invert one channel. Alternatively if your scope is battery powered you might be able to float it (there's other more dangerous ways to float it too). I'd recommend the safer route though.
You chose that 0.1 Ohm resistor to make your life easier. Ohms law says V = I * R so if you draw 10mA your scope will move by 1mV. Hopefully you're not drawing only 10mA if you are you may need to get more serious (or use a bigger resistor to adjust your voltage output. Keep in mind your scope will pick up some noise as well so you need to play with that resistor till you find a happy point where you're getting more of your signal and less ambient noise.
Hope that helps |
H: Multiplex Seven Segment Display Fast enough to make Solid
I have been trying to multiplex a 4 digit seven segment display on my FPGA board but have been running into not being to get it fast enough so it looks solid to the human eye.
You can see an example of the speed here: http://youtu.be/geTgZcHrXTc
How do multiplex fast enough so it looks solid to the human eye?
I am using the Basys 2 board.
Right now my VHDL looks like:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity main is
port(
clock : in STD_LOGIC;
sevenseg : out STD_LOGIC_VECTOR(6 downto 0);
anodes : out STD_LOGIC_VECTOR(3 downto 0);
switches : in STD_LOGIC_VECTOR(6 downto 0);
dp : in STD_LOGIC
);
end main;
architecture Behavioral of main is
signal counter: STD_LOGIC_VECTOR(1 downto 0) := (others => '0');
signal r_anodes: STD_LOGIC_VECTOR(3 downto 0);
begin
anodes <= r_anodes;
-- Given Binary Value print it
multiplex: process(counter, switches)
begin
-- Set anode correctly
case counter(1 downto 0) is
when "00" => r_anodes <= "1110"; -- AN 0
when "01" => r_anodes <= "1101"; -- AN 1
when "10" => r_anodes <= "1011"; -- AN 2
when "11" => r_anodes <= "0111"; -- AN 3
when others => r_anodes <= "1111"; -- nothing
end case;
-- Set segments correctly
case r_anodes is
when "1110" =>
if switches(0) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "1101" =>
if switches(1) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "1011" =>
if switches(2) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "0111" =>
if switches(3) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when others => sevenseg <= "1111111"; -- nothing
end case;
end process;
countClock: process(clock, counter)
begin
if rising_edge(clock) then
-- Iterate
counter <= counter + 1;
end if;
end process;
end Behavioral;
And my constraints file looks like:
NET "sevenseg<0>" LOC = "L14";
NET "sevenseg<1>" LOC = "H12";
NET "sevenseg<2>" LOC = "N14";
NET "sevenseg<3>" LOC = "N11";
NET "sevenseg<4>" LOC = "P12";
NET "sevenseg<5>" LOC = "L13";
NET "sevenseg<6>" LOC = "M12";
NET "dp" LOC = "N13";
NET "anodes<3>" LOC = "K14";
NET "anodes<2>" LOC = "M13";
NET "anodes<1>" LOC = "J12";
NET "anodes<0>" LOC = "F12";
NET "switches<6>" LOC = "E2";
NET "switches<5>" LOC = "F3";
NET "switches<4>" LOC = "G3";
NET "switches<3>" LOC = "B4";
NET "switches<2>" LOC = "K3";
NET "switches<1>" LOC = "L3";
NET "switches<0>" LOC = "P11";
NET "clock" TNM_NET = clock;
TIMESPEC TS_clock = PERIOD "clock" 20 ns HIGH 50%;
AI: Thank you Dave Tweed for finding my small mistake.
I forgot to add the "LOC" in the constraints file.
NET "clock" LOC = "B8";
I also had some pulse width issues(segments partially on) with the full 50 MHz as Dave Tweed also mentioned. So I used a prescaler to tone it back to 500 Hz.
Divide a 50 Mhz clock by 100,000 (base 10) or 11000011010100000 (binary)
Final code looks like:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity main is
port(
clock : in STD_LOGIC;
sevenseg : out STD_LOGIC_VECTOR(6 downto 0);
anodes : out STD_LOGIC_VECTOR(3 downto 0);
switches : in STD_LOGIC_VECTOR(6 downto 0);
dp : in STD_LOGIC
);
end main;
architecture Behavioral of main is
signal prescaler: STD_LOGIC_VECTOR(16 downto 0) := "11000011010100000";
signal prescaler_counter: STD_LOGIC_VECTOR(16 downto 0) := (others => '0');
signal counter: STD_LOGIC_VECTOR(1 downto 0) := (others => '0');
signal r_anodes: STD_LOGIC_VECTOR(3 downto 0);
begin
anodes <= r_anodes;
-- Given Binary Value print it
multiplex: process(counter, switches)
begin
-- Set anode correctly
case counter(1 downto 0) is
when "00" => r_anodes <= "1110"; -- AN 0
when "01" => r_anodes <= "1101"; -- AN 1
when "10" => r_anodes <= "1011"; -- AN 2
when "11" => r_anodes <= "0111"; -- AN 3
when others => r_anodes <= "1111"; -- nothing
end case;
-- Set segments correctly
case r_anodes is
when "1110" =>
if switches(0) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "1101" =>
if switches(1) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "1011" =>
if switches(2) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when "0111" =>
if switches(3) = '1' then
sevenseg <= "1111001"; -- 1
else
sevenseg <= "1000000"; -- 0
end if;
when others => sevenseg <= "1111111"; -- nothing
end case;
end process;
countClock: process(clock, counter)
begin
if rising_edge(clock) then
prescaler_counter <= prescaler_counter + 1;
if(prescaler_counter = prescaler) then
-- Iterate
counter <= counter + 1;
prescaler_counter <= (others => '0');
end if;
end if;
end process;
end Behavioral; |
H: clarification about amdahl's law
A system is designed as a cascade of of 4 subsystems, each contributing the same amount of time to the average service time of the system. If we wish to increase the speed of the system by a factor of 2 by reducing the service time of each subsystem equally, how much speedup should be applied to each subsystem?
This is how I solved the problem and I was hoping someone could let me know if I am on the right track:
Amdahl's Law is Speed Up[overall] = 1 / (Fe/Se + (1 - Fe)) where Fe is enhanced fraction and Se is enhanced speedup. In this case Speed Up overall = 2 and enhanced speed up = 4 because there are 4 subsystems. All I did was solve for Fe and I got .66, which is 66.66%. This means each subsystem must increase it's speed by 66.66%.
Is this correct? Am I on the right track at all?
The next question asks a similar question except the average times of the first two subsystems are to be reduced by twice as much as those of the last two subsystems, but the overall speed up should remain at 2. I'm a little confused how to use Amdahl's Law here.
Would appreciate all / any advice or any literature that might help.
AI: No, you're way off base, and Amdahl's Law does not apply in this case.
It's a simple rate problem, like you had in your first algebra class. You have four subsystems, each of which contributes the same amount of time to the overall operation:
T1 = T2 = T3 = T4
Ttotal = T1 + T2 + T3 + T4
Ttotal = 4 × T1
If you want to divide the total time in half while keeping the subsystem times equal to each other, just divide both side of the last equation by 2:
Ttotal/2 = 4 × T1/2
In other words, you have to speed up each subsystem by a factor of 2; i.e., each one must run in half of its original time.
The second problem is a little trickier. Let's call x the amount of time by which the second two subsystems are sped up, which means that the first two subsystems are sped up by 2x. Now we can write:
Ttotal/2 = (T1-2x) + (T2-2x) + (T3-x) + (T4-x)
Solve for x:
6x = T1 + T2 + T3 + T4 - Ttotal/2
Making the other substitutions we know about:
6x = 4 × T1 - (4 × T1)/2
6x = 2 × T1
x = T1/3
Therefore, the first two subsystems must run in 1/3 their original time (T1 - 2x), and the second two must run in 2/3 of their original time (T3 - x). |
H: Ethernet (100 Mb/s) through relays
I'm trying to transmit Ethernet through relays. I'm using relays because I need them to switch to another signal path, and I'm specifically going to use relays and not other switching devices so that things are fail-safe and still provide a path when my device controlling the relays is off. So, I wonder if anybody out here knows can I safely transmit 100 Mb/s Ethernet through relays? I'm a bit worried because the spec says that Ethernet must be transferred through 100 Ω impedance (unshielded twisted pair).
Will the signal be OK?
Are there timing issues or any other issues with doing this?
AI: Ethernet is surprisingly robust and you can use surprisingly bad cables before it starts to fail. So to send data through would probably work quite ok.
But when you switch the relays you would end up with a disconnect and a reconnect and those could cause the connected devices to behave strange since you on a logical level "moved the cable" from one device into another in a ms or so. And I am not sure how they would react to that...
But I get the feeling that there is another solution to your problem that will work better, even if this probably will work. |
H: Replacing (and perhaps upgrading) bad capacitors within a speaker system?
A few months ago the volume of the left speaker of my pair of low-cost audio monitors began slowly diminishing. Every day it seemed to lose a fraction of it's normal operating volume until the speaker became nearly completely silent. Since I bought these speakers in 2010, I noticed that the left speaker tends to run very hot. So, when the speaker began to die out, I assumed that the speakers were poorly designed and weren't built to withstand their own level of heat, and after a certain amount of time they broke. However, I wasn't sure about the cause. I thought it might have been that a solder joint might have weakened and broken or something like that. However, I thought back to an experience that I had before where my PC's video card made a loud crack and upon investigation, some of the capacitors on the PCB had broken open. This was my first experience with bad capacitors.
So, with that in mind, I thought to pop open my left monitor and check around to see if something was visibly wrong. And sure enough, I saw something that looked like two capacitors that had overheated (i think) and vented some of their fluids.
[I can't post my image due to the spam filter]
I'll admit that, while I'm interested in hardware and electrical engineering, my knowledge is much more limited than I would like it to be. I would love to try this repair/upgrade, but I'm worried about messing it up and winding up with a pair of non-working speakers (which, is only slightly worse than a pair of half-working speakers...).
Now, at this point, I've been able to identify a potential cause of the problem. But, I'm not sure what to do about it, or if I can even do anything by myself.
I know that there are places online where I can get replacement capacitors (in this case, it looks like the caps that were used were 4700uF/35v caps). But is this an easy D.I.Y. job for someone who is inexperienced with electronics and soldering, but is willing to learn?
Long story short: I think that I need to replace two capacitors inside my speaker system. The caps that were in there (4700uF/35c) broke too quickly for my liking, maybe due to overheating.
Is replacing these capacitors something that is relatively easy for an inexperienced person?
Do I need a special type of soldering iron or can this be done with a cheap hardware store one?
Also, would it be possible to buy replacement capacitors that are stronger/better/durable/heat resistant, instead of simply re-buying the same type?
Should I (or do I have to) replace the bad caps with new ones that are also 4700uF/35v? Or could I/should I replace them with something else? If i can repair and improve these at the same time, I'd like to. I'm not sure if that's possible though, as I don't really understand how capacitors work...
Finally, If I manage to remove the old capacitors, do I have to do something to remove the capacitor fluids that are all over my speaker's PCB? What can I do to clean that and is there anything I should know about that stuff?
AI: You can replace them with pretty much any capacitor that has the exact same rating. It will be relatively easy to replace them, and can be done with any soldering iron that can adjust its temps to under 400*f coupled with solder that has a similar melting point. Preferably you want an iron that is regulated at the tip (not just a dimmer), but for low-power electronics like this that really isn't as much of an issue.
You'll need to desolder the joints, which just consists of heating them until hot enough to pull out of the holes. If you can manage it, put slight tension on the cap while you heat the solder so it will come out as soon as it's hot enough.
When putting the new one in, make sure to apply a light amount of flux to the joint, then put a small amount of solder on the iron, then touch the dab of molten lead to the joint. If all goes well, it will transfer from the iron to the board. After a successful attempt, cut the cap leads as short as possible. Alternatively, if you feel comfortable, pre-cut those leads to protrude about 3-4mm from the back of the board so that the entire lead is encompassed by the new solder.
Here are some recommended supplies:
376* melting point solder
Waterless Tip Cleaner
Aoyue 937+ Digital Soldering Station |
H: Basic ac circuit analysis
When are we going to append the "j" term when analyzing ac circuits. When i say j term, im pertaining to opposition to current/impedance. In the image below, notice that Xl is not written as jXl. When are we going to use the j term and when are we not going to use it?
AI: "notice that Xl is not written as jXl"
You've answered your own question. The problem is that \$X_L\$ is not written as \$j X_L\$. :-)
While it also has the dimension Ω, just like impedance, \$X\$ is the symbol for reactance, not impedance, that would be \$Z\$.
\$ Z_L = R + X_L = R + j \omega L\$
The factor \$j\$ indicates a 90° phase shift with respect to the resistance which does not have a phase shift. For an inductance the phase shift is positive, for a capacitance it's negative, since
\$ Z_C = R + X_C = R + \dfrac{1}{j \omega C} = R - j \dfrac{1}{\omega C}\$
It's because of the 90° angle between resistance and reactance that you can't add them arithmetically, like 5 Ω + 12 Ω = 17 Ω. \$X\$ and \$R\$ create a right angled triangle, so you have to apply Pythagoras to find the magnitude of the impedance:
\$ |Z_L| = \sqrt{|R|^2 + |X_L|^2} \$
so for \$R\$ = 5 Ω and \$X_L\$ = \$j\$ 12 Ω we get a magnitude of 13 Ω instead of 17 Ω.
Right, back to your calculations. The reason it seems to go in the right direction, even without \$j\$ is that you applied Pythagoras implicitely in the first line already; you wrote
\$ V_S^2 = (V_1 + V_R)^2 + V_L^2 \$
and not
\$ V_S^2 = (V_1 + V_R + V_L)^2 \$
or simply
\$ |V_S| = |V_1 + V_R + V_L| \$
That's why you won't see \$j\$ anymore; you got rid of it at the start. |
H: Any reason power supplies always use single sided PCB's?
I am designing a PCB that has an onboard power supply switching module which requires filtering and protection on the input and output side. Its going to be a double sided PCB but I was wondering if the power supply section should be kept to a single layer. Just about every power supply I have seen always uses a single sided PCB.
The switching module is a 120VAC-24VDC. I am using a common mode choke, power factor correction cap, bypass caps, MOV, fuse and thermistor on the input side and filter cap, bypass cap and transient voltage suppressor diode on the output. I used a few topside traces to make everything fit neatly together. I imagine the single sided PSU's are solely for cost but is there anything I should be concerned about?
AI: It's entirely about the cost. For most power supplies, the circuit is simple enough that it lays out with few, if any, crossovers required. In high-volume production, installing a few jumper wires or zero-ohm resistors is much cheaper than using a 2-sided PCB. |
H: How to test if the voltage in a circuit is a certain amount
I recently found out that memory is stored in a computer with lots of capacitors that hold 0 or 5V. I presume this is how binary would work (so 5V is 1 and 0V is 0). How would I (say) turn on a lightbulb if the voltage is (say) 25V?
AI: Olin's transistor circuit is a standard way to switch a load from a microcontroller, but it's not a universal way. The main limitation is that it only works for DC loads (direct current), and not for AC (alternating current).
It's not clear where your 25 V comes from. Is that the rated voltage for the bulb, and do you expect that your logic should work at the same voltage to switch it on? In that case it's worth noting that Olin's circuit has two different voltages: a 5 V control voltage, which may come from a microcontroller's output, and a 25 V load voltage. The two voltages don't have to be related in any way. With the right transistor type you can switch 1000 V from a 3.3 V microcontroller. What is required is that you can connect the two supplies; they should have their respective grounds ties together (the black down arrow in the schematic).
Sometimes you can't do that, for instance because the 25 V (or 1000 V) is directly connected to the mains. You don't want to be electrocuted when you press the microcontroller's button, so you provide isolation between the two voltages. You'll still use the transistor, but that will switch a relay instead of the bulb. The relay's contacts are isolated from the activation voltage and you use those contacts to switch the load. This is also a solution if your bulb works on AC instead of DC.
About the data bit you stored in the capacitor. That's how DRAM (Dynamic RAM) works. But the capacitance is extremely small (otherwise it would need too much real-estate on the IC), and the contents leaks away in milliseconds. That's why DRAM memory has to be refreshed all the time: data is read and rewritten, so that the capacitor's voltage for a "1" stays near the required 5 V. It's not that voltage that can control the transistor either: in between refreshes the microcontroller reads the level (which again discharges the capacitor, so that it has to be rewritten again) and may decide to make an I/O pin high, which controls Olin's 2N4401 transistor. There's a lot of transistors between the stored data bit and the microcontroller's output. And remember that you don't have to work at 25 V to switch a 25 V load. As far as I know there are no microcontrollers working at a voltage higher than 5 V. |
H: Can a lead-acid battery charger be used for "Gel" type?
I have a PB-600-24 lead acid battery charger.
Can I use it for the battery type that has an image as below? 4 of the batteries are in series.
AI: Yes a gel battery is just another name for sealed lead acid battery or SLA and your charger clearly states that it is capable of charging sealed lead acid batteries |
H: Formula calculation and printing negative value.
I am successfully reading external ADC value using ATmega32-A.
Unsigned int adc;
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %d\r\n", adc);
I am getting ADC value as decimal number range between "0 to 65535". I want to convert it into analog voltage using the fallowing formula.
Code = 2N – 1 × [(AIN × GAIN / VREF) + 1]
where:
AIN is the analog input voltage.
N = 16 for the AD7798, and N = 24 for the AD7799.
I have simplified the formula and calculating
// formula to caluculate analog voltage from digital output :Code = 2N – 1× [(AIN × GAIN/VREF) + 1]
// GAIN / VREF = 1 / 2.5 => 0.4
// 0.4 Ain = ((adc / 32768) - 1)
float Ain;
Ain=(((((float) adc) / 32768) - 1) / 0.416);
printf("value:%.2f [v]\r\n", Ain);
The above formula returns always negative value. I want to print that negative value. I have tried as above but its not working. How to print Ain value? here adc is unsigned value so I am converting into float.
I have tried like this also
Ain = (((adc / 32768.0) - 1) / 0.416);
printf("value:%.2f [v]\r\n", Ain);
but I am not able to print that value.
AI: The AVR libraries don't compile in support for printing of floating point values by default. This is to save space on their limited resource environments. You need to tell the compiler and the linker to enable support for this feature.
From the avr-libc documentation on vfprintf():
Since the full implementation of all the mentioned features becomes
fairly large, three different flavours of vfprintf() can be selected
using linker options. The default vfprintf() implements all the
mentioned functionality except floating point conversions. A minimized
version of vfprintf() is available that only implements the very basic
integer and string conversion facilities, but only the # additional
option can be specified using conversion flags (these flags are parsed
correctly from the format specification, but then simply ignored).
This version can be requested using the following compiler options:
-Wl,-u,vfprintf -lprintf_min
If the full functionality including the floating point conversions is
required, the following options should be used:
-Wl,-u,vfprintf -lprintf_flt -lm
(emphasis mine)
Since you are using CodeVisionAVR as we discussed in chat, they have this option built in to their configuration window as seen on Page 4, Step 9 of this tutorial: |
H: Multiplex dip switch input to microcontroller
I have 3 DIP switch packages with 8 switches each, and not enough inputs on my microcontroller. This article (you have to download the pdf to see the schematic) gives an example of what I want to do.
In the comments section, many people say the circuit won't work. I disagree; It looks like those commentators missed the fact that one of the lines is drawn as an 8 pin bus, and the fact that unused RA pins will be set as high impedance inputs. Still, I wanted to get a second opinion from the experts here!
Edit: After reading the many good answers to this question it seems my initial impression was wrong. This circuit will only work for momentary push buttons, not dip switches.
AI: The schematic in the article is poorly drawn. I think he probably meant to imply an 8-bit bus, but the dots imply discrete connections. On top of that, there isn't a bus width called out (which would disambiguate things).
As DaveTweed points out, there is a risk of false switch closure detection in certain switch combinations unless a diode is used in series with each switch. Note that if the design requirement only requires reading one closed switch at a time, the circuit will work just fine. |
H: What's the use of the bypass capacitor on the LM380 amplifier?
I've read the LM380 amplifier data sheet and application notes, and they show a power supply ripple rejection number that's based on the size of the bypass capacitor. There are also a few designs that use trimmer potentiometers into the bypass pin. Other than that, there's no actual mention of what this pin does or what the requirements are. (This is pin 8 on the DIP-8 package, pin 1 on the DIP-14.)
Here's the data sheet and application note link: http://www.ti.com/product/lm380
The data sheet also talks about a 100 nF decoupling capacitor on VS / GND, as usual for most ICs. But what is the bypass pin really for? Will the voltage ever swing negative, or can I use a regular electrolytic/tantalum on that pin?
Here's my proposed circuit (I'm learning KiCAD, so it's not all that great; apologies in advance for the vertical labels!) if it helps answer the question:
Also, regarding capacitor polarity: I'm assuming the output AC coupling capacitor can be a regular polarized capacitor, even though the charge of the capacitor and inductance of the speaker will temporarily reverse the effective potential when the output goes close to ground in a waveform swing?
AI: First of all, the output coupling capacitor will never go negative. The speaker will, but the capacitor won't, and that's one of the reasons it exists at all, to provide a dc offset so that the amplifier doesn't have to go negative in order to drive the speaker negatively with respect to ground. It needs to be large enough so that it doesn't get charged/discharded too much during voltage swings, which would distort the audio signal.
Secondly, the datasheet includes a schematic on page 2, and you can see exactly where the bypass capacitor goes. I'm no audio expert, but I can see that it is basically part of an RC low pass filter to power/bias the differential stage of the amplifier, so it basically isolates it from power supply fluctuations. A side effect is to partially separate the dc bias current setting resistor from the open loop differential gain setting resistor of that stage. |
H: What does it mean for amplifiers to be stable only down to N gain, where N > unity?
This is related to
What's special about "unity-gain stable"?
which is about unity gain stability.
But what exactly does it mean if some op-amp is said to be only stable to, say, gain 3 rather than all the way down to unity gain?
Guesses:
Does this gain 3 refer to open-loop gain? (The amplifier has an adequate phase margin at the upper frequency where open-loop gain is 3, but not beyond?)
Or does it refer to closed-loop gain? (The amplifier will be stable up to its unity open-loop gain frequency, if the closed-loop gain is not less than 3?)
AI: To expand on my comment, they are talking about closed loop gain.
If an op-amp is not unity gain stable, it has to be stable under some conditions, or what's the use of it?
So, if they say the op-amp is "gain-of-3 stable", they're telling you, this op-amp is not unity gain stable, and the minimum gain where it is stable is 3. |
H: Problem with MPLAB's toolsuite
I'm taking a module at University that involves MPLab. I'm trying to get it setup at home and so far its been a little tricky. I've got my files from University which I've attached below - if there any help in regards to finding out what language toolsuite I need to use, then that would be great. If it helps, when I use the Project Wizard the device that it gives me is: PIC24FJ128GA010
Version: MPLAB IDE v8.87
My current issue with MPLAB
Each time I try build my files that I've attached, all I get is Build Failed. For my debugger I'm using Proteus VSM 7.8. I believe it's a compiler error - I don't believe I've got the correct compiler setup, or even setup a compiler at all.
Test Files: https://www.dropbox.com/s/sekuzv92jsjpaht/testFiles.rar (these work fine on the University computers but when I try build from home it just fails).
I'm sorry if this is a little vague but I'm very new to MPLAB but I'd like to learn more of its features so I'm trying to get it working at home. I apologise in advance if I've not included the correct information and/or missed anything out, if I have, I'll add it as soon as possible. Many thanks.
AI: The .map file that's part of the bundle you shared shows that the Microchip C30 compiler was used to build this project. Unfortunately I don't see what version of C30, but at least the compiler is known.
c:/program files/microchip/mplab c30/bin/../lib\libpic30-coff.a(crt1.o)
(_resetALT)
c:/program files/microchip/mplab c30/bin/../lib\libpic30-coff.a(crt0.o)
(_resetPRI)
Program Memory Usage
There's a free version of C30 (no optimization) that can be downloaded and installed from Microchip's website. Give the latest version a try and see what happens. |
H: High-pitched noise from boost converter. Need your help
I'm experiencing some high-pitched squealing noise from my boost converter, I'm getting some resonating frequency when I start increasing the load current.The inductor is a 47uH inductor. The part number for the diode is MBRD640CTT4G.
This is my schematic:
[1]
I checked the power line with the scope and this is the 12V line @ 100mA using AC Coupling:
[2]
As you can see, the ripple noise isn't so bad, I'm getting about 200mV peak to peak.
But when I run it at 500mA load this is what happens:
[3]
The ripple is horrible, I'm getting about 4V p-to-p.
Any ideas what is going on?
AI: I went into AN19 http://cds.linear.com/docs/Application%20Note/an19fc.pdf and it has a section for Frequency Compensation on pin VC. I simply increased the capacitance to 1uF and kept the resistor on 1K and I no longer have this problem. I am going to talk to Linear Tech to better fine tune this circuit and see if there is a more optimal value for that Capacitor (C112). |
H: MOSFET Over Heating. So hot it's melting the solder
Alright, continuing with the debugging of my new board tonight I found another issue worse than the one before: My switching MOSFET is getting so hot that I'm getting molten solder.
I replaced the MOSFET with a short circuit just to see if the components sorounding the MOS were the cause of the problem (mostly a big Inductor I have right next to it) but the copper reaches a temperature of 110°F, not enough to melt solder.
This is my schematic:
As you can see, my VGS is around -11V and I'm running 3A through it using an Electronic Load. Based on the datasheet of my NTD20P06L-D this thing can do up to 15.5A.
Any ideas of what might be going on?
The only thing I could think of was that the heat on the copper could be increasing RDS(on) but at that particular low current it shouldn't be so serious.
I am using the TO-252-3, DPak (2 Leads + Tab) package.
AI: It sounds like you need a heatsink.
Another thing to check is your gate voltage when you have the FET switched on. If your Gate-Drain voltage is too high, the MOSFET may not be properly biased on, a situation which would generate a lot of heat.
Also, how often is this switching? Is it a steady-state thing, or is this part of a switching supply? If it's a switching supply, you will also need to look at the rate at which the system switches.
Anyways, assuming you have everything biased properly (probably a safe assumption, but measure it anyways):
RDS(on) = 130mΩ @ G-D voltage of 5V
So, with 130 mΩ in series with 3A:
$$V = 0.130 * 3$$
$$V = 0.39$$
$$Power = V * A$$
$$Power = 0.39 * 3$$
$$Power = 1.17W$$
So you're going to be dissipating 1.17W of power in the MOSFET, in the best-case situation.
That will get very toasty without a heatsink. If you're just running this as a bare TO-220 device, it getting extremely hot isn't too suprising.
So, assuming we have a TO-220 in free-air:
TO-220 junction-to-air thermal to ambient equals 62.5 degree per watt.
(From here)
Therefore:
$$Δ°C = 62.5 * 1.17$$
$$Δ°C = 73.125$$
$$Device Temperature °C = 73.125 + Ambient$$
$$Device Temperature °C = 98.125$$
So assuming ideal thermal dissipation on a bare TO-220, it's still going to easily reach ~100°C.
Any environmental factors that further reduce the device's cooling will make it worse. |
H: Unexpected pulses in the output signal from IR Detector
I have a Sharp GP1UX311QS IR detector connected to a msp430 launchpad. I wrote a small bit of code to read the output signal from the detector and print the on/off times. However, without emitting any IR light (from a remote) a small pulse appears on the output signal every 5 to 20 seconds. I tried shielding the detector with aluminum foil for about 5 minutes and the random pulse never showed up. After removing the foil the pulse starts showing up again about 20 seconds later.
Screenshot of the signal from my oscilloscope:
Took a few samples of the small pulse to see how much it differed:
I also tried just a simple circuit that supplies 3.6 V to the IR detector and get the same results as above when connected to the launchpad.
The fact the detector only detects modulated IR at 38 kHz makes me wonder why I get interference. Any ideas where the interference may be coming from and what I can do about it? I would prefer a hardware solution rather then accounting for it in software. Thanks.
AI: The datasheet warns in point 9 on the last page:
There is a possibility that noise on output may be caused by environmental condition (Disturbing light noise, Electromagnetic
noise, Power supply line noise, etc.) even if there is no input
transmission signal.
So it sounds like the manufacturer accepts that you may get false positives once in a while. Other than controlling your environmental conditions and having good power supply bypassing, you're probably going to have to filter out these glitches in software. You could have a circuit that filtered them based on minimum duration for example, but this so easily done in firmware that it's not worth the cost+area involved in a pure hardware filter. |
H: Logic Analyzer Basics
I am buying a second hand logic analyzer (Agilent 1661A) and I see the terminology such as the following:
100MHz State Speed
Maximum Conventional Timing Rate: 250 MHz full channel, 500 MHz half channel
Maximum Timing with Glitch Rate: 125 MHz half channel
And there are many more. I expect to measure 50MHz signals between FPGA and other custom ICs.
I have the following questions:
For 50MHz measurement, what is the minimum speed I should pick up? (If this were a scope, for 50MHz, I would probably need 500MHz scope to see the signal very clearly)
I need to measure set up and hold times and some other timing parameters, how does the speed of the scope impacts these.
AI: A logic analyzer generally has two modes of operation, depending on where its sampling clock is coming from. The clock can be coming from your circuit, in which case, the samples are synchronized to the operation of the circuit, or it can be generated internally by the logic analyzer itself, which means that the samples are not synchronized. I tend to refer to these as "synchronous" and "asynchronous" operation, respectively, but Agilent is using the terms "state" and "conventional timing", respectively.
State mode is useful for tasks such as capturing the bus activity of a microprocessor to trace how it's executing software. Conventional timing mode is used to measure actual delays between signal transitions.
The specification is telling you that in state/synchronous mode, the 1661A can accept a clock of up to 100 MHz, but in conventional timing/asynchronous mode, it can generate a clock of up to 250 MHz, and by interleaving the channels it can achieve a 500 MHz sample rate.
At the highest rate, the analyzer is taking a sample every 2 ns, so this is the limit of the resolution you can get for measuring things like setup/hold times.
Also, keep in mind that any transition you see on the screen could have actually happened at any time ± 2 ns from the position shown, so if two transitions are shown within one sample interval of each other, you can't be certain which one actually occurred first. This makes it tricky to measure small intervals with a logic analyzer, and an oscilloscope is often a better tool for this sort of task. |
H: Connecting a 12.5VDC switch output to a GlobalStar SmartOne GPS unit
I have a device (hermetically sealed onboard computer on a diesel generator) with a power switch that is connected directly to a lead acid battery (~12.5VDC). I would like to trigger a gps device when the on switch is closed. Although I cannot find the data sheet for the gps unit, I suspect the I/O input on the GPS unit is max 5 VDC.
If I wanted to provide a easily patched in solution (something that is easy to install for a laymen with thick fingers), what is the best solution? My thought was some type of screw terminal voltage regulator.
AI: A simple voltage divider should do the trick:
It seems like a 20k on top and 30k on the bottom should give you 5V in the middle that you need.
Now is this battery also connected to an alternator? At least in a car that means the DC voltage is around 14V or so when it's running. If that was the case a quick fix would be to put a 5V zener diode in parallel with the bottom resistor.
Vreg
Also if you want to go the Vreg route, this little adapter might help you.
Here's the link to the site that sells them. It looks like you can choose from their regulators you want to use with it like this 5V one. Although I'm sure you can jam any similar packaged 3 pin regulator in there. |
H: Can FPGAs dynamically modify their logic?
It would be theoretically possible for an FPGA to write a configuration image to an external memory, and load the configuration image from the memory to reconfigure itself. This would be "non-dynamic" reconfiguration.
Do FPGAs have the ability to rewire their logic fabric dynamically? Indeed, while flip-flops can have their value modified, I have not heard of dynamic reconfiguration of the look-up tables and internal wirings that make up the logic fabric.
Can FPGA internal logic (other than memories) be dynamically modified? If not, why not?
AI: Yes, I know that at least Xilinx has parts that support dynamic reconfiguration, and the other major vendors probably do, too.
It's a major undertaking to do it, though, so you really need to make sure you need it. You need to partition the chip physically into two or more areas, at least one of which is non-reconfigurable, and physically "pin down" all of the internal interfaces among the areas so that the synthesis tools can make all the right connections. |
H: Why is the Triode operating region of a MOSFET named such?
If triodes were used for amplifiers, why is the triode region generally used for digital and the saturation region generally used for analog? Am I missing a fundamental understanding of the MOSFET's characteristics?
AI: Why is the Triode operating region of a MOSFET named such?
When a FET is operating in the triode (ohmic) region, the drain current is strongly dependent on drain-source voltage. The plate current of a vacuum tube triode is also strongly dependent on plate-cathode voltage and this is, I believe, why the triode region of operation is so named.
FET drain curves operating in triode region:
Vacuum tube triode plate curves:
This strong dependence of drain (plate) current on \$v_{DS}\$ (\$v_{PK}\$) severely limits the available voltage gain of the device. The greater the dependence, the less available gain as this dependence is, in effect, acting as a resistor in parallel with the load, shunting signal current around the load.
So, although triodes were (and still are) used as amplifiers, tetrodes and pentodes were developed that, like the saturation region for FETs, greatly reduce the plate current dependence on plate-cathode voltage. These devices offer, among other things, much higher amplification factors, i.e., they have much higher plate impedances. |
H: What kind of diode to use with ADC inputs
I am looking for diodes to protect my ADC from over voltage conditions. From what I have researched so far, I know that I need schottky diodes hooked up from the input to the ground and the input to the VCC line, but I am confused of what properties of the diodes that I need to consider.
My ADC has a max input of 3V, and has some internal protection, but I have read that it is not good to rely on the internal protection circuitry. What kind of diodes properties would I need to protect my circuit, if someone accidently hooks up a 5V or a 12V input?
The diode properties that I am confused about are things like forward voltage, reverse voltage, etc.
AI: The function you describe is the use of "Clamping Diodes" to protect the ADC input from voltage swings too far above the positive rail, or too far below the negative (typically ground) rail.
See the the Voltage Clamp section in this nice Diodes and Transistors guide, and specifically the schematic provided in it:
The diode parameters of interest:
Forward voltage: Less than or equal to the ADC's upper tolerance limit above the nominal positive full-range voltage of the ADC (often Vcc, and specified as 3 Volts per your question) and the ADC's lower tolerance limit below ground voltage.
So if your 0-3 volt ADC is designed to not get damaged by inputs up to +4 volts and down to -1 volts, then maximum forward voltage required of D1 and D2 is 1 volt each, so the 0.7 volt silicon diodes shown in the schematic would be good enough
Schottky diodes are usually recommended not for low Vf, but for fast switching, since modern ADCs typically can tolerate voltages of at least a volt or two above Vcc, and a volt or two below ground, without harm.
In many cases a standard silicon diode might be better suited than a similarly rated Schottky due to its lower reverse leakage current.
Reverse breakdown voltage: Greater than the maximum envisaged voltage likely at the ADC input, even with erroneous connections. This is rarely a constraint with commonly used diodes.
Diode forward current rating: Sufficient to be able to serve as a short for the incoming signal difference after passing through the resistor R.
Thus, with a 12 Volt worst-case input, a 3 volt positive rail, 0.7 Volts Vf for D1, and R=100 Ohms, the diode should be able to handle 83 mA without magic smoke coming out. There is no dearth of suitable diodes meeting this parameter.
Notice that the diodes in the schematic are connected "upside down" compared to typical diode uses:
The idea is, when Vin is within the range {Vmax+Vf .. Vmin-Vf}, both the diodes are reverse biased, and only the marginal reverse leakage current flows through them.
When Vin goes above Vmax + Vf, the diode D1 conducts, and shorts the signal to the upper voltage line.
When Vin goes below Vmin - Vf, D2 conducts and shorts the signal to the lower voltage (or ground) line.
It is assumed that the upper and lower (ground) voltage rails are regulated with a low enough impedance that they can shunt the excess current from the clamping diode without perturbation of regulated voltage. Hence the ADC would never see those out-of-range voltages at Vout.
I hope this answered your questions. |
H: Exam question: measure amplifier \$h_{oe}\$ using a signal generator and oscilloscope
I'm running through some old exam papers at the moment and one of the questions are:
The parameter \$h_{oe}\$ is needed to calculate the output impedance of an amplifier. Explain in detail how to measure the parameter \$h_{oe}\$ practically in totality from start to end by using a signal generator and oscilloscope.
I've founf a couple of examples showing how to meazure the output impedance of an amplifier using a signal generator and an osciloscope with a variable resistor such as this example at learnabout-electronics.
In my book they go through an equation where you can get \$h_{oe}=\frac{Z_oR_3}{R_3-Z_o}\$ (This is from a Bootstrapped common emitter ammplifier circuit.) So would you go through the process to find the output impedance abnd then plug the values into the equation above and calculate \$h_{oe}\$?
Update
\$Z_o\$ is the output impedance and \$R_3\$ is the resister between the \$Ecc\$ and the collector which is dynamically in parrallel with the \$R_L\$.
AI: The answer to your question is yes. Measure Zo and then calculate hoe. |
H: Integrating Signals
Yes that simple,
Can someone explain what the main purpose is behind integrating an incoming signal?
What advantages does this offer over lets say reading the voltage directly with an A/D?
How does this function as a low-pass filter?
Ive seen the schematics and understand how they work, just trying to fill the gaps in my mental picture.
Thanks guys
AI: Integration, as you probably know, is a widely used effect and has many applications.
As it applies to determining Phase-Noise:
First we should distinguish the difference between "Phase Noise" and "Jitter". Phase noise in short, refers to random fluctuations in the phase of a signal. While jitter refers to random time domain fluctuations.
Now that we know the difference between the two, let's take a closer look at "phase noise" and determine why you would need an integral. While there are varying definitions of how to obtain a measurement of phase noise, every definition agrees on the fact that phase noise is read by determining the power spectral density of the signal.
Finally, let's look at the definition of power spectral density and it will become clear why you need the integral of the signal. While there are a few ways to determine the power spectral density of a signal, all of them involve the same symbol at some point... You guessed it: $$\int$$
So in review, you need to take the integral because:
To read the phase noise, you must know the power spectral density of the signal
To know the power spectral density, you must take the integral of the signal
Thus, we arrive back at the conclusion which Scott tersely led us to. You take the integral of the signal, because you need the integral of the signal. |
H: Can I add buttons to the Arduino ide that automates selection of serial port, board then compiles and uploads
I am developing four different Arduino projects. I want to have a button on the tool bar for each project that automatically compiles uploads using a fixed board and port.
AI: The only way to do that with the Arduino IDE would be to download the source and add the buttons to the java code.
If you are using windows you have the option to use Visual Studio Pro and the Arduino Plugin. The plugin is 100% compatible with Arduino and is easy to install. The important point being that it provides every Arduino function as a macro.
This means that you can extend the user interface easily using the Visual Studio standard Visual Studio customization features.
Basic example here
So, you can create your own macros using Arduino commands and attach the macros to your own buttons and menus. This allows you to re-program the micro-controller setting anything such as the Arduino Board, Serial Port etc. then Compile and Upload. You can even open a serial monitor on the correct port.
Considering your application a little more, you might also find it useful to know that in Visual Studio you could have all four projects open in a single solution using the same or different boards and serial ports. So your macro could simply switch the Visual Studio "Start Up Project" and call the standard Visual Studio "Start>Without Debugging" macro. This would be simpler to maintain than creating your own macro with hard coded settings such as board and port. |
H: 1S Lipo Powered BLDC Motor Control?
I have a 1S Lipo battery, and would like to drive a micro brushless motor at upwards of 6 Amps. I'm trying to design the h-bridges using 2 N channel mosfets each, but ran into the issue of finding a high-side/low-side driver that will drive mosfets at low voltages. Am I just completely missing the point here, or does such a product exist?
AI: A diagram and/or explanation of your proposed or available control signals and desired frequency of operation will help.
A full H Bridge requires 2 FETs per leg or 4 per bridge.
Each "leg" runs from V+ to ground with the motor connected to the middle.
Each leg is switched to connect the motor lead high or low.
Switching the motor led high and low simultaneously is very nearly always a very very nad idea :-).
A 1S LiPo cell produces 4.2V maximum output.
The low side drive voltage for this is so easily provided for N Channel FETS that a large range of drivers would be possible.
If an N Channel FET is used for the high side it needs Vbattery + Vgate for gate drive. 10V of drive would usually be acceptable and as low as about 6.5V would work with FETs with appropriately low gate drive voltages.
As long as a source of say 10V can be provided at modest power levels for gate drive, the high side control is a relatively trivial operation.
Bridge drivers are avaiable which provide high side gate voltages for hi-side N Channel FETs. Even many that would usually be used at much higher voltages are OK at 4.2V supply.
A LiPo cell can be run down to about 3V. As long as the driver IC ran OK on 3V it could be used directly.
A simple discrete design is possible. High side gate drivers can be as simple as 2 or 3 cheap small bipolar transistors per high side gate.
High side N Channel drive is not overly hard, but use of P Channel high side FETs means a high side driver supply above Vbattery is not required and high side drive becomes very very very easy indeed. If I was doing this at 6A and 4V or so then I'd see if suitable P Channel FETs were available (cost, specs, ...) as overall the circuit becomes very simple. |
H: Critique my Soft-start circuit
I've been working on a soft-start circuit to solve an inrush current problem that is causing some sparking when I hotplug my power supply into my board. I played around with different solutions and this is the one I like the best so far. It adds a delay of 250ms between Vin and Vout on the power MOSFET on my load.
My schematic:
My simulation results:
I want to get some opinions from the PROS out there.
Now, since I'm only using M1 to drive M2, there is no reason to use a power MOSFET, am I correct? I could use a small current MOSFET to drive the other one.
Edit:
Updated shcematic thanks to Kaz:
Edit #2:
I'm working on a soft-start circuit to avoid some sparking when I plug it my external power-supply to my board. I'm using 2 P-channel MOSFETS and some RC circuit to control the gate on one of them whicl will help me control the gate on the power mosfet that willl feed my board.
This is my little circuit:
R3 = My Load. I'm using max 8A hence I am representing it with a 3ohm resistor.
R2 and R4 are there to bias my MOSFET's gate with a Vgs goign from 0V to -12V.
The problem I am having is on biasing M1. Currently Vgs is going from -24V to 0V, and I need it to go from -12V to 0V, otherwise I might end up damaging the device. a Vgs of -24V is too high.
The only thing I could think of was shifting the reference point of C1 up by 12V using a voltage divider but I don't know if this is recommendable.
Like this:
My only concern now is the behaviour of the MOSFET, no matter how slow I ramp the Vgs voltage, it is still acting like an ON-OFF switch. Any ideas?
AI: There are a large number of off-the-shelf solutions to this sort of problem. The advantage that these schemes have is not only do they manage the hot-plug, they limit the inrush current so that the power supply isn't overloaded.
Your simulation result shows a wicked slew rate after 250ms - that doesn't look at all like soft-start to me. The voltage rise should be a ramp, not a straight edge. |
H: How do I dead bug solder this SOT-23 to my PCB?
I swapped the base and emitter of my NPN transistor land pattern. If I flip over the part, the pins are in the correct orientation, although there is a 1mm between the pins and the pads. When I tried to solder one I just made a mess. I soldered wire wrap wire in the vias and then tried to solder the wire to the pins. Is there a better technique?
Here is a photo of the part before I would desolder:
Here is the mess I made of a different one:
AI: One way is to leave the SOT-23 soldered to the board, simply cut those two traces on the PCB, and solder jumper wires to the base and emitter on the part, swapping the wires over to the correct vias. Cleaner, less risk of mess-up. |
H: Designing a simple ALU
I need to design an ALU with two 8-bit inputs A and B and control inputs x, y, and z that supports the following operations:
x y z | operation
0 0 0 | S = A-B
0 0 1 | S = A+B
0 1 0 | S = A*8
0 1 1 | S = A/8
1 0 0 | S = A NAND B (bitwise)
1 0 1 | S = A XOR B (bitwise)
1 1 0 | s = reverse the bits of A
1 1 1 | S = NOT A (bitwise)
This is supposed to be done with an 8-bit adder and an arithmetic-logic extender. Reading through my textbook, I see that the purpose of an AL-extender is to alter the input bits so that an adder, rather than a lot of extra components, can be used to do everything (or at least that's what I understand from it). For example, the AL-extender could put the bits in two's complement so that the adder does a subtraction. Likewise, for the bitwise logical operations, the bits could be altered appropriately and one of the adder inputs could just be zero so that the result comes through properly.
But what exactly do I do about multiplication? My book is very vague, so I'm not sure if an AL-extender would require me to do something clever to make the adder do the work (just add 8 times in my case? ...ha ha), or if I can just throw a multiplier in there. I'll have to read up on division, but I bet it's similar to multiplication.
Well, anyway, the bottom line is still, what is an AL-extender "allowed" to be/able to have in it? Is its only purpose to alter input so that it can be fed to an adder?
*EDIT: Well, it is multiplication/division by 8, so this can be easily performed with shifting left or right by 3. Would I still have a real/proper AL-extender if I added some shifters in there? (Maybe I'm overthinking this as a complete beginner...)
AI: The simplest approach would be to decode the x y z inputs into eight lines. Then from these, you implement logic which drives chip select lines to enable the appropriate unit which handles the inputs, as well as any transformations that are needed so that the unit performs the correct operation.
I don't think you can use an adder for your logic operations because the adder carries (unless it has some input which disables the behavior of carry propagation). But you can have a single unit to do all the logic.
Maybe there is a reason why they call these ALU's, with a separate A and L. :)
Multiplication by 8 just means driving zeros on the lowest three input lines, ignoring the upper three lines, and mapping line 0 to line 3, 1 to 4, and so on. It's like a railway switch. |
H: Arduino serial via python not working
I have a arduino running with bitlash running on it connected to a shiftbrite.
I can use a terminal program to send it commands such as rgb(1023,0,1023) and it will work but when I do it with python it doesn't.
Here is my python code. I don't know why it doesn't work. I can even print the string on an LCD connected to it and it comes out correctly
#Python Menu
#File: PythonMenu.py
#Basic menu system for use with Arduino and Shiftbrites
#over a wireless xbee link
import os #For clear
import time #For delay
import serial #For serial comms to the device
def printMenu():
"""Prints the menu ready with all options"""
print "/--------------------------------------------\\"
print "| | | | | /--- | | __ ---| |"
print "| |--| | | | - |--| |__ |___ |"
print "| | | |__| |__| | | |__ ___| |"
print "|--------------------------------------------|"
print "| Please select from the following options |"
print "| |"
print "| (1) White |"
print "| (2) Red |"
print "| (3) Green |"
print "| (4) Blue |"
print "| (5) Fade |"
print "| (6) Off |"
print "|--------------------------------------------|"
print "| (0) Exit |"
print "\\--------------------------------------------/"
def clear():
"""Clears the console screen"""
os.system('clear')
def sendColour( r, g, b ):
"""Sends a RGB value to the shiftbrite"""
#build up string
tmpData = "rgb("
tmpData += str(r)
tmpData += ","
tmpData += str(g)
tmpData += ","
tmpData += str(b)
tmpData += ")"
ser.write(tmpData)
print(tmpData)
return
###
#
###
#Setup serial
ser = serial.Serial('/dev/tty.usbserial-A600dJm8',9600)
#Start main code LOOP
while True:
clear()
printMenu()
userInput = raw_input('Selection:')
if userInput == '1':
sendColour(1023,1023,1023)
elif userInput == '2':
sendColour(1023,0,0)
elif userInput == '3':
sendColour(0,1023,0)
elif userInput == '4':
sendColour(0,0,1023)
elif userInput == '5':
sendColour(0,0,0) #To be implemented
elif userInput == '6':
sendColour(0,0,0)
elif userInput == '0':
print "Quitting"
ser.close()
exit()
time.sleep(2)
Anyone got any ideas?
AI: I think you are forgetting a line-feeds / carriage-return character to finish off the command. If you wrote a command in the terminal and hit enter they would be sent.
Change code to:
def sendColour( r, g, b ):
"""Sends a RGB value to the shiftbrite"""
#build up string
tmpData = "rgb("
tmpData += str(r)
tmpData += ","
tmpData += str(g)
tmpData += ","
tmpData += str(b)
tmpData += ")\n"
ser.write(tmpData)
print(tmpData)
return
Note the \n.
The bit lash-cmdline.c file has this in it:
void doCharacter(char c) {
if ((c == '\r') || (c == '\n') || (c == '`')) {
speol();
*lbufptr = 0;
doCommand(lbuf);
initlbuf();
}
(rest of function not included)
This suggests a '\r', '\n' or a '`' character can be used to terminate the command. |
H: Would replacing a resistor by another one of identical value but higher power rating affect the working of a circuit?
The schematic recommends using 20 Ω 1W as collector resistance.
What I have at hand are two 10 Ω rated for 10W. I'm guessing the change should be acceptable ...
What difference would it make if i were to use these two instead of that whose rating is specified?
AI: Other than overkill (or possible tolerance differences), two 10ohms in series (@10W) would be fine as a replacement-- there would only be possible cause for concern if they were underrated
(<1/2W ea). |
H: AC analysis from a DC fresh grad/point of view
So i was finished taking DC circuits and im adept at basic laws like KCL, KVL and Ohms. But today im taking AC circuits and i wondered why things dont work well as before. Lets take this example
A series RL circuit is connected to a 110-V ac
source. If the voltage across the resistor is 85 V, find
the voltage across the inductor.
So i solve it using phasors, using phytagoras for Vl, Vs and Vr, and I get the correct answer. Now when i try applying KVL around the loop, it doesnt give the correct answer (I just use KVL in a loop, Vs = Vr + Vl)
from the KVL perspective, everything in my equation seems valid, and so why it didn't end up the way phasors do?
PS: on the left part, youll see the phasors method, and right part is my so called KVL from DC circuits
AI: What you're missing in the second approach is that \$I\$, \$V_R\$, and \$V_L\$ have unknown phases, even if the magnitude of \$V_R\$ is known. KVL still works, but you have to be consistent in your treatment of complex numbers.
The 25V is an error. The magnitude of \$V_R\$ may be 85V, but its phase is not the same as the 110V input. The phase of the voltage across the resistor will lag that of the input, because the current through the inductor is lagging the voltage across it. As an extreme (non-physical) example, if the phase of \$V_R\$ were 180 degrees from the input voltage, the magnitude of \$V_L\$ would be 195 volts. |
H: Latching power switch question
I have the following circuit (source: EDN):
I understand the basic working principle of the circuit and it works fine when it is powered from a 1.5V source.
But when I power the circuit from a 9V source, by default it get's turned on instead of turning on only when the S1 switch is pushed.
So my question is:
what causes the circuit to get turned on by default, when the 9V is applied to it? Is it the leakage current of the transistors? Or is it something else?
I noticed that this behavior occurs only if C1 is discharged when the 9V is applied.
AI: This is one of those circuits that reminds me how clever some people can get with a handful of inexpensive bipolar transistors that can create a a boat-load of weird effects due to all the variables of transistor gain and parasitic effects, including the Miller capacitance of a few pF dominant on Vbc of the SCR pair.
I am going out on a limb here and going to suggest if you slowed the step input of 9V with a typical supply decoupling cap. or try any cap ~100pF across base-emitter of Q1,2 and/or Q3 (such as your finger tip), it may work but there are more reliable latch switch designs that actually toggle with each momentary operation and have a reliable power-on reset.
But why does it fail?
Now in your mind add 5pF of Miller capacitance on the schematic of every Vbc junction for the initial condition of V+=0V everywhere. Now do you see the transient current flowing thru Q1 c-b junction into the base of Q3. There is a chain reaction of a dozen pico-amps of charge current here getting amplified by Q3 into 1 microamp more than enough enough to bias R7 for 0.6V drop to fire Q2 into latching Q3.
Bam. You have an SCR latch.
Even noise could make this circuit false trigger depending condition of 9V battery and load and dozen other variables.
You have have heard that SCR's are prone to dv/dt noise and use snubbers to prevent false triggering by having a V+ capacitor on the rail and some series resistance to get less than < 1V/uS. Even good SCRs with sensitive gates also tend to be prone to "dv/dt supply noise" and false triggering unless very carefully designed.
Now how did you apply the 9V?
if you want a good CMOS toggle switch, just answer another question. |
H: Does there exist an IC that allows on-the-fly routing of signals?
Do there exist ICs with N input pins and N output pins which, either via EEPROM setting or via on-the-fly control by a microcontroller, allow one to route each of the N inputs to ANY of the N outputs?
In other words, for example, one might use it to connect the incoming line on Input1 to the outgoing line on Output6, and connect Input2 to Output3, and Input3 to Output1, and so on (regardless of whether the signals are SPI, or I2C, or standard digital lines, etc)... And later change up the order.
If it exists, what are such ICs called?
AI: What you're looking for is called a "crossbar chip". Since this is a fairly inefficient way to use silicon resources, the emphasis these days seems to be on using such chips to route very high speed LVDS signals. |
H: Prototyping with a very small surface mount connector/socket
I've got a Satellite modem with a connector that mates with a tiny 10pin by 10pin Samtec SS4 series surface mount connector.
The question is, how would I prototype with this component? I am thinking I will need to get a custom breakout board created and someone with precision equipment to solder the socket onto it for me?
Essentially, the strip has a centre-to-centre pin pitch of just 0.4mm and head pin is 0.23mm in width, making the distance between pins a tiny 0.17mm.
More information on the socket:
http://www.samtec.com/documents/webfiles/cpdf/SS4-XX-X.XX-X-D-X-XX-TR-FOOTPRINT.pdf
AI: When having to use connectors like these, and the associated high tech parts that tend to be used with them, it is often advisable to rethink and re-define what prototyping actually means. I would suggest that rather than get hung up on breakout boards that you consider a first pass at your circuit board design to be your prototype. Use all the part footprints that are for the target parts for your assembly. Feel free to add what ever additional test access connections and debug hardware as required to this initial design. This approach has many advantages including a main one that it puts the parts into the actual configuration they will be for your final product so that you are testing something real as opposed to debugging ghost problems on some cobbled together "quick setup". |
H: Using impulse response to control the system
This post by Olin Lathrop is rather inspiring.
The system response is the convolution of the control input with this
impulse response, computed every control sample, which is every 500 ms
in this example. To make control system out of this you work it
backwards to determine the control input that results in the desired
system output.
How is this done exactly - this "work it backwards to determine the control input"? I'm not expecting a full systems control course here, just a general description and some pointers to start looking for. Some pseudocode would be a bonus.
AI: You've entered into the wide and deep field of control theory. Here, Matlab with its comprehensive documentation will be your best guide. Matlab's help is a comprehensive compilation of many many textbooks. Where its help does not suffice, you can take a look at the references used to write the Help section you're interested in.
An impulse response is a unique way of describing a linear system. This means that two LTI systems with an identical impulse response can be judged to be mathematically identical - even if one is an automobile shock absorbeer and the other an electronic filter!
The impulse response is a useful way of testing the parameters of the system because it contains a wide range of frequencies. An ideal impulse contains ALL the frequencies from zero to infinity. In contrast, a sine wave has only a single frequency, so it's a very bad way of identifying a system. If your system is linear and time-invariant, a sinewave input will produce a sinewave on the output.
The problem you're describing is of a dual nature: you first identify a system. The knowledge of its parameters allows you to adjust the parameters of your controller. How do we work out these parameters? I recommend reading about System Identification in the Matlab Documentation. There are many textbooks on how to tackle this, but you're going to end up using a tool such as Matlab to learn this, anyway.
How do you adjust those control parameters? It's simpler than identifying a system, but there is a myriad of methods. There is no single way of doing this. There are dozens of controller topologies and many different ways of calculating the set of parameters that give you your desired response. For more information, read on about pole placement. There are many textbooks describing this. One of the best resources on this is the Matlab Control Toolbox Documentation.
For a simple SISO system you can derive the equations by hand. This tutorial explains more using a relatively simple example.
I hope this explains something. |
H: Hardware Defined Byte
I would like to make a PCB that sends a specific byte of information through a usb connection. I need the PCB to be as small and simple as possible to fit into a nice thin housing. Simply put there would be a push button that would send a byte of information identifying it had been pushed, without a micro-controller. Is there a way to specify a sequence of on-off 1-0 within the circuitry on the PCB? namely a byte. I've searched EVERYWHERE and haven't found anything relevant.
AI: USB is a master slave connection; for all practical purposes, let's assume you asked how to make a slave device which does this, as making a master is much more complicated.
While it would theoretically be possible to implement a USB slave interface as a state machine, in practical terms most implementations will use a microcontroller or stored-program processing core to handle the higher level protocol operations. Though possibly one with a factory installed firmware that is merely configurable, and not itself rewritable, by a circuit designer who utilizes it.
There are numerous physically tiny and/or inexpensive microcontrollers which implement true USB slave interfaces - pretty much every vendor offers one. For your purposes, available packages and external vs. internal oscillators may be a consideration - ease of development may also matter (for example, being able to install a raw chip on a board and program it over USB is nice, but sometimes a mid- to high- end feature).
Another option for a small project of this sort is a software emulation of the lowest rate version of USB on a small general purpose microcontroller. There are examples floating around on the net for building things using an ATTINY85 and a few zener diodes or LEDs to approximate the required signal voltage ranges, clocked off the internal oscillator so no crystal or resonator is needed. These aren't officially compliant USB implementations, but in many cases they work, and can be a simple way to have something that looks like a keyboard or virtual serial port and sends simple data in response to the state of a pin, or possible even does more complex things.
Given that microcontroller solutions are no more expensive than dedicated ones, and no physically larger, it's not clear why it would be desirable to avoid a solution of that nature. |
H: Logic needed to read and store values
I am new to programming. I have one input signal from waveform generator. I am giving this signal to one sensor and as well as channel 1 of multiplexer. The sensor output is giving to channel 2 of multiplexer. If sensor output is low then I am using some amplification, the signal after amplification is giving to channel 3 of multiplexer. I am using switch case to select one of the input as output of the multiplexer. The multiplexer output is giving to external ADC and I am able to read ADC value.
My problem is I need both sensor input voltage and sensor output voltage for calculating impedance but I have written one function to read ADC values. Is there any possibility to get input and output voltage using same read ADC function and I have to use both voltage values later on. Or I have to write two different read ADC functions to read input and output voltage values. Any advice please.
I am using C language.
Edited:
Hi,
I am able to read different MUX channels.
I am able to select first channel and reading ADC value and stored in a variable. If i change MUX channel to channel 2 and tried to read ADC and stored in another variable.
But the problem is when i tried to read second channel, first time it is giving previous channel value and then if i read second time then it is giving second channel actual value. Can any one suggest me how to overcome this.
I want to get the original value of that channel first time itself?
I have tried like this.
switch(c) {
case '1':
PORTB = 0x00;
SetWGFreq(arg);
Delay(1000);
mux1 = readADC();
printf("muxchanel 1 adc RawData:%d\r\n", mux1);
Command = 0;
break;
case '2':
PORTB = 0x04;
SetWGFreq(arg);
Delay(1000);
mux2 = readADC();
printf("muxchanel 2 ADC RawData:%d\r\n", mux2);
Command = 0;
break;
default:
Command = 0;
break;
}
But I have tried to print the ADC value out side the switch case. There it is changing at first time but when i tried to print within switch case I have to enter that case twice.
AI: You should select channel 1 of you MUX. read one value using the read function. Store it in a variable. Then switch your MUX to channel 2. Read the value using the same ADC read function and store it in another variable.
Then you can do the computation using the value stored into the first and second variable.
That's it. |
H: Circuit short circuit capacitor question confusion
I am really unsure about how to go about this question and which circuits to consider.
Here's the question:
Determine the value of the current labeled \$i\$ and the voltage labeled \$v\$ at \$t=0+\$, \$t=1.5ms\$, and \$t = 3.0ms\$.
The circuit is as follows:
simulate this circuit – Schematic created using CircuitLab
Relevant equations:
Ohm's law: \$v = iR\$
Decay in source free RC Circuit \$v(t) = v(0) e^{-t/RC}\$
The attempt at a solution:
\$i(0-) = 0.1 A.\$
Therefore,
\$v\$ across 200 ohm: \$200 * 0.1 = 20 V\$
Since no current flows through capacitor with constant dc current,
\$v\$ across capacitor: \$20 V @ t < 0\$
\$v\$ across capacitor cannot change immediately as it would require infinite power so \$v\$ across capacitor @ \$t = 0\$ is \$20V\$
Here's where the confusion is: Should I include the 200 ohm resistor in my RC circuit? Why or why not? Also, will my circuit be a source free RC circuit?
Also, what will be the current i through the 200 ohm resistor when t>0?
My last question is a theoretical one: Can a current through a resistor change immediately at one instant of time?
AI: The voltage across a capacitor discharging into a fixed resistance decays exponentially. The time constant is RC, where C is the capacitance, and R is the resistance between the terminals of the resistor.
$$
V(t)=V(0)e^{\frac{-t}{RC}} \\
$$
You're right that the capacitor starts at 20V, because that's the voltage across the 200 ohm resistor after the capacitor is charged. So you know V(0), and you know C. All you're missing is R. To analyze that properly, think of the switch as a resistor of 0 ohms when closed, and don't worry about the current source. The parallel combination of a 200 ohm resistor and a 0 ohm resistor is 0 ohms. The series combination of a 50 ohm resistor and a 0 ohm resistor is 50 ohms. So the 50 ohm resistor is the only one that matters when determining your discharge constant.
The current through the 200 ohm resistor depends on the voltage across the 200 ohm resistor. The voltage across the 200 ohm resistor is the same as the voltage across the 0 ohm resistor (the closed switch). V=IR, so what's the voltage across that pair of resistors when the switch is closed?
And yes, the voltage across an ideal resistor can change instantaneously. Keep in mind though, there's no such thing as an ideal resistor in the physical world. Everything has capacitance to everything else. |
H: Understanding electrical consumption
I have problems understanding the difference between electrical power and consumption. Can you help me understand what electrical energy consumption is?
Let's say that I have a bulb, on which is written 100 W. How much does this bulb consume in 1 hour? Can it have a power lower than 100 W? Can it have a power greater than 100 W?
I would like to know what is the relation between electrical power and electrical consumption.
I'm very sorry for the big disambiguation from my head. But I don’t know who else to ask. I hope that you will not consider my question as stupid, even if is so.
AI: The issue you're confused about seems to be the difference between power and energy.
Energy is how much work you can do. Common units are joules or watt-hours.
Power is how fast you do work. It's a rate of change. Common units are watts or horsepower. Horsepower is probably an instructive unit to consider. Say you wanted to move a large pile of straw. Whether it's moved by a horse or a housecat doesn't affect the amount of work done. But the horse does it faster, because it's a more powerful animal.
For the purposes of discussing grid electricity consumption, watts (W) and kilowatt-hours (kWh) are the most common units used. To know how much energy is consumed, multiply the power by the time. 100 W x 1 hour is 100 watt-hours, or .1 kWh. In short, the relationship between power and consumption is time.
A 100W bulb consumes 100W assuming the voltage across it is what's specified on the package, which is usually 120V in my experience. If the voltage at your socket is lower, the bulb will consume less power. It's approximately a fixed resistance, so the power consumed is
$$
P=\frac{V^2}{R}
$$
As an aside, remember energy conservation. If something consumes 100W, that energy is being converted to some other form. Either it gets stored (potential energy), it's used (light, motion, etc.), or it's wasted as heat. For an incandescent bulb, ~90% of the power consumed is converted to heat. So a 100W incandescent bulb consumes 100W, but only outputs 10W of light. It gets hot because the other 90W is being wasted. Which is why CFL's run so much cooler and consume less power for the same light output. |
H: Input impedance of a GenRad 2512 Spectrum Analyzer
Does anyone know the input impedance on the General Radio Model 2512 Spectrum Analyzer?
AI: Well according to this document on page 351 it's 1Meg Ohm with a shunted 115pF cap.
http://www.scribd.com/doc/66163879/General-Radio-Handbook-of-Noise-Measurement-by-Arnold-P-G-Peterson |
H: How do I solder headers so that they always stand straight up?
When soldering headers, usually single and double pins, I flip the board over so the pin rests on the surface and then solder them. They never come out straight. It would be great if someone has figured out how to do this correctly?
AI: Solder ONE PIN. Reheat the solder while pushing down to make sure the element is flat. When convinced, solder the rest of the pins. As a last step, reheat the original joint just to make sure it wasn't moving as it cooled, which is a bad thing for a solder joint. This technique works equally well for through holes and SMT.
I've used a PCB cradle with a foam cushioned arm that works pretty well. You can hold down elements and then rotate the board. |
H: Resistor value labeling, what does the second number refer to?
Possible Duplicate:
µ in the Middle of a Capacitor Rating
What does 3V3 or 1V8 mean
I have been looking over some schematics for an industrial Laser. Some resistors which have low values, say 100 Ohms, are labelled 100R. Makes sense. Same goes for 1000 ohms, 1k. again makes sense. But there are a few that have a additional number. For example I see one labelled 5K1. I assume its a 5k ohm resistor but what does the 1 mean? I was looking at another schematic and it has a bunch of resistors but two of them are 3K9. Again whats with the 9?
AI: Most likely the 'K' position indicates the decimal point position.
So,
$$ 5K1 \equiv 5.1k\Omega $$
$$ 3K9 \equiv 3.9k\Omega $$
In the same vein as:
$$ 3V3 \equiv 3.3V $$
Just a way to save characters/area, and avoids the issue of the decimal point fading out when printing/copying/faxing. |
H: LF398 Sample and Hold Circuit
I'm having a problem designing a circuit to interface an LF398. On it's data sheet it says that it needs +5 and -5 volts, but I only have +5.
My questions are:
Can I put V+ on 5V and V- on ground and still have a viable circuit and how would this constrain my input values?
Is there a way I can get both 5V and -5V without using another IC?
As a plan B, I could use an voltage inverter to get the -5, but this would require another dedicated IC. The samples that I'm trying to hold will be in the -1 to 1 volts range.
A little background: I'm building a pulse oximeter for a class project. We have 2 flashing LEDs that reflect off of skin into a photodiode that is connected to a microcontroller for processing. The series of events should be: LED flash -> Photodiode -> S&H -> Micro. The S&H IC should sample when that specific LED is high.
RM: LF389 does nort exist - changed to LF398
AI: The data sheet clearly says "operates from +/- 5V to +/- 18V supplies"
ie it needs a minimum of 10V from V+ to V- to operate (and a maximum of 36V).
Why would you expect it to operate on only 5V?
It does not care if you ground V- and use +10V or ground V+ and use -10V but you need 10V minimum supply.
Note that at the top of each data table it says that the figures apply for
V- + 3.5V < Vin < V+-3.5V.
ie signals must not be closer than 3.5V from either supply rail.
So on a +/- supply you get +/- 1.5V signal range.
There is a small chance that it will run on slightly less voltage than specified, but if it did there would be no guarantee re performance.
The world is awash with ways of making dual supplies. Two batteries, voltage divider from one supply, two winding power supply. ... . That's a reasonably nice IC that you are using - it deserves to be fed properly. You say that you only have +5V. Why? How?
About the cheapest build your own solution is to use an MC34063 - various application circuits with PCB layout in datasheet. But you can buy modules for a few dollars on ebay that do what you want. |
H: How to start implementing your own computer?
The question
As a first step I need to select a circuit board, CPU & RAM/ROM chips and I/O connectors. How do I select a board that can interconnect all these components? Perhaps you could give examples of a full configuration (board and chip models). What type of board would you recommend for a beginner (solderless, stripboard, PCB, ...) ?
Project Outcome: create a motherboard by myself to which I could connect a monitor and a keyboard and the monitor would display the keys I've typed. An additional extension would be receiving and sending data from a network interface.
Question background
I have a fairly decent background in software development. However I would like to start doing some hardware projects in my spare time.
I've been looking around on the internet for materials to understand how programs are executed on hardware. Two great resources I've found are the http://nand2tetris.org/ which I am currently undergoing and the raspberrypi motherboard which seems like a simple hardware platform to write your first OS. Given the understanding I can get about the basic workings of operating systems from those resources I would like to start to assemble my own motherboard using standard ICs and write programs for it.
Could you give some initial pointers on where to look for information regarding such kind of projects? In particular I have no idea which ICs would make up a working computer, which kind of board to use to assemble them, how to create the circuits between the ICs. Any kind of information on those basic things would be useful to get me started.
UPDATE:
Since the question seems to be considered vague (how else it could be if you need some kick-start information on an unknown topic) I would like to emphasize that I know programming (Java, C/C++, Python, Assembler x86), i've also done some projects in tools like OrCAD etc. The problems I am struggling with are:
I've never learned the basics for working with physical components
I have little knowledge in components other than general purpose CPU and RAM/ROM chips and how they interconnect with CPU and memory chips in order to make a working computer (the clock, power supply unit, keyboard/monitor/network interface units)
So given all this I need some pointer to resources that contain step-by-step instructions on buying the necessary components and assembling them into a working mini computer. An example of such a resource is the one given by Alfred Centauri in the comments below. [A Homebuilt Z-80 Computer].
AI: If you really want to do this, I suggest looking at old processors; something of the 6502 or 8080 vintage. In those days, you could take a cpu and some external chips and assemble a working - if limited - computer. Newer processors are much more exacting and challenging to work with.
Note that this is huge undertaking; do a search for the apple 1 schematic, and you'll get some idea of what it will take. Then you get to start writing software for it, and you'll get to do at least some of it in assembly.
If you're actually trying to get things done, the current crop of microcontrollers are so much easier to use; you can write in C/C++, they have great built-in capabilities, and they're cheap. |
H: BBQ iginter power surge
I am building a home beer brewing rig that has several electrically actuated components controlled by an Arduino.
The typical scheme is Arduino -> Shift Register -> Relay -> Component.
One of the components is an electrical BBQ igniter. The problem is that when I turn it on, the shift registers go all wonky and randomly turn their outputs on and off with every spark.
I realize that the main problem is that the igniter is being energized by the same power supply as the rest of the system and that it creates a power surge when it generates a spark. But, how do I neutralize that problem?
One idea I had was to put a capacitor across the igniter input. That didn't help. My analog circuit knowledge is not so awesome.
Anybody have any ideas? Much appreciated.
P.S. The shift registers are 74HC595.
AI: The capacitors should go across the power supply terminals of the various components like the shift register and igniter, to bypass noise riding on top of the power. When noise comes from some other device, the capacitor can help shunt it to ground. Reciprocally, when a sudden, brief current demand comes from the local device near that capacitor, the capacitor supplies the demand, so that there is less of an effect on distant parts of the circuit.
For better answers, you might want to show the exact circuit diagram, including power supply details. |
H: What is the polarity of a car cigarette lighter adapter?
There is a center pin, and two outside tabs. Which are positive and negative?
AI: Every car that I have seen had center-positive cigarette lighter 'sockets'.
All (as far as I know) modern cars use negative ground systems, so the outer negative 'body' is vehicle ground and positive center is battery
You would expect this polarity to be maintained even with positive ground vehicles made by any sane manufacturer (and most insane ones as well).
AFAIR some old British Vehicles and Volkswagens had positive ground systems. No doubt there were others. |
H: 9v AC 2000mA power adaptor for a 9v AC 1000mA device
Possible Duplicate:
Choosing power supply, how to get the voltage and current ratings?
I need to replace a 9v AC 1000mA adapter for a 9v AC 1000mA device but all I've been able to find is a 9v AC 2000mA adapter.
Will this work or will it fry my device?
AI: Yes, that's fine.
The voltage matches (important point #1), and the adapter can deliver 1000 mA or more (important point #2).
The current rating for a power adapter says how much it can provide; how much it actually does provide is up to the load.
In other words, any adapter that is 9 V and 1000+ mA should work just fine. |
H: 110V AC/ 9V AC power adapter (America) Vs. 220V AC/ 9V AC power adapter (Europe)
Possible Duplicate:
Choosing power supply, how to get the voltage and current ratings?
I have a device that I brought to Europe from America. It has a 110V AC/ 9V AC power adapter that stopped working. Over here I found a 220V AC/ 9V. I'd like to know if it'll work despite the 110V/220V difference since the device will receive the same 9V
AI: Your 9 V AC will be 9 V AC; the secondary side doesn't know about the primary voltage. So that's no problem.
What could be important is that in Europe you'll have 50 Hz output, whereas the US adapter will output 60 Hz. (Well, it doesn't make 60 Hz, that's what the mains supplies in the US.) This is not a problem if the device converts it to DC (most likely), but if you would use it for a digital clock that will run 17 % slow if it gets its clock from the mains frequency, and expects 60 Hz. |
H: Explanation for Differing Stator Winding Orientations
As a layperson, I'm trying to understand the basic configuration for an induction motor or generator. I've looked at many diagrams and photos/cutaways of stator wiring and I've noticed two different orientations for the windings:
All the diagrams/photos I've seen show an individual winding in the shape of a rectangle with rounded corners.
Type One - The axis of the winding points toward the shaft of the rotor.
Type Two - The axis of the winding points 90deg away from the the shaft of the rotor.
The difference between these two orientations is making it difficult for me to conceptualize the "rotating electromagnetic field" that exists in motors/generators. I am looking for an explanation of the pusposes behind these two winding orientations.
[EDIT]
45deg orientation:
0deg orientation:
90deg orientation: I can't find one right now.
AI: I think you may have found a good example of something that I've been looking for which came up in my answer to this question. Namely, the difference between a sinusoidally wound motor and a trapezoidally wound motor.
The way in which a motor is wound controls the distribution of the magnetic flux density throughout the motor. Which in turn controls the shape of the Back-EMF, which in turn dictates how best to drive the motor (i.e. which commutation method you choose). The different control methods can be read about in the aforementioned answer.
The below diagrams are taken from the master's thesis of James Mevey. This first diagram shows two simplified motors. Each has only a single winding. The motor on the left has "sinusoidally shaped" magnets and the motor on the right has "trapezoidally shaped" magnets.
The resultant flux densities look like so:
Having magnets of the shape in the right hand motor and modifying the distribution of the windings would have a very similar effect.
I think that your "45° orientation" motor is sinusoidally wound. And if you were able to look at how the windings are connected and overlapped you should be able to see how the magnetic field would get stronger and weaker in a sinusoidal pattern.
And I think that your "0° orientation" motor is trapezoidally wound. Which you can almost see since the windings are distributed in just a few big blocks.
As for your "90° orientation" motor, I think you mean this:
Which is a whole different beast. That is a picture of Shane Colton's Less Epic Axial Flux (LEAF) motor.
The motors shown at the top of my answer and in the OP are radial flux motors. In this design, the rotor is on the inside (or occasionally on the outside) of the stator windings. In an axial flux motor, the rotor is in front of the stator windings.
The benefits of an axial flux motor are that it can be made thinner and lighter allowing it to fit better into certain geometries and change direction quicker.
Visualization of the rotating magnetic field can be difficult without good software.
But usually a good motor manufacturer will provide you with all the details on how best to drive their motor on the side of the box. Still, the references in the answer I linked above and in this answer provide a wealth of information (perhaps too much) on what exactly is going on inside a motor as it's driven. |
H: Potential difference across one resistor with and without a known current?
Okay imagine you have a voltage supply of 10V and one Resistor of 5 Ohms.
Now find the current : I=5/10 = 0.5A
So potential difference across that resistor : V=IR=10V .. which proves this statement I found in my lecture note :
If no internal resistance is present in voltage supply, the potential difference across the resistor is equal to supply voltage.
Now imagine the same circuit but total current is given as 0.1A . The potential difference is V=IR=0.1*5=0.5V, which basically means the statement above is incorrect.
However, my question is regarding the supplied current : what does it mean when the current is given or the need to find it ourselves ?? Is it possible to have the same voltage supply but with a different current supply ?
Let me know if you need more clarification
AI: V=IR=10V .. which proves this statement I found in my lecture note
If no internal resistance is present in voltage supply, the potential difference across the resistor is equal to supply voltage.
You don't need to measure anything to prove this statement. It's a simple consequence of Kirchoff's voltage law. If you have a perfect 10 V voltage supply, no matter what you connect across it, the voltage across that element will be 10 V.
Now imagine the same circuit but total current is given as 0.1A . The potential difference is V=IR=0.1*5=0.5V, which basically means the statement above is incorrect.
I'll assume you know that your supply has an open-circuit voltage of 10 V, but you don't know the internal resistance.
If you measure 0.1 A, then you know the total resistance is 100 Ohms. This total resistance is made up of the supply's internal resistance and your external load (5 Ohms). Therefore you know the internal resistance is 95 Ohms. |
H: tablet as a keyboard (bluetooth / USB)
what would it take to get a tablet to communicate with a desktop via bluetooth (or USB)? There are some programs such as remotemouse which do this through WLAN.
AI: Get an android tablet, root it, and run blueputdroid. This is not related to electrical engineering. |
H: grounding connection?
What's the easiest way to connect a ring terminal to the ground terminal of an AC outlet? Are there plugs you can buy that make this easy?
I don't need (or want) the line and neutral wires accessible, just the ground terminal, for safety reasons.
AI: Another option is to get a replacement plug and just only connect to the ground pin.
This isn't as cheap as Michael's solution, but its easier to move from place to place. |
H: Why do I get gibrish output to the serial monitor of my arduino mega 2560?
All -
Why does my Arduino 2560 report text that looks like this:
I©ä
I©ä
!11<]=I1)!11<]=I1)!11<]=I1!11<]=I1)!11<]=I1©ä
é
©ä
I©ä
I©ä
I©ä
I©
Every time I execute "spi_dev_test" from my raspberry pi?
I have been trying to follow the instructions on this website :
http://mitchtech.net/raspberry-pi-arduino-spi/
But these instructions are for an Arduino Uno whereas I am using an Arduino 2560.
I looked up documentation for the 2560 here:
http://www.jameco.com/Jameco/Products/ProdDS/2121113.pdf
and it has indicated the SPI pins are SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).
I wired them like so:
RaspberryPi-MOSI ======>> 51(MOSI) on 2560
RaspberryPi-MISO ======>> 50(MISO) on 2560
RaspberryPi-CSO ======>> 52(SCK) on 2560
RaspberryPi-GND ======>> GND(just next to 53 on 2560).
According to the website I'm supposed to see "HELLO WORLD" output to the Arudino's serial monitor console.
The serial monitor baud rate is 115200. I have Tools >> Programmer set to "Arduino as ISP" but I've tried all other options with no success.
Would appreciate all / any advise.
AI: Your captured outputs look like either a MISO-MOSI inverted connection, a baud rate mismatch or a sync problem. Sequence of steps to diagnose this:
Check your serial settings: both sides should have the same configuration for data rate, parity, data bits and stop bits. 9600 baud/no parity/8 data bits/1 stop bit is a good starting point.
Set up both devices to a low, identical baud rate e.g. 9600 baud, then increase it if 9600 works. Push it up till a possible bottleneck at serial handling code or cabling / connections shows up.
Switch the MOSI and MISO lines at any one device - if you get nothing at all then switch them back.
If all the above steps fail, please update your question with results observed. |
H: after programming PIC, can no longer run debug or reprogram
OK, I have written a few basic programs in MPLABX C18 for both 18f4550 and 18f46k20. Eventually got them to compile and test/debug correctly and run on the PIC. After I choose, "make and program device" It works but I can no longer run debug or re-program the chip. Always says the device doesn't match, etc. Here is what the output window says:
Connecting to MPLAB ICD 3...
Firmware Suite Version.....01.28.07
Firmware type..............PIC18F
Target detected
Device ID Revision = 7
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x1ff
configuration memory
Programming...
program memory
Address: c Expected Value: 6a Received Value: 36
Failed to program device
Any ideas?
Thanks
AI: The PIC may have been told to 'raise its shields' or may have been programmed to not respond to the programmer clock or oscillator control network. These problems are usually recoverable by following a suitable path. A circuit diagram of your target application may be useful.
Without looking at your specific PIC:
You may have code protection set.
The device should be able to be erased with code protection set.
You may have selected a clock type that the programmer does not support.
Worst case if it is not seeing your programmer clock or crystal you may have to uses ICSP with the PIC in a breadboard and supply a clock source or crystal or resonator or RC network or whatever that allows the PIC to run so it can listen to the programmer well enough to find its way home.
There is a small chance that it has been damaged in the process and is irrecoverable. Be sure to use adequate anti-static precautions and correct operating voltages, insert and remove with power off, ensure that no signal levels exceed absolute maximum values. |
H: Reading a PIC datasheet
Reading MCU and component datasheets is a whole new skill to me.
I have a wire that I want to monitor as high/low (1/0) voltage, using a PIC10F200. (datasheet)
I presume somewhere in the datasheet the min/max voltage an IO pin configured as input guarantees to read 1 or 0 is defined.
Can someone teach me how to find these values in the datasheet for this particular PIC?
AI: Most microcontroller datasheets have a section "(DC) electrical characteristics", usually after the functional description of the device. Electrical characteristics usually start with "Absolute Maximum Ratings" (AMR), which you may want to look at too, and especially the note below the table.
You'll see that there are different tables for "Industrial" and "Extended" parts. This refers to their operation temperature range; Industrial is up to 85 °C, extended up to 125 °C. You'll probably want Industrial, which is the standard range. Then on page 67 (Acrobat Reader page 69) you'll find \$V_{IL}\$ and \$V_{IH}\$, which is the maximum input voltage which will be read as a low level and the minimum which will be read as a high level. Most microcontrollers only have one type of input, and then there's just one value for each, usually as a fraction of the supply voltage.
For the standard type I/Os you have
\$V_{IL}\$ is 0.15 \$V_{DD}\$ maximum, so for a 5 V supply that's 0.75 V.
\$V_{IH}\$ is 0.25 \$V_{DD}\$ + 0.8 V minimum, for a 5 V supply voltage that's 2.05 V.
Notes:
1. At the top of the table the conditions for these parameters are mentioned. Sometimes that includes power supply voltage range, but here it's only temperature range.
2. The equation for \$V_{IH}\$ with the constant factor of 0.8 V is a bit unusual. You'll more often find a value like 0.7 \$V_{DD}\$ = 3.5 V. |
H: Name this electronic connector
Pins = 16x2
Space between pins = around 2mm
What i really need is the name of a female adaptor to connect to it in order to have cables like this. Thanks!
AI: DIL / dual-in-line header.
These are available with insulation displacement connectors (IDC) allowing termination to ribbon cables, and can be bought preterminated. Molex make these and also probably have solderable versions (you'll be sorry).
IF the pitch is 2.54mm, which seems likely, then an old floppy disk drive cable (34 pins) is probably an easy solution.
You MAY have a 2mm pitch header but 2.54 mm or 2.5mm is much more likely.
Spacing is usually either 2.54mm = 0.1" or 2.5mm = not quite 0.1".
The two are interchangeable (for non-purists) after a fashion for small numbers of pins but get out of alignment by 0.04mm per pin.
When measuring something like this it is a very very (very) good idea to give people as accurate a pitch measurement as you reasonably can. In this case you have 16 pins so there are 15 x pitch distances between 1st and last pin. Measure this distance and divide by 15. Or measure 10 pitches between pins 1 & 11 and divide by 10.
Even for 10 pins 10 x 2.5 = 25mm and 10 x 2.54 = 25.4mm so you could probably detect the difference with a standard metal metric ruler calibrated in mm. At 15 pitches it is 37.5 and 38.1 mm for a difference of 0.6mm. OR if it is some pitch closest to 2mm (unlikely) it will be different.
2 of these](http://www.pololu.com/catalog/product/973) from Polulu may do, depending on how they butt, BUT you can buy 32 pin ones.
An old floppy disk drive cable is 2 x 17 pin.
A HDD parallel access cable is 40 pin
Various examples here
Mouser have a very nice parametric selector that includes cable assemblies BUT no 32 way flat cables listed. (Check for yourself just in case). |
H: Is it possible to intercept the audio data of voice call in Android?
To my konwledge, the (voice call) audio data from micphone will be sent to PCM module for resampling, then to modem for coding before sending to air.I am here for asking in Android is it possible to intercept the audio data from PCM to modem? Because I want to encrypt them before sending out.
Thank you ..
AI: You can record all Microphone audio using the Google API with your own software. Also - note that not all Android phones allow to capture incoming audio because of hardware limitations.
It will be better if your create your own Native application and use VoiP for your outbound audio, which is easily achieved because there are many VoiP application out there.
You cannot bypass the Google API because the driver level is protected by the Operating System. You application only has access to the API that the OS exposes to you. So if there is no API similar to "RedirectMIcrophoneToAuxAndThenToGSM" - then sorry you cannot do it- even using Native Java code.
Alternatives
Get Android source code and make the changes you need. Compile it and programme the devices yourself. This is not an easy task for end users and would normally be done on company phones. This is great because users cannot turn of the encryption stream you are trying to force because you control the API!
Make your own android phone device or get a Chinese factory to make one for you with a custom GSM encrypted/decrypted module. Hardware encryption is allot faster
I think the sole reason why NO phones allow you to replace the outgoing GSM audio with a altered one is it most likely illegal. TO prevent voice masking in terror, bullying, extortion, black mail,etc ...
Since you have a legitamate reason to encrypt your voice that must mean there is high financial benefit involved- So inherently you must make your own device to do it. |
H: 10-bit digital representation with SPDT switches and voltage division
I'm completely new to electronics, and have been trying to come up with a way to connect 10 SPDT switches to a single analog pin on my Ardiono Mega 2560 (and off course connected to 5V and Ground). The idea is to enable as many switches on a single pin, to try and free up pins for other uses.
I've put 10 switches in series, with unique resistor values on one pole of each, and in this way, trying to represent the bit values, 1,2,4,8,16,32,64,128,512, which will give me a resolution of 0-1023 integral values, which is the range that I understand the ADC on the Arduino chip supports. The voltage divider works, and gives the correct voltage, but ONLY when a single switch is flipped.
My circuit looks as follows:
Here we can see that the last switch is thrown, and the output voltage is 2.5V, which corresponds to a digital value of 512 as expected. However, when using more than one switch, the voltage drops more, giving me the inverse result of what I'm looking for.
I don't know if what I'm showing here makes sense, but ideally, I want to be able to detect the position of any combination of switches, by converting the voltage to binary and work from there.
AI: This isn't going to work. Between the accuracy of your resistors and the accuracy of the A/D, you're not going to get exactly one known reading for each unique switches setting. Not even close.
In general the way to produce a set of evenly spaced analog values from different switch settings is to do what most D/As do, which is to use a R-2R ladder. I have to do something else now, so don't have time to get into what a R-2R ladder is, maybe later. However, this is a well known construct and you will easily find lots about it out there.
Carefully look at your D/A error budget and that of the A/D. With .1% resistors and depending on the absolute accuracy of the A/D, you might be able to resolve 8 switches if everything works out right. 7 or 6 switches sounds a lot more doable. 10 is definitely in the guaranteed to fail range. |
H: RS232 concurrent communication
I need to interface with a printer equipped with a RS232 port from both my arduino microcontroller and my computer. It means that the printer is connected to the computer through the RS232 port and I would like to connect an arduino card to the same RS232 port in order to send some commands.
Which is the best design to put in place this solution?
AI: Hackers' way to do it, assuming cabling is short and ignoring the possibility or the severity of conflict between Arduino and the PC, would be to connect Tx lines over diodes + resistor circuits. Their Rx lines can be spliced together with no worries, and connected to printer's Tx line.
The goal is to allow each RS232 port's MARK (positive voltage) level to override other port's SPACE (negative voltage) level and vice versa, but OTOH to keep the SPACE level present on the line when both of Tx's are silent.
That means that each Tx line should be connected to joint line by two parallel branches: first, a diode with anode on Tx output and cathode on line (printer's Rx) and second, a diode and resistor in series, oriented the other way around - cathode towards Tx, anode towards printer's Rx. I can't tell you the resistance value from the top of my head, I would start with 10K, but if you have trouble with serial communication speed, try substituting smaller ones until it works.
I hope I was clear, but here is attempt of ASCII art schematic, copy it and paste into ASCII editor with fixed width font:
PC Tx -------+---------------+
| |
+----[Resistor]-+
|
+---------- Printer Rx
|
Arduino Tx --+---------------+
| |
+----[Resistor]-+ |
H: *EP pin connect to Ground
I was just wondering what is the function of the *EP pin on most TQFN package chips?
It says I should connect EP to ground, what happens if I don't ground it (I forgot)?
AI: You talking about the pad on the underside of the part? Most likely that's there to dissipate heat. People like to put parts in smaller and smaller packages but the heat that the silicon generates needs to get out somewhere. If it's just some digital IC and it has other GND pins it will most likely work. Should be fine if you're just messing around or prototyping, but fix it before you make more. Just watch the temperature of the thing.
If it's a mosfet or some other driver designed to dissipate heat then you may be in trouble. You might be able to counter it by putting a little heat sink on top of it. On the other hand if there's no other GND connection then you're in trouble.
Usually an IC is designed to operate in a range of temperatures so if you're just on the bench at 27C you have a good chance of being ok for now.
When you fix your board keep in mind that you probably don't want to just "connect" it to GND. If you look in the back of the datasheet for it you'll probably see a recommended land pattern that shows how many vias it wants to GND and maybe even a requirement to have some copper fill connected to it on the back. |
H: Op-amps that get really close to the supply voltage
I've heard that I can get an Op-amp that will be able to get it's output to within a few millivolts of the supply voltage.
Do these exist? If so then where or how do I find them.
If you want specifics, it needs to be able to work at 3.6 volts, have two op-amps and be available in a SOIC 8.
Thanks.
AI: What you want is called a rail-to-rail op-amp. Digikey lets you narrow by that as a parameter, under "Output Type". Some of the more common ones in the package you want include:
LMC662
TS912
LMV358
MCP6002
I've personally made good use of MCP6002 in a DIP8 package. |
H: Multiplex two displays or use a higher pin count uC?
I am currently learning to program a NXP LPC1347 for a project which will utilize two SSD1963 controller-based displays. The issue is that the uC only has 51 IO pins whereas the total pins of the display would amount to 26. This leaves too few pins for the peripherals that I need to have on the board (switches, UART, SPI, I2C)
I was initially going to upgrade to a LPC17xx but I figured I could also multiplex the 8-bit data and could save quite a few pins. Perhaps I could even multiplex the 5 control signals as well. Is this a better solution than using a more complex and more expensive part like a LPC17xx or are there pitfalls that I'm not considering?
AI: In general, a chip like this that has a bus interface can share that interface with other devices of the same or different types, as long as each one has a unique "chip select" signal.
For this particular chip, it looks like you'll also need a separate "TE" status connection from each one as well as a separate "CS#", but all of the rest of the interface signals can be shared. |
H: What is static/dynamic power?
I'm learning about power management in OMAP35x and I came across these terms. I can't seem to find a good explanation anywhere. What do they mean?
AI: Static means the power it will always draw no matter what you do, typically this is due to transistor leakage. Dynamic power will vary, for instance if you run it at full speed vs putting it into sleep mode it will draw more or less power respectively. As transistors switch on and off they draw more power and dissipate more heat. |
H: Why am I not arriving to non-inverting amplifier equation?
I was trying to derive the non-inverting amplifier equation and I ran into some trouble deriving it.
By making the voltage between R1 and R2 VRef, I set my equation to
Vin - VRef = Vout.
Because
VRef = Vout(R1/(R1+R2)), this means
Vin - Vout(R1/(R1+R2)) = Vout.
By simplifying the equation and moving Vout to the other side of the equation, I am getting
Vin = Vout (1 + R1/(R1+R2)) which simplifies to
Vin = Vout (2*R1 + R2)/(R1+R2).
When I then move it over to the other side of the equation, I get
Vin (R1+R2)/(2*R1 +R2) = Vout
and I am stuck with an ugly fraction I can't seem to simplify or reduce. Does anyone have any advice on how to simplify this fraction to (1 + R2/R1)?
AI: To derive this properly from basic principles, you have to work with the amplifier's open loop gain. You seem to be confusing open loop and closed loop gain, or perhaps misunderstanding how op-amps work. The output voltage is not the difference between + and -. It is the difference between + and - multiplied by the open loop gain.
In amplifying configurations of op-amps, the difference between + and - is always very tiny! Fractions of a millivolt. It is so small, that we can understand many circuits with the helpful simplifying assumption that the voltage is the same at + and -. This very tiny voltage difference between + and - is multiplied by the huge open-loop gain to produce the output. It is feedback which calibrates this tiny differential voltage so that a reasonable output voltage is obtained in spite of the huge gain.
So, let us define some variables:
$$A_0 = open\ loop\ gain$$
$$V_+ = voltage\ at\ +\ terminal$$
$$V_- = voltage\ at\ -\ terminal$$
$$V_{out} = output\ voltage$$
Now, we have:
$$V_{out} = A_o (V_+ - V_-)$$
But, since we have a feedback path, the voltage at the - terminal is established by the output voltage by the voltage divider:
$$V_- = {R1\over{R1 + R2}} V_{out}$$
For simplicity, let us reduce this fraction formed by the resistances to a single variable that we call f, for feedback:
$$f = {R1\over{R1 + R2}}$$
$$V_- = f V_{out}$$
So now we can substitute this V- into the first formula:
$$V_{out} = A_o (V_+ - f V_{out})$$
Output voltage is the V+ voltage, minus the feedback voltage, scaled by the open loop gain. We factor in the Ao and then get Vout terms together:
$$V_{out} = A_oV_+ - fA_oV_{out}$$
$$V_{out} + fA_oV_{out} = A_oV_+$$
$$V_{out} (1 + fA_o) = A_oV_+$$
$$V_{out} = {A_oV_+\over 1 + fA_o}$$
Now the next step requires us to make an assumption: the amplifier's open-loop gain Ao is very large, like 100,000 or more. What this means is that the 1 + on the bottom makes no difference, because fAo is a large number (unless f is a very small number, but we are only interested in using significant feedback, rather than negligible feedback). So what we do is simply remove the one:
$$V_{out} = {A_oV_+\over fA_o}$$
Now the open loop gain on top and bottom cancels out, leaving us with:
$$V_{out} = {V_+\over f}$$
The output voltage is the input voltage divided by the feedback. If the feedback is 1/5, the output voltage is five times the input voltage, et cetera. Now one more step: substitute the resistor fraction for f:
$$V_{out} = {V_+\over {R1\over{R1 + R2}}}$$
$$V_{out} = {{R1 + R2\over R1}}V_+$$
And of course
$${{R1 + R2\over R1}} = 1 + {R2\over R1}$$
which is what you're looking for.
Do not ever forget that this simple formula relating input and output voltage only works because both the feedback and the open loop gain are so large that we're able to ignore the 1 in 1 + fA0. This assumption can break. For instance, at higher and higher frequencies, op-amps have less and less open loop gain. At some frequency, the open loop gain drops all the way down to 1, and then drops some more at even higher frequencies. |
H: Keyboard vs mouse power consumption
I have a wireless keyboard (logitech pro 2000) and I have not changed its batteries (2 AA) for about 6 months, not even once! On the other hand, I have a wireless mouse (logitech performance mouse mx) and by golly I have to change its battery (1 AA) every 1-1½ week!
One could say that I use the mouse a bit more often but what is with its excessive power consumption? Is it just bad design? (also had had another logitech mouse, same deal) or is it normal that a mouse consumes this much more power because it has to track & send the point coordinates in every milliseconds?
AI: Off the top of my head I would think the keyboard would last longer. First you probably use it less than you do the mouse. Then it's usage pattern is basically: sleep and wait for a key to be pressed. So he spends a lot of time sleeping in a very lower power state doing nothing. It's easy to wake up to a key press, you just sit there an wait for an interrupt to come in.
The mouse on the other hand needs to know when you move it. He uses an LED that's being shone down onto your desk to detect movement. Glowing that LED takes power. So the whole time that it's detecting movement it's pumping power into this LED.
Now a quick check of a colleagues mouse here showed that when it was idle it goes into a blinking state probably to conserve power. I swear I've seen an old logitech that was left in a box blinking away too.
While it could eventually either go into a really slow blink, or alternatively have some other way of waking up like an accelerometer (although that's unlikely due to cost). The fact that it has to sit there and blink in idle instead of going to sleep right away tells me it will draw more power.
That's my best guess without thinking about it too hard. |
H: Will my Arduino output pin at 0v handle 25 LEDs cathodes
Short question: Is it safe to connect a single Arduino ADK (Mega) output pin at 0v to 25 LEDs, each with an appopriate 100 ohm resistor, and each being powered by a output pin at 5v?
i.e. 25 output pins at 5v each connected to an anode of one of 25 LEDs with all of their cathodes going to a single input pin at 0v
Also will I need to use transistors to provide enough power?
Long question: I'm working on a 5x5x5 LED cube similar to this:
The 4x4x4 LED cube (Arduino)
There's 5 levels of 25 LEDs, and using multiplexing I intend to switch between each level very quickly to give the impression they are all on at the same time.
How I understand it is this is achieved by connecting each of the 25 anode pins to the anode of the LED on the above level and connecting all of the cathodes on the same level to one another.
So with 25 anode pins and 5 cathode pins, if I switch the bottom level cathode pin to 0v and all the other level's cathodes pins to 5v I can then turn on individual LEDs on the bottom level by turning on the appropriate anode pin.
If there's any maths involved the LEDs are 20mA, and the Arduino provides 40mA per pin I think. I have a feeling I'm also going to have to use transistors to properly power this as 25 LEDs is 500mA and I have heard that the ADK only provides up to 200mA, though the project I have linked to doesn't seem to do this?
AI: I think you just answered your own question. If you want to power 25 LEDs @ 20mA that's 500mA total. So no you can't drive or sink 500mA with a single pin when that pin can only supply 40mA. Try using a transistor on the output that can handle the current. I think you're on the right track there.
Maybe try something like this. Disclaimer though I only thought about that circuit for a few minutes, I didn't try it or sim it. But that's half the fun :) |
H: Transistor question and is my circuit safe for Raspberry-Pi?
This is my first circuit designed from scratch (that actually does something interesting), so please be patient with the beginner's mistakes (and maybe point them to me).
My circuit is the following:
What the circuit does is:
When switch SW1 is open, the D2 LED turns ON and the D1 led turns OFF
When switch SW1 is closed, the D2 LED turns OFF and the D1 led turns ON (they switch state)
Most probably this circuit has a common name (astable ?) but I don't know it.
I've tested the circuit at 9V (with R1 & R2 at 470 ohms) and it workes like a charm.
This circuit will be used with Raspberry-Pi's GPIO. Basically, the SW1 will be replaced by a GPIO pin.
My questions are:
Is it ok what I did there with Q2 by not using any resistor for the base ?
Considering that the GPIO pin will create a -3.3V drop when ON and the GPIO on Rasperry-Pi has no protection (AFAIK) and the 3.3V is supplied by the Raspbery-Pi itself: is this circuit safe for my Raspberry-Pi ? I've read in some place that by drawing to much current from GPIO may brake the device, but I still didn't wrap my head around how a circuit may draw more current than what it's given :(
Thank you!
AI: About the question 1, it is not necessarily wrong provided that you have a load between its collector and the positive or between its emitter and the negative, and its impedance is high enough to reduce the current through the transistor. That's the main problem here: Q2 is shorting the battery, which will probably result in one of two things: fry the transistor or exhaust the battery (or maybe both).
So my advice: put the LED and the resistor in series with Q2, not in parallel, and use a PNP transistor for Q2 instead of an NPN.
About the question 2, if you want to wire a GPIO to the circuit to replace the switch (i.e. connect it to the 100K resistor), I don't see a problem, the resistor is high enough to limit the current drawn from the board.
It could be a problem if you tried to power an LED directly from the GPIO.
Of course you'll have to remove the switch, because if it is closed when GPIO is high, you'll be shorting the GPIO output to the ground. |
H: Wifi device with directional antenna and programmable power
I need to set up a cheap device for an experiment that sends Wifi signal in a single direction but also allows me to set the power level on the Wifi signal.
I've tried to find a solution and looked at Arduino shields etc. but haven't found anything suitable so far.
The requirements are:
Transmission to be able to be picked up by client device
SSID programmable
Power level programmable
Directional antenna (as narrow as possible)
I appreciate any help.
AI: Directionali WiFi
To send WiFi in a "single direction" you need a directional antenna. How directional depends on your requirements for directionality.
WiFi is typically at about 2.4 GHz = 125mm wavelength.
Antennas able to provide directionality of a few degrees are able to be made using either multiple element structures such as Yagi antennas (getting on the high frequency side for these) or dishes (such as satellite TV antennas) or tubular waveguide type antennas (eg "Pringles cantennas" are well known in the amateur community). Formulae and software are available to allow construction of an antenna of a desired degree of directionality.
Other:
Power level control is usually a function of the equipment used and relatively low cost units that allow this are available.
Sending SSID etc if a purely software function. Arduini 'shields' which provide the required hardware functionality and suitable software are available. Asking questions in the Arduino community is recommended.
CANTENNAS
EXCELLENT DIY Cantenna page
From their page - not too hard to duplicate:
Many ideas here
Wikipedia - Cantenna - A few useful links.
Wayback DIY Cantenna page looks useful.
Their calculation page also waybacked
Buy a commercial one or kitset here links may be broken. |
H: Transfer Function and Bode Plot from Poles and Zeroes
I've got the following bode plot from a black box:
I've calculated the zero to be 1055 and pole to be 67. Thus I'm using the transfer function \$H(s) = (s-1055)/(s-67)\$ but this gives a clearly wrong bode plot:
WolframAlpha calculation
I'm guessing my transfer function is wrong. Can anyone see how?
AI: The plot from Alpha looks pretty close to your "black box" measurement to me.
The only difference is a pre-factor.
Try \$\frac{67}{1055}\frac{s-1055}{s-67}\$: |
H: Is the theory of operation behind my FPGA design acceptable?
(This question is somewhat related to a previous question of mine.)
I'm trying to use an FPGA to drive an LED strip which contains several WS2801 ICs. (WS2801 datasheet)
The operating premise of the WS2801 is simple - clock in 24 bits of data (8 bits each for R,G,B) and then leave the clock low for 500µs. This causes the WS2801 to latch the data and change the LED color. If you have a strip of multiple WS2801s in series, you clock in 24 bits * (Number of ICs) and then hold the clock low to latch 'em all up. Simple, right?
So, I have created a "WS2801 Test Driver" module, clocked at 2MHz. (Datasheet claims it can run as fast as 25MHz but I have yet to test this in practice).
Basically, my driver is a shift register (with a pre-loaded 72-bit value) and a counter.
Why 72 bits? I wanted to test a string of 3 WS2801 ICs. In practice, I need to load in data from some kind of buffer...thing. (Any suggestions for that would be appreciated but that seems mostly out of the scope of this question.)
Here's a simple block diagram:
I will add a more accurate block diagram in a little bit, I don't think the clock enable is shown accurately.
The clock is shared between the shift register and the counter. After 72 ticks (all the data has now been shifted out), the counters output goes low, disabling the clock output and preventing data from shifting out. This is the start of the 500µS clock delay.
The clock is obviously still running the counter, which continues to keep counting. Now the counter waits 1,000 ticks and then drives the output high, enabling the output clock and serial data output.
Why 1,000 ticks? - At 2MHz, the period is .5µs. To get to 500µS,we need 500/.5 = 1,000 ticks. In practice, I've found I need to add a little fudge factor - 1,032 ticks, actually. This might be due to poor clock routing or propagation delay or something of that nature. I haven't really looked into it yet.
The design as implemented seems to work OK. I looked at the outputs on a logic analyzer, everything seems fine and I'm getting the colors on the LEDs that I expect.
My question is:
Is this a good design? If there is a better method of going about this, please suggest!
If you read the link to my previous question: Does it seem like this design will integrate nicely into the bigger picture of creating an FPGA based Ambilight clone?
Thanks for reading!
AI: I'll add a bit to Brian Carlton's answer.
Within an FPGA, it's correct; gated clocks are not at all recommended. And the flip-flops will have a separate ENable input so that it's not necessary.
In your case, though, because your gated clock only goes to the output pin and isn't used internally to the FPGA, you can gate your clock without penalty. The way to do it is to make sure the clock gating is done in the output block. Assuming you're using Xilinx, instead of instantiating an OBUF for your clock output, use an OBUFT, and you'll get access to the tristate pin of the output buffer. If you're using another vendor's FPGAs there will be an equally easy way to do this.
If you prefer to do this using inference rather than instantiation, you'll need to be sure to enable an option during compiling to push logic into IO blocks. If the gated clock does actually fan-out (but you didn't show it in your diagram), you'll also need to enable an option that allows duplicate logic to be generated. |
H: The reading distance limit on passive RFID
It appears that nearly all "passive RFID" tag-reader combinations have around a 5-10cm specification for reading distance.
But I am interested in approx. 20 cm reading distance.
I am assuming one of these is the right approach to follow, but I'm not sure which:
Perhaps the 5-10 cm range is a constraint of the passive RFID technology itself, and I should look into other technologies?
Or is it that there exist variants within the passive RFID technology (and the frequency band within which they operate)?
Or should I look into different kinds of tags specifically (I highly doubt this is the case since they do after all transmit upon being energized by the reader)?
Or should I consider adding a specific external antenna to my RFID reader?
Note: I am aware of "Active RFID", but given its battery requirement on the tags, this is not ideal for my experiment.
AI: In my experience, ISO 15693-compatible tags work fine at that sort of range (assuming that the reader antenna is properly tuned and emits a powerful enough field). For example NXP ICODE SLI-family tags are generally available online and are usually reasonably priced. |
H: Compare implementing a simple automation design on a MCU vs an FPGA/CPLD
I have been working with MCU's since the 90's, and I've recently ventured into the FPGA scene with the Spartan6 series chips from Xilinx. Assuming a simple factory automation design with sensors and motors, and some intelligence to link everything up, on which type of device could I finish the design faster and easier, MCUs or FPGAs? Small or "obvious" points are also appreciated because I'm new to FGPA's in general.
AI: There's no reason to use FPGAs unless you need to. Even two similarly talented engineers in the MCU and FPGA fields would use an MCU for a relatively simple automation task.
Pro MCU:
MCUs usually have all the peripherals to the outside world ready to go
Compiling takes seconds (FPGAs take minutes to hours)
There are an order of magnitude (or two!) more engineers that can help, or pick up where you left off. (For a fun, not necessarily statistically valid, comparison - compare the number of Q&A on Stack Overflow for C vs VHDL or FPGA)
Use an FPGA if you have to because:
The number-crunching required can't be met in the power, weight, size or cost budget with a microprocessor
There are hard real-time deadlines which can't be guaranteed with software (response times in the microsecond realm for example)
Using FPGA logic may make it easier to make robust assertions about response times
You can make big savings in cost, power etc by using custom data-types (like a 12-bit floating-point for example)
Or:
Your assignment tells you you have to :) |
H: Ground copper pour for Crystals and Real time clocks
I am laying out a (2-layer) board, with a standard SMD Crystal as well as a Real-time clock placed on the top-side of the board.
What are guidelines regarding ground copper pour under the Crystal and under the RTC, for their optimal performance? In other words, should I maintain pour-keepout areas on either side of the board, or does it not matter?
AI: I generally try to keep ground pours away from crystal traces, especially if they're more than a few cm long. One reason is to keep stray capacitances to a minimum — even a few pF can be significant. Another reason is to avoid coupling currents that might be flowing in the ground plane into the oscillator, which could increase clock jitter (which may or may not be significant in a particular application). |
H: Speed of electricity (signal propagation?) through copper for communications delay
I would like to be be able to calculate the delay for communications
data within TCP/IP networking through cat5e networking cable.
That is a pretty vague request so I will do my best to clarify (it is very likely I am missing a piece of fundamental electrical know-how here so sorry if that question is moot by its very definition!)
Lets imagine a very basic scenario of two computers with 100Mbps Ethernet NICs connected directly together sending data from one to the other, over a 10 meter piece of cat5e cable. Also lets image the same scenario with a 100 meter cable.
Transferring data at a rate of 100Mbps means we are encoding 100,000,000 bits of data on to the wire every second (ignore fancy encoding techniques that reduce this). That is one bit every 10 nanoseconds.
In the first scenario with a 10m cable length, after 10ns of initiating the transfer, one data bit has been encoded onto the wire as an electrical signal. How much more time will pass before it has reached the other end of the cable? How much later would it be if it was a 100m cable?
I assume this is some sort of propagation formulae taking into account the resistance of the material or similar, but I have no idea where to being, and I am a complete novice at electronics so please go easy on me :)
AI: It's more complicated than that, the propagation speed is going to be based on both the wire and the dielectric constant of the material around the wire. In your case that would be some plastic and air. I'll leave the detailed explanation for someone else, but for a quick check analysis wiki says the propagation delay of cat 5 is 4.8 to 5.3 ns/meter, and the speed is 0.64 c (where c is the speed of light).
So worst case 5.3 ns/m * 10 meters is 53ns. Then 5.3 ns/m * 100 meters is 530ns so the difference in delay is about 477ns. |
H: Can shutting of power bar damage cables or modem?
I switch off the power bar which has my modem and computer plugged into it a few times per day. Two days ago, a technician changed the wiring since my Internet completely stopped working for the second time.
I am wondering if turning off the power bar is damaging the cables or modem and is what caused the problem.
Can shutting off a modem directly from the power bar damage the cables or modem?
AI: Shutting off the power to such a device should not hurt it. After all, power can be interrupted for various reasons like a power outage, a breaker popping, and the like, so devices are designed for that.
Some complicated devices may have software issues when power is suddenly interrupted, but should not suffer hardware failure. For example, you shouldn't suddenly shut off power to a PC since that doesn't allow the OS to flush pending file changes to disk, allow device drivers to shut down their devices in a orderly fashion, etc. The PC will physically survive, but some files may be corrupted.
Routers and modems without mass storage devices are much less likely to have software issues with suddenly interrupted power, and should not get damaged by that physically. Cables are impossible to damage just by interrupting normal power. To kill a cable you have to put significantly more than the rated current thru it, which interrupting power doesn't do. |
H: Amount of current after DC/DC conversion for PC/104
Let say I have a AC to DC adapter with output 19V 7.9A connected to a 150W DC to DC power supply board (PC/104) with input 14-30V and output 5V.
What is amount of current I'll get from the 5V output board? Is it 150W/5V = 30A or 7.9A?
Sorry if this is so primitive question but I can't find corresponding reference.
AI: It'll probably be more on the order of 135W out, or 27A @ 5V, since the first supply is only capable of 150W, and the DC-to-DC converter's efficiency is going to be on the order of 90%. |
H: How to calculate phase shift between two sine wavefroms
I two sinewave signals with same frequency. I want to measure phase shift between two signals. There will be a small phase difference between two signals. I am using ATmega32-A micro controller and external ADC AD7798 to read the voltage of both signal. I am able to read both signal voltages using SPI communication. How to find Phase difference between two sine signals. I am using CodeVisionAVR compiler.
I know that phase shift between two signals can be find out using the fallowing formula.
A(t)= Am sin(Wt+/-theta).
I know only amplitude(Am) and w =2*pi*f. But How to calculate phase difference between two sinewave signals with knowing amplitude and frequency. Any suggestions please.
I have implemented timer functionality to get zero crossing points using the fallowing code.
void main(void){
init(); //Initialize controller
debug = 0; //Controls output during motor running
while (1){
if(rx_counter0) getCom();
if(Command) runCom();
if(logInt > 0){
if(now){
if(!(unixTime % logInt)){
if(flag){
flag = 0;
}
now = 0;
}
}
}
#asm("WDR"); //Reset WD timer
} // EOF "while(1)"
} // EOF "main(void)"
void init(void){
#asm("cli"); //Disable global interrupt
// Input/Output Ports initialization
// Port B initialization
DDRB=0xBF;
// Port C initialization
DDRC=0xC3;
// Port D initialization
DDRD=0xFC;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART0 Mode: Asynchronous
// USART Baud Rate: 9600
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x67;
UCSRA=0x00;
UCSRB=0xD8;
//UCSRC=0x86;
// ADC initialization
// ADC Clock frequency: 1000 kHz
// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: None
// Digital input buffers on ADC0: On, ADC1: On, ADC2: On, ADC3: On
// ADC4: On, ADC5: On
//DIDR0=0x00;
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;
//Global enable interrupts
#asm("sei")
}
unsigned int timer_phase (void)
{
ResetTimer1(); //reset timer to zero
while(selcase(1) > 0)
{
//do nothing until input channel crosses zero
}
StartTimer1(); //start timer counting
while(selcase(5) > 0)
{
//do nothing until output channel crosses zero
}
StopTimer1(); //stop timer counting
time_delay_ticks = get_timer_ticks(); //get the number of timer ticks between zero crossings
time_delay = ticks_to_time(time_delay_ticks); //need to get timer ticks into time domain
period = 1 / WaveFreq; //get the period from the known frequency
phase_delay = (time_delay_ticks / period) * 360; //calculate phase delay */
return phase_delay;
}
interrupt [TIM1_COMPA] void timer1_compa_isr(void){
unixTime++;
now = 1;
}
void StartTimer1(void)
{
TCNT1H = 0x00;
TCNT1L = 0x00; //Start counting from 0
OCR1AH = 0x0E;
OCR1AL = 0x0E; //Timer 1 reload value OCR1A = fCLK/(fOC1A*2*n)-1 REMEMBER 2 * OCR1A!
TIMSK = 0x02; //Enable timer 1 output compare A interrupt
TCCR1A = 0x00;
TCCR1B = 0x0D; //Start timer 1 in CTC-mode (4) with prescale 1024
}
void StopTimer1(void)
{
TCCR1A = 0x00;
TCCR1B = 0x00; //Stop timer 1
TIMSK = 0x00; //Switch of interrupt
}
void ResetTimer1(void)
{
TCCR1A = 0x00;
TCCR1B = 0x00; //Stop timer 1
TCNT1H = 0x00;
TCNT1L = 0x00;
TIMSK = 0x00; //Switch of interrupt
}
unsigned int get_timer_ticks(void)
{
unsigned int i;
i= TCNT1H;
i= i|TCNT1L;
return i;
}
when i run this code I am not getting any errors, But I am not able to enter any command from hyper terminal. When comment this whole function then only i am able to get output and i am able to enter commands from hyper terminal.
Help me if any thing with timer function start and stop and reset and get_delay_tricks. Or any thing wrong with interrupts.
AI: You need to use Olin's idea of determining the zero crossings of the signals to get the time delay. Then plug the time delay into Scott's equation to get the phase delay.
The following is pseudo-code. I'll leave it up to you to implement each function since they should either be trivial to implement or you should already have something similar written.
reset_timer(); //reset timer to zero
while(get_amplitude(INPUT_CHANNEL) > 0.0)
{
//do nothing until input channel crosses zero
}
start_timer(); //start timer counting
while(get_amplitude(OUTPUT_CHANNEL) > 0.0)
{
//do nothing until output channel crosses zero
}
stop_timer(); //stop timer counting
time_delay_ticks = get_timer_ticks(); //get the number of timer ticks between zero crossings
time_delay = ticks_to_time(time_delay_ticks); //need to get timer ticks into time domain
period = 1 / frequency; //get the period from the known frequency
phase_delay = (time_delay / period) * 360; //calculate phase delay
It's important to read the documentation on the timer you will be using so that you know how to convert from timer ticks into time. |
H: Arduino + Escudo + EL Wire on analog port: need pull-up-down resistor?
I am using a pair of El Escudo boards on my arduino. I've stacked them and fed the digital I/O pins to the first one and manually wired the analog pins to the second one. All works fine - sort of.
I wanted more than eight wire segments, so I thought I could just set the analog pins to 255 or zero and turn those wire segments on and off. I've discovered that I can sometimes turn it on, but can't really turn it back off. Sometimes it doesn't turn back on, but only if it has already been on.
I suspect that because EL wire is mostly a capacitive load that I may need a bleeder resistor to ensure the port fully changes state.
Should I put a 10K resistor to ground from the analog port? One to vcc+? Both?
AI: There are no Digital to Analog converters available on an Arduino that I'm aware of. The analogWrite() method you're calling is for PWM on a digital pin, so you might as well just configure it as a plain digital output and use it accordingly.
You don't mention what kind of Arduino you're using, so I'll assume it's a Uno. The schematic for the board will show you which pins on the ATmega328 are connected to which header pins.
The datasheet for the ATmega328 has summary descriptions for each bank of IO pins on page 3. You'll note that both PC and PD can be programmed as digital outputs.
The schematic for the El Escudo that you linked to shows that a standard board does not use pins A0 - A5, or PC0 - PC5 on the ATmega. These are the pins that you'll want to use on your 2nd Escudo, but you'll need to configure them as digital outputs and make sure that you've snipped the header leads for the digital pins that normally drive the El Escudo (Shown as pins D2 - D9) to ensure that your outputs for the 'stock' Escudo don't fight with your new hand-wired outputs. |
H: IR-Receiver signal almost constant
I have followed the tutorial from Makezine about an Infrared heart-beat sensor, and I have essentially used the same components listed on the video (that is, the same resistors and the same IR Emitter and Detector).
So, with a simple source-code just reading the analog output and printing it to the Serial Monitor, I see that the sensor is working fine by just analyzing how the amplitude changes as I move the emitter around the sensor.
The problem begins when I try to put my finger on the sensor (I've tried many different component angles, even 180°), and in my serial monitor, the amplitude is almost constant, that is, it doesn't even make sense comparing to my real heart beat rate. It looks something like (10ms delay):
34,34,34,34,34,34,34,35,34,34,35,34,34,34,34,34,34,34,34,34,34,35,34,34...
Now, I want to know if there is a way to amplify the sensibility on this sensor, if possible without using any op-amps, or if I'd have to change the IR components to something stronger, like the ones that look like a usual color LED.
Or even if the ambient light is interfering (which I don't think so, because I cover pretty much the entire IR pair with my fingers), or if the unamplified current has too much resistance (which I also think it doesn't influence in this specific problem, but I may be wrong).
Other than that, any solution is appreciated.
AI: A smaller resistor than 270 ohms will result in more current to your LED which will make it shine brighter... that might work a little bit, but don't go past what is spec'd in the datasheet for the LED.
Honestly, I would probably buy a transimpedance amplifier from somewhere like texas advanced optoelectronic solutions (TAOS) as they're made specifically for this type of application... amplifying small light-->current signals often the result of biological phenomenon. The other thing you could try is a different wavelength of light.
Red and IR LEDs are used in conjunction for a pulse oximeter but to detect heartbeat you only need one. You could try switching to a red LED to see if you get better results. I know from personal experience that positioning this type of sensor is extremely important. You need to make sure the detector is positioned right over an artery or else there will be no variation in light absorption when your heart beats. |
H: V-USB with ATtiny2313 to communicate with Android
How would one interface a ATtiny2313 with usb to communicate with a android device? I know it involves using V-USB, but how does the circuitry work? Am I supposed to connect certain pins on the ATtiny2313 to certains parts of a usb head? (How do I connect the ATtiny2313 to a micro USB connection) I would really like for the usb to end up connecting straight to the android device.
AI: What you want to do is going to be very difficult for two reasons:
The ATtiny2313 does not have any usb hardware whatsoever.
Most (all?) android phones are only made to be USB slave not host
I would recommend getting a bluetooth solution which you can talk to over some simple serial interface on your ATtiny2313. That will then talk to the bluetooth on your android phone which is designed to be a host.
For the bluetooth solution for the microprocessor side I recommend something like this, and on the Android phone you can download the app called "Blueterm" which is essentially a terminal that when you type a message and then press enter it sends the message over bluetooth. It also detects the bluetooth slave device (the chip from sparkfun) and connects to it.
EDIT: Ok some brief googling tells me I'm wrong about all Androids only being USB slave. It seems some more recent phones coupled with more recent OSes can in fact be USB host. However, it doesn't change my opinion that the bluetooth route would be much simpler.
On VUSB - that is a complex-ish code library that I will not delve into, any questions about that are probably better suited for StackOverflow. The hardware however is not that complicated, USB uses differential signaling for its data lines. Everything you need to know about pull-up and line terminating resistors can be found on this guy's site. You also need to make sure you have the right voltage level for an android's usb port. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.