Show Posts
Pages: [1] 2
1  International / Nederlands / Re: vier DC motoren aansturen met arduino, Motoren (10V) en zoon (1,2A) on: February 03, 2014, 06:26:21 am
Shields zijn print plaatjes met daarop een combinatie van onderdelen die je eigenlijk altijd los kan kopen, als je deze dus niet wilt gebruiken kan je hem altijd na maken op een breadboard oid.

Met I2C kun je heel veel dingen aansluiten op maar 2 pins van je Arduino.

Misschien handig om er bij te vermelden dat het hier om je analoge pinnen gaat.

Een serie van I2C bus expanders kan je tientallen extra pinnen opleveren. Het vergt alleen wel wat uitzoeken.
2  International / Nederlands / Re: vraagje in verbant met c++ on: February 02, 2014, 12:20:21 pm
Je wilt niet van uit C++ code naar Arduino uploaden, dat doe je van uit de Arduino IDE. Wat je wilt is een Arduino code die leest sensoren af leest en de waardes naar zijn Serial output schrijft. Vervolgens laat je je programma in C++ de binnenkomende strings uitlezen, verwerken en weer geven in je GUI. Ik ben momenteel bezig met het programmeren van een aanstuur programma voor een Arduino CNC machine in objective C, doet ongeveer het omgekeerde smiley-razz (stuurt waardes naar de Arduino)
3  International / Nederlands / Re: hulp voor absolute beginner on: February 02, 2014, 12:07:02 pm
Je kan, als je hem echt leeg wilt hebben, een sketch met alleen de basis zonder commando's uploaden:
Code:
void setup() {}
void loop() {}
4  Using Arduino / Programming Questions / Re: Clear serial memory? on: January 28, 2014, 09:55:29 am
econjack that sounds a whole lot cleaner I will definitely give that a try
5  Using Arduino / Programming Questions / Re: Clear serial memory? on: January 28, 2014, 09:54:05 am
As it TURNS (get it?  smiley-razz) out to be I made a small mistake in my objective-C codes, works fine now. Thanks for your help any way Paul!  
6  Using Arduino / Programming Questions / Re: Clear serial memory? on: January 28, 2014, 08:56:13 am
The delay() was just there to make sure it wasn't generating faster than it would make steps. It worked without it but it would only do 1 in 16 steps.

I made a new void loop():
Code:
void loop() {
  if (Serial.available() > 0) {

    incomingByte = Serial.read();
  
    Serial.print((char)incomingByte);
  }
  
}

This echo's the code and the same thing happens here some were around step 200 the communication just stops.
I won't be able to read this in my app since I used the popen() way of communicating with arduino: http://playground.arduino.cc/Interfacing/Cocoa
I could rewrite my program to read back from the Arduino, but wouldn't that result in basically the same data?

Update: I counted the steps it can make, and it is 144 every time.
7  Using Arduino / Programming Questions / Re: Clear serial memory? on: January 28, 2014, 08:15:04 am
If I make a void loop that would move every stepper 1 step can keep turning for hours,

I also changed my void loop the way you said,

Code:
void loop() {
 
  incomingByte = random(97, 102);

    Serial.println(incomingByte);
    if(incomingByte == 'a'){
      MotorX->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 'b'){
      MotorX->step(1, BACKWARD, SINGLE);
    }
    else if(incomingByte == 99){
      MotorY->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 100){
      MotorY->step(1, BACKWARD, SINGLE);
    }
    else if(incomingByte == 101){
      MotorZ->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 102){
      MotorZ->step(1, BACKWARD, SINGLE);
    }
 
  delay(16);
}

And this one is running for a few minutes with out a problem as well.
8  Using Arduino / Programming Questions / Re: Clear serial memory? on: January 28, 2014, 07:43:38 am
Thanks for your quick reply,

