Author Topic: Discussing Program of Arduino  (Read 7939 times)

athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Discussing Program of Arduino
« on: December 30, 2010, 10:32:43 PM »
This new Topic i m Starting to Post any one Queries regarding Project Code and Better understanding of it with electronic hard ware.

God Helps,
Kumar Saurav


athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #1 on: January 03, 2011, 12:43:32 AM »
Please analyse the code in setup() function.
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

Is it used as a unsigned number?
Because the syntax matched them.


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 656
    • View Profile
Re: Discussing Program of Arduino
« Reply #2 on: January 03, 2011, 04:25:33 PM »
That part of the code has to do with controlling the real time clock module. I'm not the person who wrote it, and I don't entirely understand how it works. The code that utilizes it though is under the tab "RTC_Code".

These values are turned into into floats and integers when the time comes to do the calculations with them.

You might actually know more about programming microcontrollers than I do. I basically learned how to program the Arduino by writing this program. If you find a better way of doing something, let me know.

Thanks!

athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #3 on: January 04, 2011, 12:38:42 AM »
Thank You Gabriel,
Actually what i m doing is trying to understand whole your code and make a freeware for others for better and easier understanding.
I think such a free tutorial will be very handy to the researchers on heliostat.
I would like to know what rough work you did while making this program.
I m sure me and all the other guys can help each other improve the program.

God Helps
Kumar Saurav

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 656
    • View Profile
Re: Discussing Program of Arduino
« Reply #4 on: January 05, 2011, 04:15:18 PM »
Yeah, I've been planning on breaking the code into smaller sections so that people can just take what they need and also trying to explain how it all works. Right now I'm in the middle of a rather nightmarish site update. I hope to get it finished soon though so that I'll have a little bit of time to work on documenting some of the code before the next semester starts, which is in less than a week.

So much to do, so little time.

Take Care!
Gabriel Miller


athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #5 on: January 06, 2011, 01:43:24 AM »
thank You Gabriel,
I m Really impressed with the studies of yours and helping hands for others.
Me too is also working on your codes and trying hard to break them as soon as possible.

God Helps,
Kumar Saurav

Bernard

  • New Member
  • *
  • Posts: 24
    • View Profile
Re: Discussing Program of Arduino
« Reply #6 on: January 08, 2011, 02:20:57 AM »
Hello,
I like to tell you that I have added a delay just at the beginning of the writeMotorPinsLow() function. The reason is that the steppermotor skips some steps due to hardware and software slowness. You can see it when the software goes for a step of one or two. Then the steppermotor does not make a step at all! A delay of at least 3 miliseconds is necessary. So I addes the line: delay(5); as first line in the above mentioned function.
Does someone reconnize this problem?
Bernard
 

Bernard

  • New Member
  • *
  • Posts: 24
    • View Profile
Re: Discussing Program of Arduino
« Reply #7 on: January 08, 2011, 02:40:28 AM »
Another question: Afther reaching the limitswitch the programs tells the motor to turn 4 degrees back, to loosen the switch. In my model the motor goes 4 degrees forward. The same thing hapens at 21:00 aclock: the motor goes on to the position of the limitswich! It does not turn back. (I do not use the switch yet, so it goes on for the x=1000 times in the software). Any idea?
Bernard

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 656
    • View Profile
Re: Discussing Program of Arduino
« Reply #8 on: January 08, 2011, 11:07:29 AM »
Hey Bernard,

I have indeed had an issue with my stepper motors losing steps. I had attributed it to hardware though and didn't think that there was anything I could do to fix it besides just tell the program to add 4 steps every time the stepper motors moved. I assumed that my cheap stepper motors were to blame.

I added your delay though and ran a quick Arduino sketch that simulates the movement of the stepper motors over a period of one day and tested it out on my heliostat. It seems that I'm not losing steps anymore. I haven't tested it long term yet, but I think you fixed it.

Thanks for finding the problem! I may have never found it on my own.


I can't seem to replicate your limit switch problem. The output I'm receiving in the Serial Monitor looks like the motor should reverse directions. Can you give me the settings you are using so I can try and see if the problem lies there? Or maybe just send me the whole program so that we can be sure that we are looking at the same thing.

Thanks again!
Gabriel

Bernard

  • New Member
  • *
  • Posts: 24
    • View Profile
Re: Discussing Program of Arduino
« Reply #9 on: January 09, 2011, 12:55:00 PM »
In the findLimit function I now changed de whichDir from -1 to 1 and vv. And it seemd to work in the suntracker mode.
I first investigate further to see if it is the right solution.
Remember I still have no switches in my model.
See below.

Bernard

void findLimit(int altOrAz, int motorDirection, float limitAngle){

  float whichDir;
 

  if (abs(limitAngle) != limitAngle){
    whichDir = -1;  // hier stond 1
  }
  if (abs(limitAngle) == limitAngle){
    whichDir = 1;  //hier stond -1
  }
  Serial.print(" findLimit aangesproken met whichDir= ");
  Serial.print(whichDir);
  if (altOrAz==1){
    int x=0;
   
    while(x<500){ 
     
      altStepper.step(10 * motorDirection * whichDir);
      if (digitalRead(limitPin)==HIGH){
        x=501;
      }
      x+=1;
    } 
  }
  writeMotorPinsLow();
 
  if (altOrAz==2){
    int x=0;
   
    while(x<500){ 
     
      azStepper.step(10 * motorDirection * whichDir);
      if (digitalRead(limitPin)==HIGH){
        x=501;
      }
      x+=1;
    }
  }
  writeMotorPinsLow();
}

athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #10 on: January 11, 2011, 11:11:01 PM »
question:-

const int limitPin = 13;
int latchPin = 10;
int clockPin = 12;
int dataPin = 11;
int switchPin1 = 14;   
int switchPin2 = 15;   
int switchPin3 = 16;

How are these commands directly connect the ardunio pins?
Instead we were using #define commands?

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 656
    • View Profile
Re: Discussing Program of Arduino
« Reply #11 on: January 12, 2011, 08:20:59 PM »
I'm not sure what you are asking athena?

You can change the pin assignment variables to what you think makes the most logical sense. All of that code has been taken from various example programs on the Arduino site, and I've never put much thought as to whether or not it is the best. For example, the shift register pin assignment comes from this link http://www.arduino.cc/en/Tutorial/ShiftOut


athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #12 on: January 12, 2011, 10:13:49 PM »
Thanks gabriel for the link.
I m pretty much assured now what you have done with these codes.

Can i ask you for a favour?
If you can please upload the algoritm step by step of your code including the solar calculating formulas?

Thanking again,
God Helps's
Kumar Saurav

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 656
    • View Profile
Re: Discussing Program of Arduino
« Reply #13 on: January 17, 2011, 05:38:25 PM »
It's going to be awhile before I will have the time for in depth explanations for how the program works. It is something I have wanted to do for several months now, but it's hard to find the time while attending a university.

I have attached a version of the program that has a few more comments in the code. It goes into more depth about the sun calculation algorithms, but that's about it.

What I want to do next is reorganize some of the code so that it is easier to understand. As it is now, even I have a hard time understanding parts of the program despite the fact that I wrote it.

Once this is done, it should also be easier to explain how it works.

athena

  • New Member
  • *
  • Posts: 10
    • View Profile
Re: Discussing Program of Arduino
« Reply #14 on: January 19, 2011, 01:17:23 AM »
Sir,
Can you Just tell all the formulas that you have used in calculating.

God Help's
Kumar Saurav