Author Topic: Limit switches  (Read 2921 times)

Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Limit switches
« on: April 28, 2014, 04:05:48 AM »
Hi Gabriel,
if i manual move my machine to sunrise position before I power the machine on, it seems to track the sun the hole day. If I don't do that, the machine starts up just on his actually position. Both limit switches where never triggered.
I use so far two little stepper motors which driving my assembly directly and my motor configuration is
{0 , 1  , 1 , 1 , 0 , 0 , 0 , 0 , -1 , 1 , 1  ,  0 ,  0  ,  0  ,   0  , -100 , -120  ,  -1   , 120  , 100};

What a kind of stupid fault I have done now?   ;D


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Limit switches
« Reply #1 on: April 28, 2014, 04:30:40 AM »

I don't see anything with these settings that would cause this to happen. What I would do is instead of using -100 and -120 use -100 and -100 like this.
{0 , 1  , 1 , 1 , 0 , 0 , 0 , 0 , -1 , 1 , 1  ,  0 ,  0  ,  0  ,   0  , -100 , -100  ,  -1   , 120  , 100};
I don't think that would cause your problem, but it is best to use the same value for these two settings.

Does the machine look for the limit switches when you first turn on or reset the Arduino? If not then are the below two settings still showing 1000000 (default setting)?
Code: [Select]
  //the maximum number of steps the machine(s) will take when resetting
  long altitudeMax = 1000000;
  long azimuthMax  = 1000000;
If that's the case then I would suspect a hardware problem not a software one. Are you sure you wired your limit switches normally open?


Paul L

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Limit switches
« Reply #2 on: April 28, 2014, 07:57:34 AM »
I'm guessing like Gabriel mentioned, that you may have mistakenly wired your limits as normally closed(NC) rather than normally open(NO).  If this is the case, when the machine resets, it checks limits, and automatically thinks that it's hit them.  I usually check mine with my multimeter before I hook everything up since I often use microswitches scavenged from other devices and never know which is NC or NO.   

Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Re: Limit switches
« Reply #3 on: April 28, 2014, 08:06:13 AM »
After changing these values nothing changing at all as you expected. Limit Switches where connected normaly open.
Just to be sure to have my driver boards connect the right way -  are the weiring instruction in SunTrackerCircuit3_bb.pdf applicable to  my EasyDriver 4.4 board? They seem to be identically.

and Paul thanks for your reply.
This was the first I checked with a multimeter. There was never power on pin 7 of the Arduino - if I trigger them manually it is.

Paul L

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Limit switches
« Reply #4 on: April 28, 2014, 08:43:20 AM »
Hey Wolfgang,

Hmmm, strange.  The SunTrackerCircuit3_bb.pdf diagram should work fine with the EasyDriver - I've actually used it before.  What is your moveAwayFromLimit value set as?  If it's low (2 degrees or so) you might want to set it higher (~20 or more).  That way, if the limits are actually being triggered at the wrong time for some weird reason, you'll be able to see it easily.  Barring a limit switch miss-wiring, I'm afraid I'm out of my league in helping you!   

Paul


Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Re: Limit switches
« Reply #5 on: April 28, 2014, 10:59:43 PM »
Paul, just as I wanted to check your recommendation, one of my driver board blow up and I have to wait till I get another one.
Wolfgang

Paul L

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Limit switches
« Reply #6 on: April 29, 2014, 08:09:40 AM »
Hey Wolfgang,

    Sorry to hear that!  I did the same thing once and fried a Big Easy Driver when some of my wires came loose from their terminal screw blocks.  Now I make sure they're really secure!  Once you have your new driver board and you've tried out my suggestion, give us a shout back! 

