Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Shame Boy
Mar 2, 2010

Platystemon posted:

Alternatively, change those delays to timers that fire interrupts.

Between the time the timer starts and ends (which is a lot of cycles), the processor could be looping over the IR code non‐stop.

I was reading the documentation on that IR library just now and it uses at least one of the timer interrupts for its own internal thing, though I think the Arduino still has another one?

Anyway this guy seems to have used that exact library and implemented an interrupt. What he's doing with the interrupt is kinda bad though - he's writing to the serial port while inside the interrupt. Generally what you want to do is put the minimum possible amount of work into the interrupt so it can finish as fast as possible since it's literally holding everything else the processor is doing up. So usually what you do is just read the value in the interrupt code (in this case the guy's named the function CHECK_IR()) and store it somewhere that your main loop() function can then read and do stuff with later on when it comes back around to that point.

Adbot
ADBOT LOVES YOU

rockcity
Jan 16, 2004

ate all the Oreos posted:

I was reading the documentation on that IR library just now and it uses at least one of the timer interrupts for its own internal thing, though I think the Arduino still has another one?

Anyway this guy seems to have used that exact library and implemented an interrupt. What he's doing with the interrupt is kinda bad though - he's writing to the serial port while inside the interrupt. Generally what you want to do is put the minimum possible amount of work into the interrupt so it can finish as fast as possible since it's literally holding everything else the processor is doing up. So usually what you do is just read the value in the interrupt code (in this case the guy's named the function CHECK_IR()) and store it somewhere that your main loop() function can then read and do stuff with later on when it comes back around to that point.

Ok, so how do I code the pause as a timer to check the IR code instead of having it as a delay? I haven't coded anything in over a decade so I'm really bumbling through this all.

Essentially what I want the lights to do is this:

Light up a single LED for one second, turn that LED off then wait for one second, light up the next LED for one second, then repeat on down the code. Obviously as it stands now it's only checking the IR for a brief second at the end of the loop. If you can in fact use a timer for one second instead of a delay where it is repeatedly checking for an IR signal that would work perfectly. I don't know how to sort through the remote library to see how to do that though. I've just been piece mailing this code together from a handful of different other projects I found online until I got it to work.

Edit: And I apologize for using google docs, I didn't know if there was a simple way to share code. My formatting in my code is garbage though, I was just trying to get stuff in there to make sure it worked.

rockcity fucked around with this message at 21:41 on Oct 31, 2016

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin

rockcity posted:

Ok, so how do I code the pause as a timer to check the IR code instead of having it as a delay? I haven't coded anything in over a decade so I'm really bumbling through this all.

Essentially what I want the lights to do is this:

Light up a single LED for one second, turn that LED off then wait for one second, light up the next LED for one second, then repeat on down the code. Obviously as it stands now it's only checking the IR for a brief second at the end of the loop. If you can in fact use a timer for one second instead of a delay where it is repeatedly checking for an IR signal that would work perfectly. I don't know how to sort through the remote library to see how to do that though. I've just been piece mailing this code together from a handful of different other projects I found online until I got it to work.

Edit: And I apologize for using google docs, I didn't know if there was a simple way to share code. My formatting in my code is garbage though, I was just trying to get stuff in there to make sure it worked.

On an arduino, you have access to the handy built-in functions millis() and micros(), which return the number of milliseconds and microseconds, respectively, since you powered up.

Here's the rough idea:

code:
void setup()
{
  int TIMER_DURATION_MS = 1000;
  int last_loop_time = millis();
}

void loop()
{
  int curr_time = millis();
  if ((curr_time - last_loop_time) > TIMER_DURATION_MS)
  {
    [do timer-related stuff -- sounds like you want a state machine here]
    last_loop_time = curr_time;
  }
  [do IR-related stuff, if needed]
}
That's super quick and dirty -- if anything doesn't make sense, let me know. Also, I make no warranties to the non-pseudocode Arduino code -- I haven't worked on an Arduino in ages.

