Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

DIY Moon Phase Dial


Gina

Recommended Posts

I checked the current drawn by the Nano and it was aroundd 300mA but seems to be working.  Without a heatsink the LM317T could be expected to get hot as 7v drop and 0.3A gives 2.1W.  That needs a heatsink so I attached a TO220 heat sink plus thermal compound.  Now the LM317T maintains a sensible temperature.  Then I powered down and plugged in the motor driver module and applied 12v power again but the motor didn't operate.  LM317T still seemed "happy".

I'll do some more testing but it seems to me that 300mA is far more than the Nano should draw from the USB +5v supply with no load on the output pins.  In fact it draws 300mA with only the USB connected and not plugged into the board socket.  Is that another "blown" Nano?

Here's the power supplies circuit diagram.Power Circuit 01.JPG

 

Link to comment
Share on other sites

  • Replies 1.1k
  • Created
  • Last Reply

Tested Nano connected directly to PC and tried to upload and it wouldn't - so another dud Nano :(  At least this is less expensive than my DSLR image sensor debayering experiments!

Link to comment
Share on other sites

7 minutes ago, Alien 13 said:

Hi Gina, I just wondered where you get your nanos from got mine from Maplin and it was quite expensive.

Alan

Here.

Link to comment
Share on other sites

I've bought from them a couple of times mostly 5 at a time but I bought 10 last time.  They have proved quite reliable.  I don't think the supplier is to blame - it's me doing something wrong!

Link to comment
Share on other sites

Just taken another brand new Nano from its sealed packaging, connected it to my clock USB power and it drew just over 20mA with a little more when the LED was on (Blink sketch).  Checked it directly on my desktop and sucessfully uploaded a modified Blink sketch, so not dud yet - it survived my LM317T regulated supply :)  I guess next stage is to solder its "legs" on and try it plugged into the socket on the clock circuit board.

Link to comment
Share on other sites

"Legs" soldered on, plugged into circuit board socket and powered.  Nano working.  Connected to USB extension lead from desktop PC and once more modified Blink sketch uploaded successfully.  For the tests I simply set the delays in the Blink sketch to either 200ms or 2000ms for fast or slow blinking.  Now then dare I plug in the motor driver module and upload the clock sketch?  Powering off in between, of course.

Link to comment
Share on other sites

Fingers crossed but with my experiments with my "expensive" nano I have always used a transistor drive between modules to provide some extra isolation but as a min I would measure the input of the driver module to see if there are any odd offsets.

Alan

Link to comment
Share on other sites

Plugged in motor driver module, powered up and LED on Nano blinked reassuringly :)  Then uploaded clock sketch successfully but no motor movement.  Then I realised I'd disconnected the Hall devices so it thought it was already set to 12 o'clock and finished.  Checked the Serial Monitor because I'd set up test messages but nothing.  Something is wrong.  So I thought I'd check the Nano and tried uploading the Blink sketch but the upload didn't work.  Tried Nano alone direct on PC - still no upload.  Conclusion :- another dead Nano :(

I don't think I'm doing any more on this tonight.  But I'll try to summarise results so far.

  1. Nano working fine plugged into board - motor driver not plugged in.
  2. With driver plugged in upload worked.
  3. Uploaded clock sketch but serial comms not working.
  4. Uploads no longer working.
Link to comment
Share on other sites

13 minutes ago, Alien 13 said:

Fingers crossed but with my experiments with my "expensive" nano I have always used a transistor drive between modules to provide some extra isolation but as a min I would measure the input of the driver module to see if there are any odd offsets.

Alan

These stepper motor drivers work fine driven directly off an Arduino and one was working fine with a Nano for several days continuously in my moon clock earlier plus several weeks/months sorting out other matters.  I don't think any isolation is needed but I guess I could use series resistors.  The stepper motor driver modules are MOSFET and quite high value resistors would be alright.  I just can't think what I can have done to stop things working - I can't see that using USB power on the Nano could be the problem.

Link to comment
Share on other sites

Thank you for your reply :)

The 12v supply comes from a plug type PSU and is floating.  The only connection between PC and clock circuit is via the USB cable.  Could this be the problem?  Should I abandon the idea of being able to upload while the 12v supply is on?  The cable to the PC is 5m long.

Link to comment
Share on other sites

This has got me thinking :)  When the clock was working I didn't have it connected to USB.  I think all that gubbins hanging on the end of several metres of fine wire for the earth/ground could well introduce interference and spikes could kill the Nano.  I think that could well be the answer.  I think I have answered my question "Should I abandon the idea of being able to upload while the 12v supply is on?" with a YES!

