Go Down

Topic: dual axis solar tracker + pro mini 3.3 volts + two dc motors + 4 photo resistors (Read 675 times) previous topic - next topic

knightridar

Jun 16, 2017, 04:06 am Last Edit: Jun 16, 2017, 10:37 am by knightridar Reason: title specification
I'm trying to do dual axis solar tracking
http://www.instructables.com/id/Arduino-Solar-Tracker/
I've modified geo bruces code to work with dc motors instead of hobby servo motors.

I'm using an arduino pro mini 3.3 volts
I'm powering it with a 6 volt solar cell (3.5 watts)

Two dc motors are being used (one for azimuth rotation and the other for elevation rotation)

One l298 drok dual h bridge driver
(powered via 10 watt solar cell --> 10 watts/24 volts = .417 amps (theoretical))

I'm using the attached code.
It use to work before for my 24 volt dc motors.
(JGB37-520)  --> .8 amps (stall current)
http://www.manchaimccb.com/products/aslong-jgb37-520-gear-motor-micro-dc-geared-motor-6v-12v-24vdc/


I remade the circuit for ease of assembly that's when it stopped working properly.
The serial outputs are correct and displaying in arduino ide serial monitor.

Now I switched back to 6 volt motors to try to get it to work it doesn't.
(TS-32GZ370-5300) --> .66 amps (stall current)
http://www.tsinymotor.com/Products/Worm%20Gear%20Motors/2014/0512/15.html
I switched because they have more torque for future applications.

Then I switched back to the 24 volt motors to try out the application and it still doesn't work.

I was guessing I'm not getting enough peak amperage based on the motor stall torque current/start up current ratings I'm assuming my 10 watt ALEKO solar cell is providing sufficient amperage. I'm using a lm2596 voltage buck converter and dropping the voltage down from 44 volts to 24 volts or 6 volts depending on which motors I use.

I heard online that the l298 dual h bridge has lots of voltage drop at higher currents so I'm going to try a better driver with higher peak amperage.  So I've come to the conclusion that it's either the driver or my code that is not causing one of my motors to move. It could also be that my 10 watt solar cell is not delivering enough peak amperage to start both motors at the start time.

Any input as to what's causing only one motor to move and not the other. The motor that doesn't move is the azimuth motor ?

I plan to release all code and cad files on instructables and grabcad respectively as soon as things are working properly.

Robin2

The 24v motor seems to have a stall current of just 0.8 amps so I doubt if the problem is with your L298.

What are you powering the motor with?

Make a simple pencil drawing showing how you have everything connected and post a photo of the drawing.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

knightridar

I have attached a jpeg image of a breadboard schematic.
The pins in the picture may not be the same as the code since I'm using an arduino pro mini in my real setup vs the arduino micro shown in the picture.
The concept is still the same.

I may have answered my own question.... though still confused why the 6 volt motors don't work.

At 24 Volts, I remember using a 24 volt power supply and I think things worked then.

I am using a 10 watt solar cell for my current setup and
stepped down voltage from 44 volts to 24 volts which in theory would give me .417 amps.
Less then the .8 amps current for stall current
(for two motors moving simultaneously that would be 1.6 amps)
which I am assuming is the same thing as the
motor start current (based on what I've researched online, I'm still unsure).
I think I remember things working in this scenario too.

10 watts/ 6 volts = 1.67 amps
(For the 6 volt motors, total combined stall current for both motors would be 1.32 amps)
So theory the drive should work.

I've attached additional pictures for clarity.


Here is the code I'm using:

Code: [Select]

// Special thanks to Geo Bruce on instructables.com for his version of the code.
// Enable A and Enable B pins on  dual motors h-bridge must be connected to two pwm (pulse width modulation) pins on arduino uno/micro/pro mini: 3,5,6,9,10,11.
int enA = 3; int in1 = 4; int in2 = 5; // motor azimuth adjustment
int enB = 9; int in3 = 7; int in4 = 8; // motor elevation adjustment