Cheers!

     

Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Re: Limit switches
« Reply #7 on: April 29, 2014, 02:51:42 PM »
Hi there,
after blowing up a driver board, I had a look at the Heliostat program. In the past I had a little experience with Delphi, programming the Arduino is completely new to me. I don't no, if I catched the bug, but there is one thing in the MoveMachine.ino which could be the reason, why my machine didn't reset.
The variables "dif" and "NumberOfSteps" where located after the function 'findLimits' which needs these variables. I switched the positions and Serial Monitor tells me a difference Angel and a Number of Steps
used for calling the function 'MoveTo Position'.

Is the different calling of these function intended?
 !!!! if (altOrAz==2){moveToPosition(1,  0, (NumberOfSteps));}//Moves motor away from limit switch!!!!
  if (altOrAz==1){moveToPosition(1,  (NumberOfSteps), 0);}//Moves motor away from limit switch   

Wolfgang








Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Limit switches
« Reply #8 on: April 29, 2014, 06:31:22 PM »
I wouldn't bother digging into the program. I'm like 99.999999% percent sure there's nothing wrong with it. The machine reset is one of the few things that has worked reliably from the very beginning. Also, if there was something wrong with it everyone would be having this issue.

The problem may have something to do with your particular settings. To rule it out, have you tried redownloading the original program and running it on the Arduino to see what happens? http://www.cerebralmeltdown.com/arduino-sun-tracking-heliostat-program-download-page/

When first uploaded, the program should move the az motor in one direction until the limit is pressed. After it is pressed, the az motor should stop and then move in the opposite direction for a short distance. Once this is finished, the alt motor will do the same thing.
If this doesn't happen then it must be something to do with the hardware. If this does happen then it must have something to do with the settings.

Here is the PDF for wiring the Easy Driver. http://cerebralmeltdown.com/forum/index.php?action=dlattach;topic=335.0;attach=419
It was originally posted here. http://cerebralmeltdown.com/forum/index.php?topic=335.msg1601#msg1601
It is wired slightly different from the other driver board in that you don't do the 5V connections.

Do you actually have your machine built and tracking the sun? Just curious.

Simon

  • New Member
  • *
  • Posts: 3
    • View Profile
    • My LinkedIn profile
Re: Limit switches
« Reply #9 on: April 29, 2014, 11:13:01 PM »
Gabriel, this is probably a total 'red herring', but I had a problem when using the direction settings on the V098 for Uno.

Firstly thank you for such an excellent piece of code, it is fun playing with it.

I have a working solution, currently constructed in Mecanno, based on a non standard stepper driver board from an ICL printer (L297/298 combination), and two stepper motors from a bottom drawer, one Bipolar, and one Unipolar driven both driven as bipolar, it all works well.

Currently I'm investigating a way to scale this model up, and the rigidity necessary for outdoor use, the mirror is a balanced assembly, and the whole kit has -180 to 180 azimuth scope, and -30 to 210 Elevation, not necessary but appealed it to me to get a large scope of control.

When I was constructing the system using your code and in the initial fiddling, one axis reset, the other didn't, a bit of a blessing really.  On investigation I found that if the direction was set to -1 it worked, but with 1 didn't.  I didn't document or try and understand it too much, just swapped the connection to one winding, and set both to -1 and as we say 'Bob's your uncle' it was all fine.

I should revisit that observation, but got swept up in trying to make a compact worm gear, might even pick up a couple of electric wheelchair worm gears because although capable of making a large worm wheel, just don't have access to the tools.

I hope this observation adds something to the conversation.

Simon

Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Re: Limit switches
« Reply #10 on: April 30, 2014, 03:05:28 AM »
Hi Gabriel,
I'm sorry, if you feel critisized. This was not my intention. As I wrote, I'm totally new in programming the arduino and only interested to understand how it works. It seems, that the order of calling a function and the allocation of variables doesn't matter.
What I still don't understand is, why I only get a seriel output with an particular position of calling "Seriel.print"

