Recent Posts

Recent Posts

Pages: 1 ... 8 9 [10]
91
Atmel and Arduino / Re: Using Atmega1280 to control a BLDC motor
« Last post by antmabee on June 14, 2013, 11:56:51 AM »
The buttons will be on one of the Arduino boards which transmits to the other board. The motor is 
an EG-530KD with an RPM of 1600/3200 the load should be suitable for variable. Maybe the attached block diagram maybe of some help.
92
Atmel and Arduino / Re: Using Atmega1280 to control a BLDC motor
« Last post by ElectroNick on June 14, 2013, 11:31:13 AM »
What kind of RPMs are you looking for? Also, which BLDC motor are you planning on using and what kind of a load and torque requirement that is? As far as RF - did you mean that the buttons will be on a remote device?
93
Atmel and Arduino / Re: Using Atmega1280 to control a BLDC motor
« Last post by antmabee on June 14, 2013, 10:37:50 AM »
I need to connect three push buttons to the Arduino and when I press the first button the motor increases speed in steps another reduces the speed of the motor in steps and the other changes the direction of rotation the motor.
94
Microcontrollers / MOVED: Using Atmega1280 to control a BLDC motor
« Last post by ElectroNick on June 14, 2013, 10:23:16 AM »
95
Atmel and Arduino / Re: Using Atmega1280 to control a BLDC motor
« Last post by ElectroNick on June 14, 2013, 10:22:22 AM »
I don't know about RF communication - haven't done it myself yet. But I am assuming that when you buy RF modules, you will get plenty of code examples on the Net for using them with Arduino. Are you talking about something like this ? Again, I haven't used those RF modules myself but they sound like you just hook them up to the Tx (Digital Pin 1) for transmitter and Rx (Digital Pin 0) for the receiver and use Arduino's standard Serial library. like I said, I personally have no experience with these but this is how I would approach it.

As far as BLDC though, this Arduino BLDC code should work on Atmega1280 . Since PWM is used, it limits the RPMs you can achieve with the motor but makes its rotation very smooth. So, if you can explain in some detail the actual application where you'd be using your Atmega with BLDC, I should be able to tell if this code is going to work or not.
96
Atmel and Arduino / Using Atmega1280 to control a BLDC motor
« Last post by antmabee on June 14, 2013, 09:41:57 AM »
Hi am new to Arduino and I don't have much guidance so am kind of like training myself about it. Any one can assist me on how to control a motor using arduino and then send the same signal to another arduino using RF signal
97
General Discussion / Re: dark current
« Last post by metal ken on June 14, 2013, 05:03:47 AM »
We assemble metal T.O. cans for photosensors or photodiodes...and the dark current (Id) requirements range from mA to pA. Does Id depend on the application of the device? Another question, I did a recent burn-in on one of the devices but the Id readings were high so our customer advised to repeat the burn-in process. Does repeating the burn-in process lower the high Id readings? The average Id decreased but as for the individual units, the result was erratic (i. e., some units had a lower Id while others had higher).
98
Motor Control / Re: Brushless Motor Basic Programming Question
« Last post by mamette on June 13, 2013, 09:15:20 AM »
I change the delay to microseconds, but the motor is not rotating.

How about use Interrupt? I have try using interrupts, but looks like my code is wrong, so the motor is not rotating, it's seems just hold the position..

This is my code using interrupts:

Code: [Select]
// constants won't change. They're used here to
// set pin numbers:
const int motorPin1 =3;
const int motorPin2 =6;
const int motorPin3 =5;

// Variables will change:
boolean direct = true; // direction true=forward, false=backward

int pwmSin[] = {127,110,94,78,64,50,37,26,17,10,4,1,0,1,4,10,17,26,37,50,64,78,94,110,127,144,160,176,191,204,217,228,237,244,250,253,254,253,250,244,237,228,217,204,191,176,160,144,127
}; // array of PWM duty values for 8-bit timer - sine function

 
//int pwmSin[]={511,444,379,315,256,200,150,106,68,39,17,4,0,4,17,39,68,106,150,200,256,315,379,444,511,578,643,707,767,822,872,916,954,983,1005,1018,1022,1018,1005,983,954,916,872,822,767,707,643,578,511
//}; // array of PWM duty values for 10-bit timer - sine function
 
int increment;
int currentStepA=0;
int currentStepB=16;
int currentStepC=32;

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
//long motorDelayActual = 0;  // the actual delay, based on pot value and motor delay set above
long lastMotorDelayTime = 0;

