PMOS driver for arduino

In case you are looking to make a Buck controller based on arduino, this is a simple circuit to drive the PMOS transistor mainly for buck circuit applications.

This circuit is simple and only consist of NPN and 1 PNP transistor. The circuit above is part of my MPPT solar charger circuit.

Continue reading “PMOS driver for arduino”

Arduino controlled bass mid treble and input selector with tda7419

If you are looking to control your audio with arduino, here’s it is. It uses TDA7419 chip which has a lot of features for controlling your audio. It has 4 input selector, bass control, mid control, treble control, loudness control and a built-in 7 band spectrum analyzer.

Continue reading “Arduino controlled bass mid treble and input selector with tda7419”

IOT: Wifi controlled Audio tone control

Internet of things is becoming a thing these days. Internet connected gadgets and appliance are becoming more common these days. The advantage is very obvious: you can control these devices using your smartphone with internet browser, specially made apps or with voice command using google assistant. One of the goal of this project is to create a tone control with bass, mid, treble and source selector that can be controlled via smartphone or laptop with an internet browser. You can also develop an app for this but I haven’t have time to do so.

About the Circuit

The heart of the circuit is the NODEMCU – a wifi module that can be programmed using arduino IDE. If you are already familiar with arduino then this can be easy for you. It is connected to a 1.44 inch tft lcd with ILI9163 driver. The preamp is based on TDA7419, this is a digitally controlled tone control via I2C. This features bass, mid, and treble controls with adjustable frequency. This also has a 7 band spectrum analyzer which is better than using an FFT on arduino. This makes it easier for the programming since you only need to read an analog pin directly rather than doing the FFT calculations on arduino which is a bit of a headache to do.

The TDA7419 is powered with 8V so an 8V regulator 7808 is needed. It is also used to power the Nodemcu for wider operating voltage (most nodemcu can only operate up to 10V only). 7808 regulator can operate up to 35V input voltage. You can also use any regulator as long as it has 8V output and a sufficient output current.

As you can see on the schematic, there is only 1 left GPIO on the nodemcu which is the D3. There is still GPIO9 and GPIO10 but many claims that they are not usable and are not recommended to use. This is the reason why I am not continuing this project with this kind of display. By using an I2C display, I can free up 5 GPIO’s that can be used for buttons.

About the Software

The software is developed using arduino IDE. Note that this is not very well developed, there are many rooms for improvement. I won’t be improving this software further because I decided to replace the display with an OLED I2C desplay. The reason is that the ILI9163 TFT display needs more GPIO and nodemcu has very limited GPIO. Using an I2C display will free up GPIO for other functions.

The device will not start the initialization of the TDA7419 without a wifi connection. Once it established a wifi connection, it will then go to initialization on the system. That is how I designed it, because it was just a quick programming for proof of concept only. Like what I said –  there are many room for improvements here. I just posted this project for those who want to have a quick start. For the next version of this project I will be using an OLED display to be able to use the 5 GPIO for buttons and other functions.

Prototype

For the prototype, I used LM317 instead of the 7808 voltage regulator, because that’s what is readily available on my stocks. 🙂


demo: working. (Note: I accidentally cracked the LCD 🙁 )

The IP address is displayed on the LCD. This is entered on your web browser to access the controls. Take note that you have to connect on same wifi to be able to access the device.

Controlling with web browser

This is a simple webpage I made which can be improved further. The basic functions are there so you can use it as is if you prefer. There are many rooms for improvement here.

Downloads

You can download the source code on the download page

Connecting High Power LED to Arduino

Arduino digital can only drive a few milliamps and up to 5V only. You can’t use it to drive a high power LED directly. If you want to drive a high power LED using Arduino, you need to use a driver.   There are 2 options, 1 is to use a transistor driver or use an IC driver. A transistor driver is the easiest option, it will only require 3 components(2 resistors and 1 transistor). The transistor is either a MOSFET or a BJT.

Figure 1 – Driving LED using BJT

In the example above, we are using a NPN transistor for driving a LED. R1 is used to limit the current coming out of the Arduino. Without R1, Arduino digital pin might got damaged due to high current sinking from the output pin. The output voltage of the Arduino will be limited to the Vbe(base-emitter voltage) of Q1 without R1. While R2 limits the current for the LED.

R2 = (VDD – VLED – VCEsat)/ILED
where:
VLED – voltage of the LED
VCEsat – saturation voltage of the Q1 at ILED current
ILED – current of the LED at VLED
VDD – supply voltage(in this example: 5V)

  • Note: You do not need R2 if VLED is equal to VCC. For example if voltage of the LED is 12V and your supply is also 12V, R2 will be useless.

Minimum value of R1:

R1 = (Vout – Vbe)/Iin
where:
Vin – output voltage of Arduino (usually 5V or 3.3V)
Vbe – base-emitter voltage of Q1(usually around 0.5 – 0.7V)
Iin – Max output current of Arduino ( ~10-20mA)

Max value of R1:
this is a little tricky so let’s derive the equation, shall we?

IC = Ib * β
replace Ib with equation from the circuit:
IC = ((Vin – Vbe)/R1) * β
IC = ILED
ILED = ((Vin – Vbe)/R1) * β
ILED/β = (Vin – Vbe)/R1
R1/β = (Vin – Vbe)/ILED

R1 = ((Vin – Vbe) * β)/ILED

where:
β – transister beta or HFE
ILED – LED current
Vbe – base-emitter voltage of the transistor
Vin – output voltage of arduino
IC – Collector current of the transistor

If you have computed lower maximum resistance than the minimum resistance then you should consider changing your transistor with higher HFE. You may consider using  a darlington transistor or a MOSFET.



LED Driver IC

LED driver IC is a bit expensive but it has some advantage. It can supply a constant current which leads to more constant brightness especially if you are using multiple LED’s at a time. It also has some sort of overload protection. It is also more efficient and very ideal for battery powered applications which will have longer battery life. It is not usually simple because it is usually using switching power supply topology.

 

Figure 2 – LED driver IC

Dimming LED with Arduino

Dimming is done by using PWM or Pulse Width Modulation. PWM works by rapid turning on and off of the output. The brightness of the LED is controlled by controlling the ratio of the on versus the off state. PWM is easily done with Arduino, thanks to its very simple library.

Sample code:

int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup() {
    pinMode(ledPin, OUTPUT); // sets the pin as output
}

void loop() {
val = analogRead(analogPin); // read the input pin
     analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}

 

Note: analogWrite command only works on PWM pins. 

 

-tataylino.com

Arduino Controlled Bass Mid Treble and input selector

My LC75341 project was a bit of a disappointment. It was working ok but it only offers bass and treble controls. The frequency response is not that good. It has very limited controls. I decided to stop that project because it is not what I am looking for. Now after lots of research, I stumble upon this digitally controlled bass mid treble IC from ST. What is great is that it has 7 band spectrum analyzer feature and a differential input. Plus it also has Q and frequency control and a subwoofer output. This is almost exactly what I want to do.

Continue reading “Arduino Controlled Bass Mid Treble and input selector”

Simple Current Sensor for Arduino and PIC

Last time I have posted a simple Current sensor for Arduino using only a resistor here in this post. But there are some problems on this kind of simple circuit and they are 1)  very lossy due to the big voltage drop on the resistor 2) if you decrease the voltage drop on the resistor, it will decrease the resolution 3) There is a significant voltage drop on the load at higher load current which is not good. The allegro current sensor ACS7xx series is a good alternative but it cost too much for my project so I search for another option.  Then I found this ZXCT1008 that is just right for my application.

Continue reading “Simple Current Sensor for Arduino and PIC”

Simple Current Sensor for Arduino

There is actually a board that you can attach to arduino for measuring current but if you don’t need a very accurate measurement, you can use this very simple circuit. Usually a low resistance resistor is connected in series to the load. The voltage of the resistor is measured and divided to its resistance, the result will be current.

Continue reading “Simple Current Sensor for Arduino”