huhu
Feb 24, 2006

rockcity posted:

Ok, so how do I code the pause as a timer to check the IR code instead of having it as a delay? I haven't coded anything in over a decade so I'm really bumbling through this all.

Essentially what I want the lights to do is this:

Light up a single LED for one second, turn that LED off then wait for one second, light up the next LED for one second, then repeat on down the code. Obviously as it stands now it's only checking the IR for a brief second at the end of the loop. If you can in fact use a timer for one second instead of a delay where it is repeatedly checking for an IR signal that would work perfectly. I don't know how to sort through the remote library to see how to do that though. I've just been piece mailing this code together from a handful of different other projects I found online until I got it to work.

Edit: And I apologize for using google docs, I didn't know if there was a simple way to share code. My formatting in my code is garbage though, I was just trying to get stuff in there to make sure it worked.

Instead of delay you could (on my phone now) change 50ms with whatever time it takes for a button press to occur.
code:

Void ir_delay(int delay_time){
     Int time_per_delay = 50;
     int delay_iterations = delay_time / time_per_delay;
     for(int i = 0; i<= delay_iterations; i++){
          check_ir();
          delay(time_per_delay);
     }
}
This way your code delays for delay_time but runs check_ir() every time_per_delay.

rockcity
Jan 16, 2004

KnifeWrench posted:

On an arduino, you have access to the handy built-in functions millis() and micros(), which return the number of milliseconds and microseconds, respectively, since you powered up.

Here's the rough idea:

code:
void setup()
{
  int TIMER_DURATION_MS = 1000;
  int last_loop_time = millis();
}

void loop()
{
  int curr_time = millis();
  if ((curr_time - last_loop_time) > TIMER_DURATION_MS)
  {
    [do timer-related stuff -- sounds like you want a state machine here]
    last_loop_time = curr_time;
  }
  [do IR-related stuff, if needed]
}
That's super quick and dirty -- if anything doesn't make sense, let me know. Also, I make no warranties to the non-pseudocode Arduino code -- I haven't worked on an Arduino in ages.

Would that just go at the start of the program? i.e. I would change the IR loop to include that time function and then tell it to run the IR code during that? If so, what would I change the delay to to loop back to that?

I really don't care about how long anything is going overall, just that there is a way to put a timed pause between lights/words/phrases and a way to look for more IR singals than just the very moment after the sequence runs, which on the "RIGHT HERE" sequence is every 25 seconds.

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin

rockcity posted:

Would that just go at the start of the program? i.e. I would change the IR loop to include that time function and then tell it to run the IR code during that? If so, what would I change the delay to to loop back to that?

I really don't care about how long anything is going overall, just that there is a way to put a timed pause between lights/words/phrases and a way to look for more IR singals than just the very moment after the sequence runs, which on the "RIGHT HERE" sequence is every 25 seconds.

An interrupt is definitely the *proper* way to do that.

But here's a revised way of doing it with a timer-esque philosophy. The concept is, you have a state (the pattern you're running) and a timer that ticks up from the time you push the button. If you push the button, the timer resets. Otherwise, you have a table of LED states that you want for each second in the sequence, and it steps through that. I *don't know* if it will work A) in general, B) for your application. I'm just trying to illustrate the concept, so let me know if something doesn't make sense, and then you can adapt it as necessary.

code:
void setup()
{
  const int RIGHT_HERE_MODE = 0;
  const int RUN_MODE = 1;
  const int SEQUENCE_INTERVAL_MS = 1000;
  int right_here[][2] = { { 22, CRGB::Red },
                          { 22, CRGB::Black },
                          [...]
                          { 46, CRGB::Black } }; // table of LEDs and values by second in sequence
  int run[][2] = [...]  // same for other mode
  int start_time;
  int curr_time;
  int mode_state = 0;
  int sequence_state = 0;
}