A bit of a rethink then...  I could just go back to the original circuit and add a 2 pole switch in the 12v supply.  Just unplugging leaves a lot of unshielded wire etc. to pick up interference.  OR I could just go back to what I did before of unplugging the Nano and taking it to the PC and connecting via USB to upload the sketch.  After all, once it's working properly there should be no need to upload a new sketch.

While testing and sorting things out I needed the USB connection to PC to display information to the Serial Monitor but had the clock on top of the PC tower with a short USB lead.

Link to comment
Share on other sites

Been looking at current required at +5v for devices other than the Nano itself :-

  1. A4988 driver module logic supply current 8mA max
  2. A3144 Hall sensors 5mA x2 = 10mA
  3. RTC module supply current 300μA max

Total current = 18.3mA

Found this :-

Quote
  • The absolute maximum for any single IO pin is 40 mA (this is the maximum. You should never actually pull a full 40 mA from a pin. Basically, it's the threshold at which Atmel can no longer guarantee the chip won't be damaged. You should always ensure you're safely below this current limit.)
  • The total current from all the IO pins together is 200 mA max
  • The 5V output pin is good for ~400 mA on USB, ~900 mA when using an external power adapter
    • The 900 mA is for an adapter that provides ~7V. As the adapter voltage increases, the amount of heat the regulator has to deal with also increases, so the maximum current will drop as the voltage increases. This is called thermal limiting
  • The 3.3V output is capable of supplying 150 mA.
    • Note - Any power drawn from the 3.3V rail has to go through the 5V rail. Therefore, if you have a 100 mA device on the 3.3V output, you need to also count it against the 5V total current.

So it seems using the 5v output pin on the Nano to supply the other devices should be fine.  I added in the Hall sensors above because it occurred to me that though a 12v supply is fine, if a short occurred between the supply and the output it would destroy both the Hall device and the Nano.  OTOH thinking about it, such a short from the 5v pin would also destroy both Hall device and Nano.  I'll sort out another method of protection...

Link to comment
Share on other sites

A 470Ω resistor in the 12v supply to the Hall sensors would drop less than 5v leaving 7v for the sensors.  If a short occurred on the wire to the sensors the power dissipation in the resistor would be about 300mW - well within its ½W rating.  I could protect the Nano inputs with Zener diodes.

Link to comment
Share on other sites

I can upload to the Nano and the Mega with the 12V supply attached with no problems.  I have to as the RTC is powered by a separate supply and not the Arduino to set the time.  The Arduino always chooses the higher voltage input if multiple connections are made.  All of my GNDS are also on a common rail.

My Vin (9V) and +5V for the LCD and peripherals are both supplied by two of those MP1584's with no problems.  My CNC box (Uno) also runs and uploads with +12V power and USB connected with 4 A4988's attached on a shield

I think there is another underlying problem somewhere and in these cases I find it easier to replace everything in one hit instead of piece by piece just in case each component is taking each other out

Link to comment
Share on other sites

Thank you Mark :)  I get the general idea though the component names and values are too small to see :)

Here's my latest layout.  The RTC module can stand on end as I have plenty of space and that will allow a smaller stripboard which I have, enabling me to build a completely new unit.  I agree with you in replacing everything in one hit.  The RTC modules came in the post this morning and I'll be using a brand new Nano and can use a new A4988 motor driver module.  If I find the Nano won't upload with the Vin supply, I'll put a switch in the line so that it's powered via USB from the PC instead.

Circuit Layout 07.JPG

Link to comment
Share on other sites

Here is the amended sketch to go with the new circuit.  It compiles but otherwise untested as I haven't yet built the hardware.