void setup()
{
 Serial.begin(9600); // initialize the serial port
 pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(enB, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); // set all the motor control pins to outputs
}
void loop()
{
 // LIGHT SENSOR (in this case a Light Dependent Resistor) pin connections and analog pin on respective arduino board
 int tr = analogRead(0); // top right
 int br = analogRead(1); // bottom right
 int tl = analogRead(2); // top left
 int bl = analogRead(3); // bottom left
 int delaytime = analogRead(A7)*2; // control delay time in milliseconds of LIGHT SENSOR readings
 int tolerance = analogRead(A6)/4; // set range of tolerance between LIGHT SENSOR readings

//print LIGHT SENSOR values to serial monitor for debugging
 Serial.println(tl); Serial.println(bl); Serial.println(tr); Serial.println(br); Serial.println(delaytime); Serial.println(tolerance); Serial.println();

  int count = 0; //start millisecond count of LIGHT SENSOR readings
  count++; //incremental count increase, continues to show LIGHT SENSOR results

  int avt = (tr + tl) / 2; // average value top
  int avd = (bl + br) / 2; // average value down
  int avl = (tl + bl) / 2; // average value left
  int avr = (tr + br) / 2; // average value right
 
  int dv = avt - avd; // average difference of top and bottom LIGHT SENSORS
  int dh = avl - avr;// average difference of left and right LIGHT SENSORS

if (-1*tolerance > dv || dv > tolerance) // check if the difference in top/bottom LIGHT SENSORS is greater than tolerance
{
  if (avt > avd) // if average LIGHT SENSOR values on top side are greater than on bottom side then elevation motor rotates CLOCKWISE
  {
  digitalWrite(in3, LOW);  digitalWrite(in4, HIGH); analogWrite(enB, 200); // set speed out of possible range 0~255
  }
  else // if average LIGHT SENSOR values on bottom side are greater than on top side then elevation motor rotates COUNTERCLOCKWISE
  {
  digitalWrite(in3, HIGH);  digitalWrite(in4, LOW); analogWrite(enB, 200);
  }
}
  else if (-1*tolerance < dv || dv < tolerance) // if difference is smaller than tolerance, STOP elevation motor
  {
  digitalWrite(in3, LOW); digitalWrite(in4, LOW);
  }

if (-1*tolerance > dh || dh > tolerance) // check if the difference in left and right LIGHT SENSORS is within tolerance range
{
  if (avl > avr) // if average LIGHT SENSOR values on left side are greater than right side, azimuth motor rotates CLOCKWISE
  {
  digitalWrite(in1, HIGH);  digitalWrite(in2, LOW); analogWrite(enA, 200);
  }
  else // if average LIGHT SENSOR values on right side are greater than on left side, azimuth motor rotates COUNTERCLOCKWISE
  {
  digitalWrite(in1, LOW);  digitalWrite(in2, HIGH); analogWrite(enA, 200);
  }
}
  else if (-1*tolerance < dh || dh < tolerance) //if difference is smaller than tolerance, STOP azimuth motor
  {
  digitalWrite(in1, LOW);  digitalWrite(in2, LOW);
  }
  delay(delaytime);
}

Robin2

Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

I am not prepared to comment based on those images - it would be too easy for me to misunderstand them. As I suggested in Reply #1, please make a pencil drawing based exactly on your system and post a photo of the drawing.

This all seems to me to be mixed up
Quote
I am using a 10 watt solar cell for my current setup and
stepped down voltage from 44 volts to 24 volts which in theory would give me .417 amps.
Less then the .8 amps current for stall current
(for two motors moving simultaneously that would be 1.6 amps)
which I am assuming is the same thing as the
motor start current (based on what I've researched online, I'm still unsure).
I think I remember things working in this scenario too.

10 watts/ 6 volts = 1.67 amps
(For the 6 volt motors, total combined stall current for both motors would be 1.32 amps)
So theory the drive should work.
First of all, a 10  watt panel will only produce 10 watts in very bright sunshine when aimed directly at the sun and when matched carefully to the load so that it operates at its most effective voltage. I suspect it would be more sensible to assume you panel provides 1 watt and treat any extra as a bonus. Maybe even 1 watt is optimistic.

You have not said how the voltage is stepped down. Many ways of doing so simply do it by deliberately wasting energy.

IMHO there is no prospect of running motors directly from a solar panel without a suitable battery to store energy. When the motor moves it will probably need more current than the panel can provide and that can be supplied by the battery.

The stall current of a motor is the worst-case scenario. In normal operation the current draw is likely to be considerably less.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

knightridar

#5
Jun 20, 2017, 09:12 am Last Edit: Jun 21, 2017, 04:22 am by knightridar Reason: updated picture
hi, I've attached a drawn out schematic and the actual soldered and assembled circuit on its side.
the results on the arduino ide serial monitor are reporting properly.


to drop down voltage I'm using a lm2596 buck converter.

cad models of it can be downloaded here:
https://grabcad.com/library/lm2596-buck-converter-4-0-40-to-1-3-37v-adjustable-step-down-power-module-with-led-display-volt-meter-1

cad models of the solar panel are here:
https://grabcad.com/library/aleko-solar-panel-10-watt-24-volt-monocrystalline-1

I've reposted the code for reference:

Code: [Select]

/ Special thanks to Geo Bruce on instructables.com for his version of the code.
// Enable A and Enable B pins on  dual motors h-bridge must be connected to two pwm (pulse width modulation) pins on arduino uno/micro/pro mini: 3,5,6,9,10,11.
int enA = 3; int in1 = 4; int in2 = 5; // motor azimuth adjustment
int enB = 9; int in3 = 7; int in4 = 8; // motor elevation adjustment