void loop()
{
  curr_time = millis();
  if (irrecv.decode(&results)) 
  {
    irrecv.resume();   // Receive the next value
    start_time = curr_time;
  }
  
  switch(results.value)
  {
    case 0xFFA25D:
      mode_state = RIGHT_HERE_MODE;
      sequence_state = 0;
      break;

    case 0xFF629D:
      mode_state = RUN_MODE;
      sequence_state = 0;
      break;
  
    default:
      break;
  }
  // switch

  sequence_state = (curr_time - start_time) / 1000; // number of seconds into sequence
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // copied from yours
  switch (mode_state)
  {
    case RIGHT_HERE_MODE:
      leds[right_here[sequence_state][0]] = right_here[sequence_state][1];
      break;
    case RUN_MODE:
      leds[run[sequence_state][0]] = run[sequence_state][1];
      break; 
  }
  FastLED.show();
  
}

Sagebrush
Feb 26, 2012

KnifeWrench posted:

An interrupt is definitely the *proper* way to do that.

But here's a revised way of doing it with a timer-esque philosophy. The concept is, you have a state (the pattern you're running) and a timer that ticks up from the time you push the button. If you push the button, the timer resets. Otherwise, you have a table of LED states that you want for each second in the sequence, and it steps through that. I *don't know* if it will work A) in general, B) for your application. I'm just trying to illustrate the concept, so let me know if something doesn't make sense, and then you can adapt it as necessary.

Here's how I explain it to my students:

Using a series of delays to time your program is like putting a cake in the oven, then standing in front of it and counting "one, two, three, four..." until you hit the number of seconds it needs to cook for. It's very accurate and simple to do, but you're tied up and can't do anything else while the cake is baking.

Using an asynchronous timer to time your program is like putting a cake in the oven, checking your watch, and saying "okay, fifteen minutes from now I need to take the cake out." You can go and do other things and still get the cake out on time as long as you check your watch regularly, but if you don't check it often enough you might miss the exact time and be late getting it out. You can choose to balance the inaccuracy you'll accept with convenience by checking your watch more or less frequently.

Using an interrupt is like setting a timed alarm connected to a machine that automatically opens the oven door and fires the cake out with a catapult. It's guaranteed to get the cake out on time without you having to check your watch, but when you hear that alarm you have to drop whatever you're doing and run to grab the cake before it hits the floor.

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
While I fully understood interrupts/timers/etc before, I like that analogy.

Sagebrush
Feb 26, 2012

Anyway, yeah, KnifeWrench's general idea is the best way to handle fast animation (or similar time-sensitive task) while remaining responsive to input and not getting bogged down with interrupts. You write a timer structure for the lights that triggers every 33ms or whatever (30Hz), and only sets the lights to the appropriate state. This could be as simple as loading the next value from an array representing the states and writing that out to your outputs. Then you write another timer structure that triggers at whatever rate you need the input to react (say, every 10ms, or 100Hz) which reads the inputs and reacts accordingly. The two structures are independent, and while there may be small time errors depending on how complex each subroutine is, the errors won't stack up.

This gets you easily tuneable response rates and minimum wasted CPU time. If you need one or the other of these to run in hard real-time, then you can set a timer interrupt to trigger it instead of using a conditional check in the code.

rockcity
Jan 16, 2004
Those are great analogies and definitely steer me toward using the timer method. I'm still a bit lost on how/where exactly to implement them, but I'm getting there. It sounds like I need to program an IR loop inside of a timer and then call for that timered loop instead of using the delay between letters in the sequence of lights.

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin
If I'm understanding your IR code correctly, you don't strictly need a timer for it. You can just put it in the main loop and check for new messages as fast as possible, because nothing will happen if there isn't a new message.

The main function of the timer is to allow you to skip right past the LED stuff if you don't need to change anything. You want LEDs to change every second, but the program loop runs much faster (so you can check the IR receiver). So you just record the current time every loop, and check it against the last time the button was pressed to find out what frame of the animation you're supposed to be on.

Bear in mind the example above is incomplete and cruder than I'd probably do for myself, but it should solve your input delay problem.

