Laser Blaster garden game - kinda working but hardware advice needed

Hi all

I'll go through this as logically as possible...

Project description
I've been making a laser blaster game for about 7 years now. I kinda drift in and out of it so it never gets my full attention. In short, the blaster uses an Arduino Nano and has three inputs - trigger, align switch (this turns the laser on permanently for alignment purposes) and a 3 position rotary switch so there's 3 firing options - single shot, 3 shot blast and full auto.

In terms of outputs, the Nano sends a signal direct to a sound board for a blaster noise and the laser and 6v 2a recoil solenoid are each handled by a STP55NF06L Mosfet. The whole thing is powered by a 2s lipo. Image below is the wiring diagram and below that an image of the board. Not shown in either image is the flyback diode on the solenoid and the voltage regulator that's soldered to the laser module.

Issue
Single shot works fine but on 3 shot burst, the solenoid can lock sometimes rather than recoil. In full auto mode, the solenoid will lock after a few shots with the laser staying on too. Its easy to reset though with the nano's on-board reset button or a quick power cycle.

How I think it can be resolved
Firstly, I don't believe its the code causing the issue as the system does work, at least for a little while. Having had a read online, what I believe is causing the issue is the lack of any resistors on the Mosfet circuitry. However, I'm confused about where they might go, the required resistor values and whether, most importantly, that adding them would solve the issues I'm having.

Any advice would be great!
Cheers
Dan

Use a 180 - 220 ohm resistor between the gate and the output. Connect a 10k ohm resistor between controller output and GND.
Make sure the FET is a **logic level N channel MOSFET **.

thank you. So the 200ohm resistor is connected to the gate and drain/ output pins of each Mostfet? and the Mosfet pins on the Nano are to have 10k resistors connected to GND too? Want to make sure I'm understanding you right!

No!
Connec the 200 ohm resistor between each gate and its controller output.
Yes. Each controller output should have a 10 k connected to GND.
Sorry, only a tablett in use, no Pc and drawiings available.

1 Like

See e.g. the schematic at Gammon Forum : Electronics : Microprocessors : Driving motors, lights, etc. from an Arduino output pin. You're also missing a flyback diode (D1 in linked article).

These might or might not be the cause of your issue.

thank you. get it now. I think i can bodge my existing PCB and components quite easily to fit these in so that's good.

If this isn't the issue, its got to be a component issue somewhere.

Fitted some 200 and 10k resistors as suggested as its working much better. Thank you! its still getting confused on the full auto setting though after a handful of shots, almost as if the system can't keep up with itself. Any ideas?

Hi all

Giving this thread a nudge as I'd like to get the system working properly.

Would increasing the 200ohm resistors that connect between the gate and controller MOSFET pins to 1k ohm help the reliability of the 'pull down' effect on the solenoid? On full auto rapid fire, the whole system can still lock up and need resetting.

I'm not much of a hardware engineer but I would say "No". That resistor needs to be as small as possible so the FET can open as quickly as possible when the output of the Arduino goes HIGH. But making it too small will damage the Arduino.

hmmmm ok. I can't understand then why the solenoid and laser are locking 'on' at times on rapid fire. The flyback diode on the solenoid is very chunky but maybe ill try removing the solenoid from the circuit then see if the laser still locks on.

No they will not, probably make thing worse.

The problem is that the Nano cannot supply enough current to turn the MOSFET on/off fast enough and it get stuck somewhere in the middle. That's why single shot works and auto does not.
You will need a gate driver for both MOSFETS

1 Like

thank you! i shall have a look into them.

You will need to run the driver directly from the 2s battery, so find one that can at least work up to 12V. Also make sure that the inputs will work with the 5V logic signals from the Nano.
You will now need a good fast flyback diode for the solenoid.

These gate drivers look a bit beyond my meagre capabilities so I might focus on making it a single shot blaster but with a pump-action reload that has to be done after every shot.

I can recommend one if you want.

Yes please! If that's ok?! I'm guessing I'll be needing two as the laser and solenoid are controlled independently?

Can you buy parts from Digi-Key or Mouser?
Can it be a surface mount device or do you need a through hole part?
If it must be through hole, the selection will be limited or none.

Is this the project? https://www.instructables.com/Duino-Tagger/
I think (your lockup issue) might be the slow software serial and looong, blocking code to play audio.

How fast is it supposed to fire when in auto mode?
More than 10 times a second?

The Duino tagger isn't my project. That's IR tag and what I'm making is a simpler laser shooting gallery. I don't think its the audio causing the problem either as that's dealt with by the separate ISD1820 audio board and just receives the signal from the Arduino.

I've included the code below and, in full auto, the code is 116 milliseconds long so its roughly 8.6 times a second.

I can buy parts from wherever but I use easyeda then JLCPCB so I'm reckon I'd try to get SMD resistors, MOSFETs and Gate Drivers pre-installed when I get new boards. I'd probably move to a Arduino Pro Micro too to save space.

const int alignPin = 4; // laser alignment switch pin no.
const int triggerPin = 5; // trigger button pin no.
const int recoilPin = 6; // recoil pin no.
const int laserPin = 7; // laser pin no.
const int audioPin = 8; // Audio pin no.
const int RotSwitch1 = 9; // 1/3 rotary switch position 
const int RotSwitch2 = 10;  // 2/3 rotary switch position
const int RotSwitch3 = 11;  // 3/3 rotary switch position

int triggerState = 0;  // variable for reading the trigger status
int alignState = 0; // variable for the align pin/ switch
int RotSwitch1State = 0;  // variable for the Rotary switch 1 pin for single shot
int RotSwitch2State = 0;  // variable for the Rotary switch 2 pin for 3 shot burst
int RotSwitch3State = 0;  // variable for the Rotary switch 3 pin for full auto

