@xfpd Yeah. I put it in tinkerCad and ran it.
@InquisitiveMind Fair point. Like I said, it's conceptual only. W/out seeing the OP's code, we wouldn't know how to implement any changes yet. But yeah, good point.
@xfpd Yeah. I put it in tinkerCad and ran it.
@InquisitiveMind Fair point. Like I said, it's conceptual only. W/out seeing the OP's code, we wouldn't know how to implement any changes yet. But yeah, good point.
By who?
Did you read post #2 where I citated manufacturers estimation for time needed to reach critical temp? And about ED 30%.
I have now moved the topic to a more appropriate category.
Carry on.
Hi, thanks. Yes, I've been trying lots of things that didn't work, ramps too steep, buttons that break after 3 hits, etc... At first it was all mechanic, with manual levers for the flips and launcher, and bells. It worked, and then I added just a simple circuit with 3 AAA batteries, for lights. Then I wanted more, so I came across Arduino and started trying things. Lot of trying, especially for the flips, which are working now.
Here is my code, please be gentle. Any tips or improvements are welcome.
//www.elegoo.com
//2016.12.08
int ledPlateau = 9;
int ledRampes = 10;
int ledSpot = 11;
int flipGauche = 3;
int flipDroit = 4;
int lanceur = 2;
int buttonFlipGauche = A1;
int buttonFlipDroit = A2;
int buttonLedPlateau = A3;
int buttonLedRampes = A4;
int buttonLedSpot = A5;
int buttonLanceur = A0;
int buzzer = 13;
int moteurPin = 12;
byte leds = 0;
void setup()
{
pinMode(A0,INPUT_PULLUP);
pinMode(A1,INPUT_PULLUP);
pinMode(A2,INPUT_PULLUP);
pinMode(A3,INPUT_PULLUP);
pinMode(A4,INPUT_PULLUP);
pinMode(A5,INPUT_PULLUP);
pinMode(ledPlateau, OUTPUT);
pinMode(ledRampes, OUTPUT);
pinMode(ledSpot, OUTPUT);
pinMode(flipGauche, OUTPUT);
pinMode(flipDroit, OUTPUT);
pinMode(lanceur, OUTPUT);
pinMode(moteurPin, OUTPUT);
pinMode(buttonFlipGauche, INPUT_PULLUP);
pinMode(buttonFlipDroit, INPUT_PULLUP);
pinMode(buttonLedPlateau, INPUT_PULLUP);
pinMode(buttonLedRampes, INPUT_PULLUP);
pinMode(buttonLedSpot, INPUT_PULLUP);
pinMode(buttonLanceur, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
}
void loop()
{
if (digitalRead(buttonLanceur) == LOW)
{
digitalWrite(lanceur, HIGH);
digitalWrite(ledPlateau, HIGH);
delay(200);
digitalWrite(ledPlateau, LOW);
}
if (digitalRead(buttonFlipDroit) == LOW)
{
digitalWrite(flipDroit, HIGH);
}
if (digitalRead(buttonFlipDroit) == HIGH)
{
digitalWrite(flipDroit, LOW);
}
if (digitalRead(buttonFlipGauche) == LOW)
{
digitalWrite(flipGauche, HIGH);
}
if (digitalRead(buttonFlipGauche) == HIGH)
{
digitalWrite(flipGauche, LOW);
}
if (digitalRead(buttonLanceur) == HIGH)
{
digitalWrite(lanceur, LOW);
}
if (digitalRead(buttonLedPlateau) == LOW)
{
digitalWrite(ledPlateau, HIGH);
delay(200);
digitalWrite(ledPlateau, LOW);
digitalWrite(buzzer, HIGH);
tone(buzzer, 2000);
delay(100);
tone(buzzer, 4000);
delay(100);
tone(buzzer, 6000);
delay(100);
noTone(buzzer);
}
if (digitalRead(buttonLedSpot) == LOW)
{
digitalWrite(ledSpot, HIGH);
delay(200);
digitalWrite(buzzer, HIGH);
tone(buzzer, 3000);
delay(200);
tone(buzzer, 3100);
delay(200);
tone(buzzer, 3200);
delay(200);
tone(buzzer, 3300);
delay(200);
tone(buzzer, 3400);
delay(200);
noTone(buzzer);
}
if (digitalRead(buttonLedRampes) == LOW)
{
digitalWrite(ledRampes, HIGH);
delay(200);
digitalWrite(buzzer, HIGH);
tone(buzzer, 2500);
delay(200);
tone(buzzer, 4500);
delay(200);
tone(buzzer, 6500);
delay(200);
noTone(buzzer);
}
}
Here is a basic concept to implement the changing solenoid power after holding the button for X amount of seconds.
if (!rightButtonPressed && digitalRead(buttonFlipDroit) == LOW) {
rightSolenoidTimer = millis(); //Record time for high solenoid power
rightButtonPressed = true; /*Set boolean to true to prevent mulitple button readings while pressed. WIll prevent
reentering this IF block during button bounce*/
analogWrite(flipDroit, fullPower); //Turn on solenoid full power
}
if (rightButtonPressed && digitalRead(buttonFlipDroit) == LOW) {
if (millis() - rightSolenoidTimer > highPowerInterval) { //Start the debounce timing
analogWrite(flipDroit, holdingPower); //Set solenoid to holding power
}
}
if (digitalRead(buttonFlipDroit) == HIGH) { //If button not pressed
rightButtonPressed = false; //Reset state
analogWrite(flipDroit, 0); //Turn off solenoid
}
// -----------Delete this-----------------
/* if (digitalRead(buttonFlipDroit) == HIGH) {
digitalWrite(flipDroit, LOW);
}*/
EDITED>> as @kmin has pointed out twice, it is up to you to determine how much power for how long your solenoids can handle. There may or may not even be a problem to address.
The warning repeated by @scottcalv about determining how much power for how long your solenoids can handle is important!
In addition, I would recommend monitoring the solenoid temperature directly as a simple fail-safe approach. Even if the calculated power dissipation looks acceptable, heat can accumulate under real-world conditions, and higher ambient temperatures may reduce the available thermal margin significantly.
A DS18B20 attached to each solenoid would allow you to establish real-world temperature data under your actual operating conditions instead of relying solely on estimates of duty cycle and power dissipation.
You could then define a temperature limit and automatically shut the solenoid down before overheating becomes a concern.
If you decide to go that route, I recently put together a detailed analysis of the common DS18B20 pitfalls (including the well-known 85°C and -127°C readings) and ways to make the readings more reliable:
Nice!
That's pretty cool! Good job!
Why would the solenoids burn?
They won't, thank you for helping me understand why.
I tried pushing the flip for 10 seconds, it just gets a little bit hotter.
In your original post you state, "avoiding the solenoids to burn". So now you claim they don't?
That's what I was afraid of, yes.
Are they continuous duty solenoids?
No they're not.
Then you need to reduce the current once the solenoid if fully closed. The holding current (when fully closed) is much less then the initial current required to move the plunger.
As suggested by others, you could use PWM to reduce the current once the plunger is fully seated.
One way to reduce holding current is to use a driver like the DRV101:
https://www.mouser.com/datasheet/2/405/sbvs008b-125860.pdf?srsltid=AfmBOordjZik90OaumValuQsg0OQ54_zsTdEk8znXKWYxZ19cjp-zRGv
You can set them up for initial full on current and then a reduced holding current.
My thinking was that he already has all the components he needs. Instead of changing the whole design and making the overall design more complicated, just change the code a little bit and hit upload.
I agree.