Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 02, 2013, 07:43:56 pm
Seeing as once the code is up and running the MR pin works perfectly as advertised, even when the code is altered to specifically test it's function, I am going to conclude the wiring is correct and the chips are in working order (as far as MR is concerned, anyway.)

I am going to move things around and try the OE/pull-up resistor method next.  Results to follow.
32  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 02, 2013, 05:51:44 pm
Hmm...  pull down 10k resistors on each MR line, with a pin controlling when it goes high, STILL does not alleviate random lights from coming on when power is first applied.

Why aren't these solutions working?  Should I be using different sized resistors?

The only thing I haven't tried now is a pull-up resistor on the output enable lines...  But judging by these attempts I am having little faith that it will work?  What I don't get is, on Nick Gammon's schematic he lists a single 10k pull down.  He says it will stop erroneous inputs from coming in during power-on.  This leads me to believe that it works for him.  Why didn't the same method work for me?

Then I used pull-downs on the master reset lines, and controlled the output with pin 5.  This didn't stop the erroneous inputs, either.  (granted, with this setup, the inputs would go away as soon as the code initialized and brought MR low, but by this time I would already have 8 different types of booze splattered all over my counter...)

Maybe I am just doing something wrong...  I'll quad-check it...

...seems to be correctly wired.  I don't get it.  Should I have to use this many outputs to control this phenomenon?  These pull-down resistors should have done the trick, right?
33  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 02, 2013, 04:41:11 pm
I did, but haven't implemented it yet.  Just wanted to share the story  smiley
34  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 02, 2013, 03:00:40 pm
Also of note:

Yesterday while I was out of the house- the house lost power!  How ironic that we JUST disscussed this in the thread!  And just as we discussed- when power came back on a bunch of random lights came on- causing two liters of water to be pumped into a cardboard box full of clothes and books  smiley-eek-blue

I returned to find a mess, but it could've been WAY worse if a finished barbot with 24 bottles of booze was connected!  I really need to fix this glitch before pressing on any further lol
35  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 02, 2013, 02:51:45 pm
EEK!

It sounds like this auto ink creation could use a little less "auto" !
36  Using Arduino / Programming Questions / Re: Triple Shift Register question on: February 01, 2013, 11:44:43 am
Johncc:

Whoa, blowin my mind.  I have been meaning to learn about structures... perhaps now is the time!  I'll try to dig up a tutorial or two so I can wrap my mind around the idea you just laid down.  It seems like a cool solution.  Now to just understand it fully LOL.  I'll get on some tutorial action after work tonight!

Nick Gammon:

I tried the 10k pull down resistor on the latch pin like the diagram shows, but it still lights up random lights on first power-on...

dHenry:

Ah yes... you are correct about that.  And I see why now.

37  Using Arduino / Programming Questions / Re: Triple Shift Register question on: January 31, 2013, 11:57:08 am
Thanks for the replies!

NickGammon:

I'll post my build of it with code here once I'm done!  That way everyone can have one smiley

SPI transfer is now a new arrow in my quiver, and as Crossroads said, if it is less work for the software I am all over it, since my code is already so bloated with crap for it to do.

After reading the link you provided though, I have two burning questions:

1. That 10k pulldown resistor on the "D10"/"SS"/"Slave Select" pin...  is that pin 11, 12, or 14?  I would LOVE to put that on my circuit- so if the power should go out and come back on, my BarBot won't start arbitrarily pouring booze on the ground!

2. Where do you buy your ribbon cable good sir?  I would very much like to get my hands on some like yours.

UkHelibob:

What you suggested is exactly what I am currently doing actually, and it is very clunky for my purposes.  Let me elaborate.  My current code is as follows:

Code:
void pourcount(const byte shift1, const byte shift2, const byte shift3, byte ozcount)
{
  digitalWrite(latch, 0);
  shiftOut(data, clock,MSBFIRST, shift1);
  shiftOut(data, clock, MSBFIRST, shift2);
  shiftOut(data, clock, MSBFIRST, shift3);
  digitalWrite(latch, 1);
  Serial.print(F("pumped "));
  Serial.print(ozcount);
  Serial.print(F(" qtr oz, about "));
  Serial.print(ozcount / 4);
  Serial.println(F(" full oz."));
}
void pour(const byte shift1, const byte shift2, const byte shift3, byte ozcount, const int oz)
{
  ozcount = ozcount + 1;
  pourcount(shift1, shift2, shift3, ozcount);
  delay(oz);
}

(Notice, I AM learning from the previous suggestions to my threads, albiet slowly.  I have not incorporated arrays yet... I am still learning how they fit into my master plan.  Soon...  Soon...)

