Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 03, 2013, 12:15:43 am
@UkHeliBob:

I am planning on a conventional servo, but I need one that goes at LEAST 180 degrees.  360 would be nice, but isn't explicitly required.
2  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 02, 2013, 11:43:22 am
This is my first arduino project, and first electronics project to boot! (well, I lit an LED once using a battery, if that counts)

I started learning and bought my UNO in November- and March 1st it poured me an alcoholic drink!

Still a little to iron out (like the wheel code and mechanics) but overall I am extremely satisfied with the results.  I'll post a dedicated thread in a better area of the forum once it is fully completed. For now- thanks go out to all the amazing people on the forums here that have helped me in my toughest times on the project!

@ johncc: I already have those coded and wired in.  If you look closely at the picture above showing the computer- you can see the little switches on the right hand side. They will sit positioned next to each glass holster hole so when a glass goes in it depresses the switch. As far as the actual code mechanics of
Code:
if one glass,
Turn to glass location #1
Pour
Turn back to Return glass to user

if two glasses,
Turn to glass location #1
Pour
Turn to glass location #2
Pour
Turn back to Return glass to user

if three glasses,
Turn to glass location #1
Pour
Turn to glass location #2
Pour
Turn to glass location #3
Pour
Turn back to Return glass to user

Etc...

I have not written that part yet (partly because I don't actually have a servo yet)

Basically right now I just have the barbot printing to serial to inform me that it is in fact aware that switches are depressed, and it prints which glasses are in place (ie: "two shot glasses installed" "highball glass installed" "four shot glasses installed" etc) once I actually FIND a servo capable of what I need- ill start work on the "turn-pour-turn-pour" code mechanics
3  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 02, 2013, 04:30:25 am
Four pages of debate about math, and not a peep about the pictures!?  Guess I should've thrown a picture of boobs in there eh?   smiley-wink
4  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 01, 2013, 03:28:31 pm
Ah- fantastic!  So I will just make volume an unsigned long as well, and all should be solved!  I'll try that right away!

As for the video- I certainly will!  Here is a still picture or two in the meantime:

(NOTE:  this enclosure is ONLY for use while I build the full bar downstairs- none of it (except the faucet and skull) will be in the looks of the finished product.  I just spiffed it up with the paint so it wouldn't be such an eyesore while it sits upstairs in my kitchen.  Plus, I have a party every week on tuesday- and it makes people laugh to see R2-D2 with moonshine Xs on him  smiley-lol )






Here is what the effect lighting looks like while idle (I used RGB LEDs, so I can toggle this "default" color if I like)



And here is what the lights change to when pouring, to include the skull lighting.  Now, in the FINISHED BarBot, every LED you see here will be behind a skull, and the 7th skull (the one in this photo) will not be filled with liquid.  It will be positioned above the faucet sort of like it is now, and it will have the arduino and PCB inside of it- with all the wires coming down like a spinal cord.



Here is the arduino setup now- but once I have it exactly how I want it I will use Eagle to design and etch my own custom PCB for it, making it much smaller and more manageable (etching the PCB sounds fun!)



Last but not least- here is a mockup of the wheel that will hold your glass.  The lazy susan bearing I need is still in the mail- so this is just a prototype that isn't motorized (PLUS- I NEED to find a reasonably accurate servo motor that turns at LEAST 180 degrees, with enough torque to turn the wheel plus a glass of liquid... I haven't had time to really search for one yet- if you know of one, PLEASE let me know!) 

The coolest part of the wheel is the five slots for shot glasses.  When finished- the Barbot will count the number of glasses in the slots whenever a shot recipe is selected, and pour-rotate-pour-rotate until all inserted shot glasses are filled- thus being able to pour 1-5 shots at a time based on how many glasses you put in the wheel!  I am excited about that feature.



Hope you like the photos!


5  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 01, 2013, 01:26:57 am
WOW!

I got taken away on a short notice work trip, but I didn't expect to see three pages of replies when I returned!  You guys got way into it!

I am glad you spotted my folly with the = instead of ==, I'll fix that right away.

As for the suggestion that I should just pass delay(); an unsigned long- if you look at my code from page one, you will see that the array used AND the "pourdelay" ARE in fact unsigned long variables.  I am only hoping you can spot where I am overlooking something I am passing delay that isn't- as that would be an easy fix!

The discussion as to how delay works was a bit over my head, but what I pulled from it is that even though delay accepts an unsigned long variable, it still won't count past a regular integer?  (In the original post, I realized that 32 seconds alluded to it stopping after reaching integer length- I just hoped it wasn't true?)

So,if I follow discussion on the last page...  I should create a new version of the delay function, which will be able to count higher but slightly less accurately?  Let me know if I understood that incorrectly?

P.S.  Due to the pumps I am using and the vertical distance being covered by the lines, the pour is very slow.  I'll fix that later by ordering bigger pumps... maybe... it's still more convenient than digging out all the ingredients in a seven ingredient drink...- but for now anyways pour times can easily exceed 32 seconds even for regular sized drinks.  Sorry, Goforsmoke- no giant drinks here  smiley-wink