// Filename :- Moon_Clock_v2_with_NEMA16_Microstepping_LEDs_07_2016-06-08
// Arduino test sketch for noise on RTC square wave input.
// Software timing from RTC on pin 2 using polling
// Everything to do with the seconds motor has been removed
// moveBackward has been removed
//
#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time  
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)
//
boolean BST = true;  //  British Summer Time - true=BST  false=GMT/UTC
int timeError =  15;  //  Amount of time setting error to be corrected (seconds)
boolean timeIsSet = false;
int accel = 0;  // number of steps to accellerate to full speed
long steps, h, units, extra ; // time set variables;
int lastSqWave = 0, lastHallMinute = 1 ; //  Save logic states of square wave and Hall sensor for minute hand
int sqwPin = A6;
int hallMPin = A0;
int hallHPin = A1;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int redPin = 3;
int greenPin = 5;
int bluePin = 6;
int dirPin = 8;  // DIRECTION pin
int stepPin = 9; // STEP pin
int msPin = 12;  // Microstepping pin
//
void setup() {
  Serial.begin (9600);     // Enable Serial Monitor via USB
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(msPin, OUTPUT);
  digitalWrite(msPin, 1);  //  Set 16x microstepping mode
  pinMode(sqwPin,INPUT_PULLUP);   //  One sec timing pin
  pinMode(hallMPin,INPUT_PULLUP);   //  Minute Hall sensor
  pinMode(hallHPin,INPUT_PULLUP);   //  Hour Hall sensor
  Serial.println(" Moon Clock v2.03 - NEMA16 microstepping - 2016-06-08");
  setSyncProvider(RTC.get);  // the function to get the time from the RTC
  if(timeStatus() != timeSet) 
      Serial.println(" Unable to sync with the RTC");
  else
      Serial.println(" RTC has set the system time");
  RTC.squareWave(SQWAVE_1_HZ);    // 1 Hz square wave            
  analogWrite(redPin,64        );
  analogWrite(greenPin,32);
  analogWrite(bluePin,8);
}
//
void stepForward(void){
  digitalWrite(stepPin, 1);
  delayMicroseconds(5);     // Make STEP pulse at least 5μs long
  digitalWrite(stepPin, 0);
}
//
void fastForward(long steps, int wait) {  
  for (long i = steps; i >= 0; i--) { stepForward(); delayMicroseconds(wait); }  // step then wait before next step
}
//
void fastBackward(long steps, int wait) {  
  digitalWrite(dirPin, 1);
  delayMicroseconds(5);     // Wait before sending STEP pulses
  for (long i = steps; i >= 0; i--) { stepForward(); delayMicroseconds(wait); }  // step then wait 2ms before next step
  digitalWrite(dirPin, 0);
}
//
void runClock() {  // subroutine called on both edges of the RTC square wave
// Send 32 μsteps to motor every half second
  for (int i = 31; i >= 0; i--) { stepForward(); delayMicroseconds(1000); }  //  **********************************************************
}
//
void displayTime(void)  // Digital time display on Serial Monitor
{
    // digital clock display of the time
    Serial.print(' ');
    Serial.print(hour());
    printDigits(minute());
    printDigits(second());
    Serial.print(' ');
    Serial.println(); 
}

void printDigits(int digits) {
    // utility function for digital clock display: prints preceding colon and leading 0
    Serial.print(':');
    if(digits < 10)
        Serial.print('0');
    Serial.print(digits); }
//
void loop(){
  if (timeIsSet) { 
    int val = digitalRead(sqwPin);  // read logic level of 1Hz square wave
    if (val != lastSqWave) { lastSqWave = val; runClock(); }  //  Call runClock on both edges of RTC square wave
//    val = (digitalRead(hallMPin));  // Read logic level of Hall sensor for minute hand
//    if (val != lastHallMinute) { lastHallMinute = val; if (val) { displayTime();} }
    } 

// return;  // if uncommented don't run motor                   *************************************************************************
//  timeIsSet = true;  // if uncommented don't set time         *************************************************************************
  if (timeIsSet) { return; } //  break out once time is set
  Serial.println(" Moon Clock v2.03 - 2016-06-08");
  Serial.println(" Setting hands to 12 o'clock");
  while (digitalRead(hallHPin) && (accel  < 2000)) { fastForward(1,150); accel ++ ; } // move fast forward until 12 o'clock sensed with hour hand
  Serial.print(" Speeding up ");
  Serial.println(accel);
  while (analogRead(hallHPin) && (accel  < 4000)) { fastForward(1,100); accel ++ ; } // move fast forward until 12 o'clock sensed with hour hand
  Serial.print(" Speeding up ");
  Serial.println(accel);
  while (analogRead(hallHPin)) { fastForward(1,40); } // move forward at full speed until 12 o'clock sensed with hour hand  // analogRead(hallH) > 500)
  Serial.println(" Slowing down");
  while (digitalRead(hallMPin)) { fastForward(1,125); } // move forward until 12 o'clock sensed with minute hand
  fastForward(timeError*64,125);   // correct error - seconds x 4 steps/s x 16x microstepping
  h = hour();
  if (BST) h++;  // if BST add an hour
  h %= 12;       // convert 24hr clock to 12hr - h modulo 12
  units = h * 3600;
  units += minute() * 60;
  units += second();
  steps = units * 64;
  extra = steps / 150;
  
  steps = steps + extra;  Serial.print(" Moving hands to ");
  Serial.print(h); Serial.print(":");
  Serial.print(minute()); Serial.print(" using ");
  Serial.print(steps);
  Serial.print(" steps - including ");
  Serial.print(extra);
  Serial.println(" extra steps");
  fastForward(steps, 100);

  timeIsSet = true;
}
// End

 

Link to comment
Share on other sites

I thought I had found a pack of 10 logic level power MOSFETs for £4 but on closer inspection they turned out to be P channel not N channel :(  Found some N channel ones at £12 for a 10 pack.  Anyway I think I still have some IRLZ44Ns which are rated at something like 50A as I recall.  They're in TO220 case so rather on the big side.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.