void setup()
{
 Serial.begin(9600); // initialize the serial port
 pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(enB, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); // set all the motor control pins to outputs
}
void loop()
{
 // LIGHT SENSOR (in this case a Light Dependent Resistor) pin connections and analog pin on respective arduino board
 int tr = analogRead(0); // top right
 int br = analogRead(1); // bottom right
 int tl = analogRead(2); // top left
 int bl = analogRead(3); // bottom left
 int delaytime = analogRead(A7)*2; // control delay time in milliseconds of LIGHT SENSOR readings
 int tolerance = analogRead(A6)/4; // set range of tolerance between LIGHT SENSOR readings

//print LIGHT SENSOR values to serial monitor for debugging
 Serial.println(tl); Serial.println(bl); Serial.println(tr); Serial.println(br); Serial.println(delaytime); Serial.println(tolerance); Serial.println();

  int count = 0; //start millisecond count of LIGHT SENSOR readings
  count++; //incremental count increase, continues to show LIGHT SENSOR results

  int avt = (tr + tl) / 2; // average value top
  int avd = (bl + br) / 2; // average value down
  int avl = (tl + bl) / 2; // average value left
  int avr = (tr + br) / 2; // average value right
  
  int dv = avt - avd; // average difference of top and bottom LIGHT SENSORS
  int dh = avl - avr;// average difference of left and right LIGHT SENSORS

if (-1*tolerance > dv || dv > tolerance) // check if the difference in top/bottom LIGHT SENSORS is greater than tolerance
{
  if (avt > avd) // if average LIGHT SENSOR values on top side are greater than on bottom side then elevation motor rotates CLOCKWISE
  {
  digitalWrite(in3, LOW);  digitalWrite(in4, HIGH); analogWrite(enB, 200); // set speed out of possible range 0~255
  }
  else // if average LIGHT SENSOR values on bottom side are greater than on top side then elevation motor rotates COUNTERCLOCKWISE
  {
  digitalWrite(in3, HIGH);  digitalWrite(in4, LOW); analogWrite(enB, 200);
  }
}
  else if (-1*tolerance < dv || dv < tolerance) // if difference is smaller than tolerance, STOP elevation motor
  {
  digitalWrite(in3, LOW); digitalWrite(in4, LOW);
  }

if (-1*tolerance > dh || dh > tolerance) // check if the difference in left and right LIGHT SENSORS is within tolerance range
{
  if (avl > avr) // if average LIGHT SENSOR values on left side are greater than right side, azimuth motor rotates CLOCKWISE
  {
  digitalWrite(in1, HIGH);  digitalWrite(in2, LOW); analogWrite(enA, 200);
  }
  else // if average LIGHT SENSOR values on right side are greater than on left side, azimuth motor rotates COUNTERCLOCKWISE
  {
  digitalWrite(in1, LOW);  digitalWrite(in2, HIGH); analogWrite(enA, 200);
  }
}
  else if (-1*tolerance < dh || dh < tolerance) //if difference is smaller than tolerance, STOP azimuth motor
  {
  digitalWrite(in1, LOW);  digitalWrite(in2, LOW);
  }
  delay(delaytime);
}




Robin2

I was hoping you would use the link i gave in Reply #3 to post your image so I would not have to do it

Image from Reply #5



...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

The image in Reply #5 is just a waste of time. Just post the schematic on its own.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

mauried

Solar panels dont perform very well at all when fed directly into Buck Converters, because a Solar panel behaves like a current source and a buck converter expects a voltage source.
The problem becomes worse when the solar intensity is low .
You need a battery between the Solar panel and the LM2596.

Wawa

Don't expect wires poked into the Arduino vias to make a reliable contact.
It might have been better if you had used a breadboard.
Two motor wires seem to be very close together. If they short, the chip could fry.
+1 on the battery buffer. A solar panel is basically a current source.
Leo..

knightridar

@Robin2 thanks. I get what you mean by posting pictures I overlooked that post. I will update.

@wawa
I have the wires soldered on to the pro mini.
They are single strand 22 gauge wires.

@mauried
I was trying to avoid batterys I wanted basically anyone from having to buy batteries ie if they are in wilderness, off grid, 3rd world remote location, etc... Any chance for alternatives I. E. Capacitors? Using a multi meter I am getting the required voltage can't remember about current though.will measure soon.

knightridar

well i hooked everything up to a power supply tester.
dr. meter hy3005b

have it set at 24 volts and 1.6 amps
to account for total stall torque amperage rating of 2 motors.
the power supply automatically goes to constant voltage mode
and runs at 24 volts and ~.13 amps

http://www.manchaimccb.com/products/aslong-jgb37-520-gear-motor-micro-dc-geared-motor-6v-12v-24vdc/

the elevation motor moves clockwise
after that nothing else seems to move when i cover the photoresistors.
i am reading my serial outputs and they are correct.

these are the 24 volt motors with a stall torque rating of .8 amps.

any thoughts?
my guess is it's a code issue
so I may have to move this over to the programming section of the forum.

Robin2

Please don't make major changes to older Replies. Your changes to Reply #5 have invalidated my Replies #6 and #7. Post new material in the correct chronological order so other readers can follow the discussion.

Your updated diagram is still very hard to read and shows no sign of a battery for storing the output of the solar panels even though that was suggested in Replies #4. #8 and #9

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

knightridar

Ok got it.

The power supply though works better than the battery so it must mean something is wrong with the program.

Robin2

The power supply though works better than the battery so it must mean something is wrong with the program.
You have not provided any of the information that would be necessary to make a useful comment about that.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up