Anyways, with the above code my usage of pour looks like:

Code:
    //////////////////////// 1.Vodka on the rocks (lemon twist)  /////////////////////////////////////

    if (packBuff[0]== 'V' && packBuff[1]=='O' && packBuff[2]=='O' && packBuff[3]=='N')
    {

      pour(vodka1st, vodka2nd, vodka3rd, vodka, oh); End();
   
            udpWrite( F("Vodka on the rocks- Serve with a lemon twist.  Enjoy!"));

    }


That will get very tedious and lame when pouring drinks with seven or eight ingredients. (by the way, the "oh": above is my delay time, which stands for "one half ounce")  I would LOVE to find a way to make the code work like this:

Code:
pour(vodkashift, vodka, oh);

// or even BETTER would be to do

pour(vodka, oh);

//where "vodka" in this case is a function that contains both vodkashift and the const int vodka.
//however, I have no idea how to tell a function I am creating, that I am going to give it
//a random function name as an input condition...  If what I have just described doing
// (passing a function another function as an input condition) Please tell me how!

Crossroads:

Giving all three separate latch controls IS an attractive idea...  However then I would need to pass which latch pin into my input conditions of pour() right?  Or could I make pour() do all the work and deduce which latch pin to utilize by using if() then() else() logic?

thanks again guys!
38  Using Arduino / Programming Questions / Triple Shift Register question on: January 31, 2013, 01:39:13 am
Hello again everyone!

Quick question-

Is it possible to send info across three shift registers using only one "shiftout"?  It's not is it?

I have LEDs currently connected to each output on the 74HC595s for a total of 24 lights, and I need to light only single lights at a time, on command.  Currently, if I wanted to light only the 5th LED in the middle register I am doing something like this:

Code:
digitalWrite(latch, 0);
  shiftOut(data, clock, MSBFIRST, 0);
  shiftOut(data, clock, MSBFIRST, 16);
  shiftOut(data, clock, MSBFIRST, 0);
  digitalWrite(latch, 1);

and I suppose what I am hoping for is a solution more like this:

Code:
digitalWrite(latch, 0);
  shiftOut(data, clock, MSBFIRST, 0, 16, 0);
  digitalWrite(latch, 1);

Would it maybe work if I used an array?  So possibly...

Code:
byte shiftarray[] = {0, 16, 0};

for (byte i = 0, i < 3, i++) {

  digitalWrite(latch, 0);
  shiftOut(data, clock, MSBFIRST, shiftarray[i]);
  digitalWrite(latch, 1);

}


Quite honestly, I have only just begun to grasp arrays, so maybe I am way off base.  Thanks in advance for any help you are able to provide!

