Electronic Dividing Head using the Arduino

Discussion in 'Software and Programming' started by cfellows, May 21, 2012.

Help Support HMEM by donating:

  1. Dec 31, 2013 #101

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Pin 13 has the on board LED tied to it. Some digital pins have additional uses that allow them to work together to drive specific hardware but you can still use them (and pin 13) as an ordinary digital input/output.

    Also any of the analog pins can be used as digital I/o pins provided they are correctly initialized in accordance with the documentation. This means you may have more pins than you Think!

    I would try and use separate pins for the stepper parameters just in case you change your mind down the track. If you tie the pins together, be mindful the you don't exceed the maximum current that can be supplied. You could also consider tieing the pins straight to the arduino 5 volt rail to avoid using up any pins at all in your case.
     
  2. Jan 1, 2014 #102

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    You don't really need to use an I/O pin at all. You can just tie MS1, MS2, and MS3 to the 5V output from the Arduino. These pins don't draw any current to speak of, so you don't need to worry about overloading the 5V supply.

    Chuck
     
    geoff p likes this.
  3. Jan 1, 2014 #103

    Twizseven

    Twizseven

    Twizseven

    Junior Member

    Joined:
    Jul 9, 2012
    Messages:
    33
    Likes Received:
    6
    Chuck, Rod,

    Thanks for the quick responses. I had not realised I could connect the pins directly to the 5v and get same effect.

    Chuck, you show Reset an Sleep linked to each other, the Pololu site appears to show them linked and also connected to the 5v. What is the difference between these two approaches.

    You also show "Pulldown resistors" on your breadboard in your Post#13. What is the function of these and where are they connected. The DRV8825 schematic shows a 100microfarad electrolytic capacitor between VMOT and GND (across feed to stepper motor). Is this in your circuit?

    Forgive the simple questions, the last electronic kits I built were crystal sets and a two valve radio back in early 1960's.

    Thanks,

    Colin
     
    Last edited: Jan 1, 2014
  4. Jan 2, 2014 #104

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Colin, You need to research both the hardware and the Arduino documentation and you get the answers.
    1. reset and sleep are tied together in accordance with the Pololu documentation for the break out board Chuck used here http://www.pololu.com/product/1182

    2. The purpose of the pull down resistors is that digital circuits have an on or off state (eg 0 or 1, or 0v or 5v). If there are no clearly defined values, the voltage can float either way which can lead to spurious triggering of the logic values seen on the ports. By placing a resistor between the pin and the negative rail, the voltage on the pin is Pulled down to 0 volts when it is not receiving any signal. See http://en.wikipedia.org/wiki/Pull-up_resistor
    The alternative is to use a pull up resistor that pulls the signal up to +5V in exactly the same manner. The Arduino has pull up resistors on board which can be enabled within the software. I would just use these rather than external components. See http://arduino.cc/en/Tutorial/DigitalPins

    Think of Pull up and Pull down resistors as a defensive design measure that enforces a known value if nothing is connected to the pin in the same way as defensive programming methods provide error handling for an error that cannot possibly occur.... without Murphy's Law intervening.
     
    malcolmt likes this.
  5. Jan 3, 2014 #105

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    What Rod said. I think I later removed the resistors because they didn't make any difference one way or the other. The capacitor in their design was probably just reduce spurious noise, which, again, doesn't seem to be a problem.

    Chuck
     
    malcolmt likes this.
  6. Jan 4, 2014 #106

    ivanhoe161

    ivanhoe161

    ivanhoe161

    New Member

    Joined:
    Nov 25, 2013
    Messages:
    4
    Likes Received:
    0
    Hello Chuck,

    sorry to bother you but I have nil experience with Arduino's, however I have managed to actually copy and paste the program into the Arduino uploader, but at the bottom of the attempted upload into the Arduino a message in red comes up on the bottom which says;

    Liquid crystal does not name a type,

    and then under this, up comes 10 seperate lines' and a couple of these states,
    sketch_jan04a:3:Liquid Crystal does not name a type.Then under this, again
    sketch jan04a.ino:in function 'void step (int)': and then another 8 of these sketch things with different messages. Could you help with what I'm doing wrong please ?. I do realise my age is against me , however I would love to get this up and running. Regards Ed Steel
     
  7. Jan 4, 2014 #107

    vidio1

    vidio1

    vidio1

    Active Member

    Joined:
    Aug 9, 2011
    Messages:
    26
    Likes Received:
    2
  8. Jan 4, 2014 #108

    ivanhoe161

    ivanhoe161

    ivanhoe161

    New Member

    Joined:
    Nov 25, 2013
    Messages:
    4
    Likes Received:
    0
    Vidio1,

    after a lot of frustration and hair tearing out (didnt have much anyway ) I can report "SUCCESS" and I would like to say thank you for pointing me in the right direction. :)

    Regards Ed
     
  9. Jan 5, 2014 #109

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    So, Ed, how far along are you? Have you actually finished the dividing head or just gotten the software to compile and run or ...?

    Just interested...

    Chuck
     
  10. Jan 8, 2014 #110

    ivanhoe161

    ivanhoe161

    ivanhoe161

    New Member

    Joined:
    Nov 25, 2013
    Messages:
    4
    Likes Received:
    0
    Hi Chuck, sorry I've been a little slow in replying. I have a large rotary table ( about 340 mm )with out any plates and I chanced upon this thread started by yourself and thought what a great idea !. While I had heard of the name "Arduino" I had absolutely nil experience with them as you probably gathered with my earlier question. I have bought a Geko 210x, a 48v 7.5 amp power supply and a 570 oz-in nema 24 stepper with a dual shaft and I will try to get it all working in the near future. I'ts not as easy these days as it used to be because my wife has the dreaded dementia and a lot of time is needed to look after her which limits my time to do things I like. This will be a fairly slow build because of that but I will keep trying, a bit at a time. I'ts possible I may have to ask other stupid questions in the future and I hope everyone understands. Regard Ed.
     
  11. Jan 8, 2014 #111

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    No problem, Ed. Looks like you got all the materials you need. I'm available for any questions, no matter how seemingly trivial. I wouldn't say the Arduino is overly complicated, but, then again, I've worked in computers my whole life so my perspective is likely different from others. You will probably want to make some changes to the software such as number of steps per revolution and maybe the stepper speed. Happy to help when you come to that.

    Chuck
     
    malcolmt and gdanielhoracio like this.
  12. Jan 9, 2014 #112

    ivanhoe161

    ivanhoe161

    ivanhoe161

    New Member

    Joined:
    Nov 25, 2013
    Messages:
    4
    Likes Received:
    0
    Thanks Chuck , very much appreciated.

    Ed
     
  13. Aug 6, 2014 #113

    gld

    gld

    gld

    Well-Known Member

    Joined:
    Jun 18, 2009
    Messages:
    107
    Likes Received:
    33
    Something screwy going on with the math in this dividing head program. Hope you can explain.

    I have a 200 step stepper connected to a Geckodrive 210 10micro step driver.
    This makes 2000 steps per revolution.

    My rt is 90:1 that's 180,000 steps per revolution.

    Plug those number into the program for 1 division, and it comes out with 16608 steps.

    With some experimentation, I found 30,000 for 1 division works, but 35,000 will show 30536 for 1 division.

    :wall::wall::wall:
     
  14. Aug 6, 2014 #114

    SixSixSevenSeven

    SixSixSevenSeven

    SixSixSevenSeven

    Active Member

    Joined:
    Jul 11, 2014
    Messages:
    25
    Likes Received:
    3
    well he is currently using floating point math which could be the source of the issue (oh there are plenty of "fun" rounding errors in floating point math, never use it to track money, some bank tried that once and found that suddenly there was a defecit somewhere which eventually ended up being a floating point error). Otherwise I can't see any source for the error, and even if that was the case that is an unusually large floating point error.



    Did occur to me that a good improvement for this setup would be to add encoder feedback. It would both solve the manual lock issue mentioned in some of the first pages (internal step counter incrementing when locked and causing you to start again, with encoder feedback the microcontroller would be aware of whether the step was successful or not) and just add some general position sensing feedback, if it started to move while being worked on then the motor could be stepped back or forth to counter.
     
  15. Aug 6, 2014 #115

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    The problem is I used integer types for many of the variables, never imagining that values greater than 32768 would ever be encountered. Changing the variables to float seems to fix the particular problem you identified, but also seems to introduce some other issues. It clearly requires some further testing and debugging with float variables to accept values greater than 32768.

    Chuck
     
  16. Aug 6, 2014 #116

    SixSixSevenSeven

    SixSixSevenSeven

    SixSixSevenSeven

    Active Member

    Joined:
    Jul 11, 2014
    Messages:
    25
    Likes Received:
    3
    dunno how I missed that (probably to do with me using the specifically sized datatypes on microcontrollers and saving the plain short/int/long notation for windows and linux where an int is 32 bit not 16 as on arduino), switching to unsigned int or a long would alleviate that restriction.
     
  17. Aug 7, 2014 #117

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Chuck, an unsigned long would be a better choice which can count to 4,294,967,295 which should be enough steps for most! I would try and avoid floating point maths altogether as it will bloat the code and slow execution times....

    Also consider using casts in the maths eg

    unsigned long x = (unsigned long) ((float) y / (float) z));

    Other languages do type conversions for you but C is not forgiving in this regard so you have to tell it what you want.
     
  18. Aug 7, 2014 #118

    Swifty

    Swifty

    Swifty

    Well-Known Member

    Joined:
    Mar 6, 2012
    Messages:
    2,253
    Likes Received:
    818
    I've thought about making an electronic dividing head for cutting gears, but I have not the faintest idea what you people are talking about. Obviously electronics are not in my field.

    Paul.
     
  19. Aug 7, 2014 #119

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    702
    I used floating point numbers in the calculations to get proper rounding. Integers, unfortunately, just truncate making it hard to get repeatable results. I wanted to make sure that advancing the specified number of divisions would end up back at the exact starting point. I'm sure the code could be improved or expanded to make this work with a larger number of steps per revolution.

    Chuck
     
  20. Aug 7, 2014 #120

    Blogwitch

    Blogwitch

    Blogwitch

    Ex Bogstandard HMEM Supporter

    Joined:
    Dec 26, 2008
    Messages:
    3,697
    Likes Received:
    667
    Gender:
    Male
    Occupation:
    Retired Aeronautical Engineer
    Location:
    Crewe, Cheshire, UK
    Swifty,

    If you don't understand any of it, and have the cash, then this is what you need.

    http://divisionmaster.co.uk/divisionmaster.html

    I made mine from the kit with no real problems, just solder the components into the board and assemble as it says in the very good instructions, and it works perfectly.

    [ame]https://www.youtube.com/watch?v=hWpVdQDV4fw&index=11&list=UUbmnXOvtxx1wUp4fFjFLsfA[/ame]

    [ame]https://www.youtube.com/watch?v=P1ifPuImERA&list=UUbmnXOvtxx1wUp4fFjFLsfA[/ame]
     

Share This Page