text stringlengths 83 79.5k |
|---|
H: Reading a multibyte volatile variable that is updated in an ISR
Consider the Arduino code at the end of this post for full reference that makes LED13 blink in a 0.5Hz rhythm driven by timers. It is just a proof of concept, I know it can be improved for various aspects, but lets focus on the following issue. Although in the PoC below I only use bit0, the goal of my PoC is to find a robust way to access the full 32-bit integer outside the ISR. The source sniplet discussed is this:
void loop() {
digitalWrite( led , secondCounter & 1 );
}
The ISR increases the secondsCounter every second and the led follows bit0 of that counter, making it blink.
The resulting disassembly listing for the loop looks like this:
000002ae <loop>:
2ae: 60 91 00 02 lds r22, 0x0200 ; Read secondCounter from memory
2b2: 70 91 01 02 lds r23, 0x0201 ; 4 bytes, 32-vit integer
2b6: 80 91 02 02 lds r24, 0x0202
2ba: 90 91 03 02 lds r25, 0x0203
2be: 61 70 andi r22, 0x01 ; 1
2c0: 77 27 eor r23, r23
2c2: 88 27 eor r24, r24
2c4: 99 27 eor r25, r25
2c6: 8d e0 ldi r24, 0x0D ; 13
2c8: 0c 94 0a 02 jmp 0x414 ; 0x414 <digitalWrite>
Notice that in the background Timer event interrupts are fired all the time and there is a possibility that an interrupt is serviced while r22-r25 are being read from memory. This may result in a corrupted integer value being read from memory, but it can easily be fixed by disabling interrupts while the variable is read from memory:
void loop() {
noInterrupts(); // Prevent secondCounter from being updated in ISR while being read from memory in main loop.
digitalWrite( led , secondCounter & 1 );
interrupts(); // Enable interrupts
}
Which results in:
000002ae <loop>:
2ae: f8 94 cli ; Disable interrupts
2b0: 60 91 00 02 lds r22, 0x0200
2b4: 70 91 01 02 lds r23, 0x0201
2b8: 80 91 02 02 lds r24, 0x0202
2bc: 90 91 03 02 lds r25, 0x0203
2c0: 61 70 andi r22, 0x01 ; 1
2c2: 77 27 eor r23, r23
2c4: 88 27 eor r24, r24
2c6: 99 27 eor r25, r25
2c8: 8d e0 ldi r24, 0x0D ; 13
2ca: 0e 94 0d 02 call 0x41a ; 0x41a <digitalWrite>
2ce: 78 94 sei ; Enable interrupts
2d0: 08 95 ret
But now the entire digitalWrite routine (which takes a relatively long time) is executed while interrupts are disabled and pending interrupts have to wait a long time before being serviced.
A solution seems to be the use of a dummy variable:
void loop() {
noInterrupts(); // Prevent secondCounter from being updated in ISR while being read from memory in main loop.
uint32_t seconds = secondCounter;
interrupts(); // Enable interrupts
digitalWrite( led , seconds & 1 );
}
Which results in nice and clean assembly:
000002ae <loop>:
2ae: f8 94 cli ; Disable interrupts
2b0: 60 91 00 02 lds r22, 0x0200 ; Read variable from memory
2b4: 70 91 01 02 lds r23, 0x0201
2b8: 80 91 02 02 lds r24, 0x0202
2bc: 90 91 03 02 lds r25, 0x0203
2c0: 78 94 sei ; Enable interrupts
2c2: 61 70 andi r22, 0x01 ; Do other stuff
2c4: 77 27 eor r23, r23
2c6: 88 27 eor r24, r24
2c8: 99 27 eor r25, r25
2ca: 8d e0 ldi r24, 0x0D ; 13
2cc: 0c 94 0c 02 jmp 0x418 ; 0x418 <digitalWrite>
Question: The use of an extra temporary variable seems cumbersome, is there a smarter and tidier solution to this?
Failed attempt: I tried creating a function like:
uint32_t atomic_int32( uint32 var ) {
noInterrupts();
uint32_t tmp = var;
interrupts();
return tmp;
}
Combined with:
digitalWrite( led , atomic_int32( secondCounter ) & 1 );
But the compiler 'optimizes' the reading of the variable from memory outside the cli and sei instructions. Actually there is nothing in between those instructions at all:
000002ae <loop>:
2ae: 80 91 00 02 lds r24, 0x0200 ; Read variable from memory
2b2: 90 91 01 02 lds r25, 0x0201
2b6: a0 91 02 02 lds r26, 0x0202
2ba: b0 91 03 02 lds r27, 0x0203
2be: f8 94 cli ; Disable interrupts
2c0: 78 94 sei ; Enable interrupts
2c2: 60 e0 ldi r22, 0x00 ; 0
2c4: 8d e0 ldi r24, 0x0D ; 13
2c6: 0c 94 09 02 jmp 0x412 ; 0x412 <digitalWrite>
Full code
/*
* (c) J.P. Hendrix
*
* http://blog.linformatronics.nl/213/electronics/timed-1-millisecond-interrupt-routine-for-arduino
*
* Timed interrupt using Timer2
* ISR is called every 1ms
*
* The LED on pin13 will blink in a 0.5Hz rhythm
*/
#define _BC(bit) ( 0 << ( bit ) )
#define _BS(bit) ( 1 << ( bit ) )
// Pin 13 has an LED connected on most Arduino boards.
const uint8_t led = 13;
volatile uint16_t millisecondCounter = 0;
volatile uint32_t secondCounter = 0;
void setup() {
// initialize the digital pin as an output.
pinMode( led , OUTPUT);
// Set up Timer2 for 1 ms interrupts
// - Arduino is clocked at 16MHz
// - The timer is clocked through a /128 prescaler, thus 125kHz (TCCR2)
// - The interrupt is generated when the counter hits 125 (OCR2A)
// at which moment the Timer is reset to 0, resulting in 1kHz intervals
TCCR2A = _BC( COM2A1 ) | _BC( COM2A0 ) | // Normal port operation, OC2A disconnected
_BC( COM2B1 ) | _BC( COM2B0 ) | // Normal port operation, OC2B disconnected
_BS( WGM21 ) | _BC( WGM20 ); // Clear timer on compare match
TCCR2B = _BC( FOC2A ) | _BC( FOC2B ) |
_BC( WGM22 ) | // Clear timer on compare match
_BS( CS22 ) | _BC( CS21 ) | _BS( CS20 ); // prescaler f = clk2 / 128
OCR2A = 125 - 1; // 16MHz / 128 = 125kHz => 125kHz/125 = 1kHz
TCNT2 = 0;
TIMSK2 = _BC( OCIE2B ) | _BS( OCIE2A ) | _BC( TOIE2 );// Enable compare match A interrupts
sei(); // Enable global interrupts
}
// Attach interrupt routine to the Timer Compare Interrupt
ISR( TIMER2_COMPA_vect ) {
millisecondCounter += 1;
if ( millisecondCounter == 1000 ) { // 1000 milliseconds equals 1 second
secondCounter += 1;
millisecondCounter = 0;
}
};
void loop() {
digitalWrite( led , secondCounter & 1 );
}
AI: First of all, you're worrying about a non-issue. Since the operation only depends on the value of the LSB of the first byte of the 32-bit variable, whether or not the other bytes change while that particular stretch of code is executing has no effect whatsoever.
But in the general case, your function atomic_int32() fails because it is the caller that reads the variable associated with the formal argument var before the function is called, while it is building the argument list on the stack. To fix this, and actually read the variable inside the function while the interrupts are off, you need to pass the address of the variable to the function, like this:
uint32_t atomic_int32 (volatile uint32_t *var)
{
noInterrupts();
uint32_t tmp = *var;
interrupts();
return tmp;
}
Call it like this:
digitalWrite (led, atomic_int32 (&secondCounter) & 1); |
H: Why is this BJT transistor saturated?
The bias point (without the 623mv input) is calculated as
\$I_b = \frac{5-0.6}{5.5 M\Omega} = 800nA\$
\$Ic = \beta I_b = 290*800nA = 233\mu A\$
These calculations checks out in the simulator.
But when I connect, the Input signal, whose peek is at 623mV, the transistor saturates. Why?
Because, if I do the calculations again with \$V_{BE} = 0.62318V\$, the results do not change much from the previous calculation.
\$I_b = 795.78nA \$ which should give the \$I_c = \beta I_b = 290*795.78nA = 230.8 \mu A\$, and this is \$ << I_C(sat)\$. Then why is the transistor saturated?
I know the transister is saturated because the \$V_{CE} = 67.4mV\$, when it should have been
\$5 - (230.8\mu A * 10k) = 2.7V\$
AI: You write that the peak base current, with the signal source connected is given by
$$i_B = \frac{5V - 0.62318V}{5.5M\Omega} = 795.78nA $$
But this isn't true (which should be obvious as it's less than the bias current!). What's true is
$$i_{R2} = \frac{5V - 0.62318V}{5.5M\Omega} = 795.78nA \ne i_B$$
The resistor current and base current are not equal. According to KCL at the base node:
$$i_B = i_{R2} + i_S $$
where \$i_S\$ is the current out of the signal voltage source. But you don't know what this current is.
In fact, the base current depends exponentially on the base-emitter voltage. We can estimate the change in base current as follows
$$\frac{i_{B2}}{i_{B1}} = \frac{e^{\frac{v_{BE2}}{V_T}}}{e^{\frac{v_{BE1}}{V_T}}} = e^{\frac{v_{BE2}- v_{BE1}}{V_T}} = e^{\frac{0.62318V - 0.6V}{25mV}} \approx 2.53$$
Thus, the peak base current should be larger than the DC base current by a factor of about 2.53 or
$$i_{B_{peak}} = 2.53 \cdot 800nA = 2.02\mu A$$
This gives a collector current of
$$i_{C_{peak}} = 2.53 \cdot 233\mu A = 589\mu A$$
If this were the actual collector current, the collector voltage would be
$$5V - 589\mu A \cdot 10k\Omega = -0.895V $$
So, yes, the transistor will saturate first. |
H: Is the LT8500 a current source or sink on its PWM outputs?
I am using the LT8500 as an LED driver and I need to know if the leds are current sink or source.
Also if I need to have resistors in serial with the PWM outputs since the output voltage is 4V.
I've looked through the whole datasheet and I'm not finding anything at all so any help would be great.
AI: Looks like the LT8500 is just a PWM generator, so the PWM outputs are totem-pole signals meant to be interfaced to either a MOSFET, or a companion device to actually drive LEDs. |
H: Why does a nonlinear system cause inter-modulation?
Can someone answer or point to a link explaining why a nonlinear system causes harmonics.
According to Wikipedia
... non-linear systems generate harmonics, meaning that if the input of a non-linear system is a signal of a single frequency, then the output is a signal which includes a number of integer multiples of the input frequency.
but why?
The only explanation that I can come up with is the following.
Let's say we have a frequency fc going through a NLTI system with a span. The upper and lower part of the span, as well as all the other intermediate frequencies will be affected differently than the it's surrounding frequencies due to the NLTI system causing mixing between all different frequencies thus causing harmonics.
If this is true then sending a delta function through a NLTI system will appear to be a LTI system.
AI: Can someone answer or point to a link explaining why a nonlinear
system causes harmonics.
Consider a system with a quadratic non-linearity:
$$y = Ax + \epsilon x^2$$
Let the input \$x = \alpha_1 \cos(\omega_1 t) + \alpha_2 \cos(\omega_2t)\$ be the sum of two sinusoids.
The output is thus
$$y = A[\alpha_1 \cos(\omega_1 t) + \alpha_2 \cos(\omega_2t)]+ \frac{\epsilon}{2}[\alpha^2_1 + \alpha^2_1\cos(2\omega_1t) + \alpha^2_2 + \alpha^2_2\cos(2\omega_2t)+ \alpha_1 \alpha_2 \cos(\omega_1 t + \omega_2 t) + \alpha_1 \alpha_2 \cos(\omega_1 t - \omega_2 t)]$$
Note that we have both 2nd harmonic and intermodulation distortion present.
So, the answer to your question is the well known trigonometric identity:
$$\cos(a)\cos(b) = \frac{1}{2}[\cos(a+b) + \cos(a-b)]$$
When \$a = b\$ this becomes
$$\cos(a)\cos(a) = \cos^2(a) = \frac{1}{2}[\cos(2a) + 1] $$
since \$\cos(0) = 1\$
In other words, when we multiply sinusoids, we get sinusoids with sum and difference frequencies.
If this is true then sending a delta function through a NLTI system
will appear to be a LTI system.
The delta "function" is a distribution so one cannot 'simply' write something like \$\delta^n(t)\$ and hope it has meaning. From the linked Wikipedia article:
Thus, nonlinear problems cannot be posed in general and thus not
solved within distribution theory alone. |
H: Zener Diode - Vz0
Theoretically, what is the importance of Vz0 in the following figure. When modeling the zener diode, why is Vz0 used over the diode's given Vz?
For modeling, I was given the formula Vz = Vz0 + rz*Iz.
AI: There are varying degrees of accuracy that you can expect from a model. The simplest usable model of a Zener diode might pass no current for V < Vz and always drop Vz for any current more than zero.
That model is inadequate for many purposes. The next simplest model is piece wise linear, so you need two voltages, or a voltage and a slope. I think it makes more sense to think about it being linearized about Vz as you suggest, but any way you do it defines a straight line. If the model is accurate it should yield Vz at the specified test current.
For example, take the 1N4742. It has a Vz of 12V at 21mA and a 9 ohm Zzt at 21mA.
V0 is 12V - 21mA * 9 ohms or 11.81V. So from your formula Vz' = 11.81 + 9\$\Omega\cdot I_Z \$. At 21ma, we'd have 12V, as it should be.
Note that this linearized model will be horribly wrong if you go too far from the operating point. The value of Zzt for 0.25mA is 700 ohms, almost two orders of magnitude higher.
The suggested method allows you to use the Zener impedance from the data sheet directly, which might be convenient, and from which V0 can be calculated using Vz and the test current.
Using this model you can predict output voltage load regulation, line regulation and attenuation of input ripple (really the same as line regulation). |
H: What is the purpose of D1 on the gate of the MOSFET? [NCP3065]
I've built this DC-DC LED Driver, and don't quite understand the purpose of D1. In particular it works with a 1N4007, but I wanted to replace it with a Schottky type for faster switching since the 4148 is much faster than a 1N4007, but the circuit fails to power up properly.
I understand that diodes conduct in one direction, but there is no need to prevent reverse flow of current in this situation. The only thing I can think of is maybe for it to turn off faster in the sense of having a constantly present ~0.7V on the diode to accelerate the turn off?
Or possibly is this diode creating a lower voltage essentially like a bootstrap device since Q1 will be turned OFF when the SWC is open to ground?
AI: The short answer- it's there to shunt current away from the base of the MMBT3904 BJT and to allow SWC to pull the gate down.
SWC on the NCP3065 is the collector of a darlington. When it is "off" (SWC is pulled high by R2), the 1K resistor R2 and Q1 act together to suck the gate charge out of Q2 quickly. The transistor allows a relatively high value (1K) resistor to be used, since the base current is multiplied by the \$h_{FE}\$ of the transistor at the collector, so it's like using perhaps a 30 ohm resistor, without the horrible power dissipation and wasted current a 30 ohm resistor would have when SWC goes low.
When SWC goes low (the darlington turns on), it directly pumps the gate charge into Q2. Just before it turns on the gate is close to Vin, so the gate-source voltage is close to zero and Q2 is off. As it turned on, it pulls the base of Q2 below the emitter, so it's well off, as it drops 0.6V further, the diode becomes forward biased and it limits the \$V_{EB}\$ to no worse than -1V, well within its -6V rating. It then conducts the gate current from Q2, charging the gate and turning it on (as well as conducting the current from R2). Thus Q1 is off and D1 allows SWC to pull the gate of Q2 down directly.
It may help to visualize the current flow if you imagine a capacitor from gate to source of Q2. Part of the capacitance is gate-source capacitance and part is actually Miller effect from gate-drain capacitance.
The combination of Q1, Q2, D1, and R2, together with an N-channel or PNP switch to ground (inside the chip, in this case) is a useful building block where a relatively fast high-side switch is required (for example, for a buck regulator as here). |
H: What does banking mean when applied to registers?
This answer to a question on StackOverflow about what banking means in the context of ARM's banked registers indicates that there is some confusion about the meaning of banking when applied to registers.
What does banking mean with respect to registers?
AI: The word banking is used in two different senses when applied to registers.
Banked Registers for Interrupt Handling
The sense with which the StackOverflow question is concerned is similar to the use in (memory) bank switching (used by some 8-bit and 16-bit processors) in function. The names of a collection of registers are mapped to a different collection of physical registers. ARMv7 provides one extra bank for 7 of its 16 GPRs and five more banks for the stack pointer register and link register (ARM is uses the link register to save the PC to be used for returning from the interrupt). Itanium provides one extra bank for 16 of its 31 static GPRs. (MIPS provides entire sets of 31 GPRs, calling them "shadow register sets".)
Unlike memory bank switching, the primary purpose of this type of register banking is (typically) not to extend addressable storage but to provide faster interrupt handling by avoiding the need to save register values, load values used by the interrupt handler, and restore the original register values and to simplify interrupt handling.
(Using the application's stack to save register state opens the possibility of overflowing the memory allocated for this stack, generating an exception which must then handle state saving somehow. Worse, if the page of memory immediately past the limit of the stack is writeable by the escalated privilege of the interrupt handler but not by the application, then the application is effectively writing to a page to which it does not have write permission. Some ABIs avoided this issue by defining one or more registers as volatile across interrupts. This allows the interrupt handler to load a pointer for state saving without clobbering application state, but unlike banked registers such software-defined interrupt volatile registers cannot be trusted to be unchanged by application software.)
(Using such banks of registers as fixed windows has been proposed to extend the number of registers available, e.g., "Increasing the Number of Effective Registers in a Low-Power Processor Using a Windowed Register File", Rajiv A. Ravindran et al., 2003. One might also note a similarity to register stack used to avoid register save and restore overhead for function calls as in Itanium and SPARC [which uses the term "register windows"], though these mechanisms typically shift the register names rather than swapping them out.)
In terms of hardware, banked registers can be implemented by renaming the registers in instruction decode. For ARM's relatively complex banking system this would probably be the preferred mechanism. For a simpler banking system like that used by Itanium with a single extra bank with power of two number of registers, it may be practical to incorporate the renaming into the indexing of the register file itself. (Of course, this would not be compatible with certain forms of renaming used to support out-of-order execution.)
By recognizing that different banks are not accessed at the same time, a clever optimization using this mechanism can reduce the (wire-limited) area overhead of a highly ported register file by using "3D registers". (This technique was proposed in the context of SPARC's register windows — "A Three Dimensional Register File For Superscalar Processors", Tremblay et al., 1995 — and a variant was used by Intel for SoEMT — "The Multi-Threaded, Parity-Protected 128-Word Register Files on a Dual-Core Itanium-Family Processor", Fetzer et al., 2005.)
Banking to Increase the Number of Possible Accesses
The second sense in which the term banking is used for registers refers to the splitting of a set of registers into groups (banks) each of which can be accessed in parallel. Using four banks increases the maximum number of accesses supported by a factor of four, allowing each bank to support fewer access ports (reducing area and energy use) for a given effective access count. However, to the extent that accesses in a given cycle are not evenly distributed across banks, the maximum number of accesses will not be achieved. Even with a large number of banks relative to the desired access count, bank conflicts can, in the worst case, limit the actual access count to the number of ports provided by a single bank.
There have been many academic papers on banked register files (Google Scholar search), and several general techniques have been proposed to reduce the impact of bank conflicts. The most obvious technique is to buffer instructions (as is done for out-of-order execution) providing some statistical averaging of bank conflicts. It is also possible to read a register operand before the instruction is ready to execute (e.g., if another operand is not yet ready or a structural hazard delays execution). Allocation of registers to banks can exploit information about expected use to reduce the probability of conflicts. (Software can assist by preferentially using registers in the expected manner.) Using virtual physical register names, it is possible to delay allocation of physical register names (and thus banks) until the value is stored in the register; this facilitates avoiding conflicts on the writes and may facilitate clever bank allocation to avoid read conflicts.
This type of banking is sometimes called pseudo-multiporting since it provides the illusion of a larger number of access ports. This technique is commonly used for caches since the physical structure is often partitioned into separate memory arrays for other reasons.
(One alternative to such banking is replicating the register file. Using two copies of the register file allows each copy to require half as many read ports, though the same number of write ports are required. This technique was used in POWER2 and the Alpha 21264 and is commonly used in high performance processors.)
Summary
It may be helpful to distinguish these two types of banking as temporal banking in which bank selection is spread across time (like ARM's banked registers for fast interrupts) and spatial banking in which bank access can be concurrent in time but is spatially distributed.
Temporal banking is typically exposed to software and is used to reduce the overhead (and complexity) of interrupts. (Conceptually, thread switching in a Switch-on-Event-MultiThreaded processor is very similar to interrupt handling and can use similar mechanisms to reduce overhead.)
Spatial banking is less frequently part of the ISA (though Itanium required load and store floating-point register pairs to use even and odd register numbers — which is not guaranteed given the use of register rotation — allowing a trivial two bank design to provide the extra register file access requirements) and is used to reduce the cost of providing a larger number of register accesses per cycle. |
H: Charging lead acid (car) batteries with a common ground
I have three identical lead acid batteries. All three batteries are on a common ground since they power different components on a same circuit. I have three independent "intelligent" chargers whose charging outputs are on isolated grounds.
I wonder if there is a counter-indication of charging all three batteries at the same time when on a common ground (their positive poles are disconnected from the main circuit, of course). I know this could be charger-specific, but if anyone knows anything about it.
Here is a quick schematic of what it is (would be) like when charging:
simulate this circuit – Schematic created using CircuitLab
AI: The significance of the "isolated ground" is that it can be connected to any place in the circuit without consequence. (It isn't really a "ground", but a negative or return lead. Ground usually implies a common connection.) So, it is allowable to connect it to chassis ground, and it is allowable to connect it to another charger's return lead. It probably could even be connected to another charger's positive lead in order to create a higher series voltage (though you don't need that here). |
H: Flash and RAM : Code Execution
I recently started learning assembly and came to know about linker scripts and other low-level details of hardware programming. I am also teaching myself computer architecture and somewhere along the line I came to fear that my picture of the memory model might have been wrong all along.
According to what I understand currently, all the code and data resides on the non-volatile memory just after we 'burn' the binary onto a processor - the RAM being volatile contains nothing upon reset. When the program begins 'executing' it does so from the address 0x0000 which is almost always (AFAIK) the lowest address in Flash. So, instructions are latched onto the bus connecting Flash to the CPU core and that is where the actual execution takes place.
However, when we talk about the CPU retrieving or storing data from the memory, we're usually talking about RAM - I am aware that we can read/write data from the program memory as well (I've seen this done on AVRs) but is it not as common? Is it because RAM is faster than ROM that we prefer to store data there?
The accepted answer to this question says that most pieces of code execute out of RAM.
Does this mean that the start-up runtime code (which itself executes from Flash) has to copy all the program opcodes from Flash to RAM and somehow maps the addresses in Flash to point to RAM so that the CPU fetches opcodes from there? Is it similar to the process in which we move the .data sections from ROM to RAM on startup?
I can imagine this to be simpler in von Neumann architectures where the program and data memories share a bus but in Harvard architectures wouldn't this mean that all the code and data have to pass through the CPU registers first?
As you can probably guess, I am a little too confused by this whole business. Having always programmed at a higher abstraction level I am easily troubled with such details. Any help is appreciated.
AI: This depends on the device.
RAM can be built faster than Flash; this starts to become important in about the 100MHz range.
Simple microcontrollers
Small slow microcontrollers execute directly out of Flash. These systems usually have more Flash than SRAM too.
Midrange systems
Once your device gets faster then the situation is a little different. Midrange ARM systems may do that as well, or they may have a mask ROM bootloader that does something smarter: perhaps downloading code from USB or external EEPROMs into internal SRAM.
Large systems
Larger, faster systems will have external DRAM and external Flash. This is typical of a mobile phone architecture. At this point, there is plenty of RAM available and it's faster than the Flash, so the bootloader will copy and execute it. This may involve shovelling it through the CPU registers or it may involve a DMA transfer if a DMA unit is available.
Harvard architectures are typically small so don't bother with the copying phase. I've seen an ARM with "hybrid harvard", which is a single address space containing various memories but two different fetch units. Code and data can be fetched in parallel, as long as they are not from the same memory. So you could fetch code from Flash and data from SRAM, or code from SRAM and data from DRAM etc. |
H: The options for communicating sensor data in a medium size building
What are the options for communicating sensor data to a central point in a medium size building?
I want to build a cheap centralized temperature control.
In each room there are about 4 radiators which I want to equip with a few sensors like temperature, light, sound level, and with a radiator valve actuator. Let's say the building has 50 rooms with a wireless network available.
The main requirements are low costs (for the project as a whole), and it should be relatively easy to design and implement. I have some experience with PCB design and micro controllers, and I can ask help of more experienced people. I'm not bound to specific sensors or actuator.
I guess power for the sensors and for the actuator come from a power outlet. Maybe the signal can also travel over the power net.
P.S. As newbie, I feel I could use some help to improve this question. All help is appreciated.
AI: Power line transmission is a good option for this. The chip-sets do seem to be able to handle "decent" data rates with a good degree of reliability. The 100kHz band looks probably the most attractive and is, as far as I know, dedicated to this sort of thing. This document from NXP (entitled AN10903, TDA5051A ASK power line modem) is a good reference for what you have to do. It contains a wealth of knowledge on how to couple to the AC lines and how to impedance match etc.. The chip-set is good for 1200baud and I think this would be good enough for what you are looking to achieve. Remember one thing, faster data rates = wider bandwidth = more received noise = less sensitive receiver.
Here is the data sheet for the chip and below is a diagram in that document: - |
H: Clean DC power design for very high precision circuit
We have been designing a very high precision control circuit for quite a while. And we are thinking to make it much easier to use, which is to get rid of the Lab DC Sources and use AC to DC switching power (get power from 220V/110V directly).
Our circuit runs at +-12V currently with around 200mA current. It consists of a photodiode, which 1pA precision could be measured, many OpAmps, one 16-bit ADC and one 18 bit DAC. As from the description, it can be observed that our circuit is running at very high precision.
One lab DC source costs thousands of dollars and the DC ripples are basically zero. At most on the level of 0.001mV peak to peak. If a cheap AC to DC source is to be used, however, I am afraid that the DC can be far less clean. For example this one (which has 50mV pp ripples).
I need suggestions from you:
Is this kind of AC-DC switching power a good choice (http://www.switchingpowersupply.cc/pdf/D-30W.pdf)? Or maybe the ones used in laptops are better?
How to reject the noises in power supply in the most thorough way? Any material will be appreciated.
Is it possible to make clean DC source from 220V AC, which has similar performance as the lab DC sources?
If large caps and inductance are used to filter the ripples, could they cause stability issues for the AC-DC converters?
How would the DC noises influence the behavior of OpAmp, ADC, DAC? For ADC and DAC, I think the voltage references will not be influenced.
AI: Usually if you need clean power, you need to follow up the SMPS with a linear regulator. You also have to deal with the noise created by the supply, which can be non-trivial. If you really need microvolt noise levels, a completely linear supply might be a good choice rather than SMPS, (or even use SLA batteries and an ultra-low-noise regulator).
On the other hand, getting 1mV to 10mV p-p noise over a 0.1Hz to 1MHz bandwidth is not that difficult with a SMPS + LDO combination, but care has to be taken in how the SMPS conducted and capacitively coupled noise is dealt with.
Do not underestimate the noise the supply itself can create- I found that the brick supply for a Tek scope can cause 20mV false spikes in the display if the plastic case is placed near a grounded metal object. That's the supply that the oscilloscope comes with! There are transistors (and possibly entire heat sinks) flapping around by hundreds of volts and switching fast at tens or hundreds of kHz. |
H: How is the clock frequency established between master and slave in I2C protocol?
This is a follow-up question to What happens if I omit the pullup resistors on I2C lines?
In a digital wall clock I designed (using the DS1307 RTC and the ATmega328 MCU), I accidentally omitted the pull-up resistors that must be wired to both I2C lines. In the end I was lucky enough that the internal pull-ups on the ATmega I2C lines were enough to (barely) allow the communication between the devices. The result were long rise times on the I2C lines and speed reduction to 32kHz as seen in the scope shots below.
Edit: Actually, the frequency is exactly 100kHz - there are 2 peaks per 20us on the green trace. I initially thought there was a reduction to 32kHz because my scope calculated the frequency on the yellow trace.
What's puzzling me now is how the devices decided that 32kHz was enough for the communication to take place. The DS1307 datasheet says that the device supports 100kHz frequency on the I2C bus. How come it ended up using 32kHz instead? Is there some kind of handshake phase where the frequency is stablished?
In the end, my question really is this: How is the clock frequency established between master and slave in I2C protocol?
I couldn't find that information searching the Net.
In case this matters, I'm using Arduino IDE 1.03 and my firmware handles the RTC using the DS1307RTC Arduino lib (through its functions RTC.read() and RTC.write()). That lib in turn uses Wire.h to talk to the RTC.
AI: Following up the comments:
Yes, the frequency is hard-coded into some specific I2C-related registers. At runtime.
That said, your Arduino library might be doing some probing and rise time measurement on the bus for determining a viable clock rate. Let's see.
After doing a bit of source-digging, the answer is in twi.h
#ifndef TWI_FREQ
#define TWI_FREQ 100000L
#endif
Another piece from that very file:
TWBR = ((CPU_FREQ / TWI_FREQ) - 16) / 2;
Where TWBR stands for Two Wire Baudrate Register I suspect.
I'd call that enough evidence and definitely say, yes your I2C frequency is set directly by your library without any negotiations. If you want to change it, I'd suggest you #define TWI_FREQ before you #include twi.h (or indirectly through Wire.h) |
H: What are the advantages of an ESC over a PWM?
I'm building an octocopter, and can't quite understand what an ESC (electronic speed controller) is used for. A brushless outrunner motor has three cables. Is there one common ground, one power supply (DC) and one cable to communicate with the ESC?
Does the ESC simply use the information gathered from the motor to decide when to turn the power on to get the maximum effect out of the motor? So the ESC is simply a PWM which synchronizes the pulses with the motor?
The ESC also has some extra features like turning down the power when the voltage is below a threshold, and using low resistance to brake the motor. If you don't need these features, is using a PWM just as good as an ESC?
AI: A BLDC motor is a 3-phase AC motor, which is why there are three wires.
An ESC is a set of 3 half-bridges that drive the motor phases to create a rotating magnetic field. Below is a schematic from here that should give you some idea.
If you were to feed PWM to two wires of a BLDC motor it would do very little except get hot and stay in one place.
Ideally, the output would like this (the frequency is varied to change the motor RPM, 60Hz is shown).. image borrowed from here.
A video showing what the non-ideal waveforms look like is here: |
H: How to find cause of reset in PIC16F microcontroller?
I've worked with other microcontrollers that have a register that I can check on powerup to check a register that contains debugging information on the cause of the reset.
Initial searching revealed an RCON register that may not be available in my current PIC. Haven't found much in the initial search of the datasheet either:
http://www.microchip.com/wwwproducts/Devices.aspx?product=PIC16F1704
AI: I just found the PCON register in the datasheet (took some searching). See page 61 of the linked datasheet:
Brown-out Reset (BOR)
Reset Instruction Reset (RI)
MCLR Reset (RMCLR)
Watchdog Timer Reset (RWDT)
Stack Underflow Reset (STKUNF)
Stack Overflow Reset (STKOVF)
Haven't heard of a stack underflow error. Searching the meaning of that now... |
H: Is there such a thing as a switch that can be actuated automatically?
I'm interested in a toggle switch that can be toggled without user input. That is, the physical state can be toggled electrically. It would need to incorporate some sort of motor or magnetic actuator. My google-fu is weak in this area, and I haven't been able to come up with the correct combination of search terms.
Note that I'm not talking about a relay; I'm talking about a normal toggle switch:
Except that it can be toggled without user input. As in, the lever physically moves. Like a "useless machine" except that the mechanism is internal to the switch.
AI: What you are looking for is a rare beast. Honeywell produce a toggle switch (2 position and 3 position) that can be remotely reset by removing the holding current - this releases the magnetic force exerted by a small solenoid and the switch returns to off or centre. This may do what you want but, I suspect that you would want to be able to toggle it at will remotely: -
Why can't you easily find one that can toggle in both directions? Complexity and performance expectations leading to unfeasible cost and therefore NO foreseeable market is the main reason. Hey it was hard enough to find this one let alone one that can be operated at will in both directions remotely. |
H: Differences in VHDL syntax
I'm reading a VHDL design and I came across the syntax in the architecture that looks like:
x_out <= x_in(15) & x_in(6) & x_in(19) & x_in(20) & x_in(28) & x_in(11) &
x_in(27) & x_in(16) & x_in(0) & x_in(14) & x_in(22) & x_in(25) &
x_in(4) & x_in(17) & x_in(30) & x_in(9) & x_in(1) & x_in(7) &
x_in(23) & x_in(13) & x_in(31) & x_in(26) & x_in(2) & x_in(8) &
x_in(18) & x_in(12) & x_in(29) & x_in(5) & x_in(21) & x_in(10) &
x_in(3) & x_in(24);
where x_out and x_in are std_logic_vector(31 DOWNTO 0). Could this be written like so:
x_out(0) <= x_in(15);
x_out(1) <= x_in(6);
x_out(2) <= x_in(19);
x_out(3) <= x_in(20);
x_out(4) <= x_in(28);
x_out(5) <= x_in(11);
x_out(6) <= x_in(27);
x_out(7) <= x_in(16);
x_out(8) <= x_in(0);
x_out(9) <= x_in(14);
x_out(10) <= x_in(22);
x_out(11) <= x_in(25);
x_out(12) <= x_in(4);
x_out(13) <= x_in(17);
x_out(14) <= x_in(30);
x_out(15) <= x_in(9);
x_out(16) <= x_in(1);
x_out(17) <= x_in(7);
x_out(18) <= x_in(23);
x_out(19) <= x_in(13);
x_out(20) <= x_in(31);
x_out(21) <= x_in(26);
x_out(22) <= x_in(2);
x_out(23) <= x_in(8);
x_out(24) <= x_in(18);
x_out(25) <= x_in(12);
x_out(26) <= x_in(29);
x_out(27) <= x_in(5);
x_out(28) <= x_in(21);
x_out(29) <= x_in(10);
x_out(30) <= x_in(3);
x_out(31) <= x_in(24);
Or in the first example is x_out(31) <= x_in(15); and so on?
Also in a VHDL design which of the 2 methods are preferred?
AI: A cleaner alternative, preventing the mistake illustrated by the question :
Use named rather than positional association.
x_out <= (31 => x_in(15),
30 => x_in(6),
29 => x_in(19),
...
1 => x_in(3),
0 => x_in(24)); |
H: How to calculate power consumed by an electrical device in a specified amount of time?
Say for example I have a TV with "140 watts" marked on it. Does this mean the TV consumes 140W per minute? Per hour? Per day? How is the power consumed by device calculated from the device specification?
AI: If a car is travelling at 40 mph it doesn't mean it travels at 40 mph per minute.
If a TV is consuming 140 watts it means it consumes 140 joules per second.
What you get charged for by your utility company is joules and that is oddly (but acceptably) converted (without mathematical error) to watt seconds or more conveniently watt hours or kilowatt hours.
Maybe that is what confused you? |
H: TRUE/FALSE or true/false?
In resource-constrained systems (like an 8-bit PIC), is there any benefit to using your own macros for true and false as opposed to using those defined from stdbool?
#define TRUE (1)
#define FALSE (0)
// OR (dummy example)
#include <stdbool.h>
bool IsThisGood(void)
{
return true | false;
}
uint8_t IsThisBetter(void)
{
return TRUE | FALSE;
}
How do they compare in terms of RAM usage? Stack usage? code portability? Code simplicity?
AI: In resource-constrained systems (like an 8-bit PIC), is there any benefit to using your own macros for true and false as opposed to using those defined from stdbool?
Macros are evaluated by the pre-compiler before compile time, not by the compiler or micro at run time. A macro defined to be "1" will be replaced by "1" before the compiler even starts to try to figure out how to optimize your code. Unless your macro is better than the stdbool macro, there is no benefit.
How do they compare in terms of RAM usage? Stack usage?
1 == 1, regardless of how the macro is defined. No difference.
Code portability?
By using non-standard macros, code portability suffers. Your code will need your defines/headers, so someone can't copy and paste a section that looks standard without getting errors. Especially with something like "True" or "False".
Code simplicity?
If you don't need all of stdbool, sure, defining your own might be simpler. That's really an opinion thing.
Update:
As far as stack usage, I mean to ask what gets returned in each case? 8bits? 16bits? register size of microcontroller?
This is a better question. It's a bit complicated. First, "bool" is really a macro for "_Bool", a c99 data type. Typically, _Bool is the smallest addressable object capable of holding a 0 or a 1. That's a char, an 8 bit sized object. (Things like nibbles are overly complicated objects that have some background code required to split a single 8 bit char into two "separate" 4 bit objects). _Bool also has some logic to where it's 0 when 0, or 1 when anything over or under 0. _bool random_variable = 5 would result in random_variable equaling 1. Memory wise, that bool will be 8 bits, but return literal 0 or 1.
Second, true and false, as you have created macro for, are exactly the same as stdbool.h defines true and false. A literal 0 or 1. Literal intergers are by default, int data types. int is not a fixed standard. It can be defined by your IDE, or compiler, or language. It changes by microcontroller manufacturer or even line of microcontrollers by same manufacturer. It can also be signed or unsigned for the same reasons (See: https://stackoverflow.com/questions/589575/size-of-int-long-etc ) So unless you typecast a variable when assigning true or false, it will be upcasted to int. But uint8_t is a stdint.h unsigned data type of 8 bits as well.
Third, your two functions are not exactly alike. Realize, that IsThisGood returns a bool (really _Bool) type (char/8 bit object). IsThisBetter returns a uint8_t type (8 bits). In practice, the same, but _Bool type has logic to make anything greater than 0 = 1, while uint8_t does not. IsThisBetter could technically return 255 for some reason.
Finally, if for some reason "char" on your microcontroller/ide/compiler/language is greater than 8 bits, then your uint_8 version will be smaller, memory wise, but still lack the "greater than 0 = 1" logic.
See this stack overflow answer on size of _Bool: https://stackoverflow.com/a/10630231/1498667 |
H: Discrete MOSFET Amplifier question: Trouble finding the Overdrive Voltage
I am working on an exercise problem (5.18) regarding Discrete MOSFET Amplifiers. I have taken pictures of the question material (Disregard the section under the question) and my latest attempt at a solution:
Alright. Keep in mind that the circuit above is from a different question, they are just re-using it in this one, but they changed the value of VDD from +15V to +5V. Also, they remove RL, but I don't think that matters for my specific issue.
Now, I decided to begin with a DC Analysis to find VOV (Overdrive voltage). I know that I can replace the capacitors with open circuits and then use the MOSFET Saturation current equation and KVL for another current equation, equate them, then solve the resulting quadratic.
However, this method yields an answer different from the book. The book provides VOV = 0.319V, whereas I get VOV = 0.83V.
Is my approach correct? I'm pretty sure the math is sound, so I'm not really sure how to proceed. My solution:
AI: I believe you are misinterpreting the question.
The question is asking you to design the circuit to meet certain specs, which includes choosing the drain resistor Rd. In your analysis, you are assuming that Rd is 10kohms. The answer states that Rd is 78.5kohms. |
H: More info about J-link v8
I have a J-link v8 and want to use it, but I can't find its name in Segger homepage, I want to know what ARM core it support and is it support BeagleBone or RPi.
AI: The information you need should be on this page, the note at the bottom of the page refers to hardware revision 8 and up which I assume refers to the V8 you have.
In particular the following CPUs are supported:
Any ARM7/9/11, Cortex-A5/A8/A9, Cortex-M0/M1/M3/M4, Cortex-R4, RX610, RX621, RX62N, RX62T, RX630, RX631, RX63N
While both the CPUs for the Beaglebone (Cortex-A8) and RPi (ARM11) are supported, I don't think that either board includes the JTAG port by default, you may need to solder pins on to make this available. Some information on the RPi here, the Beaglebone here. |
H: Is "True RMS" applicable only to measuring AC voltage?
Higher end multimeters feature "True RMS" rather than "averaging" voltage measurement. Is this applicable only for AC voltage measurement?
AI: Usually only AC ranges, which are AC coupled so you lose the DC component of the signal. The reason why you would not want the true-RMS to apply to the DC voltage range is that the accuracy of true-RMS measurements is usually not nearly as good as averaging DC measurements.
For example, the Fluke 170 series datasheet here, shows these specifications:
The True-RMS AC measurements are almost two orders of magnitude less accurate than the DC measurements.
A bit higher end is the Agilent 34401A
You can see that the accuracy is more than an order of magnitude worse for the True-RMS AC range.
Practically defining the high end, the Agilent 3458 offers several AC methods of measuring RMS AC. Even the best (and most restricted) True RMS AC measurement technique is more than two orders of magnitude less accuracy than the DC ranges (a few ppm).
Here's a one-chip RMS converter, the LTC1966 |
H: why do rechargeable batteries fail so horribly in high drain environments?
I've tried nicads and nimhs in flashlights and they always end up leaking. I know how spikes and memory work in such batteries, but why do such high drain applications cause such catastrophic failures in these batteries while alkaline batteries perform quite well?
AI: It's hard to generalize to a battery type because any poorly made mass production battery has the risk of catastrophic failure in high drain situations just because of poor quality control.
Having said that, it is generally my experience that NiCd and NiMh perform quite superiorly in high drain situations compared to alkaline. This is almost entirely due to their lower internal resistance compared to alkalines. The higher the internal resistance of a battery, the harder it is for the battery to provide higher currents and the hotter it will get when it provides those currents. When the battery overheats, it can vent and warp and leak and lose capacity.
Many of the hybrid vehicles use NiMh batteries and they are used in a very high drain situation; yet the Prius for example has had very few battery failures in its 14 year history.
I have been using high quality nimh rechargeable AA and AAA in my high drain flashlights for a couple of years without a single failure. I suspect you have just had bad luck with your rechargeables? Or possibly let them drain too far or over charge them which could lead to the catastrophic failures. |
H: Hardware advice for simple wireless embedded application
Now, I am going to learn embedded programming in microcontroller. I am going to create a device that will receive signal from wireless transmitter. The range will be less than 30 meters. So, I have some questions about toolkit.
What type of transmitter and receiver should I use that receive and send signal up to 30 meter?
What kind of microcontroller and board should I use to create embedded system?
Do I need any other circuit or device like antenna or anything else?
I am new in microcontroller.
AI: Since you are new to microcontrollers, your best course of action would be to get an Arduino (there are several types). While they are designed for beginners, they also have a lot of flexibility.
Peripherals for the Arduino are called shields, and they have many options for doing wireless. One option you might want to consider is Bluetooth, which can cover up to 100m out in the open, and quite a bit less indoors. You didn't say whether you will be indoors or outdoors. There are many Bluetooth shields, such as this one. In almost all cases, the antenna is already included on the board.
If battery life on the remote device is a factor, you might also want to investigate Bluetooth Low Energy, which has a range similar to "classic" Bluetooth but consumes much less power. It is quite new (there is no native support for it in Windows 7, for example), but since you will be providing both ends of the wireless link, this should not be a problem. |
H: What components are these?
I usually buy electronics components at an online surplus store and they usually throw in the box some more goodies to pack what you order.
I bought a multi section plastic container and it was filled with all sort of components, and this one in particular intrigues me. Here is a photo:
They seem to be transistors, maybe their odd shape is because they are RF or something...
Some "old school" guy that has used them?
AI: Transistors in a TO-50 package commonly used in RF applications. The leads can be soldered flat onto the PCB, reducing lead inductance. Can be either some type or FET or BJT. |
H: Arduino Pin value gets stuck
I'm using a Python program to send some message over serial port to Arduino. This message contains the pin number of the pin and whether it should be HIGH or LOW . Eg: Sending 2H\n should set pin 2 to HIGH.
pins array maps the pin numbers in the messages to the actual pin number of arduino. 1H corresponds to pin 22 on Arduinio Mega.
When manually sending one message at a time, things work fine. However when Python sends a series of 30 such messages one after the other in a loop with no delays, pin 1 is always stuck at whichever value it is set to on the first series of messages.
Example:
1L\n
2H\n
3H\n
4H\n
5H\n
...
followed by
1H\n
2H\n
3H\n
4H\n
5H\n
...
will cause pin 1 to be stuck at LOW when it should be high.
On arduino, this is the code that parse the message and sets the pin values.
void setPinValues(String message) {
for(int i = 1; i <= sizeof(pins) / sizeof(pins[0]); i++ ) {
String pinNumber = String(i);
if( message == pinNumber + "H\n" ) {
pinValues[i] = HIGH;
}
if( message == pinNumber + "L\n" ) {
pinValues[i] = LOW;
}
}
}
void loop(){
if( Serial.available() > 0 ) {
received = Serial.read();
message += received;
if(received == '\n') {
// Set pin values
setPinValues(message);
// Write to pins
for (int i = 1; i <= sizeof(pins) / sizeof(pins[0]); i++) {
digitalWrite(pins[i], pinValues[i]);
}
// Clear buffer
message = "";
}
}
}
Arduino Mega communicates with Windows 8 x64 system over USB using a baud rate of 57600. When using a lower baud rate of 9600, this problem is not seen.
Furthermore, at baud rate of 57600, if I were to replace setPinValues with the following code, pin 1 is properly switched on and off.
void setPinValues(String message) {
for(int i = 1; i <= sizeof(pins) / sizeof(pins[0]); i++ ) {
if( message == String(1) + "H\n" ) {
pinValues[1] = HIGH;
}
if( message == String(1) + "L\n" ) {
pinValues[1] = LOW;
}
if( message == String(2) + "H\n" ) {
pinValues[2] = HIGH;
}
if( message == String(2) + "L\n" ) {
pinValues[2] = LOW;
}
if( message == String(3) + "H\n" ) {
pinValues[3] = HIGH;
}
if( message == String(3) + "L\n" ) {
pinValues[3] = LOW;
}
}
}
Doesnt both versions of setPinValues do the same? Why does lowering the baud rate prevent the problem? I cannot use a lower baud rate because the USB buffer gets filled up and things slow to a crawl.
To compare the last char H or L:
String pinValueString = message.substring(message.length() - 1);
char pinValueBuffer[2];
pinValueString.toCharArray(pinValueBuffer,2);
if(pinValueBuffer[0] == 'H') {
digitalWrite(pins[pinNumber], HIGH);
}
AI: Not sure if this is your problem, but setPinValues looks weird to me:
void setPinValues(String message) {
for(int i = 1; i <= sizeof(pins) / sizeof(pins[0]); i++ ) {
String pinNumber = String(i);
if( message == pinNumber + "H\n" ) {
pinValues[i] = HIGH;
}
if( message == pinNumber + "L\n" ) {
pinValues[i] = LOW;
}
}
}
Going out of bounds
Each time you call setPinValues, i will range from 1 to length(pins), so if pins was declared as pins[5], i will be 1, 2, 3, 4 and 5. Assuming length(pins) == length(pinValues) this is a problem in itself, because pinValues[5] would not even exist!
pinValues[5] only creates pinValues[0] to pinValues[4] (yes, I know it's weird, you're declaring 5 elements but, since C is 0-indexed, they're 0, 1, 2, 3, and 4), so i should NEVER reach 5 or you will be out of bounds which is undefined behavior (and might well be the source of your problems) because you're writing to the wrong memory location.
The correct way to do this is looping from 0 to i < sizeof(pins) / sizeof(pins[0]) (notice the strict less-than < operator) which ranges from 0 to length(pins) - 1 and then just String pinNumber = String(i + 1);. That way, 1H will change the value of pinValues[0], mapping you 1-indexed serial messages to 0-indexed C arrays.
Looping is unnecessary
I'm not sure why you're looping over pins. You're doing unnecessary work and probably hogging the uC (specially since, as Dave Tweed points out in the other answer, you're using expensive functions such as String and string comparison with ==).
message has a single instance, e.g., 1H\n so there's no loop needed. char pinNumber = message[0] - '0'; will store the integer value of the first character in pinNumber, with which you're then able to index the array.
How does that work?
message[0] would be a char type (e.g. '1')
'0' is also a char, which corresponds to the ASCII value of 0 (48 in decimal).
If message[0] contains the char '0', then the result is '0' - '0' == 48 - 48 == 0
Since numbers are contiguous and increasing in the ASCII set the result of the subtraction is the actual number as a single byte integer.
'1' - '0' == 49 - 48 == 1 and on and on.
You might also want to reject bogus input:
if (pinNumber >= sizeof(pins) / sizeof(pins[0]))
return;
More spurious work
At each loop() iteration you do this:
// Write to pins
for (int i = 1; i <= sizeof(pins) / sizeof(pins[0]); i++) {
digitalWrite(pins[i], pinValues[i]);
}
Which has the same problem with the out-of-bounds as before.
It also does unnecessary work, since you're writing ALL pin values, whether they changed or not! Why don't you digitalWrite(pins[pinNumber], HIGH or LOW); directly in setPinValues and avoid this loop? You could even get rid of the pinValues array if you don't really need to store them (or you can keep it if you need it for some reason).
My alternative setPinValues
void setPinValue(char pin, char value) {
char pinNumber = pin - '0'; // Get the integer value of the ASCII char
if (pinNumber >= sizeof(pins) / sizeof(pins[0])) // Reject out-of-bounds input
return;
switch (value) {
case 'H':
pinValues[pinNumber] = HIGH; // Not necessary if you don't want to store the pin values
digitalWrite(pins[pinNumber], HIGH);
break;
case 'L':
pinValues[pinNumber] = LOW; // Not necessary if you don't want to store the pin values
digitalWrite(pins[pinNumber], LOW);
}
}
And then just call it from loop() as setPinValue(message[0], message[1]);
Let me know if this solves your problem. |
H: How to power up BeagleBoard-xM using batteries?
I 'm looking for a battery solution to power up BeagleBoard-xM. Until now, I used a 5 V, 3.2 A AC/DC power supply adapter (2.1 mm barrel plug).
I 'm thinking of using a 4 x 1.2 NiMH AA battery pack (or NiCd). This way voltage will be 4.8 V, that is the minimum -xM's electrical specification for input voltage DC. If this is not a proper solution, please let me know.
My question is:
How can I determine amperage to be 2 A or greater? As far as I know, the board will only take the current it needs when attached to the battery, but low amperage may be the reason of features misfunction.
Any help, or even different solution, would be appreciated.
AI: I am fairly new to this stuff as well but I will do my best to answer your question.
I do not believe that four 1.2v batteries will be sufficient on their own (at least not for too long) because of the inevitable voltage drop that will occur over time.
Most NiMH batteries I have come across have between 1800 and 2500mAh and four of these will be able to run your board for a while before they lose the ability to source 750+mA, but when they do it will cause the supply voltage to drop below 4.8v.
I see that the typical max current supplied by the USB ports on the board is 1500mA, and assuming outbound USB current was not factored into the typical average current draw of the board, it could mean that as much 2250mA could be needed at any given time. (maybe even a bit more, I don't know enough about the beagleboards to say). At that level of current draw it wouldn't take very much time for a voltage drop to occur.
I would instead use a switching regulator to power your board. I looked briefly but didn't find many prefabricated "boost" converters that would supply sufficient amperage, but I did find a lot of "buck" type converters that would take a higher input voltage (say 7.2v, from six batteries) and convert it to 5v 2A+ at the output.
You can also do a little research and build your own buck or boost converter instead of buying one, or take a simpler approach and build a linear regulator, but these are not as efficient and you wont get as much run time out of your batteries.
The max current draw may(MAYBE, not sure) also be something that is only approached infrequently in quick spikes. If this is the case then it may not be necessary for your regulator to source the max current, but it would mean that you should put some extra capacitors in your regulator's output stage to handle instances of increased current draw.
I hope this helps. :) |
H: Analog to 1-channel Digital Converter
I have 0-5 V analog value coming in, and I need to convert it to a high or low 5V digital signal. Essentially, I need to create a 1-channel A/D converter. The idea is that when my analog voltage goes above a certain threshold, it will set the digital output high, and vice-versa. I saw something about being able to do this with op-amps, but I don't remember where I saw it. I also want to do this without using a microcontroller. Any ideas?
AI: Typically you'd use a comparator for this. Or you could make a transistor version with a long-tailed pair.
A Schmitt-trigger would be a nice solution for a 0 to 5V input:
(Source)
But you pointed to an op-amp circuit...
Here's the idea. An opamp as a comparator with logic output.
It's worth reading through ADI's application note on that (source for the picture).
Their Conclusion is accurate in my opinion and worth bearing in mind:
"In conclusion, although op amps are not designed to be used as comparators, there are, nevertheless, many applications where the use of an op amp as a comparator is a proper engineering decision.
It is important to make an educated decision to ensure that the op amp chosen performs as expected" |
H: Tying ground planes together with a non-zero Resistor
I was reviewing the schematic of a motor driver board and noticed that the digital and analog grounds are tied together with a 3.9 ohm 1/4 watt resistor. I am still trying to find the gerber files to see how the ground plains are laid out, but does anyone know why this would be done instead of using a 0-ohm resistor or just connecting them in the copper?
My first thought was that it was an attempt at some sort of noise suppression but this doesn't seem like something that would be very effective at doing that. Feel free to speculate, because for now I'm at a loss.
EDIT: The analog ground feeds back to a 24V supply off the board and the digital ground feeds back to a 5V supply off the board. At each of the power connectors there are several decoupling capacitors. However the resistor is by noneof the connectors and the respective capacitors.
AI: It could be that a shorted resistor would be equally good as a 3R9 resistor or it may not. There are a few things to consider. Firstly, does the analogue circuit make an external ground connection. If it does and so does the digital side then putting a resistor in to bridge the two planes makes sense because digital currents in the digital plane will be less inclined to take the more arduous route thru the analogue plane. This reduces the likelihood of analogue noise pick up due to digital current: -
If the 3.9 ohm resistor were shorted out there will be a possibility of some digital current from [A] passing onto the analogue ground plane and passing through a sensitive area [B] before returning to the correct grounding point. With a 3R9 present, the digital current will be reduced because it will be more inclined to take the "easier" route to the power grounding point. Because also the resistor is leaded, it will have a significant inductance that might help this. Consider also that the 3R9 resistor may actually be an inductor and that the OP has misread what it is. Easy to do on some inductors.
There could be other reasons but I'm less inclined to speculate because I could be incorrect. Maybe supply pictures and a schematic. |
H: Create a fake depth encoder signal on a surface system?
I am trying to create a test box which will do away with the actual depth encoder as it is awkward to have out all the time the encoder is similar to this: http://www.encoderonline.com/UK/Data-Sheets/Incremental/Data-MXE.htm
The unit it is connected to outputs 9V DC on between the encoder + and - for both the A and B signals.
I would like the circuit if possible to be able to change direction
AI: The encoder has three signals (A,B and O). These are also available as the inverted signals making six in all.
I would suggest this was an ideal project for an arduino or similar microcontroller.
Only three signals need to be created (A,B,O) by the controller. A cmos inverter IC (4049) takes care of the inversion. |
H: Sniffing a proprietary data line at 47.5V
I need to sniff the physical layer of a proprietary data line with a logic analyser, but my analyser is limited to 5V input. Unfortunately the line runs at 47.5V, which would fry everything. I considered a simple voltage divider, but I'm concerned that I might pump a lot of current through it, or affect the data on the line.
Any suggestions on a way to do this? It doesn't need to be robust - it's just a one-time hack for a single purpose.
EDIT: To answer some of the questions asked: I don't know if it's 47.5V DC offset or 47.5V p-p, as I only have a single figure given to me as part of the spec. It's an old system produced by a company that no longer exists, so getting original specs and info is practically impossible. The data rate is 2Mbps, which to me implies that it shouldn't exceed 4MHz at the physical layer.
AI: Two options.
Option 1. If data is fully swinging from 0V to 47.5V then a voltage divider using two resistors is fine. Choose values of resistors that are not too low so that excessive power is dissipated. Check also to see how much the line can be loaded with. If necessary, make a pseudo scope input from 1Mohm and 100k potential divider - this will produce about 4.3Vp-p BUT, you may need to put 22pF across the 1M and 220pF across the 100k to keep "edge" information in the data stream clean.
Option 2. If the data is 5Vp-p superimposed on a dc level of 47.5V then it's more complex - this is like "phantom power data" and to "read" the 5Vp-p data you need to remove the DC by using a capacitor - this leaves you with an AC data signal that is 5Vp-p but undulating up and down with the average mark-space ratio of the signal.
If the data is encoded in such a way that there are always data edge transitions then that's fairly easy - connect the dc-removed signal into a signal comparator that has a 0V/5V output then feed that into your analyser. However, if the data is similar to UART data, there will be long periods when the signal is 1 or 0 and this is a problem that you may never solve easily. |
H: checking uart overrun and framing error flags in linux
Checking uart overrun and framing error flags in linux.
In some microcontrollers I can access overrun and framing error flags programmatically. Is it possible to access these flags from command line?
AI: I've read and written to registers in the past by writing a kernel module that creates an entry in the /proc filesytem. Then I can read the registers by doing cat /proc/lpc32xx_regcheck for example.
This code might be garbage; It might be against "best practices" to do it this way. I'm not a Linux programmer by any means, but it worked for me for debugging.
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/fb.h>
#include <linux/stat.h>
#include <mach/platform.h>
#include <mach/hardware.h>
#include <mach/i2s.h>
struct proc_dir_entry *lpc32xx_regcheck = NULL;
static int my_proc_read(char *buf, char **start, off_t offset, int count, int *eof);
static int my_proc_read(char *buf, char **start, off_t offset, int count, int *eof)
{
int len = 0;
len += sprintf( buf + len, "LPC3250 I2S REGISTER DUMP:\n");
len += sprintf( buf + len, "I2S0 RXFIFO :0x%X\n", __raw_readl(io_p2v(0x2009400C)));
len += sprintf( buf + len, "I2S1 RXFIFO :0x%X\n", __raw_readl(io_p2v(0x2009C00C)));
len += sprintf( buf + len, "I2S0 STATE :0x%X\n", __raw_readl(io_p2v(0x20094010)));
len += sprintf( buf + len, "I2S1 STATE :0x%X\n", __raw_readl(io_p2v(0x2009C010)));
len += sprintf( buf + len, "I2S0 DMA0 :0x%X\n", __raw_readl(io_p2v(0x20094014)));
len += sprintf( buf + len, "I2S1 DMA0 :0x%X\n", __raw_readl(io_p2v(0x2009C014)));
len += sprintf( buf + len, "I2S0 DMA1 :0x%X\n", __raw_readl(io_p2v(0x20094018)));
len += sprintf( buf + len, "I2S1 DMA1 :0x%X\n", __raw_readl(io_p2v(0x2009C018)));
len += sprintf( buf + len, "I2S0 IRQ :0x%X\n", __raw_readl(io_p2v(0x2009401C)));
len += sprintf( buf + len, "I2S1 IRQ :0x%X\n", __raw_readl(io_p2v(0x2009C01C)));
len += sprintf( buf + len, "I2S0 TXRATE :0x%X\n", __raw_readl(io_p2v(0x20094020)));
len += sprintf( buf + len, "I2S1 TXRATE :0x%X\n", __raw_readl(io_p2v(0x2009C020)));
len += sprintf( buf + len, "I2S0 RXRATE :0x%X\n", __raw_readl(io_p2v(0x20094024)));
len += sprintf( buf + len, "I2S1 RXRATE :0x%X\n", __raw_readl(io_p2v(0x2009C024)));
len += sprintf( buf + len, "\nWriting to P_MUX_CLR...\n");
__raw_writel(0x1c,io_p2v(0x40028104));
len += sprintf( buf + len, "NEW P_MUX STATE :0x%X\n", __raw_readl(io_p2v(0x40028108)));
if(len <= count + offset)
*eof = 1;
*start = buf + offset;
len -= offset;
if( len > count)
len = count;
if( len <0)
len = 0;
return len;
}
static int __init test_init(void)
{
printk("Hello.\n");
lpc32xx_regcheck = create_proc_entry("lpc32xx_regcheck", S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);
if (lpc32xx_regcheck)
{
lpc32xx_regcheck->read_proc = my_proc_read;
}
return 0;
}
static void __exit test_exit(void)
{
printk("Goodbye.\n");
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("dext0rb");
MODULE_LICENSE("LOL"); |
H: How does this wireless transceiver work?
While messing with Arduino I came across this wireless transceiver. As a newbie in all this stuff, it's written that it operates at 2.4 GHz, so the transmitter crystal and receiver crystal must operate at 2.4 GHz, right? From the photo I can see that the crystal is 16 MHz which is 0.016 GHz. Probably I'm not getting it right, where am I mistaken?
NRF24L01+ 2.4GHz Antenna Wireless Transceiver Module
AI: Most wireless transmitters (of this type) use a crystal and a phase-locked-loop (PLL) to generate much higher frequencies. See this article: -
Frequencies can be produced that are N*16MHz. This means, that for a 2.448GHz output, N equals 153. If N = 154, the output is 2.464GHz i.e. 16MHz higher.
There are other techniques that can do this but the PLL is most likely. Here's what the device says about itself: -
The type of PLL used is called "fractional N" because it has the ability to produce higher frequencies that are spaced at a fraction of 16MHz. |
H: Adesto DataFlash (AT45DB641E) reads zeros after exercising flash for several minutes
I am using the AT45DB641B Adesto DataFlash and not in Low Power mode.
In my application I am recording a stream of raw sensor data and constantly writing to flash every second. I have a self-test that is invoked every minute to read back a sentinel from flash to make sure everything is running correctly. However, when I have been running my recording for from between 10 minutes up to 4 hours, at some point the flash would read back all zeros at this sentinel address. This memory address is set once initially and is never modified during the course of the recording.
In my test unit, I exercise heavily erase/program then read back and different set of data and all operations seem to work normally.
I wonder what could possibly cause a flash to read back zeros and that it happens inconsistently.
AI: I presume your test unit uses a different physical chip. There is a huge variability of erase times possible from chip-to-chip and with supply voltage, and different ways of writing/erasing. I also presume you're not writing a file system, because that has a different set of challenges.
But the simplest thing.. are you checking the busy flag before reading the sentinel location? If the chip is in the middle of a page erase it could go off the radar for many (like 35) milliseconds. |
H: How to optimise something when multiple parameters change the output
This dilemma seems to occurs all the time in so many different engineering problems. It seems impossible to optimise something with multiple parameters, for three reasons:
There are too many possible combinations of these parameters to be able to simulate them all
You optimise one parameter at a time, but then you don't know if your final result is the best possible result. E.g: You start with a neural network with 5 layers, and 4 neurons in each layer. You perform a sweep on the number of layers in the neural network, plotting the accuracy of the network vs number of layers. You find that the optimum number is 3 Layers. You then optimise the number of neurons in the first layer, and find that the optimum is 10 neurons, then you optimise the number in the second layer and find 7 is the best, and then the number in the third and find that 6 is the best. However, this might not be the best overall solution: For example the accuracy of the network might be better if you start by using 3 neurons in the first layer, which is not the optimum, and then optimise the number in the second and third layer, finding that you get a different number of neurons but a much better accuracy compared to the first method.
You optimise parameter 1 that governs property X, and then you optimise parameter 2 that governs property Y, but then this has changed property X, so you go back and optimise the parameter 1, but then this changes property Y.
This seems like a very fundamental problem when designing any system in any area of engineering, and I thought that there may be a standard method of approaching this problem, or at least a few known methods that do a pretty good job. If there is a solution to this dilemma, can somebody please tell me?
Additional Details
The neural network example is the problem I am currently having, but I'll give another example of this problem I have had in the past. I was trying to design a patch antenna that will have a resonant frequency of 2GHz. The resonant frequency is mainly dependant on the width of the patch, and the gain of the antenna was mainly dependant on the insertion depth. In CST, I performed a sweep on the width and picked the value that gave the lowest s parameter at 2GHz, I then performed a sweep on the insertion depth and picked the value that reduces the S parameter to the lowest value (I decided that -40dB was acceptable). But this then changed the frequency at which this gain happens, so I did a sweep on the width again, and I picked the value that gave the lowest s parameter, but now the s parameter is too high again, so I optimise the insertion depth... and so on.
AI: From what I understand, those problems are often solved with metaheuristics, like genetic algorithms: they have been successfully applied in solving engineering problems.
I don't know how well it would apply to your case, but antenna design has been done using genetic algorithms. |
H: BJT vs MOSFET failure modes
I know MOSFETs are much more efficient than BJTs in that they don't consume as much power when on whereas a BJT consumes base current the whole time it is on. I also know that MOSFETs tend to fail shorted. I can't find any information on BJT failure modes though/do they usually fail open or closed. Does anyone know about this?
AI: In my experience, all semiconductors tend to fail shorted unless you put enough current through them to physically blow them apart or fuse the bonding wires. Physically broken packages (eg. diodes) can also result in an open. |
H: Control 12V MOSFET with 5V, with PMW pass-through?
I am new to electronics, and still tying to fully wrap my head around MOSFETs. I have a few questions about controlling a 12v MOSFET using only 5v to the gate, and an incredibly small amount of current.
Here's the situation:
I have a 48V power supply which I am converting down to 12V, with a maximum 33A output current. Connected to this 12V output current, is a 12V motor, and an Arduino. I would like to control the motor using one of the Arduino's PWM ports, and a MOSFET, to minimize current draw through the arduino.
Unfortunately, the Arduino's PWM ports can only provide 5V. The MOSFET that controls my motor will (I think) need to be 12V, and what I have read on the subject tells me that controlling a 12V MOSFET with a 5V gate leads to... Bad things. That is my first question -- what will happen if I flat out try to do this?
My second question is this:
How can I create a circuit that will allow my Arduino to control the 12V MOSFET using a 5V, 4-to-40 milliamp current, while still having the MOSFET reacting quickly enough to allow for PWM to reach the motors? What are the specifications of MOSFET that I will need to do this?
The most important question is, of course, what are the mechanics behind all of these things? Talking to people, I hear them talking about using a transistor as a "low impedance source", and to be honest, I don't understand what they mean. How does that play in the whole thing?
AI: what I have read on the subject tells me that controlling a 12V MOSFET with a 5V gate leads to... Bad things. That is my first question -- what will happen if I flat out try to do this?
The drain-source voltage rating of a MOSFET doesn't give you any clue about what gate-source voltage it requires. A logic-level MOSFET will work even with 3.3V drive, for instance, and may be drain-source rated for 20V or more.
How can I create a circuit that will allow my Arduino to control the 12V MOSFET using a 5V, 4-to-40 milliamp current, while still having the MOSFET reacting quickly enough to allow for PWM to reach the motors?
Indeed, the bigger problem you'll face is the limited current a microcontroller GPIO can sink or source - this current is what charges and discharges the MOSFET gate capacitance and controls how fast the device turns on or off.
What you'll need to use is a MOSFET driver - this is a circuit which will take the low current drive signal from the Arduino and stiffen it sufficiently to drive the MOSFET. There are literally hundreds of monolithic driver ICs on the market from a multitude of suppliers, which work very well and are quite cost-effective. |
H: Flash Programming for AT89S2051
Forgive me if this is a noob question, this is my first MCU project.
After reading a few tutorials here and there, I've set up my MCU circuit and programmed a simple program in Keil μVision 4 and compiled it to HEX-80. However, I'm having problems with attempting to flash the program to the MCU.
Fundamentally I am kind of lost in how to connect the devices (PC->MCU) up. I was under the impression a simple USB->TTL (Serial)->MCU UART input was going to do it, but apparently not.
After 5 hours of search, I only found articles relating to AVR or PIC with no mention of anything remotely related to 8051. I understand the AT89S2051 has ISP functionality so I don't need a dedicated chip flash programmer. I also found that the MCU does have serial flash capabilities.
Can anyone point me in the right direction here?
Additional Details:
MCU: Atmel AT89S2051 (on breadboard)
PC: Win 7 x64 (Shouldn't matter but here it is anyway)
USB->TTL: PL2303HX (on-board chipset)
Wiring:
The RXD (TTL output) is wired to the TXD (Pin 3.1) of the UART
The TXD (TTL output) is wired to the RXD (Pin 3.0) of the UART
The GND (TTL output) is wired to the circuit ground
The +5V (TTL output) is wired to the circuit +5V
The +3.3V (TTL output) is not connected.
Programs I have tried (and failed to use):
AtmelISP
PonyProg
IspPgm
AI: Where you're getting into confusion is that while ISP stands for in-system programming it often still needs a dedicated hardware programmer to provide the necessary voltages and/or protocol for programming the FLASH. For that device you'll want something such as an Atmel AT89ISP.
I've never used the AT89 series in particular but on page 32 of the AT89S2051 datasheet you'll see it's an SPI type interface that requires a clock and data in and out lines. Some FTDI devices can support SPI communications but I'm fairly sure the PL2303HX can't and after a quick check of the datasheet it only seems to mention async mode.
Generally the easiest way would be to purchase the AT89ISP programmer or I believe there are a few DIY projects and clones available. Although unless the budget is tight it's probably always easiest to start with an officially supported programmer. |
H: AC adapter: Input power vs Output power
When I look at, let's say an iPad AC adapter, the input/output rating on the charger states:
Input: 100-240V 0.45A (AC)
Output: 5.1V 2.1A (DC)
I know that the input and output ratings are maximum. The AC voltage in my country is 230V. Through a simple calculation, I can deduce the following (correct me if I am wrong):
Input power: 103.5W
Output Power: 10.71W
Now, my question is this: what is the true power drawn from the wall socket? Is it 103.5W or 10.71W? If it is 103.5W, then I presume the iPad adapter is 10% efficient?
AI: Undoubtedly the charger you have is a switching regulator. I say this because that is what all modern chargers appear to be and the input voltage range is wide enough to make this assumption valid. It's not a big charger - roughly 10 watt output means it is small in my book and more than likely it will be based around the following: -
Raw AC voltage is rectified to DC (peak will be about 338V DC on 240 Vac input and about 140V DC on a 100 Vac input)
This gets smoothed by a capacitor - probably in region of 220 uF (rated at 450V)
A switching circuit will convert this high dc voltage to 5.1 Vdc
As a thought experiment, if you connected the AC input of the charger to a 140V DC supply and the charger's output to a load resistor that took 2.1 Adc (10.71 watt load) and assumed the power conversion efficiency in the charger was 80%, you would expect to see about 14 watts taken from the input DC supply of 140V. This means a current of about 100mA.
Input power = 140 Vdc x 0.1 Adc = 14 watt
Output power = 5.1 Vdc x 2.1 Adc = 10.7 watt
So, when you connect it to an AC supply of 100V AC RMS, why could a current of 0.45 A flow? To understand this you have to recognize that this device's AC input current (as measured through an RMS measuring ammeter) is not representative of real power into the device. Unlike DC circuits (where it would be representative of real power), AC circuits like this can draw very non-linear (non sinusoidal) currents whose RMS value could be quite high compared to the "useful" current.
This means you can't make the assumption that input power into the device is Vac x Iac. The device has (more than likely) a bridge rectifier and smoothing capacitor and the current drawn will almost be like a spike of a few milliseconds every 10ms (50Hz supply). This, without doing the maths could mean that the input RMS current is twice the "useful" current: -
This would take your "useful" and needed input current of 100 mA to 200 mA - a bit closer to the 450 mA stated.
Also to consider is the inrush current - the manufacturer's rating of 0.45A may include some measure of inrush current into this figure but we don't really know.
Remember also that the rating will be most valid when the input AC voltage is at 100 VAC and not when the voltage is much higher (as per your calculation). |
H: Light sensor to sense light level
I have an application where I am trying to monitor a defect in a web based manufacturing process.
This defect can be seen if one side of the substrate is lighted and the transmitted light is viewed from the other side. When the defect occurs a change in the transmitted light is noticed.
I am looking for a commercial sensor which I can use to give me an analog signal.
I also want to experiment with a sensor on a breadboard to get an understanding of how a change of light translates into an electronic signal.
My application will require a very low response time as the speed of my process will result in the defect being in front of the sensor for less than a millisecond.
Any direction on sensors or components will be appreciated.
AI: For stability and accuracy, I would suggest a silicon PIN (P-Intrinsic-N) photodiode. Response time in the microseconds is not too difficult with good design (you'll want the response to be an order of magnitude faster than the time the sample is in front of the sensor).
Phil Hobbs has a good article here on photodiode front end design. You may just need a simple transimpedance amplifier as this one using the OPA128 (there's a mistake in the schematic on the datasheet- the resistor should go to the PD bias voltage, hey nobody's perfect).
if there is plenty of light available (so you can use a really low capacitance PD), but if you need more, that article (and his book) are a good guide. |
H: how the CPU start by execution stored in motherboards flash memory chip
I had read that at start, the CPU program counter register is fill with F000.
I though that:
PC registers contain the next instruction address.
This address is send to the address bus and value return to the data bus
Does the address bus only deal with RAM? Obviously the bios isn't store in ram.
So HOW F000 target the ROM to start BIOS execution
AI: There's a fairly detailed answer on stackoverflow here.
Bottom line, is that the hardware has to decode the address space such that the BIOS ROM appears at the appropriate address.
Here, for example, is the original IBM PC memory map from an online book. Things have moved on since then, but this should give you an idea. The actual decoding logic is the equivalent of gates, probably implemented in some other form (used to be PLDs, but probably a side job of more complex support chips now). |
H: Arduino Uno Doesn't show up under Serial Ports, but it does show up in Device Manager
My Arduino Uno doesn't show up under Serial Ports in the Arduino IDE, but it does show up in Device Manager.
I have a I2C Sainsmart LCD connected to the Arduino.
Do you have any idea why it would do this?
AI: This happens from time to time.
What can you do?
1- Try unplugging the USB and plug again.
If 1 didn't work.
2- Go to task manager> Processes> find the Arduino IDE that is already running> Right click> End Process tree> unplug the USB> run the IDE again.
Works every time for me. |
H: Why set PORTx before TRISx?
I was browsing through the example code that MikroE provides for PIC programming using MikroC, and they always set PORTx before setting TRISx. What is the reason for this?
Since TRIS just selects whether the port or pin is output/input mode, why does it matter what the pin is set to before we set the mode?
Example code
PORTA = 255;
TRISA = 255; // configure PORTA pins as input
PORTB = 0; // set PORTB to 0
TRISB = 0; // designate PORTB pins as output
PORTC = 0; // set PORTC to 0
TRISC = 0; // designate PORTC pins as output
AI: The PORTx bits are adjusted before the TRISx bits so you know what the output will be before you make the pin an output. If you are setting the TRISx bits to inputs, it doesn't matter. However, if you are clearing the TRISx bits and making them outputs, it is safer to determine what the output will be before it switches from input to output. Thus, if an alarm or something goes off when a pin is high, you would want to make sure when it becomes an output, it starts off low. |
H: H-bridge vs ESC
I'm familiarizing myself lately with the usage of ESC (Electronic speed control).
I'm unable to determine when is it the best option to chose ESC over H-bridges? - in terms of advantages and disadvantages.
Why do -at least from what I've seen- people us ESC to drive and control brush-less DC motors rather than H-bridges?
What is the principle of operation of ESCs? I mean as for H-bridges it is a simple switching circuit of 4 MOSFETs transistors, but what is the case for ESCs?
AI: Quite a few ESCs use H bridges as the motor output stage so, in effect you are comparing a "system" made up of components, with one of those components. Basically a H bridge is used in a lot of ESCs but a H bridge on its own isn't an ESC.
A helicopter would use a collection of parts that could be described as an ESC but it won't use a H bridge; it would use open collector/drain transistor drivers because that is more efficient than a H-bridge. A H bridge is better suited to RC cars because you might want to run motors in reverse or apply dynamic braking. |
H: Impedance problem (polar to rectangular)
Having a little problem understanding why this example converted polar to rectangular form to get Z. What is wrong with just leaving it in polar form and doing the algebra to get the value for Z
AI: It's semantics. If someone asked for an answer as impedance then I would tend to expect to see this answer in polar form. Converting to rectangular along the way is the simplest way of analysing the problem and converting back to polar at the end gives the answer as how I would expect it to be: - |
H: Does L293D consume power when not in use
I am designing a robot using the L293D motor driver, and I have just successfully hooked it up to my micro controller. I am using two batteries, one two control the motor and one to control the pic micro. I am wondering if the battery that is used to drive the motor would get consumed when the pic circuit is off. I need to know this, because in my design i was considering directly connecting the motor supply to the driver without a switch.
AI: Yes, it does. Look at the datasheet for the details. Quiescent Current is the spec you want to look at. It draws significant current from Vs as well as from Vss, even when Ven = L. (~30mA max), although it's important to consider the voltages. The 24mA(max) from the 5V rail (Iss) is 120mW, but the 4mA(max) from the 24V rail (Is) is almost as much power (96mW). |
H: Measure peak voltage / amp, when signal is very short (relay on/off)?
I was measuring a 'steer' signal for switching on a relay. The oscilloscope, gave me back it peaks at around 2.64V. The width of the signal is 132ms.
I then hooked up my multimeter, to measure how much amp was drawn. However the reading varies (between 4 - 14 mA). Which made me wonder.
My question: is there a minimum amount of time a multimeter needs to 'register' a correct load? In other words, is 132ms long enough to get a decent reading?
If not, what would be a correct way of measuring?
If it matters, it might be depending on the 'quality' of the multimeter? I used a UNI-T (UT61).
AI: A typical update rate for a multimeter is 3 to 10 times a second, so 132 milliseconds is likely not enough time.
Since you have an oscilloscope, you can put a low value resistor in series with the load and measure the voltage across the resistor with the oscilloscope. |
H: Why don't all motors burn up instantly?
A motor rated for 3S (11.1 V) has an internal resistance of 0.12 ohm. The maximum current is 22 A.
11.1 V / 0.12 ohm = 92.5 A
Doesn't this mean that by supplying a 11.1 V three phase current, the motor will burn up instantly? How does an electronic speed control (ESC) prevent the current from exceeding 22 A?
AI: It doesn't, the motor itself does. Once the rotor starts spinning, the motor produces a voltage that opposes the flow of current; this is commonly called "back EMF (electromotive force)".
The motor's speed increases until the back EMF reduces the current flow to the level needed to account for the actual physical load on the motor (plus losses).
The heavy current you calculate is drawn only for an instant, just as the rotor starts spinning. If the rotor is prevented from spinning, then that current will be drawn indefinitely, and yes, it can destroy the motor. |
H: Kirchhoff's Laws and Circuits?
I just started circuit analysis today and learn't about Kirchhoff's Laws.
Its pretty straightforward, but in all the examples my book gives they already specify the direction of the current and the end of the branch with the higher voltage.
For example,
there arrows everywhere indicating the direction of the current at each node and +/- signs indicating the end of the branch with a higher voltage.
Obviously, when actually designing stuff the direction of the current and the side of the branch with the higher voltage wouldn't be indicated.
So what I'm asking is:
1) Can Kirchhoff's Law be used to figure out the direction of the current and side with higher voltage?
2) If not, do techniques exist to find the directions?
Please note that I'm not talking about convention. (i.e. currents flowing into the node are positive and currents flowing out are negative etc.) You can't just have a convention because you can't differentiate which direction the currents or voltages are going.
AI: When analyzing a circuit, you can put the arrows in either direction according to whim, a flipped coin, or Tarot cards.
After applying Kirchoff's laws to compute all the voltages and currents, you'll find some variables have negative values. Those correspond to arrows you drew backwards. Fix those, and then you know the directions of currents in all branches of the circuit.
It is perfectly normal for an experienced engineer to get a few initially backwards, when multiple different voltage sources are pushing in opposite directions. You can only guess, and let algebra tell you the net result. |
H: How to trigger something once a day
What would be the right thing to use if I want the base of a transistor to be high for 12 hours and low for 12 hours?
I ask because I would like to make a circuit that regulates temperature in a room. To do this I am using a ntc thermistor and a ptc thermistor that I have set to trigger a fan or a heater depending on the temperature of the room, but my question is not about the thermistors. I want the room to be hotter for 12 hours and cooler for 12 hours a day and I don't know what to use to switch between two temperature control circuits.
I am building this for a garden. I want the plants to have a "daytime" and a "nighttime" (quotes because the plants are indoors and receive their light from lights that this circuit will help control).
I am pretty sure I can do this with a microcontroller like an arduino, but I am curious if there is another way to do this without a microcontroller. I was thinking of a 555 timer, but I don't think resistors and capacitors exist that are big enough.
Thank you for any response you might provide.
AI: A low tech but cheap way to do this is to use 24 hour AC power timers that are readily available at home stores. Set the timer to power on for 12 hours and off for 12 hours. You might need to use two for your application. Either analog or digital timers can be used and have the advantage of high reliability and ease of changing the time periods. |
H: Pseudo-Nmos inverter in LTSPICE
In LTSPICE, I've built a pseudo-NMOS inverter and I've got 2 tasks to do using it.
1) I've a initial guess for Wn value of NMOS. I start the simulation with this value however, I need to optimize it and get a more precise value.
Basically, when Vol < x for some x, I need to find the minimum Wn value that satisfies this inequality.
2)Initially, nothing is connected to the output of inverter. Then, I connect a capacitor after finding my Wn value. At this point I need to find LOW-to-HIGH delay of the inverter.
I think I need a DC sweep for the first one. But don't know how to extract my value.
I have no idea for the second one though.
Any help is much appreciated.
AI: To find the appropriate width for the transistor, make the width be a parameter rather than a fixed value. Then run a dc sweep where that parameter is swept through a reasonable range of values. Check the plot of Vout to find the value of width that satisfies your requirements.
For rise/fall times and delays you need to use a transient analysis. You will specify a voltage source for the input voltage, probably using the PULSE or PWL style of voltage source. Observe the plot of the output voltage to determine the timing parameters of interest. The cursors can be helpful here. If you want to really do it right, use a .measure command to automate the measurement.
Note that it is my intention to give you some hints to get you started rather than providing a tutorial on LTspice. There are already many good examples in the LTspice users group and in the documentation. |
H: why dc machines have double layer winding?
why do dc machines always have double layer winding?is it possible to create a single layered winding dc machine?
More generic Question: Can anyone explain the logical evolution of dc machine from the prototype (single coil) to the actual double layer-distributed winding case?
Usually in text books they use single coil to explain the principle of operation and suddenly jump to parallel paths-multiple commutator segments-double layer closed winding case .Single coil doesn't have any parallel paths and i doubt whether it is closed too.What is the logic behind the actual implementation of a dc machine and how can it be explained as progressive evolution of the simple case?
Please note I understand the reason for use of distributed winding(more no:of windings in series and hence less ripple) and to a fair extent the working of actual implementation as well.What bothers me is "can i have a dc machine with single layer, with any no: of parallel path(can it be one?),closed or un-closed winding for achieving the same emf?".
Also i'm concerned about the conceptual understanding.I tried theoretically to extend the single coil case to 2 coils in perpendicular connected in series.But i couldn't find a suitable commutator connection which will give me the required o/p(sum of their emfs).The only possible way was to go for double layer-closed form winding(which makes it 4 coils).I was not sure of this and wanted to confirm this.
AI: The double layer windings are the most widely used class of windings. Though both lap and wave types are possible, because of inherent problems of a wave windings, it is now an accepted practice to use the lap type for double layer ac windings. Double layer windings fall into two main classes depending upon the value of SSP-integral slot winding when SPP is an integer and fractional slot winding when SPP is a fractional number. To meet the requirement of symmetry among phases, the number of slots phase (S/3) must be a whole number.
Double layer windings in open slots have the following advantages over single layer windings in semi-closed slots.
Ease in manufacture of coils and lower cost of winding
Less number of coils are required as spare in the case of winding repairs
Fractional slot winding can be employed
Fractional pitch coil can be used |
H: What is wrong with this SPI implementation
I designed a system with RaspberryPi and STM32F407's, communicating with each other via SPI interfaces.
For the last 3 months, tests were OK but yesterday a RaspberryPi and 2 of STM32F407's SPI ports were burn out. I don't know why. Everything was working, I went to sleep, everything was burned out in the morning.
Here is the implementation sketch:
PCB's are 15 cm long. SPI lines are parallel. No chip-select lines are used. No termination resistance used. SPI frequency is 200 kHz. Power supplies are 5V 1A usb charger for RaspberryPi, LM2576 3.3V circuits (implemented by myself) converting 24V to 3.3V for MCU's.
I hot plugged my modules around 10 times with no problem (why hot plugging would be a problem with SPI?) although according to Wikipedia article, SPI is not hot pluggible.
So, what could possibly caused that damage? Standing waves? Hot plugging? Or maybe power supply? How can I find the root of this issue?
Do I need to use optic isolators (or cmos buffers?) for each of MCU unit?
AI: You have a very long SPI bus running across several PCBs. Not only is this not recommended for SPI — it was originally designed for chip-to-chip communications on a single PCB — you have it connected directly to your CPUs without any electrical buffering.
Any induced transient (which could include ESD while hot-plugging) on any of the bus lines could easily drive any of your CPUs into "CMOS latchup", in which a parasitic SCR is activated that essentially shorts Vdd to ground. Physical damage from the resulting temperature rise can be permanent.
SPI is particularly easy to buffer, since each of the lines is unidirectional. You should include such buffers on the next revision of each of your PCBs. |
H: Do the capacitors on the picture look broken?
I have here a CD player's board (the player is from 80s, Gründig CD 30), the player works OK first 10 seconds, after that there is loud noise (sound is still possible to recognize but is very very cracky). The capacitors [on the picture] look somehow strange to me, particularly those orange spots. Could it be the symptom of broken capacitor?
Update:
thanks for the answers, the capacitors are really not broken, with no adjustments I assembled the player and the problem is gone, no noise at all. Mystic. So those orange spots seem to be some kind of glue. Thanks for the answers once again.
AI: Those do not look broken.
Generally electrolytic capacitors will have scored lines so that if they do break, the lines will pop due to internal pressure.
The orange bit does seem funky but I would probably write it off as some of that gunc used to hold the capacitors down. |
H: Enabling Pins on the Adafruit Motor Shield V2
I have soldered together an Adafruit Motor Shield (Version 2) following these instructions for standard headers (non-stacking headers). The end result looks similar to the image below:
I'm hooking the shield to an Arduino Uno and I want to hook up some sensors to this shield as well. Unfortunately, the standard headers that I've soldered on don't allow me to do this. I see two rows of holes next to the ones I've already soldered, numbered 0-13 on the digital I/O and 0-5 on the analog I/O. Can I solder female headers onto these holes in order to enable them? Are there any pins that I can't/shouldn't use? I've heard a rumor that the motors use up some of the pins, but I can't find any information as to which pins to avoid, specifically.
Any help would be greatly appreciated.
AI: Adafruit is very good at supporting their creations, including the shields. Look for the schematic for the shield on the product page. It will show which pins are in use. You can then use any other pin.
Those second rows right by the headers are connected (check with a multimeter to be sure), and using them as alternatives are what they are there for. |
H: SN754410 output supply current - heating
I am experiencing excessive heating problem with SN754410NE (SN754410). I know that I can use heat sink, but I want to be sure that I am not doing something wrong.
I am using SN754410NE to drive a bipolar stepper motor. My circuit is similar to schematic below. The current rating of the stepper motor is about 0.6 A and since continuous output current is given as 1.1A in the data sheet, I don't expect excessive heat.
However, the other issue is output supply current is given as 70mA in the data sheet. So, for example, if I energize one solenoid of motor output current of '1out' pin will be 0.6 A (which is below rating) however '2out' pin supply current will be also 0.6 A (which is above rating). Am I correct? Can this cause excessive heat?
SN754410NE data sheet: http://www.ti.com/lit/ds/symlink/sn754410.pdf
(source: g9toengineering.com)
Thanks in advance.
AI: According to the data sheet, at 1A, the typical voltage drop per half bridge will be 2.6V. Assuming you have two half bridges energized 100% of the time, the total power dissipation at 0.6A (assuming the same voltage drop, which is a bit pessimistic, but they are 'typical' values, not guarantees) is 3.1W.
That doesn't even include the 20 to 70mA of supply current, it's just the output drop times the current. At 24V/5V, the additional power dissipation due to the supply current (half high, half low) is 0.27W max (from 5V) and 0.64W max (from 24V) for a total of 4W.
That's clearly in excess of the absolute maximum power dissipation rating of 2W at 25°C free-air \$T_A\$, so you're way over what that chip is capable of safely handling. If you want it to work with \$T_A\$ = 50°C you need to keep power dissipation under 1.7W, as per "Note 2".
Always carefully read the fine print in datasheets. When they say "1A capability per driver" that often means that you can only use one driver at once, and maybe not continuously, and often not at the maximum temperature. |
H: Designing a bluetooth 4 low energy device - what needs to be taken into account for future FCC and CE certifications
We are designing a BT4LE device based on Nordic chipset with chip antenna.
The question is how can we understand is it required to put the chipset into an RF shield or not?
I've seen some BT4LE device designs which were CE certified and contained no RF shield. At the same time I heard opinions that the shield is required for FCC certification. Is there anybody who can help and explain how the decision should be made?
AI: A shield is required for a modular device (All the RF modules with FCC certification have a shield). A non modular device, under FCC 15.245 or 15.247 (2.4GHz ISM regulations) does not require a shield, however, a shield will generally improve your performance (better SNR and noise immunity). Also, transceiver modules under FCC require a voltage regulator of some sort.
Modular in this context means that the transceiver can be assembled or replaced by the end user (easily soldered or connectorized module). |
H: What are the disadvantages of using FPGA dev kits as the 'final product'?
I understand that serious HW firms can manufacture their own boards, but what are the disadvantages of using a development board 'in production', i.e. placing a PCIe card into a server and performing calculations on it?
AI: The biggest one is that it might not be available tomorrow.
In some cases, the manufacturers intend that the development board may be used in low volume production and pledge to maintain production over some period of time. They may also make available schematics and gerbers that allow you to produce the boards yourself.
Producing a compatible board over a long period of time is a significant commitment- like making a product. They have to deal with components that go obsolete, document changes and so on.
Other disadvantages center around the fact it wasn't designed just for your application so it might be too big, too power hungry, lacking in features etc.
OTOH, the relatively high production can have advantages. The cost of a development board for an aerospace client of mine was less than the cost to just populate an equivalent bare board (that's before buying the parts or testing). |
H: H-bridge - concern about mosfets
I want to create an H-bridge using MOSFETS (IRL620SPBF). I am trying to run a 6V motor which requires max current of 1.2A . The transistors Q111 and Q112 provide level conversion as the 'signal' comes from a Dev board at 3.3V. The DAC signal comes from the Dev board (0 - 3.3V). For prototyping purposes I created an oscillator from 555 timer to act in place of the DAC signal. The frequency ranges from 0 to 1.7KHz. The circuit works but I noticed a few drawbacks. Firstly, the mosfet Q1 gets really hot. These mosfets are rated at 5.2A, 200V which is well within my range. I do not understand why only Q1 gets hot and not Q4. Doesn't the current going through Q1 also goes through Q4 or is there something wrong with the circuit design or is it to do with the switching of the mosfet? I have provided the h-bridge circuit below:
Any comments and suggestions are welcome
EDITED
New development. Just noticed that when the motor is disconnected from the circuit and the power is connected, mosfet Q3 gets hot. Is this magic?
EDIT 18 March 2014 - Discussion
I took out mosfets Q1 and Q3 and directly connected them to 6V and sending PWM signals to FETS Q2 and Q4. I noticed that the fets get a little warm when driven the motor at full load but they do not get hot at all. When I was using the 4 FET h-bridge I noticed that the top fets would get really hot which was due to improper biasing (the fets weren't switching on fully). The new design is a great improvement. Now I am choosing an N-channel mosfet with much lower Rds(on) compared to the one I am using at the moment which will be STB80NF55L-06T4. Hope that would not consume too much power and dissipate heat. Thank you all
AI: To turn on any of the MOSFETs properly in your circuit, the gate voltage has to be significantly higher than the source voltage. For the lower position devices Q2 and Q4, the sources are grounded to 0V therefore they can easily turn on into "saturation" by applying a gate voltage of a few volts above ground.
For the devices connected to the top rail, if you want the on-resistance between drain and source to be really low you have to obey the same rule - the drive voltage to the gate has to be several volts above the source. Now for low volt drop you want the source to be switched virtually to 6V - where in the circuit can the gate receive a voltage of maybe 9 or 10 volts?
There isn't one so please consider two options: -
Using P channel MOSFETs at the top rail, source to 6V. P MOS is slower than N MOS but in your application it won't make a difference (1.7kHz).
Using a drive circuit derived from a supply voltage that is at least 9V and quite possibly higher to get the best saturation from the MOSFETs.
Now the relays. What are you hoping to achieve here? The MOSFET whose gate is disconnected will float to some almost random voltage level and possibly turn on unexpectedly or just get hot. Get rid of the relays unless you have some cunning plan for their use which eludes me.
This is a standard H bridge using P and N MOSFETs: -
Please ask if you need recommendations for devices. |
H: Circuit design for variable number of leds
I am very new to this field and turned onto it by adruino and raspberry pi. So for my next project I am looking to create, I wanna have 6 leds (20mA 3v) in a line. Now depending on my output from raspberry I want a certain of the 6 to be on at time and not the others and switch among them. I have a 12v battery that I want to power the circuit with. I am confused with what resistance and how should I connect them so as not to blow out the leds.
AI: You can use a ULN2003A to drive one LED per GPIO pin. Each LED gotta have a series resistor to +12V. 470 ohms will give almost 20mA. |
H: Just making sure I won't fry my motherboard?
I'm building this circuit, which converts a toggle switch to a momentary one, which sends a key to a USB keyboard PCB by connecting 2 contacts together:
I just wanted to check, how do I know the keyboard PCB won't get fried when I flip the switch to 12v DC? Or worse my motherboard?
AI: The momentary buttons make a physical connection when pressed. The relay's actuating part, does the same. And unless you short a wire out or physically connect them wrong, you won't fry the computer or keyboard. The relay provides physical isolation between the coil and the actuating part. |
H: Powercast Powerharvester Chipset PCC110 Issues
I recently picked up a PCC110 datasheet, an RF energy harvester. I assumed the 3 pins would correspond to GND, Antenna, and Vout (the datasheet does not specify).
I attempted all of the permutations for the pins in a relatively radio noisy location, but I was unable to detect any current (uA range) across a simple load. I wasn't expecting the rated max of 50mA, but not even a uA?
Is there something I am missing? Do these devices work in ambient radio environments, without the Powercast booster station? The device is quite small and I had a difficult time soldering the connections; could I have damaged the device with the heat?
AI: The PCC110 is stated as operating from -17dBm upwards - to expect that level of RF signal prevailing even in a so-called "noisy" environment is hoping a lot. At (say) 1GHz and at (say) 10 metres distant from a 1 watt transmitter, the free-space link loss in dB is: -
32.45 + 20 log\$_{10}\$(MHz) + 20 log\$_{10}\$(km) =
32.45 + 20 log\$_{10}\$(1000) + 20 log\$_{10}\$(0.01) =
32.45dB + 60dB - 40dB = 52.45dB
Total power one could expect to receive is 30dBm (1W) - 52.45dB = -22.45dB i.e. below the lower limit for the device to work. It is intended for RFID applications is my conclusion. |
H: Nickel 500 and 200 ohms at 0 Celsius
I'm trying to find resistance table for Ni 500 and Ni 200. I found tables for Ni 1000, Ni 100, NiFe 604 and NiFe 507.7. But I wasn't able to find resistance to temperature table for Ni 500 and Ni 200. Could you please give me these tables? Or is it possible to convert Ni 1000 resistance values to Ni 500 and Ni 200. For example is it valid :
(Resistance of Ni 500) * 2 : find this value from table of Ni 1000
AI: you can calculate the Tables by using this formula for Ni xxx:
= 100Ω for Ni100, 500Ω for Ni500 and so on.
t = temperature in °C
A = 5,485∙10^(−3) °C^(-1);
B = 6,65∙10^(−6) °C^(−2);
C = 2,805∙10^(−11) °C^(−4);
D = −2∙10^(−17) °C^(−6).
For Ni 500 you will get this:
source is the german wikipedia article. (the english one does not have it) |
H: Configuring PIC16F877A PORTA as digital output port
I am trying to use PORTA of PIC16F877A as digital output port. But somehow it does not seems to be working.
I am using MPLAB X IDE MPASM to assemble the code. Below is the code I am using to initialize PORTA -
banksel PORTA;
clrf PORTA;
banksel ADCON1
movlw 0x06
movwf ADCON1
banksel CMCON
movlw 0x07
movwf CMCON
banksel TRISA
movlw 0x00
movwf TRISA
banksel PORTA
movlw 0xFF
movwf PORTA
The LEDs at the output does not glow at all. What am I missing? I am not expecting RA4 to glow as I know it requires an external pull-up resistor but what about other LEDs.
Any help would be much appreciated. Thanks in advance.
AI: It looks like this code, such as it is, is setting up the digital outputs correctly. It is good that you used BANKSEL to eliminate any issue of possibly bad bank setting. However, this code still has some serious problems:
There is not a single comment in sight.
How did this ever assemble!? Opcodes aren't allowed in column 1.
Just using a HEX constant for a number of bit fields is irresponsible programming, such as your "MOVLW 0x07". The code should be explaining what each individual bit field is and what you are therefore setting it to. Something like this:
banksel blonkcon1
movlw b'10010010'
; 1------- enable the blonkulator module
; -XX----- unused
; ---10--- prescaler of 7
; -----010 select single-shot operation
movwf blonkcon1
To test the pin setup by itself, disconnect the LEDs and just look at what the pins are doing with a scope. There is a good chance your problem is with the circuit. Show the complete circuit. |
H: cny70 with 40106 and PIC, only detects 1 time every time I reset
I am using a PIC18F2550, a CNY70 and a 40106. (Schematics below)
The problem is that when I turn on the circuit, the first time the CNY70 detects something works perfectly (I have 1 led in every B output, except for B0 that is the interrupt input). The LEDs turn on for a very short time and then turn off. But when I try to do it again, the voltage of the CNY70 output changes how it has to, but the 40106 output only change from 10mV to 100mV. Also, I have changed the CNY70 and I have the same problem. I checked all the connections several times but i can't find anything wrong.
I tried 3 different configurations with the CNY70 and the 40106:
Without capacitor:
With capacitor between 40106 input and Gnd:
With capacitor between Vcc and Gnd: (I can't post more links - the same as the 1º but with a 100nf ceramic capacitor between Vcc and Gnd)
I use a PIC18F2550. The program is very simple, right now is only for testing the sensor:
#int_EXT
void EXT_isr(void) {
output_B (0b11111110);
delay_ms (300);
output_B (0b00000000);
}
void main() {
setup_adc_ports(AN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_1(T1_DISABLED);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
port_b_pullups(TRUE);
set_tris_b(0x01);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(true){}
}
Steps to reproduce the problem:
Turn on the circuit
CNY70 to air (open). it's output is 4.5V
40106 input is then 4.5V so the output is 0V (10mV). (B0 = 0)
Now I cover the CNY70 (close). It's output is 150mv.
40106 input is then 150mv so the output is 5V. (B0 = 1)
B1-B7 output high, turning on the 7 leds for a few ms.
I put the CNY70 to air again (open). it's output is 4.5V
40106 input is then 4.5V so the ouput is 0V (10mv) (B0 = 0)
I conver The CNY70 again (close). It's output is 150mv.
40106 input is then 150mv, BUT the output is only about 100mv. (B0 = 0)
AI: Item 10 indicates port B0 has become an output and is being driven low, and is fighting the 40106. I don't use the CCS compiler, which is apparently what you're using, but consider this description of the output_B function:
So it looks like you should use the #use*_io directive rather than (or in addition to) TRIS to set the direction of the port pins (specifically #use fixed_IO).
These non-standard C things are irritating |
H: Avoiding solder mask in certain region in Altium PCB design
I want to have a region in my PCB without solder mask while the other regions should have solder mask. I am not sure how do I do it in Altium? Is it by having a Solid (copper) Fill in the Top/Bottom Solder layer?
AI: The solder mask layer is a "negative", so to remove solder mask from an area, simply place any shape on desired "Top/Bottom Solder" layer. |
H: How to adjust output current on a buck converter?
I 'm planing to use a zinc–carbon 9 V battery to power up:
the circuit that battery belongs to
BeagleBoard-xM
I 'm thinking of using a breadboard, in order to power up both circuits. Beagleboard-xM's electrical specification is 5 V, >1.5 A. For this reason, I plan to use a buck converter to get this voltage. (e.g. LM2596S-ADJ). As I can see, there is a potentiometer in order to adjust the desirable output voltage.
My questions are:
Except 9 to 5 V convertion, how can I adjust about 3 A output current?
How voltage drop of the buttery that will occur over time, affects output voltage and current?
AI: You don't "adjust about 3 A output current". The job of the regulator between whatever power voltage you have and this Beagle thing is to provide a steady 5 V. How much current the load (the Beagle thing in this case) draws is up to it.
According to your specs, it can draw as much as 3 A. In that case, your 5 V supply has to be able to supply 3 A, but that doesn't necessarily mean it will always be supplying 3 A. That is probably a peak spec, and part of the time the load won't draw that much. That's fine though. Your supply will keep its output at 5 V as long as the load draws 3 A or less.
What you need, therefore, is a buck switcher that can take around 9 V in, make 5 V out, and can supply up to 3 A at that 5 V.
Note that you are asking for 15 W. That has to ultimately come from the unregulated supply (the 9 V battery in your case). A switching power supply doesn't make more power, only coverts it to a different voltage x current tradeoff. Let's say the switcher is 90% efficient. That means the 9 V source needs to be able to supply 15 W / 90% = 16.7 W. At 9 V that is 1.9 A. A ordinary "9 V" battery can't do that.
A better alternative for this kind of power might be a 12 V lead-acid battery. There are many switcher chips that can handle that voltage and make 5 V out. The 3 A output requirement will eliminate a bunch of them, but these things are still available, especially if you are willing to use a external switching element. Look around at offerings from ST, TI, and even Microchip at that voltage. Linear probably has some offerings too, but they tend to be more pricy. |
H: What does "SoC bringup" mean?
Saw the term "expert in SoC bringup" on a job description for an embedded software developer: SoC here refers to System-on-Chip, but I was wondering what the term "SoC bringup" meant.
AI: "SoC bringup" generally refers to the process of porting an operating system to a new embedded system that incorporates an SoC chip. This includes tasks such as:
Assisting with the hardware debug by writing low-level test code to exercise memory and peripheral interfaces.
Making sure that the bootloader can communicate with the specific boot device, and verifying that the entire boot process works correctly. This could also include writing a driver that allows an initial boot image to be written to a blank boot device.
Verifying that OS-level device drivers exist for the specific peripherals being used. This could include writing custom drivers for application-specific hardware.
Making sure that the debugging mechanisms for application-level code are in place and working properly. This could include some combination of JTAG (hardware) based debugging or something like gdb running over a network interface.
Together, these things are sometimes called a "board support package", or BSP. |
H: Reading to PIC32MX's memory in C and XORing big sets of data
I have a project in which I have 102 8-bit PISO shift-registers in daisy chain configuration and they are outputting to a common SDI line connected to a PIC32MX controller.
There is a total of 816 bits I need to read and store in the memory so I can manipulate the data being read. Also, I'll have to read them 34 times because the application requires that I XOR those 816 bits for each of these read operations.
I have two questions:
How would you store the data? I'm worried because I'll have quite a bit of data to handle and I'm trying to optimize processing to the very minimum. Note that I need to be able to extract the (row, col) indexes so I can compute other values accordingly.
After XORing the data, I'll need to traverse the structure and find occurrences of '0's. What do you suggest in terms of search algorithm?
I was thinking of creating a matrix with [34,816] dimension and sequentially XOR the rows to a single, 816 column array and then search for '0's in the array, but I'm not sure how to do it, any thoughts?
AI: To process the bits as efficiently as possible, you're going to want to keep them packed into 32-bit words whereever it makes sense. 816 bits is 25.5 words, which really isn't bad at all.
To search for ones efficiently, break the task into two steps: Check entire words for non-zero in the outer loop, then search for individual bits in the words that aren't all-zero in the inner loop.
One trick that can be used to isolate individual bits in a word that has multiple bits set is to AND the word with its negation (2's complement). The result has just a single bit set — the rightmost 'one' in the original word. You can then use this result to clear that bit and look for the next 'one'.
In C:
temp = word & -word;
word &= ~temp;
For example, suppose your 32-bit word contains 0x40010080:
01000000000000010000000010000000 original word
10111111111111101111111110000000 ... negated
00000000000000000000000010000000 ... and then ANDed together
11111111111111111111111101111111 complement of previous word
01000000000000010000000000000000 ... ANDed with original word for next iteration
EDIT:
The efficiency of this algorithm comes from the fact that you only iterate once for each 'one' (three of them in this example), rather than once for each of the 32 bits in the word. This is a huge advantage if you're doing something like simply counting the 'one's. The downside is that it doesn't give you the bit index directly, but there are ways to accelerate that as well. For example, to get the bit index of a single bit set in a word, you could use a binary encoding algorithm:
index = 0;
if (word & 0xAAAAAAAA) index += 1;
if (word & 0xCCCCCCCC) index += 2;
if (word & 0xF0F0F0F0) index += 4;
if (word & 0xFF00FF00) index += 8;
if (word & 0xFFFF0000) index += 16;
The overall advantage of the two algorithms above, as compared to a brute-force iteration through the bits, depends on how many bits you expect to find in each word. If they're rare (less than about 4 per word), then these algorithms should be faster. If they're more common than that, just go with the iterative loop:
for (index = 0, mask = 0x00000001; index < 32; ++index, mask <<= 1) {
if (word & mask) {
/* do your processng here */
}
} |
H: IC555 flyback driver troubleshooting
I made a flyback driver which just uses an astable 555 circuit to drive the flyback. The 4 and the 8 pins were connected to the positive rail. 7 pin was connected to the positive rail via a 1K resistor and a 10K pot. The 6 pin was connected to the 7 via another 1K resistor and pot. A 10nF cap was between 2 and the negative rail, which was connected to the 6 pin. I used an IRF540 MOSFET directly connected to the 555 to drive it. I was able to get atleast a centimeter long arcs out my flyback (FKD15A001). As excpected, the MOSFET gets hot, I had already attached a heatsink to it so it was no problem. But, the chip also gets very hot for some reason. I have already lost 3 of my chips because of this. Is there anyway to prevent this? Why is this happening? I am using a 12V power supply.
AI: You should consider interfacing the 555 indirectly to the MOSFET for a couple of reasons: -
The gate capacitance of the MOSFET (circa 1nF) likely means that the waveform output from the 555 is being turned from a nice looking squarewave into a more triangular shape and this will cause the 555 some stress and be not ideal for driving a FET used in a flyback transformer circuit.
The output capacitance of the FET can couple significant energy from the transformer primary to the gate when switching and this may also be causing the 555 a lot of stress. Assuming you are running the circuit from 12V, the primary winding will likely be seeing 24Vp-p (as per a regular flyback design) and if you imaging this couple via (say) 100pF to the 555's output you might understand what I'm hinting at.
There may be other things wrong with your design but I would definitely consider using a high current logic driver to feed the gate. The gate driver should be able to deliver about an amp into the gate in order to charge and discharge the gate's capacitance up quickly.
With a poor driver you might also be getting an instability when the FET switches. When it turns off (gate attempts to go low), the output rises quickly and with the inter-lead capacitance this rising voltage can couple to the gate and cause it to momentarily switch off partially. Again it will warm up the FET and if it happens on the rising edge it will likely happen on the falling edge of the drain voltage. |
H: Oscilloscope sweeps only once with DC sources and shows nothing on GND setting
I got an old CRT oscilloscope someone had laying around unused in his garage (an ATAIO AI 751A which seems pretty obscure, not getting any meaningful Google results). Unfortunately the user manual is missing, I couldn't find it online and this is the first CRT oscilloscope I work with, so I'm not sure if I'm operating it properly.
It powers up but there's nothing on the display when the probe is not touching anything, even when it is set to GND. Touching the probe's tip triggers a (very flickery) 50Hz ~10mV peak to peak signal (yes, I'm european) but setting it to GND to center the signal vertically stops showing the signal. At dual display mode both channels are shown when I touch the tip in channel 1 (channel 2 disconnected is shown at ground level), but as soon as I release the finger, both channels are gone too.
Touching a 9V battery gets a single sweep when the tip touches or releases the battery, while I'd expect at least that channel to be shown at a constant value.
Setting a high period for the time division and touching the tip triggers a single sweep, but as soon as it reaches the far right it stops. I can trigger another sweep touching or releasing the tip again.
I pressed a switch labelled "Auto Level" which I think should make the trigger level automatic based on the last samples (which seems plausible since the trigger controls don't do anything when auto is on) but still nothing is shown on the display when touching a 9V battery.
Fiddling with the controls (e.g. pressing the "Auto Level" switch) triggers a single sweep too.
Is the oscilloscope broken or am I doing something wrong? Where should I start troubleshooting?
Images: (don't pay attention to the settings)
Full oscilloscope
Triggering controls close-up
AI: Pull out the trigger level knob. This will put it into "auto" trigger mode, which basically means it will automatically start a new sweep a short interval after the previous one ends. This will give you a continuous trace even with a DC input signal.
On modern scopes that have microprocessors, "auto" now means something completely different, in which the micro searches for a set of vertical and horizontal settings that give a "reasonable" display (YMMV).
The "Auto Level" button does something different: It uses a pair of peak detectors to determine the swing of the signal, and places the trigger level at some intermediate (50%?) value. |
H: Can I replace a 2N222 by a BC558B, BC549C or BC327?
I just started studying Arduino and I'm watching a online course. I got into the stage where we're suppose to build some sort of protection system so we can plug-in outsourced power supply and prevent the arduino uno from frying.
My problem is that the class course uses a 2N222 Transistor and he talks about \$V_{ce}\$ and \$V_{be}\$ numbers. All I have is a BC558B, BC549C and BC327 transistors, which I've tried to understand the datasheet and one of them is negative, and none of them seems to have similar numbers to the 2N222. I'd like some input regarding the protection system:
Are any of the transistors in hand useful for it, or should I forget about the ones I have and go buy a 2N222?
Maybe I didn't understand much of the course. But the guy says that the Arduino can't handle more than 50 mA and if I want to turn on something that consumes more than that, I need an external power source. But if I plug the power source direct into the Arduino, it will fry. I need to build a protection system using Relé and a Transistor. But he uses the 2N2222 transistor and I don't have this one here. I want to know what's important on it to figure out if the ones I have is enough.
AI: Your understanding is correct, in that you have to careful about subjecting your I/O pins directly to external devices. Sometimes, that is because the external device requires a different (usually, when it is a concern, this means higher) voltage than your I/O pin can provide or tolerate. Sometimes, that is because the current compliance of the I/O pin isn't nearly enough. (This is the ability to sink [towards ground] or source [from the power supply] current.) It's a good idea to stay well below the maximum current compliance too, because the I/O pin voltage itself is pulled away from its nominal value at the higher currents within its compliance range.
The fact that you sometimes see negative, as opposed to positive, values for different transistors when you read their datasheets is a matter of convention. There are two kinds of bipolar transistors (BJTs), NPN and PNP. By convention, the specifications use a different sign for similar parameters listed on the sheet. When considering limitations of one or the other, you focus more on the magnitude than the sign. If you see the "wrong" sign, it probably just means that you are looking at a PNP instead of an NPN you wanted, or that you are looking at an NPN when you wanted a PNP.
The \$V_{ce}\$ term is usually important for one of two things: (1) figuring out the maximum voltage that the transistor will withstand safely when OFF, or (2) figuring out the dissipation on your transistor when operated as a switch that is ON. In the first case, if you are trying to operate a 12V motor, for example, you want to make sure that the BJT can withstand 12V when it is off. (Most will do that.) So you check that parameter on the datasheet. Sometimes, you may want to switch 60VDC and if that is the case there are a number of BJTs that won't handle it. But as a general rule, almost all can handle 30V or so and often 40V. In the second case, you need to look at some of the curves for the transistor and see what \$V_{ce}\$ is when operated in "saturated mode." As a rule, driven sufficiently, small signal BJTs will achieve as little as \$200mV\$ and perhaps even less (less is better.) This can be combined with your current (amperage) requirements for the load to figure out estimated dissipation at the BJT itself.
The \$V_{be}\$ value is usually taken as 0.7V without reading a datasheet as a first approximation for small signal BJTs (most of the small ones.) It's just an estimate used to get a rough idea about setting the value of a base resistor used in driving a BJT. For example, if you have \$5V\$ outputs you might "estimate" that the actual output will be \$4.8V\$ (just to give yourself a little margin) and recognize that \$V_{be} \approx 0.7V\$, leaving only \$4.1V\$. This must appear across the base resistor you use. If the base current needs to be 20mA, let's say, then you know that the resistor is \$\frac{4.1V}{20mA} = 205\Omega\$ So you might then select a \$220\Omega\$ or a \$180\Omega\$ resistor for that purpose.
You mentioned that you need 1A peak and 800mA continuous. That's a lot for most small signal BJTs. So this suggests you need to be careful here and select a BJT that is able to handle it well. It's possible that \$V_{ce}\$ will be a little higher here, because of the higher current for one thing. So for example, if \$V_{ce}\$ will be \$300mV\$ and the continuous load is \$800mA\$ then the dissipation is \$\frac{1}{4}W\$. The BC637 and BC639 are NPN devices that can handle 1A continuous and at \$800ma\$ they have typical \$V_{ce} \approx 300mV\$, too, with \$\beta=10\$. Might be an option here, except that your I/O can't handle \$100mA\$ drive (which is \$\frac{1}{10}\$th of 1A.) So this is starting to look like either a MOSFET solution or else a two-BJT solution. |
H: Scaling down the sensitivity of an MEMS mic
I'm using an MEMS mic ADMP401, and the datasheet said, that the sensitivity form the chip is -46dbV, my question, how to can the scale it down, mean that I hear only really loud sounds?
AI: The sensitivity of -46dBV means that with an incident sound level of 94dB (SPL) at 1kHz, the device's voltage output is 5mV. For the record, 94dB SPL is 1 pascal RMS of sound pressure.
If you read the data sheet it also tells you that the absolute maximum level of sound it can withstand is 160 dB SPL and this is very loud. At this level of SPL it is likely that the device's output will be heavily distorted.
It might help if you read this document. It's also from AD and is entitled AN-1112, Microphone Specifications Explained. It contains this:-
For digital microphones, a full-scale signal is defined as the highest
signal level that can be output from the microphone; for Analog
Devices MEMS microphones, this level is 120 to 140 dB SPL. See the
Acoustic Overload Point section for a fuller description of this
signal level.
120 dB SPL can be assumed to be resolvable from the MEMs device and indeed, in the device spec it says: -
Maximum Acoustic Input Peak 120 dB SPL
I think it has been established that 120 dB SPL is the maximum sound level that the device can linearly reproduce an output voltage that is relatively free from distortion. Is 120dB loud enough (?): -
If you need something that will work over 120dB SPL maybe you should consider a different microphone technology or find a way of mechanically reducing the sounds received by the sensor. If 120dB SPL is OK then read on...
If you only want to hear loud sounds and by this I mean you want smaller sounds not to register at all then, you can build an electronic circuit that is called a noise-gate. Basically a noise gate is a regular amplifier that can be disabled (or muted) when the input signal level is lower than a predetermined (and usually adjustable) threshold: - |
H: 74HC86 XOR datasheet say Schmitt trigger "action" - is there anything special about it?
I current have a Schmitt trigger chip to clean up an output from one of my optical encoders and I am thinking about using an XOR gate to feed in both encoder outputs to double my encoder output frequency. (Its a quadrature encoder)
When I was looking up XOR gate ICs, I saw in the data sheet it literally saying
All inputs have a Schmitt-trigger action
So does that mean I can fully do away with the standalone Schmitt trigger IC and the XOR gate will take its place as well as being and XOR?
It'd just when it says "action" it doesn't sound as robust as if it were to say all inputs have Schmitt triggers.
The IC is 74AHC86
AI: According to TI's "AHC/AHCT Designer's Guide February 2000", Section 2, "DC Characteristics", subsection 1, "Input Circuit", interfaces with lower-speed circuits with a lower slew rate can cause oscillation at 74AHC/T inputs. To prevent this, 74AHC/T input stages contain a feedback loop which causes the input to have hysteresis much as a Schmitt trigger input would without containing all the circuitry for an actual Schmitt trigger input.
However, the guide goes on to say:
Hysteresis in the input circuit is intended only to process reliably signals that have a slew rate of <10 ns/V. With a signal swing
of 5 V, this corresponds to rise and fall times of about 50 ns. If signals with considerably longer rise and fall times are processed,
the specially developed Schmitt triggers, such as the SN74AHC(T)14, should be used. These components have a considerably
larger hysteresis of about 800 mV at VCC = 5 V and, therefore, allow processing of very slow edges without any problems. |
H: What means coil inductance (h) for relays?
I'm looking at the data-sheet for a Single Coil Latched Relay. In there, i see the Coil Inductance (ref. value)(H) for Armature ON and OFF column.
Specs:
Rated Voltage: 3 (VDC)
Rated Current: 67 (mA)
Coil Resistance: 45 Ohm
Armature ON: 0.09 (H)
Armature OFF: 0.06 (H)
Since it mentioned for switching on and off the armature, it got me curious.
Could somebody explain what these numbers (0.09 and 0.06) mean? And how you would use this?
AI: The inductance is measured in Henrys (H). So, the inductance is 90mH with the relay closed and 60mH with the relay open. As the relay closes, the magnetic path changes, and the inductance changes.
You could use this to predict the behavior of the relay coil voltage when the relay is energized or de-energized. You could use it to make sure the energy capability of a clamp is sufficient. You could use it to predict how smooth a current would result from a PWM energization at a certain frequency or a full-wave rectified energization at a certain frequency.
For example, consider the TPIC6A596. It has a clamp rated to withstand a single-pulse avalanche energy of 75mJ. The worst-case energy stored in the magnetic field of that relay is \$(0.067A)^2 \cdot 0.09H\$ = 0.4mJ.
The change in the inductance as the relay opens means that that energy will be dissipated in the relay coil (mostly) if you use a diode across the coil. That means that the relay contact opening is slowed just when you would want it to be fast in order to minimize arcing. From a page here is a 'scope capture of this effect.
The step plot is the relay contact opening. The bumpy plot is the current through the armature, as you can see it is not monotonic and actually increases as the clapper leaves the armature, which is just as the contacts are opening.
With the numbers from the datasheet (in addition to the typical drop-out voltage and open/close time) you can begin to model this effect, and predict the results of using a Zener clamp vs. a resistive clamp vs. an RC snubber vs. a diode clamp. |
H: Use water as a conductor for a circuit powered by 1.5v battery
I've tried to create this quite simple circuit.
V1: 1.5 v (AA battery)
LAMP1: 1.5 v, 0.2 a (E10 incandescent light bulb)
"Salt water": 10 ml regular water + 1 g salt
When I connect the wires together, the lamp lights up. When I connect the wires to various conductive materials (a spoon, tin foil, a penny,...), it works as well. But if I put the wires into a tiny bucket containing (salt) water, it does not.
Could you please explain why? (I guess that it is related to the water resistance/conductance but how exactly and how do I calculate it?)
Thank you.
AI: The spoon, tin foil, and penny are all metals, and will have a very low resistance - probably well under 1 ohm, so will allow ample current to flow to light the lamp.
The salt water will have a much higher resistance, allowing very little current to flow - this low current will not be sufficient to cause the lamp to light. I just measured the resistance of some salty water - it was about 50,000 ohms (50Kohms) which would only allow 30 uA (.03 mA) to flow in your circuit - not nearly enough to light a lamp.
If you connect an ammeter in series with the lamp, you will be able to measure the current with different test materials. |
H: How I find the current and voltage in this matrix?
My book above uses nodal analysis to find the current and voltage across the resistors.
Now consider this alternate circuit:
Look at the branch that doesn't any components (the second straight line with no components). How would I find the current across it? I only know Kirchoff's Laws and Nodal Analysis so far. Can the current across it be found using these techniques?
AI: In this case, you first want to reduce the circuit. I'm going to have to explain this without pictures, sorry. But I think it'll be pretty clear anyway!
The first thing to do is to ignore the small arrow marks that are showing the branch currents - they are no longer accurate once the circuit changed. Neither are V1 and V2.
Look at the 6k resistor. It has effectively been removed from the circuit. That is, there will be no current through this resistor. There are a few ways to see why this is so. Here are two of them:
The resistor is in parallel with a zero-Ohm path. Any current flow will happen through this short, and nothing will flow through the more difficult path of the resistor.
There can be no voltage that exists across the short. Therefore, no voltage will be presented across the 6k resistor, either, since they are in parallel.
So, now, you are left with the 1mA source, flowing though a 6k resistor in parallel with 12k resistor. Easy to analyse with either of the techniques you mentioned.
Good luck :) |
H: Powering the MCU (basic), is this circuit suitable?
Shown is a basic circuit diagram to power a MCU. I am using the recommended caps for the test circuit for the regulator.
Should I put a diode between the +ve terminal of the power source and the input of the LDO just to be safe?
Will this circuit be suitable to power and program the MCU?
Are the decoupling caps correct or suitable?
simulate this circuit – Schematic created using CircuitLab
AI: Since you're throwing away most of the 9V, a diode in series won't hurt efficiency, and could prevent damage if someone touches the input voltage in reverse, so definitely put it in.
Keep the leads short, as @Ignacio suggests. There should also be decoupling across the micro-controller pins directly as well if the two are separated by more than some mm.
If the 9V is coming from a battery, I would also suggest a largish aluminum capacitor across the regulator input, 220uF to 1000uF rated at 10V or more. If the leads are short (an inch or so), that can replace the 330nF. If it's an AC adapter supplying the 9V, there's already a big cap in there, so the 330nF is fine. |
H: Input resistance of a transistor circuit
I have a question from the razavi's microelectronics book:
I'm puzzled because in the solution provided, the first line states that:
"We know that the input resistance Rin = R1||R2||\$r_π\$."
While I understand if I transform the circuit's base input into Thevenin equivalent, R1 and R2 are in parallel (R1||R2). But shouldn't the small signal resistance \$r_π\$ be in series rather than in parallel?
e.g.
Vth --- Rth --- \$r_π\$ --- ground of emitter
Am I missing something fundamental?
AI: You need to follow a two-step process to solve this. First you find the bias point, and calculate the value of r\$\pi\$. For that, you use the Thevenin equivalent and Vt.
Once you have r\$\pi\$, you move to small-signal thinking, and in small-signal terms, the non-input side of R1, R2 and r\$\pi\$ are all connected to ground, so they are all in parallel.
Here's a nice MIT EdX open courseware lecture you might find useful. |
H: Measure on/off pulse of relay (with reversed polarity) with a MCU?
Below I have the following (simplified) circuit:
What I want is to measure (monitor) every time the relay switches on and off. The pulse is around 3V and for 32ms.
The problem is that the voltage is reversed, to switch off the relay (single coil latching), and I have no idea how to wire it correctly up with my Arduino.
One solution (not sure) I came up with is to use 3 wires. If I hookup GND with (Arduino) GND, and the A and B wires go both to its own port (with some pull-down resistors) on the Arduino.
I think it should also be possible to hook-up with only 2 wires (just A and B)? But, if I hookup A/B directly on the (Arduino) input ports, I'm basically hooking-up GND, that doesn't seem right.
AI: You can use a bidirectional input optocoupler such as H11AA1
Connect the input optodiodes to points A/B with a small resistor in series and drive the AVR pin from the output transistor.
Using this way you have to keep track of the pulses to know the current state.
Here is an alternative, an optocoupler connected to the output of the relay. The output signal will be low when the relay is on and high when it is off. |
H: Multiplex based autoscale, question on simple circuit
I was looking for a clever way to automatically scale voltages from, say, 0-50V with a mux to an ADC (0-5V) without worry of damaging my inputs.
My thought a simple amplifier with selectable gains would work: Select the lowest gain ratio first (i.e. 0.1x), and then raising that to eventually have the voltage fall nicely within my desired range, and of course I know which ratio is selected on the mux.
I stumbled across this clever circuit when looking for a solution, but it is confusing to me:
I gather that this is more or less what I am sort of looking for: I assume the DC offset of 2.5 is to allow negative voltages to be scaled (with protections diodes in place before that point) and read as a multimeter would do maybe, of which is my intended project.
The formulas given do not lay up very well however:
i.e. 0.1x gain, Rf/Rin (100k:10k), with Vin of 10 = 1V (or 3.5V I suppose with the offset?) - this is nice, however in the formula provided:
\$2.5V - (10 - 2.5V) * \frac{10k}{100k} = 1.75\$
And to me of course that does not make sense!
Will ignoring the formula and simply assuming it divides evenly and I know by how much work? (if it is just some strange "on paper" formula, and not something meant to be done on the processor, since \$V_{out}-2.5gain\$ or whatnot is a looot easier..) What is that given formula and how does it work if it does? Will the mux add any downsides (leakage current?) and should I choose lower resistors in that case to swamp that? Can you suggest any alternative circuits that simplify what I am trying to do if this is just a bad idea in general?
AI: Vref is the new 0V and this is where you are getting confused.
With 1V going in with a gain of unity (Rf = Rin), the voltage out is: -
\$V_{OUT} = V_{REF}-(V_{IN}-V_{REF})\cdot\dfrac{R_F}{R_{IN}} = 2.5 - (-1.5) = 4 volts\$
This is an offset from 2.5V of +1.5 volts and remember your input voltage of 1V (relative to ground) is actually -1.5V relative to 2.5V (the new 0V) i.e. the gain is -1
With 10V going in, relative to the "new 0V" the actual input is +7.5V (bear this in mind) so, when you do the math with Rf/Rin = 0.1 you get an output voltage of 1.75V or -0.75 below the "new 0V" of +2.5V.
So, relative to 2.5V you put in: -
-1.5V at a gain of unity and got out +1.5V and
+7.5V at a gain of 0.1 and you got out -0.75V
Does this now make sense? |
H: Voltage level too low for MAX232
I'm trying to connect TI's MAX232 to my Arduino so that I can communicate with my PC. I have connected it exactly as the picture shows:
Tx/Rx are not connected because I just wanted to see if I can get proper V+/V- on pin 2 and 6. At Vcc=5V I'm reading 1.9V on both - pin 2 and pin 6. I connected my 1uF capacitors so that the longer leg represents the white part of the capacitor symbol, and the shorter leg is in place of the black part. Should I connect some other signals so that I can read +10/-10V on pin 2 and 6?
See an image of my circuit below. The brown cable is Arduinos GND and the grey cable is Vcc.
AI: I'm assuming you're using TI's MAX232. Other than missing the bypass capacitor, your schematic seems fine. See below the Typical Operating Circuit from the datasheet for a comparison.
Also, regarding Jim's comments, according to the datasheet, your C4 capacitor negative (short) lead (which corresponds to C3 in the circuit below) can be connected to either VCC or GND (see footnote).
So, I'm guessing that either -
your IC has failed
your connections are different from the schematics you presented
A good quality picture of your board or breadboard would help us determine if the problem is in your circuit or not.
Also, if you have access to an oscilloscope, you should see a nice square wave on the kHz range at the capacitors leads (not sure which ones, but C1 and C2 certainly). That would mean the IC's charge pumps are working fine. I'll post a shot when I get home so you can see what it looks like. From memory, I would say that they are about 1V in amplitude.
In any case, I would add the bypass capacitor as well, just to make sure the MAX232 power supply is stable. Adding the correct bypass capacitor made a difference for me once. |
H: How can circuits always be solved?
I've just started circuit analysis. All the examples, I've seen so far involve using using KCL/KVL or nodal analysis. They all consist of setting up a system of equations and solving them which gives you all the voltages and currents.
But systems of equations can have no solutions, infinite solutions or one solution. It's impossible for the system of equations to have no solutions in this case, because current must be flowing through the circuit.
But how do we know that the system of equations (assuming you have n equations for n variables) won't have infinite solutions?
AI: But how do we know that the system of equations (assuming you have n equations for n variables) won't have infinite solutions?
You try to solve it and see. It's not hard to construct circuits that aren't solvable, in some ways or all ways. Perhaps they never reach equilibrium, so can't have a DC solution. Perhaps they contain contradictory constraints. Here are just a few examples:
simulate this circuit – Schematic created using CircuitLab
Of course, when you try to actually build these circuits, something happens, so there is some solution. The issue is that you build the circuit with real components, while the model assumes ideal components. The model doesn't include, for example, the resistance of the wires in the circuit, or the internal resistance of the current and voltage sources, or the leakage current or capacitance to Earth. For a model to have a solution that reflects reality, the model must include all significant parameters of the real circuit.
For very many circuits, the circuit can be solved with the usual techniques of nodal analysis and such if we are careful to include everything in our model that's significant. For example, if we model the series resistance of L1, that circuit becomes solvable.
There are a smaller number of circuits that remain unsolvable. These circuits depend on random processes, or processes so complex that we can only feasibly model them as probabilities. For example, consider the electronic detector that kills (or doesn't kill) Schrödinger's cat. Or for a less exciting example:
simulate this circuit
This is a resistor, on your desk. There is some voltage, at each end of the resistor, relative to Earth. There is some current flowing in it, too, and these things can be measured. Unfortunately, they are mostly due to the Brownian motion of the charges inside the resistor. That is, mostly random noise. We have models to characterize that noise, like Johnson–Nyquist noise. Once you model the noise, you can model (with nodal analysis) its effects on the rest of the circuit. However, the fact will remain that you still have a solution that is some set of probabilities.
Fortunately for us engineers, circuits that do random things or are strongly influenced by unintentional effects (capacitive coupling to surroundings, for example) are generally not useful. We also try to make our circuits relatively immune to parameters subject to wide variation in temperature or manufacturing. When these normal practices are taken into account, the number of circuits you encounter that can't be reasonably solved with nodal analysis are quite few. Nodal analysis is, after all, a simplification more complex, more fundamental physics, and it's our job as engineers to assure these simplifications are valid at each step. |
H: Connecting DAQs in Parallel
I need to connect a DAQ to an existing system which uses a DAQ. The idea is to connect the DAQs in parallel so the existing system is not changed. It is likely that only one DAQ will be used at a time. The DAQs will be configured to output a 0-10V signal. I believe this will be fine, but I'd appreciate any clarification.
Thus, I cannot interface with DAQ0, so can I introduce DAQ1 in parallel with DAQ0 without compromising the signal or either of the DAQs?
Would there be any benefit to keeping the systems isolated?
AI: Probably not without some means of isolating DAQ0. Even though it may be disabled, it could still take a significant amount of current from DAQ1's output and possibly one or both could be damaged. This is the worst case scenario.
I'd use DAQ1 to announce itself to a relay which breaks DAQ0's connection thus allowing DAQ1 to have full control over the target.
I'd use a relay that switched both ground (0V) and hot too. This keeps them isolated and fool proof. |
H: Why are resistance matrices always symmetric?
My book says when using nodal analysis to find the voltages and currents in resistive circuits, the resulting matrix (of the system of equations) is always symmetrical. Why?
The exact quote is:
The node equations for networks containing only resistors and independent current
sources can always be written in this symmetrical form
Also the diagonal elements are always positive and the off-diagnonal ones are always negative. Why?
AI: A resistor of R ohms between A and B will show up in the matrix as
+1/R -1/R
-1/R +1/R
The rows represent the voltage on A and B; the columns represent the net current into nodes A and B.
The columns must be equal and opposite because the current flowing into one node of the resistor must be equal and opposite the current flowing out the other node. The two numbers in each column must be equal and opposite because current should only flow in the resistor in response to a voltage difference between the two nodes. The value of the the upper-left cell is 1/R because an increase on A's voltage of 1 volt should increase the current flowing into A by 1/R. |
H: What is the best connector for this RF 434MHz transmitter module?
I have a few of these cheap RF 434MHz transmitter modules (see image below, on the left) that I want to use with my PCBs, but I don't want to solder them directly to the boards. I'd like to attach them to the PCBs using a sort of female conector. I've tried to use some female headers (image also below, on the right) but the RF module leads seem to be too thin to make a good connection.
What is the best connector for those RF modules?
AI: Try a socket with machined pins. They are usually more snug than stamped pins (which is the type of pink in the black socket pictured in the O.P).
( source )
There are single line (SIP) variants too
( source )
The pins on the transmitter module a stamped from thin sheet. In that, they are not too different from DIP pins. |
H: Current and voltage sources?
simulate this circuit – Schematic created using CircuitLab
From what I understand, the magnitude and direction from an independent current source is constant. What would happen in the circuit above? If currents flow they way they're supposed to from the current source, KCL is violated. So how would the circuit above behave?
How about this one?
simulate this circuit
AI: In circuit 1 you get infinite voltages and in circuit 2 you get zero current.
EDIT due to wrong circuit posted in question - circuit 2 takes 45mA and I'm not inclined to feed the reasons on a plate to the OP because this sort of stuff should be reasoned through. |
H: L293D heating quickly under 0.5 A (driving a DC motor using adafruit motor shield v1)
I am using Adafruit's Motor shield to drive a DC motor I got out from an RC car...
Powering the Arduino from USB. And powering the shield from a 12V / 1.5 A Power adapter (the shield is using an L293D)
I checked the datasheet of the L293D and it says max current is 0.6 A and max power dissipation is 5 Watts.
I measured the drawn current from the supply and it was : 0.5 A. (with running motor)
As soon as the motor turns on the chip gets hot quickly (withing 1 sec) & the motor's speed drops down.
Another weird thing is that when I connect the motor directly to the power supply it starts turning for 1 second then turns off for 2, then it turns back on & so on... I am suspecting that it's exceeding the power adapter's max current (1.5 A) which is also weird because the motor is small and doesn't look that powerful.
Can anyone please help me here?
AI: Maximum power dissipation of the L293D is far less than 5W. The N type package will warm up 67 degC per watt dissipated (pg 4 of data sheet) and 2.5W would likely push it past the limit of 150 degC stated on page 4 also.
It's hardly ever good news with the L293D (and its near-identical twin the SN754410). These are poor choices for H bridges if you are pushing the current over 0.5A and by the sound of it you are. There is also a suspicion that an RC motor probably isn't rated at 12V but somewhat less so you are probably pushing this just too far. Most RC batteries I've seen are about 7.5V.
Back to the L293D (aka SN754410).... When driving a load it doesn't act like a relay contact - it loses about 1.2V on the lower transistor and 1.4V on the upper transistor - take half an amp or so and the power dissipated is already 1.3 watts and has taken the N package device up 87.1 degC above ambient. That's quite hot in an ambient of 25.
Not a good choice of H bridge but, to be honest I'm yet to hear of an application when the L293D (SN754410) is a good choice. I'd look into the DRV8837 from TI. It has a combined high and low side mosfet on resistance of 0.28 ohms meaning, at 0.5 A the total volt drop is 0.14 volts and the internal power dissipated is 70mW. Maximum motor voltage is 11V but, I suspect you may be over-powering your motor anyway. There are probably others from TI that have a higher voltage rating. |
H: Full duplex shared frequency radio?
Normally shared frequency analogue1 radios (CB, aviation, etc.) can't receive when transmitting, because the signal being transmitted is much louder and will jam any signal from different transmitter.
Is it possible to somehow subtract the transmitted signal to be able to pick out signals from other transmitters even when transmitting? Is there any published design that allows receiving while transmitting or at least detecting that there is another transmission in progress?
1 Or digital, but with short packets collisions are less disruptive and there are other ways around the problem like slot allocation.
AI: This isn't trivial for a number of reasons, but it is possible. Part of the problem is that the receiver has to have a huge dynamic range to be able to receive the 1W signal and the tiny signal from afar just above the noise floor, and understand both without losing data.
One system that can help, though, is to remove the transmitted signal from the antenna before the receiver:
Some research points out that this can be made to work.
However, the point is that what you're asking is possible, but it's very difficult to do well. |
H: How does a cube sat communicate with ground station with a 1w antenna
I heard that cubesat signals can be received with a hand held radio. Its confusing me that how a 1 metre antenna radiating 1watt energy can simply be received using hand held radios. I am designing a pico sat. I don't which antenna to be chosen to connect with rf transmitter section. And which antenna to be chosen for ground station.
Assume that my satellite is 250kms above ground level.
AI: Here's how it works but a couple of factoids first: -
According to this source, the most common frequency of transmission is 437 MHz
Antenna gain\$^1\$ for a 1m dish is about \$0.5\cdot\dfrac{(\pi D)^2}{\lambda^2}\$ and at 437 MHz \$\lambda\$ is about 0.69 metres and gain will be about 10 and in dBs this also is 10dB
Link loss from satellite to earth is: -
32.5dB +20log\$_{10}\$(MHz) + 20log20log\$_{10}\$(km)
This is derived from the Friis equations for free-space transmission. At 250km and 437 MHz the link loss is 32.5 dB + 52.8 dB + 47.5 dB = 133 dB. In other words, the power reaching the receive antenna is 133 dB down on what was transmitted. If 1W is transmitted (30 dBm) then expect a receive power level of -103 dBm.
Given that it may be a dish with an antenna gain of 10dB\$^1\$, the power received might be 10 dB higher but how much signal is needed to be received?
What bandwidth/data rate is the received signal? Assume 100kbps (I have no idea what it is but here goes anyway!). Power needed by a receiver to avoid high bit error rates at normal ambient temperatures is: -
-154 dBm + 10log\$_{10}\$(data rate) and for 100kbps this is -104 dBm - beautifully coincidental eh!
Well, it's a bit worse than that because all sorts of things can interfere so realistically you'd want to see another 10 or 20 dB more received power OR, maybe the data rate is only 10kbps. If it is 10kbps then required received power can be 10 dB lower at -114 dBm and this is about do-able even without a parabolic dish at the satellite. It also assumes a low gain dipole as the receiver but there is no reason why you shouldn't use a dish if the satellite is geostationary. You'll get a couple of advantages if you do; first the received gain will be higher and 2nd, the dish is collecting power from space and the background level is much lower because space is cold. This would make the equation immediately above this paragraph much more lenient towards the receiver.
EDITED to put the negative sign in front of a couple of dBm numbers!!!
\$^1\$ I'm just seeing if it needs a dish so I thought I'd preempt the calculation up-front. |
H: Wireless "Arduino" sensors - what is at least needed on circuit?
When I finished my Master Unit for Home Control, I want to attach some Wireless sensors via 433MHz Protocol. (At least 2 ones, 1 for Measuring the outdoor Temperature/Humidity with an DHT22 and Lightlevel and 1 for checking if my mailbox lid opened)
Therefor I need a 433MHz transmitter and it would be nice to be able to programm the IC in-system with another arduino or better with the Arduino USBSerial (after flashing the boot-image inside of and Arduino UNO.
The system should run (stable) on battery and send a signal every x seconds or when some external interrupts happen (like opening the lid)
What parts do I need at least? (except the microcontroller and the 433MHz transmitter) what do I need to look for in circuit design to save as much power as possible? How can I check if the battery goes low (and send an alarm signal)?
AI: I designed a transmit-only device for use in a big freezer department in a store. They used 433MHz and a cheap little PIC micro that woke up about once per minute and transmitted temperature and its battery level to a central collection point for all the local devices. The wake-up time between one unit and the next was about a minute with a bit of variability due to their unique ID codes.
This meant the central receiving unit sometimes got garbage but, in the main it could pick up all the data from up to 100 (I think it was 100) units in about 5 minutes (given collisions were not infrequent.
Battery lasted about 1 year.
The up-time was about 40ms given that the crystal needed about 20ms to stabilize and I suspect that should I have used an RC clock I could have halved this time. The transmission was: -
Preamble to lock the central receivers data slicer
Header with ID and battery status
Temperature
16-bit checksum
Hope this helps. Here are a couple of little circuits to get you on your way. They use PICs but the general functionality can be transferred to virtually any MCU: -
They came from here |
H: 2 transistors in solar charging circuit
I don't quite understand this circuit. Why are there 2 transistors? Wouldn't 1 transistor be enough? The blink LED triggers the first transistor every time it blinks. But, how I understand it, the first transistor only triggers the second transistor. Why are 2 transistors necessary in this circuit?
AI: It's a constant current charger for the battery.
The lower transistor receives base current through the LED and 33k. I estimate it will be about 400 uA and this is probably shared mainly by the 1N400 diode - so let's say the NPN base current is about 100uA when the solar panel produces 12V. At lower voltages the current will be roughly proportionately less.
100uA x NPN current gain means the base current through the PNP is going to be in the region of 10mA (please double check the data sheets for the devices and remember this is an explanation not a definitive simulation!).
With 10mA base current it's likely that the PNP could be providing anything up to 1A for the battery and as the solar panel voltage drops this current will fall proportionately. |
H: MSP430 blinking led
I started using MSP430 Launchpad and as I was examining the code for blinking a led I found something odd. The code is this and is a ready example:
#include <msp430g2553.h>
unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
for (;;)
{
P1OUT ^= 0x01;
for(i=0; i< 20000; i++);
}
}
In the beginning you have to initialize P1DIR so to set the pin in which the led is connected to output. I searched a lot and everywhere is says that the specific register is just to set the direction. So then I deleted a part of the code and the remaining was this one:
#include <msp430g2553.h>
unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
for (;;)
{
}
}
Here is the odd part. The led is on!Shouldn't be off? The line of code with P1OUT isn't going to say to MSP if the led is on or off? With only P1DIR nothing should happening. What am I doing wrong?
AI: You can download some code I wrote at:
ZIP file containing an LED Tutorial for MSP430
It covers everything from just turning an LED on, to causing it to evenly (to the eye) diminish and increase in intensity (which requires a geometric progression to achieve.)
In the meantime, what you didn't realize is the power-on value for P1OUT. Try two different statements BEFORE your for(;;) statement:
P1OUT &= ~0x01;
and
P1OUT |= 0x01;
And apply one or the other of the above with your latter code example (the one with the deleted code.) You will see two different behaviors. I'm not certain as I haven't researched it lately, but I suspect the P1OUT values are "random" upon power-on-reset. Regardless, it matters and you need to make sure that P1OUT values are "known" before starting your code.
In the case of your first code example that blinks the LED, the initial value didn't matter since the loop XORs the value over and over. You would never notice if it started as ON or OFF, because it is toggling all the time. |
H: Determining correct requirements of Instrumentation Amp in measuring large current shunt
I'm trying to plan out a project of measuring large currents from my car battery through a shunt, and specifically I need help with the INA.
I bought this Deltec 250 amp shunt from eBay, that looks to be rated for 250A in short pulses, and 165ish continuously.
My plan is to hook it in series somehow with the car battery and use an INA to measure the voltage across, which peaks at 50mV for 250A
I've read a good deal about instrumentation amps, but I'm still confused on what specifications I should pay the closest attention to.
CMRR? Do I need to somehow detect if there is a common mode voltage near the car battery from a noise source?
Voltage input offset?
Voltage error drift?
Also, there are so many specifications/choices that I'm totally unsure about what would be deemed effective for this project.
I'm also in the process of extensively reading through Analog Device's Designer's Guide to Instrumentation Amplifiers, here, which is fantastic, but I would certainly appreciate any help or input on how to do high current measuring, specifically of a car battery, still in the car.
For example, here is a page from the aforementioned AD guide.
The selection is huge. How do I know what CMRR is good enough? 70dB? 80? 90? Or the input offset? 1mV? 500uV? 50uV? This is a major confusion of mine and hints at my lack of experience with practical design.
AI: How hard this is depends a lot on the details of exactly what you're trying to do.
For example, what is the minimum current you want to be able to measure. 100mA? 1A? 10A?
Presumably you want to be able measure cranking current, which may be more than your shunt is rated for (so the output voltage may exceed 50mV). That part is easy (lots of signal, and probably a fair bit of noise too). An offset voltage of 100uV represents 500mA. 100mA would require an offset of less than 20uV, which is challenging in the environment of an engine compartment, even with so-called "zero-drift" amplifiers. If you're looking for one part in 1000 of a 300A or 500A range, that's 300mA to 500mA.
Something like an INA331IDGK will have a 500uV maximum offset, so the error could be +/-2.5A. That could be calibrated out. The drift is typically 5uV/°C, so for a 30°C change you could see 0.75A change. That's harder to compensate for.
In general the overall strategy is usually to look at all the sources of error you can identify and calculate the input-referred error (i.e. the error in amperes measured at the shunt). Then compare those to your error budget.
I expect you'll put the shunt in the low side (between battery and auto chassis) so then the voltage across the shunt will be near or below ground, so you'll likely need a negative supply for your in-amp.
The in-amp, perhaps with some external gain setting parts, will give you a voltage relative to a reference (perhaps a ground on some external circuit). You have not mentioned what you want to do with that signal. If you just wanted to read the current on a display, you might not need an instrumentation amplifier at all- just isolate the measuring circuit and connect it across the shunt sense terminals.
Be careful of output range with the in-amp if you're going into an ADC that has a range that's a good part of the supply voltage-- depending on the type and the amplifier's supply voltage they can saturate internally. There's good information in the application notes and data sheets if you look for it.
Also consider what happens under various situations of missing connections and so on- probably the sense wires from the shunt could go -12 and maybe +12 under some conditions and those situations should not damage the front end. To some extent, that requirement degrades the available accuracy because you will have to put some resistance in series with the sense terminals, and that will increase errors due to bias current.
CMRR could be a factor if you're trying to measure currents really accurately, and for noise rejection. You can put the shunt in place and use a scope to measure the common mode voltages. Since they tend to be proportional to the current you're measuring, it's probably not a big concern.
There's a good overview here (Word Doc). Note the examples that use a regular op-amp. |
H: H-bridge output filtering
I'm driving A4952 motor driver with about 25khz PWM signal, with a simple coil connected as a load between OUT1 and OUT2. VBB is variable, testing with 15V but changing it doesn't alter the results.
As long as it's running with the PWM signal, coil works fine, and the output signal from the driver looks pretty much like input, only amplified. What I'm doing at the input is changing the PWM duty cycle on inputs so that it gives roughly 50 Hz sine wave.
As soon as I try to put a filter capacitor above certain value between output and the ground, the driver goes into fault, and that's the issue that I have been unable to figure out.
The thing has LSS pin which is meant for current limiting resistor. Initially I had about 0.25 ohms there, but eventually I just tied it directly to the ground.
Any cap that I place between output pin and ground that's more than 100nf or so, will drive it into fault condition. So I placed a small inductor, about 3μH in series with output, and placed the cap after that, same story.
I've tried to turn off the other phase of PWM entirely, lower the PWM frequency, and a bunch of other things, no luck. The driver just goes to fault as soon as I try and filter the output. (LC filter, RC filter, load connected, load off, makes no difference.)
Any ideas why this might be happening? The datasheet is not super clear about how the LSS is internally wired either.
AI: If you want to filter the output of your PWM you'll need an LC filter. The topology (series L + C to ground) is okay, but your values are way off- 3\$\mu\$H is not much better than a short at 25kHz, and without that, the current will be \$ C\cdot \$\$dv \over dt \$, which is going to be very high since the MOSFET switches quickly.
Suppose you want a 5kHz cutoff frequency (\$\omega_0\$ ~= 31000) and your load resistance is 15 ohms. Here is some useful info.
For a Butterworth response C = 1.5\$\mu\$F. L = 700\$\mu\$H |
H: How do I wire up this relay?
I'm making this circuit:
I've bought an Omron G5LA-1 non-latching SPDT relay. It looks like this (from the datasheet):
I'm struggling to figure out how I wire this up though. I believe I need to ignore a pin, but I'm not sure which. I also don't know what gets wired to which pin.
I have the circuit wired up with the power, tumbler switch, and capacitor so far.
The keyboard just looks something like this, where 2 of the 26 contacts would be connected:
Any guidance with figuring out what goes to which pin is much appreciated!
AI: Ignore pin 4, that's the normally closed contact. It's that simple. Note that the diagram is looking at the bottom of the part, not from the top through it.
1 and 3 are the switch that closes when the coil is energized, it doesn't matter which is which, and they go to the keyboard.
2 and 5 are the coil.. again it doesn't matter which is which.
Test it out before hooking it up to the keyboard- you should hear the relay clacking as it operates with the "tumbler switch".
When you do hook it up, keep the connections neat, shorts kill parts. |
H: Is the Delay in Strain Data Due to Capacitance?
I have designed a sensor board which gives a strain o/p based on wheatstone bridge principle(change in stress is measured through change in resistance).
But the starting value is not at zero level,it takes roughly 40 to 50 sec to stabilize (Please refer the attachment).
Could it be because of the internal capacitance of the board,if so how can it be reduced or avoided.
Thanks in advance
AI: A board capacitance * metallized strain resistance time constant is likely to be in the millisecond range. However the self-heating from I^2R thermal effects and temperature coefficient of the material is more-likely to have a time constant of a minute, if I imagine your design correctly.
Try lowering the bias and/or drive voltage to prevent self heating and increase the filtering of the noise to improve the signal to noise ratio at higher gain needed to achieve the same sensitivity. |
H: Simulating SMPS with ideal switch in LTSpice?
Yes, this in a portion of a homework assignment (hence the idealized and slightly asinine problem statement). Aside from solving the circuit (which I have done), I am supposed to simulate the following circuit using LTSpice. The problem is that idealized switch in the middle. I have tried using the voltage controlled switch built into LTSpice, but keep getting errors.
I am expecting a regulated voltage of (roughly) 50V.
I have tried simulated using a BJT with a square wave driving into the gate, but the result is highly dependent upon the voltage applied to the base. When I simulate with a 5V square wave, I get roughly 18V at the output, but when I simulate with a 50V square wave, I get an output around 42V.
I tried simulating using a FET (similar to above, just swap in the generic NFET model) as well, but out an output in the microvolt range, which clearly isn't correct. I also tried simulating using a voltage controlled switch, but I keep getting weird errors, I assume because the switch is only designed to be "thrown" once, not at a frequency of 200kHz. It keeps telling me that it can't find a model for my switch, even though the .op is clearly listed:
If anybody know how to simulate a switch like these, my class mates and I would be very appreciative (especially since the professor simply said 'Ask Google' when I came to him after trying for several hours).
EDIT:
I just tried running the simulation again using an NFET. It regulates to roughly 19V, which makes me think this isn't work either, consider the diode drop between the 20V source and the output. I tried several different voltages to the gate, none of which made any difference in the simulation.
AI: Try this instead
In the model you had the series resistance was too high, the off resistance too low, you also had series inductance and a series voltage.
An ideal switch has zero resistance when on and infinite resistance when off and no series inductance. LTspice wont let you have this but the model here is much closer.
When I run this simulation the output voltage settles around 52.7V
You also want to pick a different diode: I used a 1N4148 because you did but it wont handle the current. |
H: Bit-banging I2C question
When bit-banging I2C using 2 PIO lines do these lines still need to be pulled high? Obviously using a dedicated I2C bus the lines must be pulled high as the pins are open-drain outputs but PIO pins aren't open-drain.
AI: Yes, both lines need to be pulled high at all time.
Also, when bitbanging I2C, rather than switching the LOW/HIGH states of the pin, switch between LOW/HiZ by simply altering the DDR/DIR registers. |
H: Closed circuit Wifi over coax?
If you connect an access point to (PCIe/USB) Wifi card over coax (i.e. no antennas) will it work?
If it would work, what would the maximum cable length be?
(This is just a thought experiment. I know fiber optic cable is better for long distance networking.)
AI: If you used RG-58 at about 1dB loss per meter, you could theoretically run a cable of about 80 to 100 meters, depending on the output power of your transmitter. In reality, I would rather keep it to 50-60 meters and place a 5 dB attenuator at each end to make sure I wasn't saturating the receiver. You can take out the hard attenuation when you're done but I like to gradually work up to full power to make sure there aren't any kinks.
Also, if you want to hook up multiple devices, just have your clients linked through a power divider (2-way, 4-way, etc.).
Basically (excuse my first time math syntax)
\begin{aligned}
\ distance = \ (PowerOut - ReceiverMinimum)/ dBLossPerMeter \\
\
\
\end{aligned} |
H: Differential Drive for Heavy Robot
I'm asking here another question in relation to my previous one.
I would like to know how would one proceed when you want to control a heavy robot with differential wheel drive. When it comes to sending PWM values, I cannot control the robot, i.e, I cannot make the robot go into a straight line.
Another issue would be, braking the robot. Think 100Kg at its maximum weight, so It will have a LOT of momentum and inertia. Knowing this, what would you do to control its movement, with a differential drive system, and how would you control is breaking?
Note: This isn't to be considered as a hobby project. Think of this as the best way to implement it.
AI: One answer: Closed loop systems and/or sensor fusions
You can't just send the right commands to the motor and expect that the robot will act exactly as expected. Think about a very very small difference in the torque produced by your two motors that received two identical PWM signal (due to motor manufacturing tolerances). One will go slightly faster than the other and the robot will run along a circle (very big, but still a circle) instead of a straight line.
The answer to this problem is closed loop control. Your motors, or your wheels will have encoders. And your control system will receive the signals from the encoders and will react in a way that ensure that your wheels are doing exactly what you expect them to do.
But in the case of an autonomous robot, this in not enough. Think about having a wheel that is slightly bigger than the other, because of wearing, or just due to manufacturing tolerances. Or think about a wheel that slips a little bit on the floor. In this case you don't know anymore for sure where you are. This method is called odometry or dead reckoning. In order to solve this, you have to use sensors that adds knowledge about your environment to your system. (Vision, proximity sensor, bumpers, magnetometer, gyroscopes, etc). Then, advanced algorithms are used to use the best of every sensor at each time step. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.