void initBLDC() {

  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  
  //TCCR1B = TCCR1B & 0b11111000 | 0x01; // set PWM frequency @ 31250 Hz for Pins 9 and 10
  TCCR2B = TCCR2B & 0b11111000 | 0x01; // set PWM frequency @ 31250 Hz for Pins 11 and 3 (3 not used)
  //TCCR0B = TCCR0B & 0b11111000 | 0x01; // set PWM frequency @ 31250 Hz for Pins 5 and 6
  
  ICR1 = 255 ; // 8 bit resolution
  //ICR1 = 1023 ; // 10 bit resolution
  TIMSK2 |= _BV(TOIE1);
  sei();

  // Enable Timer1 Interrupt for Motor Control
  OCR0A = 0;
  OCR0B = 0;
  OCR1A = 0;
  OCR1B = 0;  
  OCR2A = 0;  
  OCR2B = 0;  
}


ISR(TIMER2_OVF_vect) {  
 if((millis() - lastMotorDelayTime) > 0)
{ // delay time passed, move one step
 
  if (direct==true)
  {
    increment = 1;
    
  currentStepA = currentStepA + increment;
  if(currentStepA > 47) currentStepA = 0;
  if(currentStepA<0) currentStepA =47;
  
  currentStepB = currentStepB + increment;
  if(currentStepB > 47) currentStepB = 0;
  if(currentStepB<0) currentStepB =47;
  
    currentStepC = currentStepC + increment;
  if(currentStepC > 47) currentStepC = 0;
  if(currentStepC<0) currentStepC =47;
  
  }
  
  
  if (direct==false)
  {
    increment = -1;
    
  currentStepA = currentStepA + increment;
  if(currentStepA > 47) currentStepA = 0;
  if(currentStepA<0) currentStepA =47;
  
  currentStepB = currentStepB + increment;
  if(currentStepB > 47) currentStepB = 0;
  if(currentStepB<0) currentStepB =47;
  
    currentStepC = currentStepC + increment;
  if(currentStepC > 47) currentStepC = 0;
  if(currentStepC<0) currentStepC =47;
  }
  
lastMotorDelayTime = millis();

}
  
analogWrite(motorPin1, pwmSin[currentStepA]);
analogWrite(motorPin2, pwmSin[currentStepB]);
analogWrite(motorPin3, pwmSin[currentStepC]);
  
};  

void setup() {
 
  initBLDC();
  
}


void loop() {

  //IMU Code Here
    
}
 
99
Motor Control / Re: Brushless Motor Basic Programming Question
« Last post by ElectroNick on June 13, 2013, 12:09:16 AM »
But all of the delay(20); is in the void setup() {..} section, there is no delay in the main loop..
You are right, I did not read it too carefully all the way through. at the same time though, you have these lines in the main loop:

Code: [Select]
  timer = millis() - timer; //how long did the loop take?
  timer = (timeStep * 1000) - timer; //how much time to add to the loop to make it last time step msec
  delay(timer);

How long does that delay take? It's in milliseconds, anyway - almost guaranteed to be too long for any serious RPMs. You may want to switch to microseconds in anything that involves BLDCs.
100
Motor Control / Re: Brushless Motor Basic Programming Question
« Last post by mamette on June 12, 2013, 10:39:26 PM »
I think the problem is with the way the code in your sketch is structured. I did not read it all very carefully, but I see a lot of delay(20);  lines in there, no doubt to accommodate the accelerometer communication. During the delay nothing is happening in an Arduino. Arduino can only process one thread at the time, and if you told it to wait, it will halt everything, including processing of the motor commutation sequences. That will either stop or slow down the motor.

20 milliseconds is a HUGE delay as far as BLDC motor is concerned. Let's say you wanted it to rotate at 600RPM - not too fast but not too relaxed either. That means that you only have 100 milliseconds (600RPM/60 = 10 rotations per second = 100ms per rotation) in which you have to process 36 commutation changes for a 12 pole/9 cog BLDC motor. That means that your commutation change routine only has  100/36 = 2.77ms to process the change if nothing else was running in the Arduino. So, during each of your many delay(20);  you are missing at least 7 commutation steps.

I think you should take a look at your code and see how you can make those 20 milliseconds  more productive. Say, instead of doing a delay(20), see if you can send it into a subroutine that for the next 20 milliseconds will be rotating the motor.

But all of the delay(20); is in the void setup() {..} section, there is no delay in the main loop..

Or i must use interrupts for the motor?

Pages: 1 ... 8 9 [10]