To make it as clear as possible:
- Your main loop likely takes less than a millisecond to run (if there aren't any delays)
- That's plenty fast enough to catch a human input like a button, so no timer is necessary for input, as long as you're not stuck waiting elsewhere in the loop.
- Therefore, all you need to do is keep track of what time it currently is (relative to the button press), and have a way to map that to the animation frames.

Sagebrush
Feb 26, 2012

rockcity posted:

Those are great analogies and definitely steer me toward using the timer method. I'm still a bit lost on how/where exactly to implement them, but I'm getting there. It sounds like I need to program an IR loop inside of a timer and then call for that timered loop instead of using the delay between letters in the sequence of lights.

So from a UX standpoint, it sounds like this is basically what happens:

- you have a bunch of LEDs on the wall like in Stranger Things, and they turn on and off in a sequence that writes out words
- you have an IR transmitter that is only used to click from one sequence to the next

If that's the case, I would do it like this:

- program each sequence of LEDs into an array. So if you had 26 letters and you wanted to write out the word DICKBUTT, you'd have something like
code:
int dickbutt[] = {4, 9, 3, 11, 2, 21, 20, 20};
then create more arrays for each other word.
- write a function that, when called and passed a single int, clears the whole chain of LEDs and turns on the appropriate one. Depending on your hardware, this could be a call to a neopixel library, a big chain of switch/cases, etc. Here's a simple bit of code for a neopixel/WS2811, which is what I'd use for this if I had 26 separate LEDs to work with
code:
void setLetter(int letter) {
  for (int i = 0; i < strip.numPixels(); i++) {  //loop through all LEDs in the chain
    strip.setPixelColor(i, 0x0); //set this LED to off
  }
  strip.setPixelColor(letter-1, 0xFF0000); //set the important LED to red
  strip.show();  //push out the color values to the chain
}
- write a timer that is refreshed at the rate you want the LEDs to blink, so once a second or whatever.
- inside this timer function, (1) increment an array index counter, wrapping around after the correct number of letters; (2) get the number corresponding to that index in the active array, and (3) pass it to your LED-setting function

Your code should now cycle through DICKBUTT indefinitely. When the LED isn't being updated, the Arduino is doing nothing (well, it's checking a timer over and over again super fast).

Then, to add the remote,
- write a little conditional statement in the main loop that checks for whatever IR sequence it is you're trying to detect
- if the sequence is detected, (1) reset your array index counter to zero, and (2) change the array that the timer function points to. This could be alternating between two possibilities, cycling through a list of several arrays, picking one randomly, etc.

Now your remote toggles to a new word and restarts the sequence.

Sagebrush fucked around with this message at 06:49 on Nov 1, 2016

rockcity
Jan 16, 2004

Sagebrush posted:

So from a UX standpoint, it sounds like this is basically what happens:

- you have a bunch of LEDs on the wall like in Stranger Things, and they turn on and off in a sequence that writes out words
- you have an IR transmitter that is only used to click from one sequence to the next

If that's the case, I would do it like this:

- program each sequence of LEDs into an array. So if you had 26 letters and you wanted to write out the word DICKBUTT, you'd have something like
code:
int dickbutt[] = {4, 9, 3, 11, 2, 21, 20, 20};
then create more arrays for each other word.
- write a function that, when called and passed a single int, clears the whole chain of LEDs and turns on the appropriate one. Depending on your hardware, this could be a call to a neopixel library, a big chain of switch/cases, etc. Here's a simple bit of code for a neopixel/WS2811, which is what I'd use for this if I had 26 separate LEDs to work with
code:
void setLetter(int letter) {
  for (int i = 0; i < strip.numPixels(); i++) {  //loop through all LEDs in the chain
    strip.setPixelColor(i, 0x0); //set this LED to off
  }
  strip.setPixelColor(letter-1, 0xFF0000); //set the important LED to red
  strip.show();  //push out the color values to the chain
}
- write a timer that is refreshed at the rate you want the LEDs to blink, so once a second or whatever.
- inside this timer function, (1) increment an array index counter, wrapping around after the correct number of letters; (2) get the number corresponding to that index in the active array, and (3) pass it to your LED-setting function