I tried timing the data sends to 1 byte every second but still some were around the 200 bytes/steps every things stops.
9  Using Arduino / Programming Questions / [Solved] Clear serial memory? on: January 28, 2014, 06:11:26 am
Hello,

I couldn't find what I was looking for on this forum so I thought I would just ask.
I am trying to make a G-code interpreter for a CNC-machine in objective-C.  My Arduino is just there pass along the commands.

Code:
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

int incomingByte = 0;

Adafruit_MotorShield AFMS0 = Adafruit_MotorShield(0x61);
Adafruit_MotorShield AFMS1 = Adafruit_MotorShield(0x60);

Adafruit_StepperMotor *MotorX = AFMS1.getStepper(200, 2);
Adafruit_StepperMotor *MotorY = AFMS1.getStepper(200, 1);
Adafruit_StepperMotor *MotorZ = AFMS0.getStepper(200, 1);


void setup() {
  Serial.begin(57600);
  Serial.println("Let's do this!");

  AFMS0.begin();
  AFMS1.begin();
  
  MotorX->setSpeed(180);
  MotorY->setSpeed(180);
  MotorZ->setSpeed(180);// 180 rpm  
}

void loop() {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
    Serial.println(incomingByte);
    if(incomingByte == 97){
      MotorX->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 98){
      MotorX->step(1, BACKWARD, SINGLE);
    }
    else if(incomingByte == 99){
      MotorY->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 100){
      MotorY->step(1, BACKWARD, SINGLE);
    }
    else if(incomingByte == 101){
      MotorZ->step(1, FORWARD, SINGLE);
    }
    else if(incomingByte == 102){
      MotorZ->step(1, BACKWARD, SINGLE);
    }
  }
}

My objective-C app interpretates the G-code and sends a signal to the serial port for every step there has to be made. It runs pretty good for the first couple of hundred steps or so, but after that I guess some of the memory gets full because signals stop showing up in my terminal and the machine stops making steps. So my question would be: What memory bank gets clutched and how do I clear them?

Thanks,
10  Using Arduino / Motors, Mechanics, and Power / Re: DRV8825 Stepper Driver + Wantai motor makes noise but no steps! on: November 08, 2013, 02:45:39 pm
Oh I over looked that one smiley-razz I used a 12V 1.5 A power supply but my Motor needs 2.5 A. So I just ordered an other one and we will see if it works next week.

Thanks
11  Using Arduino / Motors, Mechanics, and Power / DRV8825 Stepper Driver + Wantai motor makes noise but no steps! on: November 08, 2013, 07:22:48 am
Hello,

I just bought a stepper motor (Wantai) and driver (Pololu DRV8825). But I can't get them to work properly. I've got it hooked up to my arduino uno rev 3 like this:



I have used these pins:
Pin 5 = DIR
Pin 6 = Step
Pin 10 = Sleep
Pin 11 = Reset

I'm using a 12V adapter to power the motor and I've got a LED connected to Pin 12 to check the cycles.

Now I'm trying to run this code (that I found some were on the web):

Code:
int dir = 5;
int steps = 6;
int sleep = 10;
int reset = 11;



void setup()
{      
  pinMode(sleep,OUTPUT);
  pinMode(reset,OUTPUT);
  pinMode(dir,OUTPUT);
  pinMode(steps,OUTPUT);
  
  pinMode(12,OUTPUT);

  digitalWrite(sleep, HIGH);
  digitalWrite(reset, HIGH);
  digitalWrite(dir, HIGH);
  
}



void loop()
{
      digitalWrite(12, HIGH);
      digitalWrite(steps, HIGH);
      delay(1000);
      digitalWrite(12, LOW);
      digitalWrite(steps, LOW);
      delay(1000);
}

The LED seems to indicate it cycles properly but the motor is making a screechy sound and isn't making any steps at all. Could someone tell what I'm doing wrong?