void gearReductionReset(int altOrAz, float MotorDirection, float LimitAngle, float GearRatio){
     float dif = positionAfterReset(LimitAngle) - LimitAngle;   
     float NumberOfSteps = -1*steps * (dif * GearRatio)/360.0 * MotorDirection;   
    Serial.print(" AltOrAz:"); 
    Serial.println(altOrAz); 
    Serial.print("Richtung");
    Serial.println(MotorDirection);
    Serial.print("LimitAngle: ");
    Serial.println(LimitAngle);
    Serial.print("Anzahl Steps: ");
    Serial.println(NumberOfSteps);
    Serial.print("Dif: ");
    Serial.println(dif);
    findLimits(altOrAz, MotorDirection, LimitAngle);//Seeks out limit switch
    if (altOrAz==2){moveToPosition(1, (NumberOfSteps), 0);}//Moves motor away from limit switch
    if (altOrAz==1){moveToPosition(1, (NumberOfSteps), 0);}//Moves motor away from limit switch   
}
In these order I get a seriel output in all other orders I don't. This was the reason, why I thought that this function was not called.

I also wanted to have a look at the function
 void moveToPosition(int AccelYesOrNo, long altsteps, long azsteps){
    Serial.print("azsteps: "); 
    Serial.println(azsteps); 
    Serial.print("altsteps: ");
    Serial.println(altsteps);
And this seriel output still don't work at all???
I'm using Arduino 1.5.5.

Thanks for the link to the wiring instruction of the easydriver. I didn't consider to used this, because it apply the harvester shield, which I don't  have. But what I have learned ist, that I have to use the Enable pin instead
of the Sleep pin as described in SunTrackerCircuit3_bb.pdf.
I'll check, if this is the solution.

btw : I am using Google Translator ::)

Wolfgang


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Limit switches
« Reply #11 on: April 30, 2014, 07:02:36 AM »
@Simon
"When I was constructing the system using your code and in the initial fiddling, one axis reset, the other didn't, a bit of a blessing really.  On investigation I found that if the direction was set to -1 it worked, but with 1 didn't.  I didn't document or try and understand it too much, just swapped the connection to one winding, and set both to -1 and as we say 'Bob's your uncle' it was all fine."

That's really weird. I know I've played around with those values before without that happening. If you try again I would definitely be interested in hearing what happens.

@Wolfgang
I don't feel criticized. :)

I figured that you were using a translator. It seems to be doing reasonably well. I'm not sure I'm always answering the questions you are asking though, so sorry about that.

"It seems, that the order of calling a function and the allocation of variables doesn't matter."
It definitely matters, I'm guessing that it's just done differently from what you are used to using Delphi. This is actually a fairly complicated program as far as understanding the order that things happen.

"In these order I get a seriel output in all other orders I don't. This was the reason, why I thought that this function was not called."
I'm not sure I understand what you are saying here, but the gearReductionReset function should definitely be called, and you should see the Serial output.

The output from the moveToPosition function should also show, but not until the limit switch is triggered.

You say you are using Arduino 1.5.5. I'm using 1.0.5
I would double check that you have the same one. http://arduino.cc/en/Main/Software
That download link does mention a problem with the serial monitor with the newer beta versions.

Wolfgang

  • New Member
  • *
  • Posts: 12
    • View Profile
Re: Limit switches
« Reply #12 on: April 30, 2014, 11:11:12 AM »
Gabriel,
yes your are right. It is diffrent in Delphi and I have difficulties to understand the program flow. For this reason I have to learn a lot to handle the Arduino.
I guess to have figured out, why my machine was not triggering the azimuth limit switch. As I wrote in my first post my assembly consists only a metal angel, two direct driven stepper motors and a lever with a little aluminium plate simulating a mirror. Powering the machine on, the altitude motor trigger his limit switch and move away from limit disabling the motor . Because of the not existing retention force now the atitude lever fall down and was stopped by his limit switch which permanently set Pin 7 of the Arduino high.
I have driven the machine with only the azimuth motor and it works well.
With his suspicion Paul was  on the right track.
If I get my new driver boards I'll check the hole functionality.