Your code should now cycle through DICKBUTT indefinitely. When the LED isn't being updated, the Arduino is doing nothing (well, it's checking a timer over and over again super fast).

Then, to add the remote,
- write a little conditional statement in the main loop that checks for whatever IR sequence it is you're trying to detect
- if the sequence is detected, (1) reset your array index counter to zero, and (2) change the array that the timer function points to. This could be alternating between two possibilities, cycling through a list of several arrays, picking one randomly, etc.

Now your remote toggles to a new word and restarts the sequence.

Yeah, that's more or less the gist of it. And yes, they are Neopixel/WS2811 LEDs. I like the way this sound and it would definitely shorten the code quite a bit, not that I need it to be processing crazy fast or anything. A couple small questions.

I assume you just do the different int "words for the LEDs" all at the top of the code and then call for them in the main loop?
Where exactly is it calling for whatever int you want to use for the loop?
Is there a way to cycle through the LED colors using this method? Right now I'm individually calling for the LEDs so I'm just picking a new color each time so it varies as the word/phrase goes.

Time to do some research on timers and counters. Thanks for the help on this everyone. These are a gift I'm building for someone for a Stranger Things Christmas party in a month. I'm dropping them off for them tomorrow, but I'll have the rest of the month to clean up the code. Worst case scenario is we use them as is. They work fine now, even if my coding is hot garbage, the remote is just what's annoying me.

Edit: For reference, here was my trial run outside of my house last night.
https://www.instagram.com/p/BMPyREjgFev/?taken-by=rockcityphoto

Brekelefuw
Dec 16, 2003
I Like Trumpets
I need to splice an aquarium air pump power cable and put a case mount on/off switch on it. I would prefer a nice looking one. Not a light switch.
Is there anything I need to know so I don't release the magic pixies and kill myself?

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
well the first thing is I think you need to work on your overthinking skills

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Brekelefuw posted:

I need to splice an aquarium air pump power cable and put a case mount on/off switch on it. I would prefer a nice looking one. Not a light switch.
Is there anything I need to know so I don't release the magic pixies and kill myself?
It sounds like you want an inline switch?

See if any of these look good:
https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=inline+switch

Installation should be pretty straightforward, I think most just pop a clamshell apart and screw some wires down.

Effective-Disorder
Nov 13, 2013

Brekelefuw posted:

I need to splice an aquarium air pump power cable and put a case mount on/off switch on it. I would prefer a nice looking one. Not a light switch.
Is there anything I need to know so I don't release the magic pixies and kill myself?

Water conducts electricity. Do not splice a power cable by placing two ends in tank itself. This kills the fish.

Seriously, though, you're talking about taking the cord from the pump and splicing a switch in the middle? There are premade solutions for this (https://amzn.com/B01KUEYM0O), but they're generally designed for lamps and such, with two conductors and no ground.

Anything electrical around a lot of water ought to have a ground conductor and some provision for GFCI. In reality, I'm sure many small aquarium pumps do not have a ground because they're cheap and designed by cheap people. But, suppose for whatever reason the air pump stalls, or whatever else happens, and it manages to siphon a bunch of water into the case? A trout gets rowdy and splashes half the tank out the top and onto your pump? Proper ground connections and GCFI outlet would help avoid current going where you don't want it.

One problem with the lamp switches? They generally don't accommodate a ground conductor. If your pump's cord only has two conductors in the first place, maybe you'll be okay, or not. When you say air pump I'm thinking of a dinky little motor puffing some bubbles to keep some goldfish alive, but I have no idea what you're dealing with. So, the amount of current involved may venture into the territory where switches designed to handle a desk lamp are inadequate. If your motor is drawing 10 amps to begin with, this solution is out of the question, but even if not, if it stalls or draws more current than the switch is rated for, for whatever reason (say the air intake/output gets clogged/obscured, increasing the load on the motor), you could have a problem. A problem, as in, "poo poo catches fire". (This cooks the fish.)