As a side note, a few of you have been helping me tremendously along my journey and I just wanted to let you all know I am making lots of progress with the BarBot!  I now have all of my pumps and check valves- and I already have had it take an order over wifi from the iPad, and pour precise amounts of liquid!  Granted, it was colored water and not actual booze yet...  but it works anyways!  I picked up some transistor arrays too (so cool they make these!  I was planning on having to individually diode/resistor/transistor each one separately... )  And I picked up a big jug of Ferric Chloride to etch my own PCB when the time comes- that sounds fun! (I'm sure it will take a bit of practice though lol)

I gotta hit the sack for now, but I'll check back in the morning!  Thanks Guys!
39  Using Arduino / Programming Questions / Arrays, pointers, classes, and structs on: January 18, 2013, 08:16:36 am
Hello again everybody!

I am just about to run out the door for work, but I wanted to "poll the audience" real quick.

In a previous thread, my eyes were opened to arrays and what they might be able to accomplish for my particular project.  I read up on them as best I could, saw a couple examples, and made a few simple sketches of my own to play around with how they work.  I still don't think I quite grasp it, but I am getting there at least.

A couple of folks (Johncc and Cr0sh, to name two) instructed me to take a deeper look into arrays as they pertain to arrays of structs and classes, and using arrays and pointers together.  You would think there would be a million great tutorials about arrays of classes, arrays of structs, and arrays using pointers out there- but I just can't seem to find any!

Anyone have any useful links or knowledge of where I can learn about this stuff?  I read everything (I think I have anyway!) about it I could find on the "playground" and "learning" areas of arduino.cc already... I couldn't find anything that discussed what I am specifically looking for.  Google didn't seem to be much help either- perhaps I am searching with the wrong verbage...

Any help you can provide will be greatly appreciated!
40  Using Arduino / General Electronics / Re: Twisted Transistor on: January 16, 2013, 11:38:13 pm
ok...  I think a lightbulb just went off in my head about how a transistor works...  So, the current from the base has to flow through the transistor as well, and thus needs a path "home" (to GND) just like the external source.  As the "switch" current from the base moves through, it opens the door for the external current to move from the collector to the emitter, so to speak?

I think I get it now?

Thanks for your reply.. it was an "AHA!" moment for me
41  Using Arduino / General Electronics / Re: Twisted Transistor on: January 16, 2013, 11:31:14 pm
So should I run a jumper from the arduino GND to the external source's GND?
42  Using Arduino / General Electronics / Twisted Transistor on: January 16, 2013, 11:20:19 pm
Hello again everyone, I have returned with another head-scratcher.

I am trying to use my PN2222A transistor as a switch so a small liquid pump can run off an external (not from the Arduino) power source.  My pump runs like a champ when hooked directly to it's external (6V 300mA) power supply, yet the transistor switch circuit will not pass any juice through when triggered.  Sounds like a messed up circuit you say?  That's what I thought... but when I disconnect the external supply and instead connect the 5V and GND from the Arduino to the circuit the transistor passes the signal right along no problem...  So the circuit is working correctly when power from the arduino is used, but not when my external source is used.

I checked the data sheet for the PN2222A, and 6V 300mA is well within it's operating range.  I also noticed that the little wiring diagram I was using had emitter and collector mixed up, so I fixed that in the circuit.  I have also swapped transistors just in case the first one was acting funny... no dice.

Why will my transistor and circuit pass the Arduino's power through, but not my external source?

(picture of my little wiring diagram included, as well as the very simple test sketch I have been using to try to debug this problem)

In the picture below, the leads I am connecting to my external source are the ones labeled "to 5V" and "to GND", and I am using the capacitor as well.

43  Using Arduino / Programming Questions / Re: Too many "if" statements? on: January 03, 2013, 01:44:14 am
Johncc and Dc42:

I tried it, and it worked without flaw.  Three days ago I had 100 free RAM, now, with the exact same functionality (and MUCH cleaner code I might add) I have 1,583 free RAM.

I leave tomorrow on a two-week business trip, but when I return I'll be jumping right into arrays & pointers, looking into how to store these strings on the Ethernet shields SD card instead of flash (might come in handy), and possibly making it so that all of my pumps to work under one function.

Possibly with something like this:

Code:
  void delaytime(int del)    // to be used in the "liquid();" function below... this will determine how long the pump runs ie. how much liquid is poured
 {
  if (del = 125);{    // a "dash"
 delay(375); }
   if (del = 25);{    // 0.25oz
 delay(750); }
   if (del = 33);{    // 0.33oz
 delay(1000); }
   if (del = 5);{     // 0.5oz
 delay(1500); }
   if (del = 75);{    // 0.75oz
 delay(2250); }
   if (del = 1);{     // 1oz
 delay(3000); }
   if (del = 15);{    // 1.5oz
 delay(4500); }
   if (del = 2);{     // 2oz
 delay(6000); }
 }
 
  void vodka()          //one of these for each liquor, to be used in the "any function" input condition below
 {
     
  shiftOut(data, clock,MSBFIRST, vodka1st);   //once I learn arrays this may not be neccisary... we'll see
  shiftOut(data, clock, MSBFIRST, vodka2nd);
  shiftOut(data, clock, MSBFIRST, vodka3rd);
 
 
 }
   void liquid(any function, byte &amt, byte x, byte oz)  // I don't REALLY know how to make a functions input condition another function yet...
  {
    digitalWrite(latch, 0);
    any function();                   //  for example, vodka(); or cola(); would go here. I am not sure how yet though
    digitalWrite(latch, 1);
  Serial.print(F("(byte &amt) has now pumped "));
  Serial.print(byte &amt);
  Serial.print(F(" quarter ounces, or around "));
  Serial.print(byte &amt / 4);
  Serial.println(F(" full ounces."));   
 
    byte &amt = byte &amt + oz;  //for counting 1/4 ounces
 
  delaytime(x);
  }
 
 
  // called like this:
 
  liquid(vodka, vodka, 75, 3);  liquid(cola, cola, 5, 2); liquid(orange, orange, 2, 8);

Obviously the code above is just an example of an idea I'm beginning to form and was not intended to be any sort of working code.

It's late, however, and I have a big trip starting tomorrow- so I am going to call it a night.  Thanks again for all of your help- these last few days have taught me a ton.  You guys are the best.  You haven't seen the last of me  smiley-wink
44  Using Arduino / Programming Questions / Re: Too many "if" statements? on: January 02, 2013, 12:56:19 am
GoForSmoke:

That sounds like a plan.  I'll jump into learning me some of this array magic as soon as I can.

Johncc:

The code works brilliantly!  It doesn't seem to free up memory space- but it doesn't take up any extra either, AND it sure makes my warning blink section MUCH more manageable.  It's fantastic!  And thanks for clueing me in about the &amt...  knowing that helps me understand how it all works.

As for the app, it's called "Ardumote" and it is available on the app store.  The website is broken (links don't work) but I have the URL to the tutorial that explains how to set it up, and I also have an example sketch file if you are interested.  Despite the website for the app being complete garbage- the app is actually fantastic and the developer is VERY responsive to email.  I have emailed him twice with questions/issues and both times he emailed me back with answers/sketch files within the hour!

