Pages: [1]   Go Down
Author Topic: 74HC959 with stepper motor's. LED's goes off.  (Read 1216 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Arduino users!

First i want to say, the Arduino project is awesome! Prototyping with low costs smiley

Now my question, i have 16 stepper motor's and a Arduino UNO. Now i want to control the stepper motors with my code. But i have some strange problems what i cant figure out... I have used this tutorial with a dual shiftregister. And i replaced the last 8 LED's for 8 stepper motor's (from the floppydrivepin's).
So:
The first register have 6 LED's
The second register have 6 stepper motor's (it have it's own power supply)

It works, but when the first stepper motor should step all leds fell out, i think it is because it uses its own powersupply.

Here's my code i use:

Code:
const int pinLatch = 8; // Connect to ST_CP of 74HC595
const int pinClock = 12; // Connect to SH_CP of 74HC595
const int pinData = 11; // Connect to DS of 74HC595

unsigned long registerState = 0;

// First load
void setup()
{
Serial.begin(9600);

pinMode(pinLatch, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinData, OUTPUT);
}

// Call on crystal (16MHz)
void loop()
{
for(int x=0; x<16; x++)
writeRegister(x, 1);
delay(500);
for(int x=0; x<16; x++)
writeRegister(x, 0);
delay(500);
}

void writeRegister(int pinNumber, int pinState)
{
digitalWrite(pinLatch, LOW);
bitWrite(registerState, pinNumber, pinState);
byte shiftRegister[2];
shiftRegister[0] = registerState;
shiftRegister[1] = registerState >> 8;
shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[1]);
shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[0]);
digitalWrite(pinLatch, HIGH);

delay(100); // <- I use for testing...
}
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps draw or show how it is wired. Or a clear photo.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps draw or show how it is wired. Or a clear photo.

Well, it tooks some time to do it. But here is it.

The unknown parts, IC's with the '?' sign are the folloring pins:
1st pin: Floppydrive-PIN: 20
2nd pin: Floppydrive-PIN: 19
3th pin: Nothing.. (Not connected)
4th pin: Power supply
5th pin: Power supply
http://www.interfacebus.com/PC_Floppy_Drive_PinOut.html

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't drive a stepping motor from the direct output of a shift register, it can not supply enough current. You need some sort of buffer or driver between the shift register and the motor, like a UNL2003.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Assuming pin 1 of the 595 is on the top RH corner (judging by the Gnd and 5V connections) you don't have any input to DS on the RH chip (pin 14) and DS on the LH chip is connected to an LED for some reason.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Assuming pin 1 of the 595 is on the top RH corner (judging by the Gnd and 5V connections) you don't have any input to DS on the RH chip (pin 14) and DS on the LH chip is connected to an LED for some reason.

Whoops smiley-kiss Yes, on my board there is a red wire on pin 14. However, i have updated my code. And it seems that it works smiley, well.. When i remove the USB cable from my laptop the arduino get powered from the external powersource for some reason. And everyting is flickering.. See the video:


New code (where updates can be followed here: https://project.zdev.nl/projects/floppypiano/repository/entry/arduino/floppypiano-controller.c):
Code:
//**********************************************************//
// Name : Floppy Piano Arduino Controller //
// Author : Kevin van der Burgt //
// Date : 29 Dec, 2012 //
// Version : 2.0.3 //
// Notes : For project details checkout the //
//  following website: http://floppypiano.com //
//**********************************************************//

const int pinLatch = 8; // Connect to ST_CP of 74HC595
const int pinClock = 12; // Connect to SH_CP of 74HC595
const int pinData = 11; // Connect to DS of 74HC595

unsigned long registerState = 0;

// First load
void setup()
{
Serial.begin(9600);

pinMode(pinLatch, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinData, OUTPUT);
}

// Call on crystal (16MHz)
void loop()
{
runTest();
}

void writeRegister(int pinNumber, int pinState)
{
digitalWrite(pinLatch, LOW);
bitWrite(registerState, pinNumber, pinState);
byte shiftRegister[4];
shiftRegister[0] = registerState;
shiftRegister[1] = registerState >> 8;
shiftRegister[2] = registerState >> 16;
shiftRegister[3] = registerState >> 24;
//shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[3]); - 4th SHIFTREGISTER NOT IN USE.
//shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[2]); - 3th SHIFTREGISTER NOT IN USE.
shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[1]);
shiftOut(pinData, pinClock, MSBFIRST, shiftRegister[0]);
digitalWrite(pinLatch, HIGH);


delay(1);
}

// Testing . . . .
void runTest()
{
// LED test's
writeRegister(0, 1);
writeRegister(1, 0);
writeRegister(2, 0);
delay(250);
writeRegister(0, 0);
writeRegister(1, 1);
writeRegister(2, 0);
delay(250);
writeRegister(0, 0);
writeRegister(1, 0);
writeRegister(2, 1);
delay(250);


// Floppydrive Test's
writeRegister(3, 1); // Connected to stepper motorA - directionpin
writeRegister(5, 0); // Connected to stepper motorB - directionpin

for(int x=0; x<80; x++)
{
writeRegister(4, 1); // Connected to stepper motorA - steppin
writeRegister(4, 0); // Connected to stepper motorA - steppin
writeRegister(6, 1); // Connected to stepper motorB - steppin
writeRegister(6, 0); // Connected to stepper motorB - steppin
}

writeRegister(3, 0); // Connected to stepper motorA - directionpin
writeRegister(5, 1); // Connected to stepper motorB - directionpin

for(int x=0; x<80; x++)
{
writeRegister(4, 1); // Connected to stepper motorA - steppin
writeRegister(4, 0); // Connected to stepper motorA - steppin
writeRegister(6, 1); // Connected to stepper motorB - steppin
writeRegister(6, 0); // Connected to stepper motorB - steppin
}
}
« Last Edit: December 30, 2012, 08:18:09 pm by Dragon707 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would say that Grumpy_Mike is right and you need to have a higher power supply. See if you can measure the current drawn. I think the 595 has a maximum rating of 35 mA per pin.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, the pins 20 and 19 should connected together to trigger. Now there is some power on it. and the ground of the external power supply is connected to the ground of the arduino.
The problem with low power that the leds go's off is solved by the way (wrong cable). This is the second problem of it.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The problem with low power that the leds go's off is solved by the way (wrong cable). This is the second problem of it.
Is that supposed to be an English sentence? If so it fails to convey anything to me.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The problem with low power that the leds go's off is solved by the way (wrong cable). This is the second problem of it.
Is that supposed to be an English sentence? If so it fails to convey anything to me.
My English isn't so good as i wish smiley-sad
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So want another shot at saying what your problem is?  smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So want another shot at saying what your problem is?  smiley
Ah yes smiley

Everything works fine now. But when i disconnect the USB cable from the Arduino. The Arduino get powered from the external power source. A thing i know is that the pin 19 and pin 20 on the floppy drives doesn't need to be powered just connected with each other. Maybe i should use an relay for that? (Problem, what happen can you see in this video)

That black crocodile clip is the external power supply (to power the floppy drives)
« Last Edit: December 31, 2012, 09:22:09 am by Dragon707 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your external power supply is too weak. The AA batteries can not supply all of the current you need. I suggest a 2 amp 5 volt DC power supply connected to the VIN and GND connections on the Arduino to fix.

Cheers!
Logged

Pages: [1]   Go Up
Jump to: