texts: Unable to assign value in an always-block

texts:
NO IDEA that the value of register just never changes whatever the clock and the cases are. but no problem while compiling. WHAT is happenning? It is really confusing...

`timescale 1ns / 1ns

module p2(SW, KEY, LEDR, HEX0, HEX4, HEX5);
  wire t0;
  wire [3:0] A, B, C;
  wire [7:0] AplusB;
  reg [7:0]  register;
  input [3:0] KEY;
  input [9:0] SW;
  output [6:0] HEX0, HEX4, HEX5;
  output [7:0] LEDR;

  assign A = SW[3:0];
  assign B = register[3:0];
  rippleCarryAdder4 a(.X(A), .Y(B), .Cin(1'b0), .Cout(t0), .S(C));
  assign AplusB = {3'b000, t0, C};

  assign LEDR = register;
  HEX h0(.data(A            ), .HEX0(HEX0));
  HEX h4(.data(register[3:0]), .HEX0(HEX4));
  HEX h5(.data(register[7:4]), .HEX0(HEX5));

  always@(posedge KEY[0]) begin
     if (SW[9])
       register[3:0] <= 4'b1111;
     case (KEY[3:1])
       3'b000: register <= AplusB;
       3'b001: register <= {4'b0000, A} + {4'b0000, B};
       3'b010: register <= {A | B, A ^ B};
       3'b011:
         if (A | B)
           register <= 8'b00000001;
       3'b100:
         if ((A & B) == 4'b1111)
           register <= 8'b00000001;
       3'b101: register <= {4'b0000, B} >> A;
       3'b110: register <= {4'b0000, B} << A;
       3'b111: register <= {4'b0000, A} * {4'b0000, B};
       default: ;
  endcase // case (KEY[3:1])
end // always@ (posedge clock)

endmodule // p2

module fullAdder(X, Y, Z, C, S);
  input X, Y, Z;
  output C, S;

  assign C = (X & Y) | ((X ^ Y) & Z);
  assign S = X ^ Y ^ Z;
endmodule // fullAdder

module rippleCarryAdder4(X, Y, Cin, Cout, S);
  input [3:0] X, Y;
  input       Cin;
  output      Cout;
  output [3:0] S;
  wire         c1, c2, c3;

  fullAdder a0(.X(X[0]), .Y(Y[0]), .Z(Cin), .C(c1  ), .S(S[0]));
  fullAdder a1(.X(X[1]), .Y(Y[1]), .Z(c1 ), .C(c2  ), .S(S[1]));
  fullAdder a2(.X(X[2]), .Y(Y[2]), .Z(c2 ), .C(c3  ), .S(S[2]));
  fullAdder a3(.X(X[3]), .Y(Y[3]), .Z(c3 ), .C(Cout), .S(S[3]));
endmodule // rippleCarryAdder4

module HEX(data, HEX0);
  input [3:0] data;
  output [6:0] HEX0;
  wire         c0, c1, c2 , c3;

  assign c0 = data[3];
  assign c1 = data[2];
  assign c2 = data[1];
  assign c3 = data[0];

  assign HEX0[0] = ~c0 & ~c1 & ~c2 &  c3 | ~c0 &  c1 & ~c2 & ~c3 | c0 & ~c1 &  c2 &  c3 |  c0 &  c1 & ~c2 &  c3;
  assign HEX0[1] =  c0 &  c1 &  c2 |  c1 &  c2 & ~c3 |  c0 &  c2 & c3 |  c0 &  c1 & ~c2 & ~c3 | ~c0 &  c1 & ~c2 & c3;
  assign HEX0[2] =  c0 &  c1 &  c2 | ~c0 & ~c1 &  c2 & ~c3 |  c0 & c1 & ~c2 & ~c3;
  assign HEX0[3] = ~c0 & ~c1 & ~c2 &  c3 | ~c0 &  c1 & ~c2 & ~c3 | c1 &  c2 &  c3 |  c0 & ~c1 &  c2 & ~c3;
  assign HEX0[4] = ~c0 &  c3 | ~c0 &  c1 & ~c2 | ~c1 & ~c2 &  c3;
  assign HEX0[5] = ~c0 & ~c1 &  c3 | ~c0 & ~c1 &  c2 | ~c0 &  c2 & c3 |  c0 &  c1 & ~c2 &  c3;
  assign HEX0[6] = ~c0 & ~c1 & ~c2 | ~c0 &  c1 &  c2 &  c3 |  c0 & c1 & ~c2 & ~c3;
endmodule // HEX


texts: Emulation of a custom system based around an SAMD51

texts: I am designing a system based around the samd51 chip. It will have an SPI screen and the buttons will be read through a shift register. Also, there will be an SD card for IO. I need a way to emulate this so I can develop a custom OS. But I can't find anything like this. What should I do to emulate this? Thanks!


texts: Is it good to code combinational and sequential logic separated into two always blocks?

texts:
Modeling both sequential and combinational logic within the same always block a good practice or is it recommended to code them in separate blocks.

always @(a or b)
  y = a ^ b;

always @(posedge clk or negedge rst_n)
  if (!rst_n) q <= 1'b0;
  else
  q <= y;

Or doing this:

always @(posedge clk or negedge rst_n)
  if (!rst_n) q <= 1'b0;
  else
  q <= a ^ b;

I know both would result in same functionality.

But it is also said that mixing blocking and nonblocking assignments in the same always block is a poor coding style. Do we not use blocking for combinational logic and non-blocking for sequential logic.

Modeling both sequential and combinational logic within the same always block a good practice.
Mixing blocking and nonblocking assignments in the same always block is a poor coding style.

Then in that case above statements are contradicting isn't it?


texts: Why is the width of gate the length of barrier?

texts: In MOS capacitor, it is often said that width of gate is the length of barrier that blocks the flow from source to drain. Why is it called like that? I am getting mixed up in diagrams, and can someone clarify these? Thanks.


texts:
I'm making a project/rc boat to map the bottom of a lake and therefore I need a relatively big battery (say 12V 10Ah) for the operation and electronics of the small boat (propeller motor + telecoms + servo rudder control + GPS + depth sensor + micro-controllers etc).

To make the boat more stable I would like to make the heavy batteries submerged in a sealed container along with the depth sensor.

From all the batteries I've searched LiFePO4 seems like the most viable choice.

Is this a wise choice for this particular application?

I recall everyone that the sealed container can be made in metal (no problems with weight/mass) hence it would always act as a heat dissipation for the batteries therefore reducing possible damage due to high temps.

Is there something that I'm missing about this type of batteries that would not make then suitable for such an application? The boat/rover would have on top a solar panel to recharge at least a bit the boat making it way more autonomous in the lake and hence avoiding annoying recharging of the battery on shore. So the battery would operate sealed and recharging while submerged.
Thanks in advance for your comments.


texts: 7805 5v Regulator outputting 5.8v? TTL chip not functioning correctly? LED + TTL chips?

texts:
I've read a number of other similar questions to mine, but none of the answers have helped me so far.  I also don't have any electrical schematic software, so I'm afraid I'll have to explain in words and picture the situation.

What I am trying to create is a basic 5v regulator that will be used to power TTL chips and LED's.  In front of the 7805 is a 220uF capacitor, and another one after it. The load at the output is a 330ohm 1/2 watt resistor with an led.  The middle pin is correcting connecting to the - lead.  I'm trying to create:

The brown wires are connecting to my multimeter leads.

Without load, when a 9v battery is used, the regulator's output is correct at 5.00 on the dot.  When I use a 7.5v 250mA DC adapter, the output is 5.8.  Why is this?  I've read on one forum that greater than 9 volts should be used, but another forum said that ~7v and above is fine for a 7805.  I have tested another 7805 chip, with the same results.

My second question is about TTL chips.  Earlier, I was using the 9v battery to power a 7400 quad 2-input NAND chip, and I noticed that it was functioning inconsistently.  From what I read, when there are no inputs, the TTL chips will "float" and assume that all the inputs are 1.  If that is the case, why are my all of my gate outputs 1 as well?  If the input 1/2 are assumed to be 1, and the chip contains 4 NAND gates, shouldn't all 4 outputs be 0?  The chip is functioning how I would expect an AND gate to.

Accepting the behavior of my NAND gates, I still have another confusing issue.  When I do add power to one of the input pins, the output of the NAND gate will correctly become 0.  However, when I remove that added power to the input pin, the output doesn't turn back back to 1!  I have to the input pin with my multimeter to get it back on.  Why is this?  I've tested another 7400 chip, same problem.

If TTL chips need a consistent supply of ~5v, does that mean I cannot use LEDs at all?  When I add a standard T-1 3/4 led to my load, the voltage drops to ~2.3, which is inadequate for my TTL chips.  But a number of guides I've read online suggest experimenting with the output of TTL chips with LEDs, so I am wondering if there is a problem with my setup.  The voltage drop of ~2.7 should be expected when using an LED, right?


texts: What is the reasoning behind Barkhausen's criteria?

texts: Especially why should loop gain be equal to 1, won't that give us infinite circuit gain?


texts: Which one of these DS18B20 temperature sensors is fake?

texts:
A while back I bought two DS18B20 for half price, and today I bought another one for double the price. The part number on the cheaper one is printed while on the expensive one it's laser etched:

On the left is the expensive one.

Even though the price was double, the readings that I'm getting using Arduino are the same:

Sensor1 is the expensive one. While the temperature on mercury thermometer was 23.9-ish degrees.

So what's the difference? Why is the build quality and price different but the temperature readings are the same?


texts: Maintain output for ~3secs after losing input

texts:
I have a simple circuit in my car. A +12V signal wire that comes from the ignition is used to tell an amplifier to power on.

When +12V is present here, the amp turns on and is powered by a separate, higher rated +12V feed from the battery.

The issue is that my car has start stop technology, so when I roll up to lights, the engine dies, and when I pull away, it starts again.

The +12V signal is present when the engine is not running, but when the car starts itself, it drops to 0V for a couple of seconds, before returning. I can only assume this is because the car routes the current through the starter relay instead.

My question is this. Is there a means of maintaining that 12V signal at an output for a couple of seconds after the input goes off? It literally only needs to be a couple of seconds, the input is back before long. I was thinking some kind of capacitor bank?

Let me know your thoughts.


texts: voltage current converter by op amp circuit

texts:
I am trying to convert 5V to a constant current source

for op amp I use AD822.
for 250 ohm I use 180 ohm, so I should get a current of 28 mA.
I verified when Rload = 0, 28 mA across negative terminal to ground.

But when I put Rload to circuit, 680 ohm, my current exceeds 28mA as Vcc increase.

Can anyone please point where might be the error?


texts:
Good Morning,

I'm developing a bio-impedance system.
To perform the impedance calculation, I am trying to use the method described in this article, and mentioned below:
http://www.ijirset.com/upload/2015/july/112_Body.pdf

An electrical signal is injected into the patient's body through 2
electrodes, and the same signal is collected through 2 other
electrodes.
This collected signal is then connected to the Arduino ADC, and n
samples of that signal are acquired.
The Frequency spectrum is found from which FFT is calculated in
MATLAB.
So, according to the article mentioned above, Least curve fitting
method is used for the estimation of impedance value. The result of
calculation is a single complex number containing real and imaginary
values of the impedance. These real and imaginary values will be
applied in equations later.

My question is, how should I apply the method Least curve fitting, to the N complex numbers returned from the FFT calculation?

I have as a result of FFT a complex vector of 1x2048.

I took a look at the documentation of matlab:
https://www.mathworks.com/help/optim/ug/lsqcurvefit.html

But I did not understand how to configure the parameters (fun,x0,xdata,ydata) of the lsqcurvefit function, in my case.

Thank you very much!


texts: I don't understand what are the difference between UNO and Leonardo?

texts: I found that they sell UNO Starter kits and Leonardo Starter kits. There are many different products. My eyes are so busy. I am a greenhand. If I want to buy a stater kit, which one should I buy? UNO or Leonardo?


texts: How to switch separate circuit from doorbell?

texts:
My doorbell rings as long as somebody pushes the button. I measured 10V AC at the bell when it is ringing. Now I would like to use this AC voltage to switch another circuit.  How can I achieve this?

Here is what I want to happen when the doorbell button is pressed:

Let the doorbell ring. That is currently the case.

Close another circuit, which is independent from the first one.

Edit: As Olin says in a command, the proposed duplicate is about how to get the doorbell signal into a arduino and not about closing another circuit.


texts: How does this single supply opamp circuit work, and what does the output look like?

texts:
When building audio circuits, I have often used a single-supply non-inverting configuration in which the feedback resistors are connected to via 10uF electrolytic capacitor to ground instead of directly to ground. I found this circuit online once, but don't generally see it when looking up single-supply circuits.

How does this circuit work? And how does the output end up more or less in the middle of the output range of the opamp (0v -> 9v in my particular case).

simulate this circuit – Schematic created using CircuitLab

EDIT:
The reply that states that this doesn't work isn't quite correct - since it does :). However I did omit to mention that the input is not referenced to ground but instead somewhere around 5v or so. It's not half-supply though, since it came out of a class-A FET input stage and ultimately from an electric guitar input.

Anyway, the answer that you get a DC gain of 1, and an AC gain of 10 is the one I was looking for. I'd like to understand more about this though. Is it that at DC the capacitor is effectively an open circuit, and so the op amp becomes a voltage follower? And at AC it is a resistor of some frequency-dependant size, and thus it becomes an amplifier of some gain?


texts:
My lecturer gave us the following problem today:

"A CMOS gate (with inputs A, B, C) consists of a pull-up network with 0 or more PMOS transistors, and a pull-down network with 0 or more NMOS transistors. The output is \$ f(A,B,C)\$. The truth table for \$ f(A,B,C) \$ has both 0's and 1's as outputs.

What is \$ f(1,1,1) \$?"

My initial thought was that \$ f(1,1,1) = 0 \$ since the PMOS transistors would be open (so that current can't run through) while the NMOS transistors would be closed and allowed a current through to GND resulting in a low output.

But since I don't know the actual boolean expression of \$ f(A,B,C) \$ can I really be sure this is the case?


texts: Using a via fence without a top layer ground pour

texts:
I'm designing a 4-layer 6GHz RF PCB. The top layer is a signal layer and has the RF microstrip traces and the 2nd layer is an unbroken ground plane. I'm leaning against filling the remainder of the top layer with a ground plane stitched to the 2nd layer ground plane after reading a number of posts on this site indicating that it (1) isn't very useful when a full ground plane is used and (2) can create unintentional antennas. Additionally, since I'm using microstrips, I would need to keep the coplanar ground pour sufficiently far away which means that the total size of the copper pour would be significantly reduced.

However, I'd still like to use a via fence to prevent my microstrips acting like antennas and either disturbing nearby circuits or being disturbed by them. Are there any issues with using a via fence where the vias are not tied to a ground plane on the same layer as the microstrip? The vias would still, of course, be connected to the 2nd layer ground plane. I can't think of any reason why this would be an issue, and based on my understanding should be an equally effective EMI shield. Is this correct?

In a similar vein, is there any benefit to still keeping stitching vias in a \$\lambda/20\$ grid? The idea wouldn't be to stitch ground planes, but instead to act like a sort of general-purpose EM wave short for radiation from non-microstrip traces, or for any signals that managed to get through the microstrip via fence.


texts: How does my screen driver handle so much data?

texts:
I just did some quick calculations:

On my MacBook I have a resolution of 2560x1440 multiplied by 24 Bit for colors we get 11.05MB for a single picture or 663MB per second at 60 fps.

I guess there is some compression, but for example when I move with three fingers over my touch pad thats quite random, what happens next on the screen and almost every pixel changes. Same as with almost every other interaction.

Please explain if my calculations are wrong and how is this data transported from my graphics card to my screen? How wide are buses between my graphics card and my screen? Perhaps explain in a nutshell how a display does store pixels? Shift registers? Cache?


texts: STM32 Sleep Mode: Interrupt gets executed but the CPU stays in WFI

texts:
I'm fairly new to the ARM architecture and I'm working with a board that contains STM32F0 microcontroller and an RF modem, which sends an interrupt every time it receives a message. I'm trying to implement a sleep mode in a microcontroller to save power but I don't quite understand why it behaves the way it does.

I started with a simple program that puts the CPU into sleep mode at the beginning of the execution. Then it waits for the external interrupt to wake it up, execute the interrupt and continue with the main program. In the ISR I toggle an LED on pin PA0 every time the routine is called, but then use pin PA1 in the main() that toggles and LED on and off with a short delay, indicating that the microcontroller exited the sleep mode.

My code basically looks like this:

int main()
{
    periph_init();
    modem_init();

    HAL_PWR_EnterSLEEPMode(0,1);

    while(1)
    {
        HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_1);
        Delay();
    }
}

And the ISR for the EXTI

void EXTI0_1_IRQHandler(void)
{
    HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);

    // Some other stuff

    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
}

The ARMv6 Architecture Reference Manual states the following regarding the Wait For Interrupt on the page B1-243:

  When a processor issues a WFI instruction it can suspend execution and enter a low-power state. It can remain
  in that state until the processor detects one of the following WFI wake-up events:

  A reset.
  An asynchronous exception at a priority that, if PRIMASK.PM was set to 0, would preempt any currently active exceptions.
  If debug is enabled, a debug event.
  An IMPLEMENTATION DEFINED WFI wakeup event.

If my understanding is correct, the second line applies in this case. Which means, that calling any interrupt regardless of its priority would wake up the processor, since the WFI was called from the main. For information, all the implemented interrupt priorities are set to 0 except for the EXTI, which is set to -1.

Now this is what actually happens. The LED on PA0 toggles appropriately, indicating that the ISR does indeed execute. But the LED on PA1 stays turned off, which means that upon completing the ISR, the CPU remains in a WFI. This is confirmed even during the debugging, while I inserted a breakpoint in the interrupt service routine. After letting the code run, it succesfully stops at the breakpoint. If I then continue debugging with a step-by-step function, the program jumps to the WFI instruction (upon which it continues to the main, since debugging can cause to terminate the WFI).

My question is, why does the CPU return to the WFI when the interrupt clearly gets called? Given my understanding, if the CPU is in WFI, it should continue with it's operation wherever it left off as soon as any interrupt get called.


texts: ULN2003 driving Relays with status indicator

texts: How to drive the ULN2003 to show the on/off status of relays (green LED for ON and Red for off)?


texts:
I'm trying to design my project, Super OSD, to be as reliable as possible. I want it to work good as new when 5 years old. I hate unreliable products, environmentally it's a waste, and economically it's expensive.

To that end, I'm avoiding electrolytic capacitors, and I've spec'd everything at least 1.5x, most 2x where size/cost permits. However, I am still having to use tantalum bead caps for the on-board regulators of the microcontrollers.

Are there any other things I should be aware of?


texts: Does a DC toy motor emit AC when you spin it?

texts:
I just watched a video on Facebook by somebody who built a project to run an LED using a 9 volt DC motor scrounged from a battery operated toy. They simply wired the LED to the motor and then used a pulley system to spin the motor.

Here's a link to the video: Creating a generator from a DC motor.

Doesn't a typical DC motor like those used in toys act like an AC generator if you spin it? When you move a magnet past a coil of wire you get an AC pulse out of the coil. I would be surprised if a cheap DC toy motor contained a rectifier diode since it's designed to be a DC motor, not a DC generator.

So my expectation is that a typical DC motor would act like an AC generator.

Further, a 9 volt DC motor spun at a fairly high speed would probably emit around 9 volts AC with a fair amount of current behind it, so I would think you'd risk exceeding the reverse breakdown voltage on a small LED and burning it out.

I think the project in the video in question would need a rectifier diode (ideally a full-wave rectifier) and a current limiting resistor or it would risk blowing out the LED.


texts: Does regularly spaced via stitching contribute to standing waves on an RF PCB?

texts:
Should vias be irregularly spaced? Can consistent spacing between ground vias create standing waves.

Has anyone ever heard of this? I've been doing this for awhile and I've never heard this and google wasn't returning anything remotely useful.

I've worked with a half-dozen or so RF specific engineers over the years and no one has ever brought this to my attention.

If you have heard of this, can you quote sources?

Edit: this is for 2.4GHz ISM bands like BTLE and Zigbee


texts: My shift register is working when I use LEDs, but not a solenoid

texts:
I'm trying to operate a solenoid push pull motor with a shift register. It works fine with LEDs, but when I try to use the shift register to trigger my solenoid it doesn't work. I suspect it's a power issue, but I'm using an external 6 V battery for the 6 V solenoid.
I'm using a Raspberry Pi to shift bits into the shift register also, but I don't think that would be an issue.
I have a feeling this is a very basic problem, but I'm having trouble wrapping my head around the data sheets for (potentially) higher voltage shift registers. I'm wondering if a shift registers act as a bottleneck for voltage, and if so are there options for higher voltage usages?
Here's a link to the parts I'm using:
Shift eegister: SN74HC595N
Solenoid: GANGBEI 0530

OK, so 35 minutes after asking this question it's apparent how out of my depth I am with this stuff. I have recorded a video to show what I'm seeing.
https://youtu.be/OP3iYP2QCuA


texts: PORTB Interrupt On Change changes state unintentionally

texts:
I am running below code in a PIC16F887 that runs at 20 MHz. I feed PORTB.0 a signal of 1 KHz from my signal generator. However, whenever the signal is low, PORTC.1 toggles at a rate of either ~5usec or ~10usec.  Also, I've connected an OP-AMP's output that gives 0V-4V, still the same.

I have tried enabling weak pull ups inside, didn't work.

The microcontroller is on an EasyPIC5 development board, so I can enable and disable either pull-up or pull-down resistors that are 10K. Didn't work, either.

Is this some kind of silicon problem(?) or is there a mistake in my code?

Here is a screenshot from the oscilloscope that probes PORTC.1:

Here is my code, please omit off-topic part of it:

volatile unsigned int fiftymicros=0;
volatile unsigned int milis=0;
volatile unsigned char fiftymicroscounter=0;
volatile unsigned int data_time=0;
volatile unsigned int milis_ctr=0;
unsigned long int data_bar[20]={0};
void interrupt()
{
     if(INTCON.T0IF)
     {
      TMR0=198;
      INTCON.T0IF=0;
      fiftymicros++;
      if(++fiftymicroscounter==40) { fiftymicroscounter=0; milis++; }
     }
     if(INTCON.RBIF)
     {
      PORTC.F1=~PORTC.F1;
      INTCON.RBIF=0;
     }
}
void main()
{
     ANSEL =0;
     ANSELH=0;
     TRISA=0; PORTA=0;
     TRISB=0x01; PORTB=0;
     TRISC=0; PORTC=0;
     TRISD=0; PORTD=0;
     TRISE=0; PORTE=0;
     OPTION_REG.INTEDG=1;
     OPTION_REG.T0CS=0;
     OPTION_REG.PSA=0;
     OPTION_REG.PS0=1;
     OPTION_REG.PS1=0;
     OPTION_REG.PS2=0;
     //OPTION_REG.B7=0;
     //WPUB=0x80;
     INTCON.TMR0IE=0;
     INTCON.RBIE=1;
     IOCB.B0=1;
     INTCON.GIE=1;
     UART1_Init(9600);
     Delay_ms(100);
     milis_ctr=milis;
     while(1)
     {
     }
}


texts: PIC 16f628a succesfully programmed and simulated but not working on circuit

texts:
I simulated this circuit successfully in proteus but it doesn't work on breadboard.

The motor is unipolar stepper motor

I checked the motor and ULN2003A darlington transistor IC.

They work perfectly. Only problem is with the pic.  I used a 16f628a

edit 1: programming device detects and programs the PIC. but when i put the PIC on the breadboard it doesnt do anything.

edit 2: programming device is "brenner 8" and software is "USburn"

edit 3: fixed circuit and codes after answers and comments

edit 4:  after fixing; only 2 leds are constantly lit and nothing else happened.

edit 5: (May 10th 2019 11:15 hours GMT) it doesnt work no matter what i tried (i tried all answers to this date). Fortunately the teacher gave me a decent grade. I will try with a pickit 3 if i want to try again(currently using a brenner 8).

// CONFIG
#pragma config FOSC = INTOSCIO  // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = OFF      // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

#include <xc.h>

void wait();

void main(void)
{
    CMCON = 7;
    TRISA = 255;
    TRISB = 0;
    PORTB = 1;
    PORTA = 0;

    int portb_value = 1;
    int minimum_step_count = 3;
    int counter = 0;

    wait();

    while(1)
    {
        if(PORTA == 1)
        {
            while( counter < minimum_step_count )
            {
                counter++;
                if(portb_value != 16)
                    portb_value=2*portb_value;
                if(portb_value == 16)
                    portb_value=1;
                PORTB = portb_value;
                wait();
            }
            counter=0;
        }
        if(PORTA == 2)
        {
            while( counter < minimum_step_count )
            {
                counter++;
                if(portb_value == 1)
                    portb_value=16;
                if(portb_value != 1)
                    portb_value=portb_value/2;
                PORTB = portb_value;
                wait();
            }
            counter=0;
        }

            PORTB = 0;

    }

}

void wait()
{
    int time = 0;
    while( time < 30000 )
    {
        time++;
    }
}


texts:
I am trying to do uart program in pic. I want to display characters send by controller to pc. But i am not able to do this. following is my code

#include<pic.h>

__CONFIG(0x3f72);

#define FOSC       10000     //10Mhz==>10000Khz
#define BAUD_RATE   9.6     //9600 Baudrate
#define BAUD_VAL   ((char)(FOSC/ (16 * BAUD_RATE )) – 1)

void main()
{
 unsigned char ReceiveChar;
 TRISC=0xc0;   //RC7,RC6 set to usart mode(INPUT)
 TXSTA=0x24;   //Transmit Enable
 SPBRG=BAUD_VAL; //9600 baud at 10Mhz
 RCSTA=0x90;   //Usart Enable, Continus receive enable
 TXREG='0';

 while(1)
 {
   if (RCIF==1) //char received? Send 'A' back to Terminal
       {
     ReceiveChar=RCREG;

     if(TXIF==1)
     TXREG=ReceiveChar;
   }
  }
}


texts:
I'm using AD7190 (datasheet) and having trouble on the AINCOM pin.
First, I'm using AD7190 to sample two channels of differential voltage. In that configuration, I don't need the AINCOM pin. But instead of let it float, I connect it directly to the ground. I happen to see today that connect the AINCOM pin to ground will have leaky current. Unfortunately, I can't change my schematic now, because my PCB was already sent to production. My question is how much performance penalty will I have and would it potentially breaks the ADC(long term stability)? The buffer and PGA was enable.
Moreover, If I want to sample single-ended voltage, I would need to use the AINCOM pin. For example, I want to sample the single-ended voltage coming out of a instrument amplifier. Where should I connect the AINCOM pin? Should I connect it to the ref voltage that the instrument amplifier used or straight to the ground?
Forgive me for hand drawing this.

The input of the instrument amplifier was 0-10mv differential dc voltage and 2.5v common mode voltage. The gain of the amplifier was set to 200 and the ref pin was connected to 0.5v. The buffer and PGA was disable in AD7190.


texts:
I have a spare laser diode lying around not being used. The other day I had an idea that it would be cool to have it draw the time on the wall for me as a laser wall clock. In order to do that, I'd have to bend the laser beam very quickly and precisely.

A thing that does just that is a DVD-lens actuator, except that I'd substitute the lens with a small mirror. That's the easy part, the hard part is controlling the actuator. I tried to Google around a bit but I couldn't find any information, not even a description of the wires. The drive logic has to have a way of controlling it, but I haven't been able to decipher it yet.

Can anyone tell me something more about these actuators? Is there documentation or maybe someone could at least point me in the right direction?


texts: whatis the difference between mounting holes and through holes?

texts:
I am new to pcb design, and I am using eagle for this purpose. I am confused by mounting holes and through holes. They are all holes, what's the difference?

In eagle, layer of drills(layer 44) is used for through holes, holes layer(layer 45) is used for mounting holes. am I right?


texts: Ways to use electromagnets to pick up metal shavings at a distance

texts:
I work at a rotor machining plant and there is an issue for shutting a line down to clean up metal shavings, causes too much down time. I was thinking of using a strong electromagnet to have a "pick up" radius under the machining cells, say 12". After thinking about creating my own and a failed prototype and also looking online to buy one I am not seeing any that have a effective radius. Is it even possible to achieve what I am trying to do? Any suggestions?
Thanks


texts:
Im trying to design multiplex camera system for my raspberry pi something like this https://www.tindie.com/products/canerdurmusoglu/ivport-dual-v2-raspberry-pi-camera-multiplexer/#product-description

Does anyone knows, what kind of chip is on a board like this, something like 14bit bus 2:1 mux. But I cant find something like that


texts: Open Loop Buck Converter - Regulating output voltage during rapid load change

texts: I am designing an open loop buck converter. I want to limit the change in output voltage during rapid load change to a certain value. How should I modify my circuit design to achieve this goal?


texts: How do metal pipes amplify radio time signal?

texts:
I ran into this YouTube video on how you can amplify the signal for your radio controlled watches: https://youtu.be/wI4FwQMCN9w

In short, the guy in the video said he stumbled on a way to amplify the signal by accident. All you need to do is hang your watch on a metal pipe and it will help it receive the signal successfully and sync. Later on, I found out some people on the internet claim even wearing a watch on your wrist will help it get reception.

As someone living too far away from the German DCF77 transmitter (https://en.wikipedia.org/wiki/DCF77?wprov=sfla1) to ever receive the signal with my radio controlled watch, I found the video useful. By hanging the watch on my bike's handlebar, I got my first sync ever. I also tried syncing it on my wrist once when I was up late and it also worked.

But how does this work? The metal pipe can't add any energy to the signal so it doesn't really amplify anything, does it? And the watch's metal case doesn't really touch the pipe, just the plastic strap, so can it even act as some sort of an antenna or something? So does it just focus the signal somehow? Obviously, I know nothing about radio reception, but I am interested in how this works.

Also, is there a way to increase the reliability of the reception? I still can't receive the signal 100% reliably, even with the metal pipe over night. Would a certain length, shape or material of the pipe help? Maybe orientation?


texts: Two different power sources with same voltage and current producing different results

texts:
I'm working on a little 3D printed robot (Otto DIY) with an ESP8266 and four servos, and I need to feed it with batteries.

As a first thought, I considered some 18650 cells I had lying around, with a TP4056 charger and an MT3608 step up for powering everything. It didn't work, the ESP turned on but the servos didn't move. I tried everything but I had no luck, so I kept testing the robot with a 5V 1A Samsung charger. Then, a new idea came to my mind. I had a 5V 2A TP-Link power bank. Because of the size, I couldn't use it, but it powered everything perfectly. I found a much smaller and more suitable 5V 1A power bank (oh, just like the Samsung charger that worked just fine), but it didn't. It did just the same as the 18650 cells with the step up.

As I have little knowledge of electronics, I no longer understand the problem. The charger and the power bank are the same voltage and current, so why do they work differently? And most importantly, which is the best way to power this robot having in mind these details? It can't be too big or heavy; this little robot falls easily.


texts: Does current flow between a positively charged conductor and a neutral conductor?

texts:
Having some trouble understanding the concept of voltage.

Suppose an initially neutrally charged wire is touched only to the positive terminal of a 9V battery, but not the negative terminal. The positive terminal of the battery has an accumulation of positive charges, and the wire has no accumulation of charge. Since voltage is related to how much charge is separated between two points, shouldn't the potential difference between the + end of a battery and a neutral wire be greater than zero, therefore causing a flow of current between the positive terminal and the neutral wire? Or is the negative end of the battery always required to create a flow of current?

I know that there is no 'absolute voltage' but what exactly is the voltage between a positively charged conductor and a neutral conductor, and why? Does voltage only exist between + and - regions?


texts: Asynchronous FIFO for fast-write-slow-read

texts:
I'm not quite sure how to generate full signal in a FIFO with fast-write and slow-read. Eg., if f_wr=10*f_rd, when the updated writing pointer is synchronized to reading side using simple methodologies for synchronization from fast clock domain to slow clock domain (e.g., by extending the lifetime of the data in fast clock domain), several data could have been written into the FIFO. In such cases, the full signal is not up-to-date and may cause the data in FIFO be overwritten. What kind of special processing should be taken here?

As I tried to generate an FIFO IP in Xilinx ISE, there's no option to input the parameters of the clocks if I choose not to use built-in FIFO, i.e., it doesn't know which side (write/read) goes faster. How does the IP do such synchronization correctly?


texts:
I recently bought an USB sound card to do some measurements/experiments with. What I want to do first is to build a simple amplifier for the headphone output.

Therefore I took the sound card apart and traced out the in- and outputs. Interestingly the ground of the female audio jack is not connected to the USB ground, it is DC biased with about 1.67 volts with respect to USB GND (half the AVDD supply voltage).

The problem I now face is that I don't know what to do with the audio jack's ground on my amplifier board. The amplifier board uses the USB power supply and obviously I can't connect the audio jack's ground directly to the USB ground...

Can I just pull the audio jack's ground to USB ground via a resistor?

PS: The amplifier chip I intend to use is a MC34119 (Datasheet) and the USB sound card uses the VT1620A chipset (Datasheet)

Here is a simple schematic of the sound card (the male audio jack should be female actually):


texts: how do i know if Vc(0+) or Vc(0-) is zero?

texts: i mean like in this picture, why is Vc(0-) = 10 v? why isnt it =0? when do i decide that there exists a voltage there even though it was in steady state? im not completely getting it.


texts:
Background

I am building a simple web application using raspberry as a server. I am using this raspberry also to control an arduino. A user can send commands through the browser to the raspberry, and it can control some arduino functions!

What I want

I want to use an arduino to turn a lamp on and off, parallel to a normal manual switch that I can use to turn on the lamp on and off, like this:

1: If the lamp is off and the switch is also on OFF position (open switch), I can turn the lamp on by using the switch, putting it on the ON position (closing the switch). Then, the monitoring system is gonna tell arduino (and the web server) that the switch is on/closed and the light is on.

2: I can use arduino to turn off the light, without necessarily  puting the switch on the OFF position. If the light is OFF (because I turned it off using an arduino) and the switch is on the ON position (closed), I should need to switch it to OFF position and then to ON position again, in a manner that I can sense these changes and send it to arduino (and consequently, to the web server).

3 (Possible improvement?): Whenever I change the state of the switch, the light would change its state to whichever is the opposite of the current one: if the light is on, it goes off and vice-versa, regardless of the switch state.

The problem

How can I actually know if the switch is on and off? There is anyway to use a sensor, some electronic circuit or component that can if tell the switch is on or off?
I was thinking about using a relay to control the light, depending of the state of the light that is stored on arduino/web-server. Is this a reliable way (I mean, using a relay) to do that?

I appreciate any possible help on this, I have been interested on IOT and I want to do some simple applications for home automation; this is my first one! Thanks in advance for any help, again.


texts:
I'm kind of confused on what connector (labelled B+, M and B-) this is below:

(http://kellycontroller.com/kdz4840024v-48v400aseriespm-p-955.html)
This is a 48V speed controller designed for up to 400A. The connector looks like a spade connector with a screw terminal. I plan on using it with an ME0909 motor Here are my questions

Q1 - I'm planning on buying 2AWG wire and then buying some connector to crimp onto the end of this wire to attach it to B+/B-/M. What appropriate connector do I buy to attach it to the speed controller? What bolt/lug/screw do I need?

Q2 - If it is a screw connector, is there any way of covering it up to prevent shorts? Like is there some special heat shrink or something?


texts:
I want to build a circuit with logic gates and flip-flops, in each clock which will turn 6 LEDs in
the following sequence: 1 - 6, 2 - 5, 3 - 4, 4 - 5, 4 - 6, 5 - 6, (repeat). I have spent 2 days in order to get perfect design. Does anybody can help me for making the perfect structure.


texts: Check for live high voltage shielded three phase conductor

texts:
We would like to know if a shielded high voltage cable 8000V AC, 3 phases, is "live".  Whether there is current flowing or not.

Ideally we design a little device that's strapped around the cable (non contact with conductors) and a light lights up when live. We are also fantasizing of having this sitting on the cable, with no batteries, using somehow a bit of power from the cable.

I must admit that I'm a bit rusty on the electricity fundamentals.

I do understand that there should be no magnetic field measurable (no current, and all conductors in one cable).
I presume there is also no electric field measurable outside the shielded cable.
I was looking up different devices, and was even trying a simple capacitive sensing detector AC voltage testing tool (Klein NCVT-2) (was only rated to sensing 1000V). To no avail.

I wonder if I am overlooking something or if there are other means of sensing the presence of voltage.

ps as a last resort, it would be possible to open up the connector, so we would have access to individual conductors.


texts: Can a Laser Engraver be used to develop PCB with photoresist?

texts:
I'm building a simple laser engraver/cutter following these instructions:
http://www.thingiverse.com/thing:1780556

Now my question is: can I use the laser light on the PCB photoresist instead of "black master + UV neon"?

I'm on early stage of building, and I have not bought laser yet. The instructions report "Laser: 1.6W Laser Diode 445nm (Basic Model) / 3.5W (Power-up Model)", so it's blue laser, but I may consider to buy another model if required to PCB photoresist.


texts:
My CD player's infrared receiver for its remote control has failed.  (The remote still works with a friend's identical player.)  I'd like to buy a replacement receiver and solder it in.  How do I identify it?

Service manuals for similar units (Teac CD-P1250 and CD-P1450, instead of my Teac CD-P650) name their IR receiver GP1U281X.  That looks like mine, but lacks the X over the dome.
The service manual for GF-650 names its receiver FM-6038TM2-5A, which has the X, but lacks the side legs.
I can't find my unit's service manual.
Digi-Key lists over 500 through-hole receivers, but only two have a photo showing a metal cage, and those cages have quite a different shape.
All I really want is to be able to navigate MP3s on a thumb drive!  The front panel lacks the necessary buttons that the remote has.
Should I instead work backwards from the remote's transmitter?

Edit:  bottom view.


texts:
I'm using an existing keypad with 8 LEDs that source power. I was hoping to use and LED driver of sorts, but all of the ones I find only refer to sinking power. Is it possible to use these drivers to source current, and if so is there a way of understanding how to convert the sinking specifications to sourcing? The Vcc for my system is 3.3V and LEDs are 3.4V and 20mA

Was looking at this TI TLC5917 driver.

The LEDs on keypad are Lite-On LTST-C150TBKT.

The circuit is setup like

simulate this circuit – Schematic created using CircuitLab


texts:
I'm an American living abroad in the land of 220v with various 110v appliances. Here in the Philippines, for some wacky colonial reason, the plugs are the same two flat prongs as the US, but the wall provides 220v power. I have a transformer, so this is all fine and well as long as I'm careful to not plug it into the wall. Always careful. (Which of course I am not.)

What I would like is a simple adapter plug that can go on the end of each 110v appliance (and never come off) with a fuse inside that will pop if it is ever accidentally plugged into the 220v socket. Obviously, fuses are for current and don't work for overvoltage, but I'm not sure if there's another term.

Do you know if a product like this exists? Do you think there's perhaps a way to DIY one if not?


texts:
I am designing a gate driver for SCT3160KL using a UCC21732 gate driver ic from Texas Instruments. I have made roughly made the circuit using the ic, but I want to test its overcurrent protection circuit. Would just a DC voltage in series with the mosfet work? I tried this on Pspice but it is not giving the right solution.
Apologies if this is a trivial question,I'm not nearly an expert in this field.
EDIT 1:-
So thanks to csabahu's answer I did manage to make the circuit, and it does trip at the required current (i.e Drain current 17 A as per datasheet). But my supervisor says that there's a lot of phase lag between the OC pin voltage and the sense voltage. I don't get what he means entirely - "Design the RC filter to make the detection instantaeneous , i.e no lag". How do I do this? Here is the schematic & waveforms:-

(L5 is parasitic inductance)
This shows the V_GS and FLT_N pin voltages

Also, I am trying to simulate the double pulse test for this analysis. Is there anything wrong in the schematic? I selected D1 with current rating = Drain current rating of MOSFET (17 A). Is this wrong?


texts: Circuit parts identification (simple FM transmitter)

texts: I try to identify 'parts' of this circuit, I learn with the Internet and I start the electronics since a few time. I try to know the location of each 'type' (LC, RC, LRC etc ...) on this simplest FM transmitter found on makezine. Also, I'm learning with falstad but I do not understand the starting point of identifying the 'parts'. I create this schema with my questions .Thank for your help and your time.


texts: Why does this capacitor shorten the clock pulse?

texts:
I am trying to understand more about electronics. To this end I started studying the Ben Eater videos. Brilliant. But there is something I don't understand about this circuit. Specifically it's to do with the reason why that capacitor will shorten the clock pulse.

simulate this circuit – Schematic created using CircuitLab

Link to a video that shows the capacitor. You can fast-forward to 3:19 to see it.

Another video where he's got the clock pulse up on the oscilloscope. This may be seen at around 9:21.

Why does the voltage after the capacitor slope down like that, and then stay low? It's as though the capacitor's resistance increases to infinity as it charges, but that can't be right. Otherwise I'd expect the inverse when CLK goes low and the cap starts to discharge and release its pent-up energy somehow.


texts: STM32CubeIDE: Why does Serial Wire Viewer show Unknown Function?

texts:
I'm trying to use the STM32CubeIDE's Serial Wire Viever Statistical Profiling tool. The problem I face with is that the result table does not show all functions visited. I, especially, want to see the functions from my own 'mySource.c' file. I tried to add a 500ms delay into some of them, but even then I couldn't see any entry for them in profiling table. I'm sure that those functions are visited at least one time. Also, an entry named "Unknown function" is in table somehow. It has an instruction address of 0x80033F4, which is located at the very end of machine code, in a function named "_fini".
What do you think that I'm doing wrong?


texts:
It seems that all Bluetooth-enabled devices require the Bluetooth SIG Qualification in order to be marketable, but it isn't clear why it's needed so I'm hoping someone here has more experience. I've looked up this other post but I'm not sure how accurate the accepted answer is. For instance, it seems to suggest that the qualification fees go toward licensing the patents, but chip makers should already have that covered.

So, is the qualification purely for granting the license of the Bluetooth logo? What if the logo isn't used in marketing materials except for textual mentions, e.g., "Technical requirements: Bluetooth 4.0 enabled phone".

UPDATE

After spending even longer on the agreements, it seems that TI might be right. Unless a reference (qualified) design is followed (so called "Complaint Portion" in the agreement), qualification is needed. However, it's not clear whether this includes the circuitry or just the soft/firmware side of things, e.g., stack.


texts:
I've tried connecting a small DC Motor I got in a starter kit for a Raspberry Pi Model 4. I believe it is a 1 - 6V.

I used this circuit diagram:

This worked, but subsequent runs seem to have no effect. My motor does not run anymore. I am curious if anyone has any ideas regarding this. Did I overload the motor? Is the motor just faulty?

I also don't want to damage my Pi, and everything else seems to be working properly.

Any insights would be appreciated.

The motor is part of this kit.


texts: Why doesn't LTSpice predict this op-amp oscillation?

texts:
I'm developing a circuit to act as an electronic load for bench testing power supplies. An earlier question about how to test this circuit received several very useful answers and can be found here: How to test op amp stability?. This question is about how to interpret my simulation and test results.

This is the circuit schematic as simulated and tested on the breadboard:

The plot produced by LTSpice indicates the circuit is quite stable. There is a 1mV overshoot on the 5V rise that resolves in one cycle. It can barely be seen without zooming in quite a bit.

This is a shot of the same test using the scope on the breadboarded circuit. The voltage rise is much smaller and the period is longer, but the test is the same; feeding a square wave into the non-inverting (+) input of the op-amp.

As you can see there is significant overshoot, perhaps 20%, then an exponential decay to a steady oscillation for the duration of the high signal, and there is some minor-ish overshoot on the fall. The height of the low signal is just the noise floor (about 8mv). This is the same as when the circuit is turned off.

This is what the breadboard build looks like:

The MOSFET is at the top on a heatsink, connected by the yellow, red, and black wires; gate, drain, and source, respectively. The red and black wires leading to the small proto-board are IN+ and IN- respectively, connected to the breadboard banana jacks to avoid power-level current through the breadboard. The power source being loaded in the test is a sealed lead-acid (SLA) battery, to avoid any instabilities in the power source itself. The silver jumper is where the square-wave is injected from my function generator. The resistor, diode etc. on the lower left is part of a manual (potentiometer-based) load level setting sub-circuit and is not connected.

My main question is: Why does LTSpice not predict this significant instability? It would be really handy if it did because then I could simulate my compensation network. As it stands I just have to plug in a bunch of different values and re-test.

My main hypothesis is that the gate capacitance of the IRF540N is not modeled in the SPICE model and I'm driving a ~2nF capacitive load that's not accounted for. I don't think this is quite right because I see capacitances in the model (http://www.irf.com/product-info/models/SPICE/irf540n.spi) that look to be the right order of magnitude.

Any way I can get the simulation to predict this instability so I can also tune in my compensation network values?

REPORT OF RESULTS:

Ok, it turned out that the LTspice model I was using for the LM358 op-amp was quite old and was not sophisticated enough to model the frequency response properly. Updating to a relatively recent one by National Semi did not predict the oscillation, but clearly showed the 20% overshoot, which gave me something to work with. I also changed the pulse peak voltage to match my breadboard test, which made the overshoot easier to see:

Based on that "feedback", I started with the unanimously recommended compensation method which I believe is an example of dominant pole compensation. I'm not sure if the gate resistor is part of that or a second compensation scheme, but it turned out to be critical for me. Here are the values I ended up with after a fair amount of trial and error:

This produced a very stable waveform, although I'd like to get the rise and fall a bit sharper if I could, to better test the frequency response of the power supplies I'll be testing with this load. I'll work on that a bit later.

I then used the new values on the breadboard, and lo and behold I got this:

I was pretty psyched about that :)

Especially since, to fit in the new components, I made the breadboard parasitics worse rather than better:

Anyway, this one ended happily, hope this helps others who find it on search. I know I would have torn out what little hair I have left trying to dial in these values by poking different components into the breadboard :)


texts: Why is AC coupling needed between PHY and Fiber transceiver?

texts:
I'm using the DP83620 with the AFBR-5803 Avago transceiver.  This question is not specific to these parts, but I'm including them for the sake of clarity.  The datasheets for both devices indicates that they are PECL compatible.  The reference schematic in the DP83620 datasheet (page 35) includes AC coupling for the TD+/- pair.

If the two devices work with the same logic levels, why is AC coupling needed?  Why wouldn't it be necessary to include AC coupling for the RD+/- pair? (at least according to TI's datasheet?)

Thanks!


texts:
I'm currently trying to build a DC voltage source from an AC source to a school project. The circuit worked fine when it had no voltage regulator, as it was just a transformer + full-wave rectifier + capacitor filter; the output was a DC voltage varying from 23V to 21V.

The desired output is 15V. So, the goal is to use a regulator (which is actually a 10V-Zener in this case) and a controller built using a comparator amplifier to keep the output voltage as closest to 15V as possible; there's also a NPN BJT in amplifier's output that's there to supply the needed current to the load - it's written 'Carga' on the load, which means Load in portuguese.

So, the final circuit is the following:

simulate this circuit – Schematic created using CircuitLab

The problem is that when I run the simulation and check the load's voltage, it's 15V for an interval of time and then it suddenly goes to 23V, which is the not-regulated-circuit output voltage; then it goes back and do it all over again. I guess the transistor is actually going into the saturation region of operation, and I really don't know why. The result of the simulation is in the image below; the red lines are the output voltage and the blue lines are the amplifier output voltage.

If anyone needs I can upload the .asc file (LTSpice schematic), but I guess it's just a stupid mistake I'm doing.. anyone got any idea?

I really appreciate any help. Thank You.

edit: for anyone who needs a better schema of the regulator, which is my problem: http://i.imgur.com/LiA4x1w.png. sorry for the bad drawing.


texts:
I currently have an inspection robot deployed in a remote part of Africa that has a failing Turnigy TGY-6114MD servo. The issue started happening during normal operation and was working fine previously. Now the servo won't respond to commands unless given a slight push or nudge and then it will move to it's commanded position. We thought there may be some binding in the gearbox. After removing the gearbox and the gears we found that the motor shaft itself needs a slight push to start spinning. So with no load on the motor at all, it still won't start unless given a slight push.

Does anyone know what may be causing this behavior? We are unfortunately unable to get a replacement part in a reasonable amount of time so any repair ideas are welcome!

EDIT: Update. We measured the voltage across the motor electrical connections during operation. When the motor is turning (with no physical load) the voltage is 4.98V. When the motor stops, the voltage drops to 1.4V. On an identical working servo on the robot, the voltage is 0V when the motor stops. What would cause the 1.4V at the motor when stopped?

Cross posted here: https://robotics.stackexchange.com/questions/18424/tgy-6114md-servo-motor-needs-push-to-start


texts: How to combat noise from my circuit polluting my 12V rail?

texts:
I made a controller for 12V DC fan. It is basically a buck DC-DC converter controlled by voltage. It regulates voltage for fan from 3V (lowest speed, fan draws 60mA @ 3V) to 12V (full speed, fan draws 240mA @ 12V). This controller works well, it controls fan speed as expected. I tried to make some filtering but there is still some significant noise polluting my 12V rail. How to minimize it?

Here's my circuit:

SW_SIGNAL is just a PWM signal, where duty cycle is set by other circuit.

Problem is at point A. Inductor L1 is meant to filter that noise, it works but not so good as I expected:

Signal at point B:

So the noise is lowered from 6V p-p down to 0.6V p-p. But 0.6V is huge noise.
It is related to the operation of buck converter, not the fan itself. I tried to put a 47Ω 17W resistor instead of the fan and the noise is still there. I was using scope probes with the smallest spring contact to minimize the loop.
The noise goes away only in case there is 100% PWM duty cycle, what is obvious, because 100% PWM stops switching.

Inductors I'm using:

UPDATE:
This is the layout (upper part is the buck convertor, fan connector at the left side, 12V power input at the right side):

I used generic electrolytic capacitors. I have no datasheet for them.

I have added 10uF ceramic capacitors to C1 and C3.
I have increased value of R2 from 0Ω to 220Ω.
Changed D4 from US1G to SS12. My mistake, I used US1G originally.
And the noise went under 10mV (resistor was used instead of fan).

After I plugged fan instead of power-resistor:

UPDATE2:
I was using 130kHz switching frequency in my circuit. And rise/fall times were 10ns.

Yellow trace = gate of switching transistor Q2.
Blue trace = drain of Q2 (10ns rise time).

I changed frequency to 28kHz (I will need to use bigger inductor because of this change), and increased rise/fall times to 100ns (I achieved it by increasing value of resistor R2 to 1kΩ).

The noise decreased down to 2mV p-p.


texts: Simulation/modelling of a RFID system (reader, antenna, tag)

texts:
The input parameters for the simulations are:

Area of environment where the RFID system will be placed i.e. in a rectangular space.
Number of antennas.
Number of passive tags within the environment

Output:

The performance of the RFID system in terms of for a given number of antennas and tags how many tags will be successful in being powered up from the antennas in order for communication to take place.

How do I even begin to model such a system in Simulink, whereby I keep one the input parameters constant and then vary the other two, and then repeat this process for the other two input parameters? I want to determine for a given area how many antennas will I require to adequately power a certain amount of passive tags.

I have decided to first find how many rfid tags I can power using, let's say as the first scenario, 3 antennas will be used. Once this is done my next step would then be to determine if I achieve successful communication between the reader and the tag. If someone can at least give some guidance to the first part, how many tags can I power up using 3 antennas with the tags been located in a fixed position and how do I determine how many tags are powered in Simulink?


texts: How to derive apparent power formula for three phase AC system?

texts:
I know that the total power output of a three phase system is √3 EI cosØ
Where E and I are the line voltage and line current.

Now my question is how can one derive the apparent power equation i.e.. √3 EI
 from the totalpower equation  √3 EI cosØ ?


texts: Disposal of the used acid/hydrogen peroxide etchant?

texts:
This thread repeated the question how to dispose the used acid/hydgogen peroxide etchant. So how can I dispose acid/hydrogen peroxide etchant?

Perhaps interesting thread to other readers, Disposal of ferric chloride etchant.


texts: I'm charging an SLA battery and it just keeps taking amps what's going on?

texts:
I found a Razor electric dirt bike and figured I'd see if I could fix it.

Batteries were dead and the "control board" was dead too.  It's an on and off throttle so really a relay is all that is needed, though I'll probably put in a motor controller to set max speed while I'm in there.

Now the batteries are SLA 7ah 12v batteries (two in series).  I disconnected them and they were DEAD.

I figured I'd try to give them a charge and see what happened.

I got out my bench power supply, did some googling and set it to give 14.7v at a max of 2 amps.

I hooked it up and the (individual) battery was taking .3 amps at 14.7v.

I did some more googling to see that might be because of sulfation on the plates.  Sure enough, as I let it sit, it started to increase in the amperage it was taking.

Now, I've put it on to charge for like 12 hours, several times over the last few days.  I take it off the power supply when I leave the house for safety.  I have now left it on for 24 hours and it's still taking 2 amps at 14.7v.

I'm just confused as to where this power is going.

Any ideas?


texts: Is there a reason to use 4 diodes instead of 2 when controlling a motor with L293B?

texts:
I am looking at the datasheet of L293B and there are some usage examples provided in it:

Is there a reason to use 4 diodes instead of just 2?

Why are these connections needed here in the first place? What would be wrong with just connecting Output 1 and Output 2 alone to the motor?


texts: How would JTAG program an MCU with flash memory? I realise that this probably varies from chip to chip, but I'm assuming there's some process they all have in common. Specifically, I'm asking in regards to the LPC1768, which doesn't specify how you would do this is the datasheet.


texts: What device would be the best for producing the loudest beep possible with the smallest size?

texts:
I need to have my device be able to produce sounds of at least two different frequencies, as loud as possible at around 3/5V. So far it seems like the best thing to go for would be a piezo speaker but the cylindrical case ones are still a little bulky for my needs. I've found some flat piezo speakers too which would be better but they seem to need casing built for them anyway to make them as loud as they can get. Is there any clever acoustical tricks or devices I should be aware of while investigating this issue?

I'm looking for a loudness of around 80dBA @ 1ft (90dBA @ 10cm) and a size of <10mm for all dimensions.


texts: Calculating the sensitivity of an ADC with respect to resolution

texts:
I am reading a text that explains about measurement sensitivity and accuracy. In a part of it it has the following examples (with no explanation!)

3 and 1/2 digits (2000) on 2V range = 1mV

Which makes sence if you do calculate 2/2000 = 0.001 = 1mV

Now it has the following:

4 and 1/2 digits (20000) in 2Ohm range = 100mOhm

I can't get this one, I am calculating 2/20000 that results in 0.0001 which is equal to 100uOhm, Or I am stupid and doing it wrong!?

Link to the original text, You can see the example above on page 3.

Apparently, they have a new version here. I can see they changed "m" to "µ" in newer version, so the problem was not at my side :P


texts: Understanding hFE values in a datasheet to choose a proper BJT base resistor

texts:
I already read the post Which resistor for NPN transistor base? But I still cannot understand the base resistor calculation.

I need the transistor to be a switch to 5V 200mA relay. The base will get its power from the AVR, which will give it 5V.

I am using 2N2222, and I understood it is related to the \$ h_{FE} \$ value.

On the datasheet I can find the \$ h_{FE} \$, but it has a lot of values.

Do someone have simple tutorial for the calculation ans explanation of the BJT values? I tried to Google a lot of stuff and read a lot of articles, but none of them was simple enough.


texts: How can a smartphone's extended battery be same size as the original battery?

texts:
I know this is kind of a basic question, there might be a few ways to answer it...

Recently I found out there is a slim extended battery which has the same size as OEM battery (I mean really same size height and width, not using a different battery cover,) how is that possible?

In simply physics, if the OEM Battery already max out the capacity of storing mAh in such a size, how is the Extended Battery able to have more capacity with the same size?

For example, I found original battery capacity is 2800mAh
But here the extended battery can be up to 3800mAh, 4400mAh, that's a huge difference...

Are those extended batteries just fake products?


texts:
I am trying to figure out the stability of an amplifier, for which I have to calculate the loop gain and make sure its not negative for instability.
In Cadence one can use 'stb' analysis to calculate loop gain. The loop gain and phase looks as follows

The circuit:

With respect to the phase of the loop gain starting at -180 degrees, this has to do with a sign convention adopted by cadence. Please check these links if you are more interested https://sites.google.com/site/frankwiedmann/loopgain
https://community.cadence.com/cadence_technology_forums/f/custom-ic-design/30938/stb-analysis-phase-margin-gain-margin-functions/1338980#1338980
In this case the 0 dB gain is at roughly 9.2 MHz and the phase margin is negative 5 degrees, indicating unstable behavior. But if I try to calculate phase margin from direct plot form, I do not get a value of phase margin as shown below:

Can anyone throw light on this problem?


texts: How can I ground the external shield of the USB cable?

texts:
Currently, we're trying to carry out electrophysiological recordings from the mouse brain using Open Ephys acquisition box and a silicon probe, and we are suffering from severe noise in probe signals.

This page in Open Ephys documentation says:

  Line Noise caused by USB ground

  Sometimes, the USB cable that connects the acquisition board to the PC (which is grounded to the building ground via the power supply) isn't good enough -  grounding the external shield of the USB cable that connects the FPGA to the computer can help.

We really wonder how to ground the external shield of the USB cable (we know which USB cable he is talking about). We tried to find answers on the Internet, but could not find one. Could someone elaborate this further, so we can actually make some actions?


texts: PCB with 5 Pluggable RF modules and 1 LTE puggable module - will it cause issues for reception at different antennas?

texts:
I am designing a prototype PCB which shall have 5 pluggable RF modules and one 4G LTE module as shown in the image

The Base board size shall be 240 x 140 mm, RF board size is 40 x 50 mm and LTE board size is 45 x 70 mm.

The 5 RF boards are identical and they operate in the 868 MHz band for short range communication. The center frequencies of successive RF boards shall be separated by 400KHz each (they use different channels in the band).  The boards have transmit power capacity of 22 dbm.

The LTE module has a 3dbi antenna. All antennas are rubber duck type antennas. All the RF radios shall operate independent of each other.

The whole set (including antennas) shall be enclosed in a polycarbonate enclosure.

I tried looking at posts with the configuration like what I have, but I could not find any. I found couple of posts which talked about 2 or 3 radios on one board, but of different type and frequency bands.

My questions is as follows. Since all the radios are physically close to each other and operating independently (center frequencies of RF boards are also close to each other), will they cause issues at the receivers of each radio? Will the transmission from surrounding radios cause interference, saturation or reduction in data rate issues? Would any other issues crop up? Are there any specific points that I need to take care of?


texts: USB GND DP DM 5V port connect to 3.3V microcontroller

texts:
I have an ELP camera module (http://amzn.eu/9XcCjWm). It has a port connecting a usb2.0 cable, with GND DP DM 5V pins. I want to connect it to an esp8266 nodemcu v0.9 board, and then I will either send it directly to my computer or upload some opencv code on to the board, I haven't done that bit yet, (not actually sure if micropython can do opencv yet).

My question is about the best(for now simplicity is more important than speed, I don't need many frames per second anyway) way to hook them up. I occasionally use the usb port to attach to computer, so don't really want to do anything there.

I have an external ADC attached to the hardware SPI pins, so I'm hoping there may be something simple through either the RX/TX, software SPI maybe?, or something else I don't know about. I have some ICs for logic level conversion, I'm assuming will be needed, TE291s, or CD4050BEs.

I'm hoping for something as MCU universal as possible also, as the nodemcu v0.9 is annoying me, I'm hoping the newer esp3212 will be less glitchy, or something else entirely.

Thanks very much, guys. (I have namedropped some chips, however I'm pretty rubbish, baby speak is always appreciated :) )


texts: Filter opto-coupled mains signal for a digital input

texts:
I need to read an input of 220V and convert it in TTL logic 0-5V for my Arduino. If there's a presence of 220V at the input of my circuit, I read 0V in my Arduino, else I read 5V.

In parallel, I have a speed variator for a DC MOTOR 42V/11A with PWM frequency 4Khz.

My problem is, I have noises coming from the motor which cause 0V input in the Arduino without presence of 220V.

Here are the circuits:

I use a soft Pullup resistor.

There's two part, the first one is without a RC filter so I can clearly see the noises, and the second one with a filter I tried to make, here are the signals I got from each one.

Below the oscilloscope showing the signal with RC filter (2V/DIV 1ms/DIV):

Below the oscilloscope showing the signal without RC filter (2V/DIV 1ms/DIV):

So what should I add or change to my circuit to get a smooth 5V?


texts: Why are there no SMD AC Power Connectors?

texts:
Is this just a matter of having the wrong search terms, or is there a reason why there are no SMD AC connectors. They all seem to be thru-hole, like this:

I can imagine several benefits to an all SMD power supply board, such as eliminating spacers and mounting directly to a metal back plate (if one uses tented vias and perhaps a layer of kapton-like film between the board and plate), potentially leading to improved ruggedness, thermal performance (chassis as heatsink, backplate allowing for greater heatsink mounting forces), and compactness.
The only reason I can think of is mechanical strength, but that seems like a non-issue for most applications where the connector is firmly mounted to the chassis and there are no plugging forces transferred to the PCB.


texts: LED to electrets in parallel (using sound card bias)

texts:
I've tried to add an indicator LED to a couple of electrets I have in parallel, plugged into a soundcard. At the LED I'm only reading 0.45V (I believe the bias is 5V). and obviously the LED isn't lighting up.
Am I being a tad stupid? Do I need to add another power supply using a transistor (and some large resistors)?
The LED is in parallel with the last mic. All the mics work fine (in fact I seem to have some added gain by having the LED in there).

Sorry to be dumb. Thanks in advance.


texts: Is it possible to see how much logic an IP core uses?

texts:
Is it possible to see how much logic an IP core uses in Vivado?
I just found out that one of my variable might create a giant mux.
I want to know how much logic this mux uses, so I could document it somehow.


texts: Is it possible to run 2 motors independently with USB?

texts:
Is it possible to run two motors independently in both directions with usb using no microcontroller but just some discrete components?

I'm trying to create the cheapest possible robot that can just move about via two motors that can be run independently, for rotation, and rotated cw or ccw for going backwards. This robot must be controlled by an android device through USB.

Can this be done without any microcontroller?

I'm not creating this just for fun but also as a prototype so I'd like it to be as cost efficient as possible.


texts:
That is the question.

Neither the datasheet nor the family reference manual provide any information on this, other than:

Register AD1CON3
PUMPEN: Charge Pump Enable bit
1 =  Charge pump for switches is enabled
0 =  Charge pump for switches is disabled

So, should it be 1 or 0?


texts: Are there any special requirements for charging lead-acid batteries?


texts: Is there a such thing as a UV EPROM whose contents cannot be burned unless the UV-sensor is uncovered?


texts: Signal conditioning for piezo shock-sensor digital input

texts:
I have a piezo element glued to a piece of material, and I want to get a digital signal (to drive an interrupt on an Arduino) when something strikes the material. So, there's a certain noise floor on this signal (mains hum, and general vibration in the material from sound etc.) But then when the strike occurs, there should be a much more substantial voltage from the piezo element. So far so good, I've seen this on a 'scope, and of course, the signal is pretty messy, and might be either polarity initially, and likely swings about for a bit after the strike.

My goal is to clean this up. So far as my pretty rudimentary electronic knowledge goes, I figure I'll need to:

high pass filter to reduce picked up mains hum
bridge rectify, which should make the signal unidirectional, and also put a minimum threshold on the input, based on the forward drop of the diodes (and I might actually want to deliberately increase this drop, double up the diodes in series, to reject spurious noise signals)
put this through a zener diode to clamp the peak at 5v for the TTL logic input (I suspect that the peak signal will be over 5v from this piezo element, but if not, then I guess I'll be adding some amplification too).

At this point, I think I'll likely get many edges, but if they're going into an edge triggered interrupt that disables when triggered and has to be re-enabled in software, I'll probably be OK. But I'm figuring perhaps I could/should clean it up further with a bit of capacitative smoothing and a schmitt trigger?

On the basis of this, I came up with the starting point circuit below (entirely devoid of values so far!) But, this is likely a pretty standard problem, so if can I ask would this work? Is there a better / more standard solution? Generally any guidance that's on offer, I'll be most grateful.

EDIT: It occurs to me that I should mention that it will not be appropriate to put the "raw" signal into the A/D input. Two reasons, a minor one is that I have several of these inputs, and insufficient A/D inputs. The main one, however, is that I need a pretty precise measurement of the instant of the shock, and the converters would be far too slow.

EDIT2: comments have indicated that I'll likely want a) high input impedance, and b) some kind of amplifier (which presumably is a good way to solve a too :) So, my immediate go-to would be some kind of op-amp. However, that raises a couple more questions:

I need pretty fast response times (most of my op-amp experience has been in audio frequency range 30 years ago). I'll need rise times to full scale in the sub microsecond range. I'm not sure if that's fast or not by today's standards.
I am likely to be getting voltages from the piezo element that are much higher than the supply rails on the op-amp. I recall talk of "latch up" on the 741 (yeah, does that even exist these days!?) if you pushed the input hard to the rails. But whatever, I'll need to be OK in that respect. I imagine I could clamp this with a nose-to-nose pair of zeners, maybe.

So, am I still heading in a good direction? And any suggestions for a suitable, robust, doesn't-mind-over-voltage-on-input, fast rise-time op-amp? Guessing a 741 doesn't exist, and if it does, perhaps wouldn't have the slew rate I need. So, any recommendations for today's go-to op-amp would also be welcome.

EDIT: I found this Texas Instruments data sheet specifically on signal conditioning for piezo sensors. It addresses several issues including the impedance, and frequency response Texas Instruments Data Sheet: Signal Conditioning Piezoelectric Sensors


texts:
What is the difference between those two circuits, when only output node is changed?

Is there any changes in the output resistance, voltage gain, or somewhere else?

simulate this circuit – Schematic created using CircuitLab

simulate this circuit


texts: What are the implications of a MOSFET not listing switching losses in the data sheet?

texts:
Many MOSFETs do not specify switching losses in their data sheets. Does this imply that the losses are too low to worry about? Too high for the device to be used in a switching application? Variable between units of the same product line? Or does it imply different things with different devices?

Example without losses: http://ixdev.ixys.com/DataSheet/DS100088(IXFN360N10T).pdf
Example with losses: http://www2.microsemi.com/document-portal/doc_download/8195-aptm50hm75stg-rev4-pdf


texts: What factors can determine the constant coefficient when calculating torque?

texts:
In this servo motor's datasheet, both motor have the same torque of 0.32 Nm, have the same power of 100w, but have different rated currents and voltages. It seems that the "torque" relates to the controller's supply voltage, is it true?

Mechanical Power: Pm=τ∗ω; Electrical Power: Pe=VS∗I;

motor rated output power:

100w ≈ 115 = 2.4A(motor rated current) * 48v(controller's supply voltage)

motor rated output power:

100w ≈ 119 = 1.4A(motor rated current) * 85v(controller's supply voltage)

The torque generated by the motor is proportional to the amount of current flowing through the motor:
τ = kt ∗ I ; (kt is a constant; τ is the torque; I is the current)

motor rated torque:

0.32 Nm = 2.4A(motor rated current) * kt(constant)

motor rated torque:

0.32 Nm = 1.4A(motor rated current) * kt(constant)

It seems that the "kt" is determined by the controller's supply voltage, is it true?
What factors can determine "kt" when calculating torque?

Thank you.

(The above formulas come from this thread:
How are current and voltage related to torque and speed of a brushless motor?)


texts: High pitch noise when resistive heating elements turn on

texts:
I am a service engineer for a company that manufactures lab equipment. I want to ask for electrical engineering help with a problem.
We make a product that consists of two parts, one of which is a heatable water bath.
I have a customer who since he has had the unit, has had a problem where the instrument emits a loud noise only when the heating elements are turned on.
I took a microphone to the instrument hooked up to my scope on FFT, and measured the noise to be at 3.1 kHz. The heating control PCB and power supply PCB are both located in the heating bath part of the unit. The bath contains 2x 750 Watt resistive elements in parallel.
In order to resolve this, we replaced the heating bath with a new one, assuming the noise was coming from one of the PCBs. The customer plugged the new one heating bath in and it is still making the noise when the heating elements are on.
I took the old heating bath home, and when I plugged it in I do not hear the noise. The heating bath has resistive elements which are controlled by a triac off of 110 V.
The only variable that makes sense is that the noise is caused by something with the mains power supply in his lab, If anyone has any insight it would be much appreciated. Could the mains 110 V in a lab be coming from a buck/boost converter which is exhibiting audio noise at high current demand? The origin of the noise seems to be from the water bath and not the outlet.
What could cause a loud 3.1 kHz tone to be produced when a heating element is powered on in one environment, but not in another? The rest of the instrument does not contain any electrical components related to the heating circuit.


texts:
With a microphone sensitivity of -33dB = 22.4mV/Pa, picking up a conversation (about 60dB SPL), What is the voltage output of the microphone? My concern here is power vs voltage decibel calculations.

60dB SPL is 34dB below 1 Pa. (Treating SPL as power), this is equivalent to 1/(10^3.4) Pa, or 398 microPa, correct?

So then, if I multiply 398 e-6 x .0224 My microphone should produce 8.9 microvolts? Almost -99dBu (-99dBm)?

Which means I would need at least 80dB in front end voltage gain to record this properly?


texts: How to make a wheel recharge the battery as it decelerates?

texts:
From my knowledge, a motor acts as a generator and has voltage in its inputs if the shaft is spun.

If I use a battery to spin a motor+wheel to high rpm and then turn it off (with a switch), how can I regenerate the battery? The wheel has a lot of energy which can be used to recharge some of the energy lost by battery to accelerate it.


texts:
I need to get some more of this connector and solder my own cables however I can't find this exact one online.

It looks like some variant of JST but from looking up the different types of JST I can't find one that matches this.

The cable came with a LiDAR sensor. One end is a JST SH 1mm and the other end is the connector I'm having trouble finding.

Can anyone help identify this connector?

Male end

Female end


texts: Noisy or malfunctioning PIR HC-SR505 sensor

texts:
I bought 5 PIR Sensors to trigger when movement is detected, using an Arduino.

During bench tests, all 5 sensors show many false triggers. I wonder if all 5 sensors have something wrong, or whether there is a way to reduce "noise" on the sensor?

1) code is simple - just print out to serial monitor its digitalRead values.

2) to reduce IR in the room, the window was closed.

3) wiring scheme is very simple, example

Still, detection was notified erratically even when I was not in the room.

Any explanations why? And how to overcome this behaviour?


texts: I am trying to power a RPi of 4 AA's, and my mobile power device can only output limited current (500mA), but I can underpower my RPi by frequency scaling. Is frequency scaling and current draw a linear relationship?


texts: Timer0 and Timer2 configuration on atmega1280

texts:
I want to setup Timer0 and Timer2 to control the intensity of the LED (L) on the Arduino Atmega1280.

The frequency has to be 10khz and the duty cycle will be controlled by a switch or using serial comm via uart (increment and decrement); currently the only part where I'm having issues is initializing the timers and not being sure if my approach is the correct one, which is the following:

Since I need control over freq and on the duty cycle I think that I need to use two timers, I've searched if it can be done using only one but most of the tutorials and guides only focus on changing freq or duty so I've reached the conclusion that by using one timer you can only control either frequency or the duty cycle.

My plan is to use Timer2 as the 10khz clock for Timer0, when Timer0 overflows it will toggle it's signal, the duty cycle is controlled using OCROA and the freq for Timer2 is set with the pre-scaler being 8 and OCR2A = 200:

$$ f_{pwm} = \frac{f_{clk}}{N \cdot R_{OCR0A}} $$
$$ 10000 = \frac{16000000}{8 \cdot 200 }$$

I've set Timer0 to have no clock source since I'll be incrementing it manually with the TIMER2_OVF_vect, here is the routine that sets up both timers.

/**
 * Configures a PWM with variying duty cycle at 10Khz.
 *
 * First we set Timer2 to be the 10khz clock source:
 *     f = 16e6 / (8 * 200)
 *
 * Second we set Timer0 to be the duty cycle specifier
 * Timer2 is incremented by each tick of Timer0 and the one that
 * sends the signal to the Led (L)
 *
 */
void setupPWM(void) {
    // Timer2
    // Set the top to be 200
    OCR2A = (uint8_t) 200;

    // Set the clock source to use Pre-scale 8
    CLR_BIT(TCCR2B, CS20);
    SET_BIT(TCCR2B, CS21);
    CLR_BIT(TCCR2B, CS22);

    // Set the Waveform generation mode to OVF on top
    SET_BIT(TCCR2A, WGM20);
    SET_BIT(TCCR2A, WGM21);
    SET_BIT(TCCR2B, WGM22);

    // We don't need to set COM2A, because
    // we won't use wiring, we'll use
    // interrupts as a counter inc for Timer0
    SET_BIT(TIMSK2, TOIE2);

    // Timer0
    // Set PB7 for output and clear the value
    SET_BIT(DDRB, PB7);
    CLR_BIT(PORTB, PB7);

    // Disable the internal clock source, we will clock it with the TOVI
    CLR_BIT(TCCR0B, CS00);
    CLR_BIT(TCCR0B, CS01);
    CLR_BIT(TCCR0B, CS02);

    // Set waveform gen to FPWM with OCRA as the
    // top, OCRA will be set by the duty cycle functions
    // We start at 50%
    SET_BIT(TCCR0A, WGM00);
    SET_BIT(TCCR0A, WGM01);
    SET_BIT(TCCR0B, WGM02);

    // Set COM mode to toggle the output on
    // OCROA match
    SET_BIT(TCCR0A, COM0A0);
    CLR_BIT(TCCR0A, COM0A1);

    SET_BIT(TIMSK0, TOIE0);

    OCR0A = (uint8_t) 128; // Set it to 50% duty initially
    TCNT0 = 0;
}

Timer2 overflows correctly, however Timer0 seems to be not working as it should my guess is that since the CS0:2 bits are 0 the TIMER0_OVF_vect ISR is not triggered, however I'm not sure that if I set Timer0 to Fast PWM I'll loose the 10khz freq.

Any help is really appreciated.


texts:
I need some way to know whether the microcontroller (PIC) is receiving (or transmitting)  any data. So I thought of keeping a separate LED so that it'll blink when any data transfer occur.

But I need to know how to attach this LED. Is it OK to directly attach an LED to PICs Tx (and Rx) pins? I mean will it affect the transferring data in some way (like by dropping out the voltage etc...).


texts:
I've been lurking around the net for days trying to find a Slimline SATA to mSATA\microSATA adapter, the only one remotely related is the laptop optical bay HDD\SSD enclosure which I already have and use for a full sized SATA HDD. I'm curios of this because I have a 15" mobo in a 17" PC which results in having a spare Slimline SATA connector on my mobo and an extended one used by the HDD\SSD enclosure.

I'd appreciate answers to any of these questions:

1) Is it possible to make a female Slimline SATA to female mSATA adapter for SSD?

2) Is it possible to make a female Slimline SATA to female microSATA adapter for SSD?

3) If either one can be made, what voltages could it output?

4) If either one can be made, how small could it be?


texts:
I need to build voltage divider to measure the battery voltage (7.3V) using max 3.3V ADC. As the device most of the time spends in the sleep mode (<1uA), the current drawn from the battery should be very low (best <70nA) so the resistance of the voltage divider has to be  > 100MOhm.
I know that I need to buffer this voltage but I struggle to design the voltage follower working with such a high impedance source.
My question is: will JFET input opamp (as I know they have high input impedance) will be good for this application?
Maybe there is another method of lowering the voltage which will draw such a small current form the battery.


texts:
I've got a motor that's driven by a 1.5V battery. The shaft turns slowly and that's the way I'd like after replacing with a USB cable (5V) source.

In the current circuit there's no resisters (just a diode) - so using ohms law - not sure what the current draw is. It's V/0 right? Infinity?

If I can find the current draw - I plan to use 5/I to add an appropriate resistor and I should be good to go - right?

Please help the nube boob.


texts: How to establish communication between microcontroller on a bread board and laptop using usb cable?

texts:
I want to learn about microcontrollers and use them in some projects. But I do not want to buy an Arduino, although that is what would be easy for doing projects. This creates a problem in programming the microcontroller. Although a programmer can be used, I noticed that many microcontrollers have an SPI. I thought I could use this along with a USB to programming it serially. I may also read the data serially (using shift registers) into the computer. This way, I think, I can establish communication of some sort between the two. But I am not sure if my computer will allow me to write to a USB port without any identifiable device being connected.

I am aware I would have to write some code to make this smooth since, both the microcontroller and the computer have different clock speeds.


texts: Protecting arduino (destroyed two) when controlling pump with MOSFET

texts:
I am trying to control a MOSFET with an Arduino. I have followed few tutorials and created schematic below. When I made circuit it did work, but I managed to destroy two Arduino nano clones with it. It did work fine with lightbulb on J4, then I was experimenting with fan which also worked, and small 12v air pump. With air pump it worked until I turned it off and Arduino was no longer working. It was powered with 12v from bench power supply.

The MOSFET show below is actually RFP30N06LE but I could not find it in Eagle.

OUT and T are screw terminals and are connected.

Diode is 1N4001 and the air pump was using 0.8A while working.

What did I do wrong?

Can you please advise what I could change to make this work and to be more reliable? It took me no more than 10 minutes to destroy it.

I am planning to place an optocoupler between the Arduino pin and OUT. What else could be done to protect it?


texts: Control a fan motor (with PWM IC burned out)

texts:
After the IC fan controller burned out by a voltage error I pulled it out to see what the motor coils were like.

They are so I think:

4 series coils, but I'm not sure if it's the 4 coils in series.

Coils

PCB

Coils and fan

Where the coils are not found, so I think the 4 are in series.

I was sad because I had burned out the PWM IC of the fan.

I analyzed the 4 coils well, only two filaments are soldered on the PCB, soldered two wires as you can see in the image and plugged in a common 12v 1a power supply, it turned and stopped, so I was making contact and removed quickly it spun a few seconds and stopped.

I try use PWM pulse with the Arduino and a transistor, I can see the pulse in the scope that uses the sound card in my desktop PC but the nothing happens if I connect directly in a source of 12v 1a simply tries to spin and stop.

NOTE:

In the Arduino I tried different intervals for the pulse from 50ms to 2000ms. Possible to use IC 555?

I need help because I do not understand much about electric motors, both dc and ac.


texts: How can I know what parts a manufacturer uses in their schematic?

texts:
I have an old printer, and I have the schematics from HP.  The image is below.  They have names on the parts, but if I look up something like "PM706," I can't get anything.

How can I find out what a manufacturers parts are from the schematic?  Is it possible?  I don't want to take things apart, if I don't have to.


texts: How to specify polarization voltage in polarized capacitors in Orcad Capture

texts:
I have a polarized capacitor like below. it's 1uF and 16V.

the schematic in Orcad is like this:

How can I specify that 16V voltage?


texts: Using RadioShack relocatable power tap (120V/60Hz) in 230V/50Hz country

texts:
I have RadioShack relocatable power tap 34C4.

It says "max. load 15A 125VAC 60Hz".

We have a 230v/50Hz standard in my country. Will it cause any problems if I just plug it in the 230V/50Hz outlet to power 230V/50Hz devices? What output frequency and voltage will I get? Also, how to calculate max. load/wattage for it, considering it will be used with 230V, and not with 125V, will it be lower?


texts: Why does the MIT Racecar not use the build in ESC?

texts:
MIT has build an autonomous RC race car. They put everything on GitHub. I have a similar project and therefor build one of those for my self (Almost the same but without TX1 and Sensors).

I am currently ordering parts. Thats when I found out that they have replaced the build in motor controller (VXL-3s) with a VESC motor controller. I haven't found a seller in my region yet. Ordering it from overseas takes maybe too long. Why are they even using a VESC in the first place? Can't one just control the ESC with PMW? The three cables (red, black, white) are there.

The much cheaper Donkey-Car (link) does it that way (on a toy). No controller was replaced. Do all ESC controllers have the same PWM frequency and width? Because in my opinion the only reason for a replacement could be that they didn't manage to communicate with the VXL-3s.

EDIT 1:

Just found this article from Makzine in which they state too that almost any ESC where the receiver is not integrated can be controlled by PWM. I'm just scared that I order a car which I can't control in the end.


texts: Basic question regarding power consumption of different devices

texts:
I have current values for devices measured at different DC voltages.

4.2mA at 2.4V
68.8uA at 3.0V
44mA at 2.0V
65mA at 3.4V

If I were to power them at a voltage of 3.6V and would like to estimate the current for each device at this voltage, what is the correct way to do this?


texts: How to make one switch control multiple identical subcircuits?

texts:
I have an audio circuit with 8 identical subcircuits (one for each voice).
In each subcircuit or voice, a resistor controls one aspect of the sound.
I would like to have a switch which allows me to switch between two different resistor values in that part of the circuit, thus altering the sound.
However I would like this single switch to make the same change simultaneously in all 8 subcircuits. What approach would you recommend?


texts:
I've started simulating a Class D amp, but it seems the MAX999 (I saw recommended elsewhere on this site) isn't working. Could anyone point me in the direction of why? I swapped in an LM311 which jumped around (due to being too slow I believe) and a virtual ideal comparator (placed in parallel here to save on screen shots) which works fine.

I'd like to understand why the 999 isn't working, so if anyone can point me in the direction as to why, and even make some recommendations, I'd much appreciate it. I've looked at the data sheet and nothing is jumping out at me.

It's not shown on the screenshot, but the tri is 200kHz, the supply current to the 999 is 6.5mA and the current on pin 3 is 16uA RMS, if it's relevant.


texts:
Is there an approximate equation giving the optimal miter for a non-90degree mitered bend? In particular, I'm trying to determine the correct miter for a 45degree bend. There are a number of resources giving the correct miter for 90degree bends (e.g. Microwaves101), but I haven't found anything for other angles. Is this because angles less than 90degrees have a negligible Z0 discontinuity effect?

I can simulate this in OpenEMS (and I probably will), but it's nice to start from an approximate equation.

I've come across a design that does miter 45degree bends. The result looks like this.

The original trace width is 0.34mm (corner to miter here, as shown in picture, is 0.3mm). The height to the ground plane is 0.17mm. My max signal frequency is 6GHz. Again, I could use this as a starting point for an openems simulation, but it would be nice if there was an easy way to make a rough calculation first.


texts:
For a project, I need a simple battery cutoff circuit for protecting a 9V battery from over-discharging.
(by simple, I mean with only a few off the shelf components, and no micro-controllers)

Looking for inspiration on the web, I found this article, which at first sight looked exactly like what I wanted/needed.

It uses the voltage comparators of the NE555 to operate a relay, based on the resistors value.

Everything works as expected on the breadboard, but there's something I don't understand.

The NE555 chip, as well as the voltage dividers and filter cap will obviously consume some current, even when the relay is off, and the main load disconnected.

In such conditions (relay off), my test circuit drains 0.006 amps from the supply.
So in fine, the battery may still be damaged from over-discharge.

So what's happening here? Is such a circuit OK, and 0.006 an acceptable value, am I missing something, or is the article flawed?

For info, here's the (poor) schematic given on the website I mentioned:


texts: How to design for electrical connection for a food dryer

texts:
I am on this project in building food dryer to dry 2 kg fish cracker maximum per use. Based on the calculation, I only need to use power of approximately 60 watt for the heating to achieve the energy required to dry the food.

So, here is my question:

1)Is it possible to have only a 60 watt of heating element to dry 2 kg of food?

2)How can I select for a heating element? (I also use a blower fan to distribute the heat in the food dryer uniformly)

3)If I want the user can enter the temperature that they want(maximum will be 80 degree Celcius), how can I connect the heating element with the knob and Arduino? Here I also use a temperature sensor to detect the surrounding temperature inside the dryer.

I am very much a beginner and really have a difficult time in understanding the working principle of an electrical circuit with a heating element. I am aware that the principle is similar to the oven but I dont know how to improvise it since I am using a microcontroller here which I cannot find any commercialized example of such oven in in the market.
I really appreciate your help or comment and thank you for helping me.


texts: How to control a piezoelectric actuator programmatically?

texts:
How can one control a piezoelectric actuator programmatically (e.g. with a 3.3. Volt digital signal from a Raspberry Pi or any other method you recommend)? The goal is to be able to output an arbitrary signal (0-220 Volts +/-5% , 0-10 kHz frequency +/-5% to derive a piezo. My signal contains high AND low frequencies that are both important.
I appreciate any links to YouTube, articles, and component products, datasheets since I'm new to circuits (physics background here). Compactness is very important but the output signal doesn't have to be linear (as long as I can map an input to a known output). I cannot use PWM since the output signal shouldn't contain unwanted frequencies.