Thanks
12  Using Arduino / Programming Questions / Re: Random LED's on: February 10, 2013, 09:33:32 am
The code looks OK.  Have you checked to see that all of the lights work?  Watch each light for 10 seconds or until if comes on.  It might be that one or more of your LEDs is not working (bad connection) and so the random patterns will sometimes hit a non-working LED.

I ran a test and there was indeed a lose wire, thanks!
13  Using Arduino / Programming Questions / Re: Random LED's on: February 10, 2013, 08:49:45 am
Oh and my set up is like this:
14  Using Arduino / Programming Questions / Re: Random LED's on: February 10, 2013, 08:45:33 am
I think you have to show your code.

yeah it was basically the code you gave me, modified for shift register usage

it works when my loop is like this:

Code:
void loop(){

    // Turn on "Number" randonm LEDs
  for (int i=0; i<Number; i++) {
    do {
      thisPin = random(8);
      alreadySet = pattern & (1<<thisPin);
      pattern |= (1<<thisPin);
      setRegisterPin(thisPin, HIGH);
      writeRegisters();
    }
    while (alreadySet);  // If the LED was already on, try a different one
  }
pattern = 0;


  delay(timer);
  
  clearRegisters();

}

but as soon as I change the 8 in:
Code:
thisPin = random(8)
to a higher number, (starting to use the second shift register, which is a 74HC595 by the way) I get the problem (most of the time the desired amount of LEDs are burning but about 10% of the time a couple of them don't light up)

Here is the complete code if needed

Code:
int timer = (1000);
int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int SRCLK_Pin = 10; //pin 11 on the 75HC595
int Number = 4;
int thisPin;
int alreadySet;

#define shiftCount 2 //How many shift registers
#define pinCount shiftCount * 8 //How many pins

boolean registers[pinCount];
unsigned long pattern;

void setup(){
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);
  Serial.begin(9600);

  //reset all register pins
  clearRegisters();
  writeRegisters();
}              

//set all register pins to LOW
void clearRegisters(){
  for(int i = 0; i <  pinCount; i++){
     registers[i] = LOW;
    
  }
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);

  for(int i = pinCount - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);

  }
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
  registers[index] = value;
}

void loop(){

    // Turn on "Number" randonm LEDs
  for (int i=0; i<Number; i++) {
    do {
      thisPin = random(8);
      alreadySet = pattern & (1<<thisPin);
      pattern |= (1<<thisPin);
      setRegisterPin(thisPin, HIGH);
      writeRegisters();
    }
    while (alreadySet);  // If the LED was already on, try a different one
  }
pattern = 0;


  delay(timer);
  
  clearRegisters();

}
15  Using Arduino / Programming Questions / Re: Random LED's on: February 10, 2013, 08:19:07 am
Thanks John! Although this way I won't be able to use shift registers won't I? because in my final project I will be using 27 LED's. But that's not to big of a problem, in that case I will use I2C I/O expanders.

You can use an unsigned long (32-bit integer) to keep track of which LEDs you want on and off.
Code:
int timer = 1000; //Sets timer
const int pinCount = 6; //Sets the number of pins
int Number = 3; //Sets the amount of LEDs that will go on
unsigned long pattern;
int thisPin;
int alreadySet;

void loop(){
  // Turn off all the LEDs
  pattern = 0;

  // Turn on "Number" randonm LEDs
  for (int i=0; i<Number; i++) {
    do {
      thisPin = random(pinCount);
      alreadySet = pattern & (1<<thisPin));
      pattern |= (1<<thisPin);
    }
    while (alreadySet);  // If the LED was already on, try a different one
  }
  //  Send 'pattern' to shift registers
  delay(timer);
}

So i thought this did the trick since I tested it with one shift register (register pin 0 - 7), today I tried daisy chaining an other one to it (register pin 0 - 15). And I ran in to the same problem: most of the time the desired amount of LEDs are burning but about 10% of the time a couple of them don't light up (I guess it has some thing to do with the pattern being full or something?). Is there a fix for this?
Pages: [1] 2