void setup() 
{
pinMode(triggerPin, INPUT); // initialize the pushbutton pin as an input
pinMode(alignPin, INPUT); //initialize the align pin as an input
pinMode(laserPin, OUTPUT); // initialize the laser pin as an output
pinMode(recoilPin, OUTPUT); //initialize the recoil pin as an output
pinMode(audioPin, OUTPUT); // initialise the audio pin as an output
pinMode(RotSwitch1, INPUT_PULLUP); //initialize the rotary switch pin 1 as an input and enable the internal pull-up resistor
pinMode(RotSwitch2, INPUT_PULLUP); //initialize the rotary switch pin 2 as an input and enable the internal pull-up resistor
pinMode(RotSwitch3, INPUT_PULLUP); //initialize the rotary switch pin 3 as an input and enable the internal pull-up resistor
}

void loop() 
{  
triggerState = digitalRead(triggerPin); // read the state of the pushbutton value
alignState = digitalRead(alignPin); // read the state of the alignment switch
RotSwitch1State = digitalRead(RotSwitch1); //read the state of rotary switch pin 1
RotSwitch2State = digitalRead(RotSwitch2); //read the state of rotary switch pin 2
RotSwitch3State = digitalRead(RotSwitch3); //read the state of rotary switch pin 3

// SINGLE SHOT FIRING SEQUENCE
if (triggerState == HIGH and alignState == LOW and RotSwitch1State == LOW) // Determine when trigger is pressed, its on single shot and alignment switch is off
{
  delay(6); //UIPM 6ms barrel time delay
  digitalWrite(laserPin, HIGH); digitalWrite(recoilPin, HIGH); digitalWrite(audioPin, HIGH); // turn Laser, recoil and audio on
  delay(20); //wait 20 ms. UIPM standards are 15.6ms and 25.2ms
  digitalWrite(laserPin, LOW); //laser off
  delay(40);
  digitalWrite(recoilPin, LOW);digitalWrite(audioPin, LOW);// recoil and audio off
  delay(684); //This means the whole 'shot' sequence is approx. 0.75 second long. Audio file is 1 second long. Should also mean the gun won't double fire as easily without having to use debounce

    while(triggerState == HIGH and alignState == LOW) // should mean the gun should only fire once per trigger pull
    {
    triggerState = digitalRead(triggerPin);
    alignState = digitalRead(alignPin);
    digitalWrite(laserPin, LOW); digitalWrite(recoilPin, LOW); digitalWrite(audioPin, LOW);
    }
}

// 3 SHOT FIRING SEQUENCE
else if (triggerState == HIGH and alignState == LOW and RotSwitch2State == LOW) // Determine when trigger is pressed, its on 3 shot burst and alignment switch is off
{
  delay(6); //UIPM 6ms barrel time delay

  digitalWrite(laserPin, HIGH); digitalWrite(recoilPin, HIGH); digitalWrite(audioPin, HIGH); // turn Laser, recoil and audio on
  delay(20); //wait 20 ms. UIPM standards are 15.6ms and 25.2ms
  digitalWrite(laserPin, LOW); //laser off
  delay(40);
  digitalWrite(recoilPin, LOW);digitalWrite(audioPin, LOW);// recoil and audio off
  delay(50);

  digitalWrite(laserPin, HIGH); digitalWrite(recoilPin, HIGH); digitalWrite(audioPin, HIGH); // turn Laser, recoil and audio on
  delay(20); //wait 20 ms. UIPM standards are 15.6ms and 25.2ms
  digitalWrite(laserPin, LOW); //laser off
  delay(40);
  digitalWrite(recoilPin, LOW);digitalWrite(audioPin, LOW);// recoil and audio off
  delay(50);

  digitalWrite(laserPin, HIGH); digitalWrite(recoilPin, HIGH); digitalWrite(audioPin, HIGH); // turn Laser, recoil and audio on
  delay(20); //wait 20 ms. UIPM standards are 15.6ms and 25.2ms
  digitalWrite(laserPin, LOW); //laser off
  delay(40);
  digitalWrite(recoilPin, LOW);digitalWrite(audioPin, LOW);// recoil and audio off


    while(triggerState == HIGH and alignState == LOW and RotSwitch2State == LOW) // should mean the gun should only fire once per trigger pull
    {
    triggerState = digitalRead(triggerPin);
    alignState = digitalRead(alignPin);
    digitalWrite(laserPin, LOW); digitalWrite(recoilPin, LOW); digitalWrite(audioPin, LOW);
    }
}

// CONTINUOUS FIRING SEQUENCE
else if (triggerState == HIGH and alignState == LOW and RotSwitch3State == LOW) // Determine when trigger is pressed, its on Auto and alignment switch is off
{
  delay(6); //UIPM 6ms barrel time delay
  digitalWrite(laserPin, HIGH); digitalWrite(recoilPin, HIGH); digitalWrite(audioPin, HIGH); // turn Laser, recoil and audio on
  delay(20); //wait 20 ms. UIPM standards are 15.6ms and 25.2ms
  digitalWrite(laserPin, LOW); //laser off
  delay(40);
  digitalWrite(recoilPin, LOW);digitalWrite(audioPin, LOW);// recoil and audio off
  delay(50);

}

// CALIBRATION CODING
else if (alignState == HIGH) //is alignment switch on for calibration?
{digitalWrite(laserPin, HIGH);} //if yes, laser gets turned on constantly}
  else (alignState == LOW);
{ digitalWrite(laserPin, LOW);}

}