Login    Register
User Information
Username:
Password:
We are a free and open
community, all are welcome.
Click here to Register
Sponsored
Who is online

In total there are 64 users online :: 4 registered, 0 hidden and 60 guests


Most users ever online was 155 on Mon Aug 15, 2016 1:40 am

Registered users: Bing [Bot], Google [Bot], MSNbot Media, Yahoo [Bot] based on users active over the past 5 minutes

The Team
Administrators
Global Moderators
global_moderators.png CS

Need help with Arduino - RJB INDUSTRIES

All non-spudgun related discussion goes here such as projects, theories, serious questions, etc. All "off-topic" posts (aka useless posting, determined by moderators) will be removed.
Sponsored 
  • Author
    Message

Unread postAuthor: evilvet » Sat Apr 27, 2013 4:09 pm

Not a gun yet, just some bits on the bench.

For my next trick I need to design and construct an alignment circuit, something to tell me that the drum is in the correct starting position for the stepper to index from. I am thinking of an IR photodiode hooked up as a voltage divider with a LED illuminating the diode via a hole in the drum.

This might give you an idea of where I am headed.
  • 0

Attachments
2013-04-24_12-37-10_498.jpg
User avatar
evilvet
1st Lieutenant
1st Lieutenant
 
Posts: 266
Joined: Sat May 01, 2010 2:48 am
Reputation: 0

Unread postAuthor: evilvet » Sat Apr 27, 2013 10:53 pm

Update:

Grabbed a BP104 IR photodiode and an IR LED, changed some code and hey presto, it works.

Press Button 2 and the rotary magazine spins slowly and at the same time polls for voltage on Analogue Pin 1. The theory is a small hole in the magazine plate that aligns with two others, one on each side of the breech. When the holes are lined up the voltage at the pin goes high due to the IR LED shining on the photodiode and the rotation stops.

Now you can press Button 1 and the first relay fires, this activates the solenoid valve that pilots the QEV and launches the round. The next relay fires to open and close the solenoid that feeds from the bulk HPA source to the chamber. Finally the drum then rotates by a preset number of steps to align the next round.

TO DO:

**
Change the code on BUTTON TWO so that instead of looking for a threshold value it runs until the voltage has declined for two or more readings, that should mean the LED is being obscured by the drum moving past the best alignment point.

**
Finish the mechanical stuff so I can get the electronics bolted on.


It's starting to get cold, winter is coming so I foresee a long series of nights in the shed tinkering with this until Spring.

[edit]

[youtube]
http://www.youtube.com/watch?v=vuTBwP7ot80
[/youtube]

New code is below.

Code: Select all

const int StepPin =  13;      // the number of the Stepper Motor signal pin
const int ButtonPin1 = 2;     // the number of the pushbutton pin
const int ButtonPin2 = 5;     // the number of the pushbutton pin
const int RelayPin1 = 3;     // the number of the first relay
const int RelayPin2 = 4;     // the number of the second relay
int SensePin = 1; //the analog pin the anode of the IR photodiode is connected to
int SensorValue;
int ButtonState1 = LOW;
int ButtonState2 = LOW;


void setup() {
  // initialize the Stepper Driver pin and the relay pins as outputs:
  pinMode(StepPin, OUTPUT);
  pinMode(RelayPin1, OUTPUT);
  pinMode(RelayPin2, OUTPUT);
  // initialize the pushbutton pins as inputs:
  pinMode(ButtonPin1, INPUT);     
  pinMode(ButtonPin2, INPUT);     
  Serial.begin(115200);
}

void loop(){
  // read the state of the pushbutton value:
  ButtonState1 = digitalRead(ButtonPin1);
  ButtonState2 = digitalRead(ButtonPin2);
  if (ButtonState1 == HIGH) //Has the button been pushed ?
  {
    Serial.println("BUTTON ONE HAS BEEEN PRESSED");
    delay(1000); //remove after debug
    digitalWrite(RelayPin1, HIGH); //Fire the solenoid valve and reset the pin
    Serial.println("Relay 1 fired");
    delay(500); //Open the pilot valve for 500 milliseconds
    digitalWrite(RelayPin1, LOW);
    digitalWrite(RelayPin2, HIGH);
    Serial.println("Relay 2 fired");
    delay(2000); //Leave the relay on for two secconds to fully pressurize the chamber
    digitalWrite(RelayPin2, LOW);
    for (int Step1Count = 1; Step1Count < 18 ; Step1Count++){ //change the number of steps to equal 1/8th rotation
      Serial.print("Step One Count = ");
      Serial.println(Step1Count); //Remove once debugging finished
      digitalWrite(StepPin, HIGH); // Send X pulses to the stepper controller
      delay(10);
      digitalWrite(StepPin, LOW);
      delay(10);
    }
  }
  else if (ButtonState2 == HIGH) //Has the button been pushed ?
  {
    Serial.println("BUTTON TWO HAS BEEEN PRESSED");
    delay(1000);
    for (int Step2Count = 1; Step2Count <2000>= 750) //0-1024 possible values, need to play with this to get max alignment
      {
        digitalWrite(StepPin, LOW);
        break;
      }
     }
  }
  else
  {
    Serial.println("Button 2 Waiting...........");
    Serial.println("Button 1 Waiting...........");
  }
}

  • 0

User avatar
evilvet
1st Lieutenant
1st Lieutenant
 
Posts: 266
Joined: Sat May 01, 2010 2:48 am
Reputation: 0

Previous

Return to Non-Spudgun Related Discussion

Who is online

Registered users: Bing [Bot], Google [Bot], MSNbot Media, Yahoo [Bot]

Reputation System ©'