Go Down

Topic: 74HC959 with stepper motor's. LED's goes off. (Read 1 time) previous topic - next topic

Hello Arduino users!

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

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: [Select]

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...
}

Nick Gammon

Perhaps draw or show how it is wired. Or a clear photo.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics


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


Grumpy_Mike

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.

Nick Gammon

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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

#5
Dec 31, 2012, 02:03 am Last Edit: Dec 31, 2012, 02:18 am by Dragon707 Reason: 1

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 :* Yes, on my board there is a red wire on pin 14. However, i have updated my code. And it seems that it works :), 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:
http://www.youtube.com/watch?v=SMhDp86TdUE

New code (where updates can be followed here: https://project.zdev.nl/projects/floppypiano/repository/entry/arduino/floppypiano-controller.c):
Code: [Select]
//**********************************************************//
// 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
}
}

Nick Gammon

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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

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.

Grumpy_Mike

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.


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 :(

Grumpy_Mike

So want another shot at saying what your problem is?  :)

#11
Dec 31, 2012, 03:20 pm Last Edit: Dec 31, 2012, 03:22 pm by Dragon707 Reason: 1

So want another shot at saying what your problem is?  :)

Ah yes :)

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)
http://www.youtube.com/watch?v=SMhDp86TdUE

brs0906

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!

Go Up