Additionally, with the power supply I have used- only one pump is capable of running at any given time.  The idea that I should have the computer checking other sensors or running other pumps or doing anything at all whilst pumping isn't something I am interested in incorporating.  The code already keeps track of every bottle and alerts me when they reach a certain level- which is all the help I require from it.  When it is pouring- that's all I want it doing.

If I can fix this delay problem- I will be in business here.  Fingers crossed that I can!
6  Using Arduino / Programming Questions / Re: Delays and unsigned long on: February 27, 2013, 05:17:59 pm
@ Maltelec:

I really would rather use Delay();

I don't want my CPU doing anything else while it's pouring, so delay works fine for me.  Plus, once this is up and running it will never be unplugged- so when millis rolls over in 72 days I don't want to be surprised by any implications that could have anywhere in the miles-long code I wrote.  Delay(); is simple, and doesn't rely on the 72-day long millis clock.

If I can make it work using delay();, I would like to.
7  Using Arduino / Programming Questions / Re: Delays and unsigned long on: February 27, 2013, 05:03:19 pm
From the website link Goforsmoke posted:

Quote
Thus, at a CPU speed of 1 MHz, delays of up to about 262.1 milliseconds can be achieved.

Since the uno is 16 Mhz, does that mean it can only delay for 4,193.6 milliseconds?  That can't be right.  You said to guess which one delay(); is, but I am not sure either one of them is?  How can I use that in my situation (see above code)?
8  Using Arduino / Programming Questions / Re: Delays and unsigned long on: February 27, 2013, 04:57:14 pm
Firstly, way up top in the code is this:
Code:
byte drinkozarray[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
byte drinkozprevarray[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned long pumpcompensatearray[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

Then there is "pouramount" which is used inside of "countandpour", which is then used inside of "pour"

Here is "pouramount":
Code:
 
 
void pouramount(byte drink, byte &previousdrink, unsigned long &runtime, byte volume)
{
unsigned long pourdelay = 0;

 if(drink < previousdrink) {
    previousdrink = 0;
    runtime = 0;          //when I refill the bottle and reset the count, this should reset the added runtime too.
  }
    else if(drink >= previousdrink) {
    previousdrink = drink;
    runtime = runtime + 925 * volume;  //this should add 925ms for each full oz poured to account for lack in bottle backpressure
  }                                   // seeing as every 10 qtr oz I pour, the rate drops by about one qtr oz
 
 if (volume >= 1, volume < 32){
  pourdelay = volume * 9250;
  delay(pourdelay); //9250ms = one quarter ounce.  This way, when I type in my ingredients, I just tell it how many quarter oz to pour
 }
 
else if (volume = 0){
  delay(1157);               //This gives me a way to specify a "dash", or 1/8th ounce in a recipe, without getting all math crazy
  runtime = runtime + 116;
}
else if (volume = 33){
  delay(3053);
  runtime = runtime - 305250;  //This gives me a way to specify a "third", or 1/3rd ounce in a recipe, without getting all math crazy
  runtime = runtime + 305;
}

delay(1250);  //this account for the pump spin-up time, while it's pumping liquid but none has yet come out of the nozzle
  delay(runtime); //this should add the extra backpressure acounting time to the runtime of the pump.

}

Here is countandpour:
Code:
void countandpour(byte array, byte volume) {
    if(volume >= 1, volume < 32) {
      drinkozarray[array] = drinkozarray[array] + volume;
    }
    else if(volume = 33) {
           drinkozarray[array] = drinkozarray[array] + 2;
    }
   
   pouramount(drinkozarray[array], drinkozprevarray[array], pumpcompensatearray[array], volume);

}

and last but not least, here is "pour":
Code:
void pour(byte array, int drink, byte volume)
{
  switch (drink)
  {
  case vodkas:
    digitalWrite(latch, 0);
      lightredpour1();
      pour_vodka();
    digitalWrite(latch, 1);
      countandpour(array, volume);
    break;

  case rumlts:
    digitalWrite(latch, 0);
      lightredpour1();
      pour_rumlt();
    digitalWrite(latch, 1);
      countandpour(array, volume);
    break;

//etc, etc...

You'll notice that "pour" also calls "pour_vodka();" and "lightredpour1();"
The function with the liquor name just looks like this:
Code:
void pour_vodka()
{
  shiftOut(data, clock,MSBFIRST, shiftoutarray[1]);
  shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
  shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
  //vodka = vodka + volume;
}

void pour_rumlt()
{
  shiftOut(data, clock,MSBFIRST, shiftoutarray[2]);
  shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
  shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
}

//etc, etc...

And the "lightredpour();" function just controls effect lighting, changing it to red lights while pouring.


NOW to my original problem, which occurs inside "pouramount();"
I try to feed delay
Code:
unsigned long pourdelay = 0;
pourdelay = volume * 9250;
delay(pourdelay);
and if the result is anything over 32k, the delay just never ends.  What is going on?  (Additionally, I know my code is probably sloppy... I am still a dummy at this and I am working on that.  Please try to stick to the delay problem I'm having instead of the ugliness of my code- as I would like it to work first before I spend lots of time optimizing something that doesn't work in the first place)

Oh and for those of you that have been helping me since the beginning- IT WORKS!  I have booze in it, and it is pouring recipes!  Until I fix this delay issue though, if a pour has to last longer than 32 seconds- it just pours until the end of time LOL.
9  Using Arduino / Programming Questions / Delays and unsigned long on: February 27, 2013, 04:25:13 pm
Hi guys!

I am feeding a delay(); an unsigned long variable- but it acts funny with anything over int size (32k)

Do delays have trouble with large numbers that won't fit in an int?

(by "acting funny" I mean that if the number I feed it is over int size, it delays forever instead of stopping. I need it to delay anywhere between 3 seconds and 200 seconds. I am hoping to accomplish that simply by using an unsigned long- but it never stops delaying if I try anything over 32 seconds)

Thanks in advance!
10  Using Arduino / General Electronics / Re: Servo Motor Experience? on: February 14, 2013, 10:53:59 am
Quote
-and preferably will run off a 6v 300mA power supply.

Yeah, the power supply matching isn't required, just preferred if possible since that's what I have handy.  It is worth it to note, however, that the Traxxas motor I just returned was pumping out around 125 oz-in and ran just fine off 6V 300mA.

If you have suggestions and they don't match my power ratings- that is cool too.  Those ratings are just ideal for what I currently have is all.

EDIT:  Truth be told, I didn't actually test how much torque it was putting out, those were just the advertised max values.  It very well could've died if put to the test with only 300mA to work with.  It SEEMED like it was working well, however.
11  Using Arduino / General Electronics / Re: Enable more power in usb port on: February 14, 2013, 10:25:31 am
If you can, search online for the specs of your servo.  Find out it's electrical specs under load/from stall, then return the power supply you bought and use the money to grab a power supply that matches the values you saw on the spec sheet.

EDIT:  I find it ironic that I am posting servo motor advice for you here, while simultaneously having a post right next to yours looking for folks with servo motor experience to help answer questions I have.  LOL.  As such, please take my experience level into consideration when following my servo motor advice- I would hate to hear I steered you wrong!
12  Using Arduino / General Electronics / Re: Servo Motor Experience? on: February 14, 2013, 10:19:38 am
Oops! No, oz-in is what I meant.  Haha, that's just a jet mechanics old habits shining through!

I'll edit the original post to fix that.
13  Using Arduino / General Electronics / Re: Enable more power in usb port on: February 14, 2013, 10:15:04 am
Sure!

Here is a little schematic I found using a transistor and a DC motor.  It uses a transistor that does not have it's own internal diode, which is why it is in the schematic.  This is the same way I started wiring my pumps before I bought transistor arrays (chips with 8 transistors + diodes)

Be sure to check the datasheet of your transistor, because your emitter and collector may be on opposite leads as this schematic, and it may even have it's own diode.

14  Using Arduino / General Electronics / Re: Enable more power in usb port on: February 14, 2013, 10:04:11 am
I've learned a cheap little transistor will do the trick!  Just make sure to read the datasheet for your servo, and the transistor you want to use, to make sure you are matching the transistor adequately to the application.  Then route your external power source through the transistor, and trigger it with an arduino pin!

Viola!

EDIT:  I don't have tons of experience with servos...  I have been working more with DC pumps, but this is what I do for them and it works great!  Since servos have 3 leads coming off them, maybe you can just power them directly from an external source?  That is a bit beyond me at the moment actually, and I didn't want to steer you wrong with my inexperience.  So, this is my disclaimer lol
15  Using Arduino / General Electronics / Servo Motor Experience? on: February 14, 2013, 09:59:10 am
Hi Guys,

I am looking for a
-high torque (100 or more oz-in, the more the better) accurate servo motor
-that turns at LEAST 180 degrees (360 would be a bonus, but not required.  Anything past 360 is un-useable travel for me)
-and preferably will run off a 6v 300mA power supply. 
-Speed is not a factor.

I am inexperienced in servo motors, and I bought a Traxxas motor off amazon that I thought fit the bill- and it DID everything described above EXCEPT it only traveled 90 degrees, which is no good to me.  I returned it to save myself the $30, but now I am looking for another product.  After reading up on servo motors, I found out that 90 degrees is apparently the norm...  Ooops.   smiley-roll-blue

I am sure that the right motor is out there for me SOMEWHERE though... right?

I am hoping maybe someone here has some servo experience and can guide me in the right direction.  I have done a lot of online searches, but I was SO SURE last time and it turned out to be a non-starter- so I think seeking a little advice from here isn't such a bad idea!


EDIT:  inch-pounds... I'm silly.  Changed to oz-in
Pages: [1] 2 3 ... 7