Hardware

Hardware

Preface: What our project does is to sensitively detect the presence of pathogens in sewage for regionalized epidemic warning. We sincerely expect that our project will bring a healthy and safe life to human beings.Based on this project, we designed a hardware device and expected this device to be installed near sewage treatment pipes in residential areas to detect virus.

Name:Jiang Ziya2.0

Top cover: The top cover is the location of our bacteria enrichment and is fixed with 6 self-tapping screws, water is fed from the lateral side and it integrates 3 normally closed solenoid valves. A central solenoid valve for blocking wastewater and bacteria-rich liquid, and two small solenoid valves for wastewater discharge with controlled reaction intervals. According to the tendency of bacteria to light, the top is made of transparent glass laminated with led light strips to attract the movement of bacteria for the purpose of enrichment. An opening is made on the side for the connection of the solenoid valve lines.

The middle body: the reaction position is located in the middle of the 6 cylindrical holes. Detecting independently and constantly for multiple times is what we are pursuing. To realize this assumption, we designed a rotating scheme that the motor at the bottom drives the whole reaction device to rotate, which cooperating with the solenoid valve in the top cover to deliver the liquid to the reaction vessel hole, with the reaction stock solution placed inside the hole in advance. In order to avoid the device too heavy, opening is made on reaction vessel to reduce the weight in order to reduce the load of the motor and ensure the accuracy. The Below the reaction device is the observation room, the liquid after the reaction is finished flows from the reaction tank to the observation room, the top of the observation room adopts inclined openings and covered with glass, so that the reaction results can be seen clearly and intuitively.

Bottom: The bottom layer is fixed with 4 screws and the middle body. Waterproof treatment is done in the middle of the two layers to prevent water leakage which will burn the circuit board and battery at the bottom.

Product Parameters:
Overall size radius 85mm, height 235mm
Top Cover: height 80mm, radius 85mm; volume of enrichment zone: 80mm3
Rotating reaction area: height 55mm radius 70mm; reaction cell height:45mm radius 15.5mm volume 46mm3
Middle body: Height 140 Radius 85 Thickness 4mm
Bottom: Height 15 Radius 85

(the physical image printed out by 3D modeling)

Development Boards

The Arduino Uno is a development board based on the microcontroller ATmega328P. It has 14 digital input/output pins (6 of these pins can be used as PWM output pins), 6 analogue input pins, a 16 MHz quartz crystal, a USB interface, a power supply interface, support for in-line serial programming and a reset button. All we need is to connect the development board to the PC via the USB interface and it is ready to use. Here are its main parameters.

Microcontroller ATmega328P
Working voltage 5 volts
Input voltage (recommended) 7 to 12 volts
Input voltage (limit) 6 to 20 kv
Digital input output pin 14 (of which 6 pins can be used as PWM pins)
PWM pin 6
Analog input pin 6
Input/output pin DC current 20 ma
3.3V pin current 50 ma
A Flash Memory. 32 KB (ATmega328P) of which 0.5 KB is used for system boot
SRAM(static memory) 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Built-in LED pins 13
Long 68.6 mm
Wide 53.4 mm
Heavy 25 g
The clock frequency 16 MHz

Stepper motor

Our sampling module is a six-hole, equally divided disc. After each sampling is complete, a stepper motor drives the disc to rotate by 60°. This allows the next sampling hole to be aligned with the valve

Drive Boards

The DRV8825 is an integrated motor driver chip designed by Texas Instruments. The chip has two H-bridges and a 1/32 microstepping indexer to drive one bipolar motor or two DC brushed motors. The input voltage range is from 8.2 to 45V, providing a drive current of 1.75A and a peak current of 2.5A at 24V 25°C. The on-state resistance of 0.2 ohms ensures good thermal stability. The chip also has integrated short circuit, overheat, undervoltage and cross-conduction protection circuits to detect fault conditions and quickly cut off the H-bridge, thus protecting the motor and driver chip.

DRV8825driver module pinout diagram

The pin connections of the DRV8824/8825 and even the common A4988 motor driver modules are not very different. In the diagram above, M0, M1 and M2 are not connected then they are high and the operating mode of the driver board is 32 subdivision. M0, M1 and M2 can be connected to ground separately or all together to achieve different working modes. The following is the subdivision setting table for our DRV8825 driver module. 

M0 M1 M2 TYPE
Low Low Low Full Step
High Low Low Half Step
Low High Low 1/4 Step
High High Low 1/8 Step
Low Low High 1/16 Step
High Low High 1/32 Step
Low High High 1/32 Step
High High High 1/32 Step

Arduino CNC

Arduino CNC motor expansion boards are commonly used to drive NEMA17 motors (42 stepper motors) in 3D printers, robotic arms or robotic systems. We use the AFMotor motor expansion board to drive the 28BYJ-48 stepper motor. The CNC expansion board can support stepper motor driver boards such as the A4988 and DRV8825. We have paired it with a 12V external power supply.

Software

Angle

#include "AccelStepper.h" 
#include "MsTimer2.h"
#include "elapsedMillis.h"
// Define constants for motor control
const int enablePin = 8;  
 
const int xdirPin = 5;    
const int xstepPin = 2;   
const int ydirPin = 6;     
const int ystepPin = 3;   
const int zdirPin = 7;    
const int zstepPin = 4;   
 
const int moveSteps = 200;    //The number of running steps used to test motor operation
 
AccelStepper stepper1(1,xstepPin,xdirPin);//Create stepper motor object 1
AccelStepper stepper2(1,ystepPin,ydirPin);//Create stepper motor object 2
AccelStepper stepper3(1,zstepPin,zdirPin);//Create stepper motor object 3

elapsedMillis sinceTest1;
elapsedMillis sinceTest2;

int state = 0;
int ok = -1;
void setup() {

  // Serial.begin(9600);

  pinMode(xstepPin,OUTPUT);     // Arduino control DRV8255x stepper pins for output mode
  pinMode(xdirPin,OUTPUT);      // Arduino control DRV8255x direction pins for output mode
  pinMode(ystepPin,OUTPUT);     // Arduino control DRV8255y stepper pins for output mode
  pinMode(ydirPin,OUTPUT);      //  Arduino control DRV8255y direction pins for output mode
  pinMode(zstepPin,OUTPUT);     //  Arduino control DRV8255z stepper pins for output mode
  pinMode(zdirPin,OUTPUT);      // Arduino control DRV8255z direction pins for output mode
  
  pinMode(enablePin,OUTPUT);   // Arduino control DRV8255 enable pin for output mode
  digitalWrite(enablePin,LOW); // Set the enable control pin to low to put the motor driver board into operation
                                
                             
  stepper1.setMaxSpeed(3000.0);     //  Set maximum motor speed 300 
  stepper1.setAcceleration(200.0);  // Set motor acceleration 200.0
  stepper1.setSpeed(300.0); 
 
  stepper2.setMaxSpeed(3000.0);     // Set maximum motor speed 300 
  stepper2.setSpeed(300.0); 

  stepper3.setMaxSpeed(3000.0);     //  Set maximum motor speed 300  
  stepper3.setAcceleration(20.0);  //Set motor acceleration 20.0

  

}

void loop() {
  
  if (ok == -1){
    stepper1.moveTo(33);
    ok = 0;
  }else if (ok == 0){
    if (stepper1.currentPosition() == 33){
      stepper1.setCurrentPosition(0);
      ok = 1;
      sinceTest2 = 0;
    }
  }else if(ok == 1){
    if(sinceTest2>=3000){
      stepper1.moveTo(33);
      ok = 0;
    }
  }
  if (sinceTest1 >= 5000) {
    sinceTest1 = sinceTest1 - 5000;
  
  }
  stepper1.run();   //No.1 motor operation
  stepper2.run();   // No. 2 motor operation
  stepper3.run();   // Motor No. 3 running
 
}

Timer

#include "AccelStepper.h"
#include "MsTimer2.h"
#include "elapsedMillis.h"
const int enablePin = 8;  
 
const int xdirPin = 5;    
const int xstepPin = 2;   
const int ydirPin = 6;     
const int ystepPin = 3;   
const int zdirPin = 7;    
const int zstepPin = 4;  

AccelStepper stepper1(1,xstepPin,xdirPin);//Create stepper motor object 1
AccelStepper stepper2(1,ystepPin,ydirPin);//Create stepper motor object 2
AccelStepper stepper3(1,zstepPin,zdirPin);//Create stepper motor object 3

elapsedMillis sinceTest1;
elapsedMillis sinceTest2;
elapsedMillis sinceTest3;

int state1 = 0;
int state2 = 0;
int ok = -1;
void flash() {
  if (state1 == 0){
    state1 = 1;
    stepper1.stop();
  }else{
    state1 = 0;
    stepper1.runSpeed();
  }
  Serial.println("Test1 (1 sec)");
}

void setup() {
  pinMode(xstepPin,OUTPUT);     // Arduino control DRV8825x stepper pins for output mode
  pinMode(xdirPin,OUTPUT);      // Arduino control DRV8825x direction pins for output mode
  pinMode(ystepPin,OUTPUT);     // Arduino control DRV8825y stepper pins for output mode
  pinMode(ydirPin,OUTPUT);      // Arduino control DRV8825y direction pins for output mode
  pinMode(zstepPin,OUTPUT);     //Arduino control DRV8825z stepper pins for output mode
  pinMode(zdirPin,OUTPUT);      // 
  
  pinMode(enablePin,OUTPUT);   //
  digitalWrite(enablePin,LOW); // 
                               // 
                                
                             
  stepper1.setMaxSpeed(3000.0);    
 

  stepper2.setMaxSpeed(3000.0);     
  stepper2.setSpeed(300.0); 

  stepper3.setMaxSpeed(3000.0);     
  stepper2.setSpeed(300.0);

}

void loop() {
  if (sinceTest1 >= 5000) {
    sinceTest1 = sinceTest1 - 5000;
  Serial.println("Test1 (1 sec)");
    if (state1 == 0){
      state1 = 1;
      stepper1.setSpeed(300.0);
    }else{
      state1 = 0;
      stepper1.setSpeed(0.0);
      sinceTest1 =4000;
    }
  }
  Serial.println("Test2 (1 sec)");
    if (state2 == 0){
      state2 = 1;
      stepper2.setSpeed(300.0);
    }else{
      state2 = 0;
      stepper2.setSpeed(0.0);
      sinceTest2 =4000;
    }
  stepper1.runSpeed(); 
  stepper2.runSpeed();
  stepper3.runSpeed();

}