Question on a different topic:

Do you know of a way to make

Code:
Udp.write(F("Amaretto Mist- Serve with a lime wedge.  Enjoy!"));

work just like

Code:
Serial.print(F("Amaretto Mist- Serve with a lime wedge.  Enjoy!"));

?

I looked in the core files for a "write.h" file... but when I didn't find one I took a look in the EthernetUdp library folder... not there either.  In fact there aren't ANY .h or .cpp files in there...  weird.

ALTERNATIVELY- can the Udp.write send a string instead?  (I can't seem to get it to.)

For instance, something like this:

Quote
      FLASH_STRING(AMON, "Amaretto Mist- Serve with a lime wedge.  Enjoy!");

 
      Udp.beginPacket(iPhoneIP,iPhonePort);
      Udp.write(AMON);   
      Udp.endPacket();


In this way I can store all of my text snippets in flash memory- when I did a test removing only these text snippets from the sketch- it saved me TONS of RAM.  It sure saved me a bunch when I did it for these:

Quote
void water1()
{
  digitalWrite(latch, 0);
  shiftOut(data, clock,MSBFIRST, water1st);
  shiftOut(data, clock, MSBFIRST, water2nd);
  shiftOut(data, clock, MSBFIRST, water3rd);
  digitalWrite(latch, 1);
  water = water + 4;
  Serial.print(F("Water has now pumped "));
  Serial.print(water);
  Serial.print(F(" quarter ounces, or around "));
  Serial.print(water / 4);
  Serial.println(F(" full ounces.")); 
  delay(o);
}




Or, like a previous poster had alluded- do you think putting these lines of text into flash memory would be a waste of my time to pursue?
45  Using Arduino / Programming Questions / Re: Too many "if" statements? on: January 01, 2013, 08:00:20 pm
Jacksac67:

Awesome idea for a quick grab at some memory.  I changed a whole bunch of my integers and bytes to const and that freed up about 100 in memory.  THAT, when combined with using the flash library to move all of my serial.print messages into flash memory, brought me from 107 memory free, to 771! (I have a small library running constantly printing my available memory- strictly for debugging purposes while I build the program- it won't be in the final version).  I would LIKE to see if I can alter my Udp.write header file like I modified my print.h file, to accept the F macro as well.  As a gentleman mentioned earlier though- I very well might be barking up the wrong tree with the entire idea of using the flash library to begin with...  hmmm

Judging by other's suggestions though- changing all these bytes to const is a temporary measure as it seems soon I will be building some fancy arrays to handle many of these integers?  Thanks for the knowledge about it- I'll be keeping that trick in my hip pocket!

Cr0sh:

The reason the program is printing out to the iPad (i know it SAYS iphone, but it's not, I am running the program from my iPad) instead of sending a small code for the iPad app to interpret into the intended line of text is that I am using an arduino interface app on the iPad that I didn't design, and it doesn't come with any feature like that.  All it has is a bunch of configurable buttons strictly for sending info out, and one monitor area for printing messages that come in, exactly as they arrive.  The app is VERY handy and awesome, but translating incoming messages into something else do display just isn't something it was designed to do.

Johncc:

Code attached!  You'll find the functions "definition" at the VERY bottom, and you'll find where I use the function under the WARNING LIGHTS header, under vodka.

GoForSmoke and Johncc:

Wow.  This stuff looks ideal (still a wee over my head, but once I get my hands dirty in it I'm sure it will become more clear)  You have made it obvious that I need to completely re-design all my crazy variables.  I am going to start by directly copying some of your examples, googling an array tutorial for some down-n-dirty know-how, and seeing if I can make some sense of it all.

Just for fun, here is a quick snapshot of the iPad control screen.  It is a work in progress still, but the general idea is there:

Pages: 1 2 [3] 4 5 ... 7