Developing a new digital circuit using a micro-controller to drive Laser (LED1) replacing analog methods of curent control.
The Existing circuit we are trying to reeplicate digitally:
Some of our objectives :-
- Controlling the current to a LASER thorugh digital means instead of analog means (Variable Resistors)
- Reading the current drawn and power of the LASER dynamicvally using INA219 Current Sensor
- Interfacing an LCD to monitor the display the PWM value of micro-controller and the curreent and poweer drawn dynamically
Additional improvent and additions
- Adding a temperature sensor to measure the ambient temperature
- Adding a bluetooth transreciever to control the curreent value remotely
- Developing an app or webpage based GUI application
- Logging all the data recieved and store it on sd card or cloud
- Housing all the electronics in a approprite housing.
Made the circuit following the schematic to drive the LASER
code snippet of sending increased PWM signals through A9 pin of Arduino
void loop() {
analogWrite(9,100); // Laser diode connected to pin A9
delay(1000);
analogWrite(9,150);
delay(1000);
analogWrite(9,200);
delay(1000);
analogWrite(9,250);
delay(1000);
analogWrite(9,0);
delay(1000);
}
Code with LCD initialsed:
// include the library code:
#include <LiquidCrystal.h> // initialize the library by associating any needed LCD interface pin
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; // with the arduino pin number it is connected to
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() { // set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
analogWrite(9,100); // Laser diode connected to pin A9
delay(1000);
analogWrite(9,150);
delay(1000);
analogWrite(9,200);
delay(1000);
analogWrite(9,250);
delay(1000);
analogWrite(9,0);
delay(1000);
// LCD Message
lcd.print(" HELLO ");
lcd.setCursor(0,1); // Set the cursor for the second line( the second 1 after comma sets the cursor at the 2 or lower line).
lcd.print(" WORLD ");
}
The vale from the INA219 using the LCD's LED as load :) (As I am doing this project Hochschule, I am quite restricted with parts)
Code for inteerfacing INA219 and measuring the current values
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup(void)
{
Serial.begin(9600);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
Serial.println("Hello!");
if (! ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) { delay(10); }
}
Serial.println("Measuring voltage and current with INA219 ...");
}
void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
float power_mW = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");
delay(2000);
}
Schematic for the entire plan and existing circuits which are already implemented, we can futher make the system more compact using an on-board ATMEGA328 IC.
We plan to use MCP4725 to convert the analog PWM signals from Arduino to digital values then use that to drive a current controlled Op-amp circuit in a voltage followeer mode.
Some of my simulations :-
and then use a HM10 Blueetooth module to control the system oveer bluetooth remotely.