-
Testing
03/13/2016 at 12:15 • 0 commentsOk here is the video of system under testing.
I kept it running for 24Hrs. Testing thoroughly is the best thing,
-
Hardware - PCB Design
02/24/2016 at 19:43 • 0 commentsDiptrace is really a best tool for Schematics and PCB designing. I really recommend you to use it.
Once schematics is drafted and tested (using 123Dcircuits), it was quit easy to design the PCB.
I pre-decided about the placement of the components, by considering ease of use, ease of routing, minimum noise.
PCB will be Single Layer & Homemade, baked at college lab.
PCB design with DipTrace isn't a tough task.
Following are the images, to walk you through.
Home baked PCB etching.
- Single Layer
- etched using Layout photo print + Iron + Copper Clad + PCB etchantFeCl3
-
System Simulation - 123D Circuits
02/03/2016 at 12:04 • 0 commentsSelf Cleaning Filter - 123D Circuits
While this project, I came across cool website https://123d.circuits.io/.
Honestly You no longer need Hardware to Master Hardware. It's complete package for design and development of circuits.
Schematics, Coding, Simulation and PCB Design Everything on a single place. You should try that out. Super Cool!!
-
Hardware - Schematics
02/03/2016 at 11:22 • 0 commentsWell, After carrying out all the necessary calculations to choose right component, it's time to design schematics.
I decided to use Diptrace, to Draw Schematics and PCB.
I really love this CAD tool, It won't take much time to learn this tool. And it is full of some cool features. Am planning on to write a blog about this.
In Last log, I discussed about driving and power supply circuits. There isn't much to mention about MCU and circuit around.
Atmega328P (DIP) running on 16MHz Xtal and Reset button, thats all.
- INLET Valve is always going to stay on, in Idle & Clean Modes.
- So I have not used special driver circuit (Running directly on +12V Power Supply), for INLET valve.
- Terminal Block Connector are provided for connecting Solenoid Valves and DC Motors over long wires.
Download Schematics. -
Firmware - pseudo Code
02/03/2016 at 09:33 • 0 commentsAs stated earlier in Details, System will operate in Two Modes, Idle Mode and Clean Mode.
This system is a better example of Real-time parameter monitoring and control.
In Real-time monitoring, Continuously monitoring the sensor value, and comparing it with the specified value. Depending upon the current sensor value, System goes either into Idle or Clean Mode. Also, Manual button is provided to manually clean the system, On pressing the button system goes into Clean Mode.
In control, We are switching ON/OFF Solenoid Valves, DC Motor and couple of LEDs.
Pressure Indicator LEDs:
For Controlling, Operating modes and pressure indicator LEDs, I have decided to take state-machine based approach.
There are total 5 LEDs( 3mm - GREEN, YELLOW, RED) are used
GREEN = Low Pressure.
YELLOW = Medium Pressure.
RED = High Pressure.
pseudo code:
//----------Variable deceleration----------
Valves = INLET,OUTLET,DIRT;
Motor = DC_MOTR;
button = man_clean;
LEDs = LD1,LD2,LD3,LD4,LD5;
Sensor = LDR_val;
States = curr_state;
//----------Initialization----------
INIT Valves (As OUTPUT).
INIT DC_MOTR (As OUTPUT).
INIT LEDs (As OUTPUT).
INIT button (As INPUT).
INIT Sensor(As INPUT).
//----------Main Function-------- Run Forever---------
WHILE(1)
READ LDR_val;
IF man_clean == pressed
curr_state = press_state_5;
ELSE
IF LDR_val < 1000 and LDR_val > 800
curr_state = press_state_1;
ELSEIF LDR_val < 800 and LDR_val > 600
curr_state = press_state_2;
ELSEIF LDR_val < 600 and LDR_val > 400
curr_state = press_state_3;
ELSEIF LDR_val < 400 and LDR_val > 200
curr_state = press_state_4;
ELSE IF LDR_val < 200
curr_state = press_state_5;
ENDIF
CASE curr_state OF
press_state_1: HIGH = LD1; LOW = LD2,LD3,LD4,LD5; CALL idle_mode();
press_state_2: HIGH = LD1,LD2; LOW = LD3,LD4,LD5; CALL idle_mode();
press_state_3: HIGH = LD1,LD2,LD3; LOW = LD4,LD5; CALL idle_mode();
press_state_4: HIGH = LD1,LD2,LD3,LD4; LOW = LD5; CALL idle_mode();
press_state_5: HIGH = LD1,LD2,LD3,LD4,LD5; CALL clean_mode();
END CASE;
//----------Utility Function-----------
FUNCTION idle_mode()
Turn ON INLET;
Turn ON OUTLET;
Turn OFF DIRT;
Turn OFF DC_MOTR;
ENDFUNCTION;
FUNCTION clean_mode()
REPEAT
Turn ON INLET;
Turn OFF OUTLET;
Turn ON DIRT;
Turn ON DC_MOTR;
UNTIL TIMER != 30Secs.
ENDFUNCTION;
ENDWHILE
-
Hardware Design - Electronics
02/03/2016 at 07:13 • 0 commentsAs described in details above it is clear that, we need to drive Solenoid Valves, DC Motors and few LEDs.
Component Quantity Power Rating Solenoid Valve (8 mBar) 3 +12V / 5Watts. DC Motor (30 RPM) 1 +12V / 400mA LEDs (3 mm) 5 5V / 20mA So taking into consideration, the power ratings of a system we are going to design Power Supply and driving circuits and choose components.
Power Supply Design:
Well, as mentioned in Table Above,
Solenoid Valves and DC Motor needs +12V DC supply. So we are in a safe spot, that we don’t have to use of-the-shelf components for powering the system. We can get good quality +12V Adapter from nearby store.
By studying Operating and Inrush current rating ofcomponents, I think +12V/3A supply
will be enough.
Powering Microcontroller: We need +5V supply, to power microcontroller and surrounding circuit. I have couple of LM317 (TO-220) in inventory, so decided to use them in my design. After all LM317 is one of the best & popular regulator.
Now Power drop here is quite large i.e. 12V – 5V = 7V, but that isn’t worry cause current drawn by the MCU is small, about 100-200mA.
Thus, Power Dissipation = 7x200mA = 1.5W, attaching Heat sink to LM317 is better way to avoid heating. [Next Design, going to add LDO].
Driving Solenoids Valves:
Solenoid is nothing but electromagnetic switch, available in various sizes and ratings, widely used in many industrial applications. More info.
One can use BJT or MOSFET based driver circuit. I choose BJT for easy-availability and cost of component.
We are using solenoid valves of rating +12V/5W, that is Operating current is around I = 200mA. We can drive the solenoid from MCU GPIO using driver circuit, with proper safety consideration.
I decided to go with TIP122 (NPN) Power Transistors, which is more than enough to drive the Solenoid Valves.
Calculations:
When we are driving any load using either BJT/MOSFET we are using it as a switch. So For Transistor, we need to calculate the minimum base current required to fully turn ON (“Saturate”) the transistor.
Calculating Base Current and Base Resistor:
Load Current [Solenoid Valve] = ILOAD = 200mA.
And ILOAD = IC.
From the datasheet of the Transistor we will need, β, IC, VBE (MIN).
From the Datasheet of TIP122 we have,
- β = 1000 (Typ.2500).
- IC = 5A (Max).
- VBE (MIN) = 2V to 4V.
We Have Formula for Base Current,
Putting values, Base Current = 200mA/1000 = 0.2mA
We have formula for Base Resistance,
Putting values, Base resistor = ( 4V - 0.7V) / 0.2mA = 16.5KΩ
(Standard Value = 16KΩ).
Safety: Flywheel Diode.
Generic diode 1N4007 is added, to safe guard MCU circuitry from back EMF/ Inductive kick generated by Solenoid Valve.
Indication: We have added RED LEDs (5mm), to get notified when, Valve turns ON.
Driving DC Motors:
DC Motor which is again an Inductive load. Same principle that we used for solenoid valves applies to the DC Motor. more info.
We do not need to control the speed of a motor, simply Switch ON/OFF.
Principle behind the driving DC motor is same as for the Solenoid or Relay.
Again, we are going to use BJT based driver circuit. Same TIP122 Power transistor used here to drive DC Motor.
We are using DC Motor of rating +12V/400mA.
Calculating Base Current and Base Resistor:
Load Current [DC Motor] = ILOAD = 400mA.
And ILOAD = IC.
Using same formula as above, Calculating the base current and hence base resistance required to drive transistor.
Base Current = 400mA/1000 = 0.4mA
Base Resistor = (4V - 0.7V) / 0.4mA = 8.2KΩ
(Standard Value = 8.2KΩ).
Driving LEDs:
We are using 3mm LEDs (GREEN, YELLOW, RED) for indicating real-time pressure inside the filter chamber.
Driving a LED directly over MCU GPIO is simplest part. Everyone is well familiar with Hello World - Blinky program.We have,
- Supply Voltage, VCC = +5V.
- Forward Voltage, Vdiode = 2V.
- Required Idiode = 5mA-10mA
From above parameters it is easy to calculate current limiting resistor, for our circuit we are using
Rdiode = 680Ω (5mA sufficient).
[NOTE:
Remember, When designing such a driver circuit, you need to over-rate it.
Why? – In such loads (Solenoids,DC Motors) starting current A.K.A. "Inrush current" is high for few-millisecs. Your driver circuit should be capable of this high inrush current.]