And then there's the whole question of mechanical connections and de-straining. That is to say, ensuring that nothing decides to get loose if you trip on the cord. Worst case you'd possibly have energized, exposed electrical conductors waiting for someone to touch them and enjoy that experience.

So, if you do a poor job of this, even with available solutions, your possible failure modes may yield fire, fish murder-death-kill via asphyxiation, electrocution... not in any particular order.

Maybe reconsider the reasons you "need" to do this as opposed to just plugging this into a surge protector style device that already includes a power switch? You get additional cable length, a nice elegant switch, packaged up neatly in your choice of business-y black, tangled-lights-on-a-christmas-tree green, freshman-year dorm room fluorescent blue, painkiller-addled contractor orange, or even plain old household white. You can also plug other poo poo in there that you can use to kill fish, keep them alive, or whatever it is you want to do.


EDIT:

In general if the inline switch isn't a piece of crap and it securely connects everything, you should be fine so long as it's just a small air pump.

Or... When you said "case mount", did you mean like as-in "mounted directly onto the case of the air pump"? Like you don't even care about the length of the cord, you just want to splice a switch into the hot conductor inside the case? Just forget about that. The pixies inside the pump will swarm the second you cut plastic. I suggest a pixie-free pump. Or you can just remember what I said about "current ratings" and "good mechanical connections" and such as a general rule and apply it where you can. In this case, the magic words are "illuminated SPST rocker switch". Extra points if you find a toggle switch with a guard on it to keep you from accidentally suffocating some fish without having to flip the guard up first.

Effective-Disorder fucked around with this message at 09:34 on Nov 2, 2016

Brekelefuw
Dec 16, 2003
I Like Trumpets
This is not going to be used with water. I am building a machine that tests for leaks, and uses an aquarium pump to generate air pressure to find the leaks.
The pump is a pump rated for 10 gallon tanks. Very small.

I want a case mount switch, because I am building a case for the machine and would prefer to leave it plugged in all the time, and just have to switch the machine on from the case rather than from the power cable.

Here is the machine I am making.

http://musicmedic.com/products/repair-tools/leak-detection/musicmedic-com-leak-tester.html

Brekelefuw fucked around with this message at 14:20 on Nov 2, 2016

csammis
Aug 26, 2003

Mental Institution

Brekelefuw posted:

This is not going to be used with water. I am building a machine that tests for leaks, and uses an aquarium pump to generate air pressure to find the leaks.
The pump is a pump rated for 10 gallon tanks. Very small.

...

Here is the machine I am making.

http://musicmedic.com/products/repair-tools/leak-detection/musicmedic-com-leak-tester.html

I'm not sure that a cheapo aquarium air pump that's "rated for 10 gallon tanks" is going to be able to pressurize very much. The reason for that rating is because it isn't able to effectively push air down through more than 12" (the height of a 10 gallon tank) of water pressure, which at sea level is something like 0.4 PSI, and those pumps don't handle backpressure well in my experience.

Now all that said I know some stuff about aquarium equipment and its limits but I've never tried to pressurize a vessel with one of those. I'm not saying it can't be done but you may want to do some tests with your specific pump before going to the trouble of cutting wires and such.

Shame Boy
Mar 2, 2010

By "testing for leaks" are you going to use some pressure meter or something, or are you going to do the time-honored tradition of "drizzle soap on the outside and look for bubbles." I think this would be fine for the latter but I'm not sure if you could get enough of a pressure gradient to actually measure properly with an actual gauge.

Shame Boy
Mar 2, 2010

ate all the Oreos posted:

I'd like something akin to a servo, or at least something that can rotate 90 degrees, but that more or less holds its position once powered down. I assume this can be done with a worm gear of some sort but plugging "worm gear servo" into Amazon just got me a bunch of high-torque DC motors and whatever the hell this thing is. Any suggestions on what I can use?

Also I went ahead and "solved" this issue by realizing that actually I don't care if the thing in question slips when the power is off, but I'm still curious as to if something like that exists as a packaged thing or not.

Effective-Disorder
Nov 13, 2013

Brekelefuw posted:

This is not going to be used with water. I am building a machine that tests for leaks, and uses an aquarium pump to generate air pressure to find the leaks.
The pump is a pump rated for 10 gallon tanks. Very small.

I want a case mount switch, because I am building a case for the machine and would prefer to leave it plugged in all the time, and just have to switch the machine on from the case rather than from the power cable.

Here is the machine I am making.

http://musicmedic.com/products/repair-tools/leak-detection/musicmedic-com-leak-tester.html

Oh fine, ruin my fun. I was looking forward to stories about cooked fish.

Generally much of the safety stuff I said still applies, look for a switch with appropriate ratings in terms of voltage and current for your application. SPST rocker switches, illuminated or not, come in all sizes and colors.

For stuff involving enclosures and mounting switches and grommets and dials and what not, this might help if you're not familiar:

https://www.sparkfun.com/tutorials/38

Does that about cover it, or did you have some more specific questions?

Brekelefuw
Dec 16, 2003
I Like Trumpets
Thanks guys, I'll grab a spst switch.

The pump will be hooked to a flow regulator, a fluid gage, and a magnahelic gauge, which is what gives me the reading.
Soap and water are great for finding out where the leak is after you know there is a leak.

You don't need much of a pump to do the job. If I need to get a bigger one, that's fine, but the pressure is extremely low for these kinds of machines. You can hardly feel the air coming out of the tube when it's running.

ekuNNN
Nov 27, 2004

by Jeffrey of YOSPOS

ekuNNN posted:

How do you figure out the needed current for a whole bunch of servo motors? Is there anything special youd need to think of or keep in mind?

So, remember a while back when I asked you guys about running hundreds of servos and you gave me lots of helpful info?

This is what it turned into:
https://www.youtube.com/watch?v=_Gs8gWRMS-o

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
That's loving awesome

Slanderer
May 6, 2007

ekuNNN posted:

So, remember a while back when I asked you guys about running hundreds of servos and you gave me lots of helpful info?

This is what it turned into:
https://www.youtube.com/watch?v=_Gs8gWRMS-o

Holy poo poo, that owns

Were those special waterproof servos, or did you modify normal ones?

ekuNNN
Nov 27, 2004

by Jeffrey of YOSPOS
Thanks guys :sun:

Slanderer posted:

Were those special waterproof servos, or did you modify normal ones?

I thought they were waterproof servos, turns out waterproof doesn't mean really waterproof in the servo world :v: So I waterproofed 600 servos using plastidip and sillicon grease. Apart from maybe 10 they have all held up for over a month under water by now, so it worked quite well luckily.

I looked up real waterproof servos later on and it turned out it wouldn't have been affordable to use those anyway. The current servos I use are €3.85 per servo, while submersible servos stuff are around €40,- :v:

ekuNNN fucked around with this message at 13:10 on Nov 3, 2016

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
That project is awesome. Great impact.

Collateral Damage
Jun 13, 2009

That's an awesome project ekuNNN, and now I understand why you needed so many.

How did you solve the servo controlling? Did you daisy chain a whole bunch of control boards, or end up with some bus solution?

ekuNNN
Nov 27, 2004

by Jeffrey of YOSPOS

Collateral Damage posted:

How did you solve the servo controlling? Did you daisy chain a whole bunch of control boards, or end up with some bus solution?

I used these 16-channel servo driver boards from Adafruit: https://www.adafruit.com/products/815 and daisy-chained 38 of them, controlled by a single arduino.

Stabby McDamage
Dec 11, 2005

Doctor Rope

ekuNNN posted:

I used these 16-channel servo driver boards from Adafruit: https://www.adafruit.com/products/815 and daisy-chained 38 of them, controlled by a single arduino.

Wow. You should post to Adafruit to let them know that their boards are awesome and can daisy chain that far. I would not have bet on it!

Collateral Damage
Jun 13, 2009

Yeah that's a good idea, I know they like to showcase cool stuff being done with their boards.

Shame Boy
Mar 2, 2010

I can't remember how you solved the power problem, but since I assume being a public installation means people are playing with it nearly all the time I'd drop back in at the end of the day or something and make sure the 10 million amps you're running through the whole thing aren't heating stuff up too much

asdf32
May 15, 2010

I lust for childrens' deaths. Ask me about how I don't care if my kids die.
At least it's water cooled.

ekuNNN
Nov 27, 2004

by Jeffrey of YOSPOS

ate all the Oreos posted:

I can't remember how you solved the power problem, but since I assume being a public installation means people are playing with it nearly all the time I'd drop back in at the end of the day or something and make sure the 10 million amps you're running through the whole thing aren't heating stuff up too much

I use two 300 Amp 5 volt power units, but those A values are based on every single servo having a hard stall all at the same time with a safety margin on top of that. In practice only a handful servos move at the same time. The whole thing surprisingly doesn't get hot at all, I was worried about that too.

Jamsta
Dec 16, 2006

Oh you want some too? Fuck you!

ekuNNN posted:

So, remember a while back when I asked you guys about running hundreds of servos and you gave me lots of helpful info?

This is what it turned into:
https://www.youtube.com/watch?v=_Gs8gWRMS-o

Dang that's sweet!

What software did you use, or write it yourself?

ekuNNN
Nov 27, 2004

by Jeffrey of YOSPOS

Jamsta posted:

Dang that's sweet!

What software did you use, or write it yourself?

I wrote it myself using Max/MSP and Arduino. A kinect takes a depth image. That's changed to a black and white image with as many pixels as there are servos. Then I just send a 1 and the servo number over Serial to arduino if the corresponding pixel is white, or a zero and the number is it's black. The arduino just monitors the serial communication and basically turns any incoming servo number to its' zero position if it's followed by a zero or to 180 if its' followed by a 1.

ekuNNN fucked around with this message at 18:51 on Nov 3, 2016

Stabby McDamage
Dec 11, 2005

Doctor Rope

ekuNNN posted:

I wrote it myself using Max/MSP and Arduino. A kinect takes a depth image. That's changed to a black and white image with as many pixels as there are servos. Then I just send a 1 and the servo number over Serial to arduino if the corresponding pixel is white, or a zero and the number is it's black. The arduino just monitors the serial communication and basically turns any incoming servo number to its' zero position if it's followed by a zero or to 180 if its' followed by a 1.

Do you plan to do a build log somewhere? It would be cool to have a deep dive of a nice, professional-looking project.

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

ekuNNN posted:

I use two 300 Amp 5 volt power units, but those A values are based on every single servo having a hard stall all at the same time with a safety margin on top of that. In practice only a handful servos move at the same time. The whole thing surprisingly doesn't get hot at all, I was worried about that too.

:lol:

That'll do it. The servo heat is handled by the water, for sure. Do you happen to have an ammeter on it? I'd be interested to see how much it draws during a full black->plastic image switch. I'll bet it's a lot less than you planned, because the servos are not working at max load.

Adbot
ADBOT LOVES YOU

Jamsta
Dec 16, 2006

Oh you want some too? Fuck you!

So I keep burning out DC fans, specifically sensored 12v CPU/case fans from PCs when I connect them to my variable DC supply.

I think I overvolted them a touch to 14v/16v for tens of seconds.

Are the +/- V tolerances for these types of fans really small and I've just burnt out the ancillary electronics and not the windings themselves?

Am I being a big dummy and I should leave them at the rated 12v, and not gently caress about with them?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply