Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / DelayMicroseconds() interrogation? on: October 08, 2013, 02:19:56 pm
Hello everyone,

How does the delayMicroseconds() function works. From what I understood the prescaler of timer0 is set to 64. For a 16MHz clock gives a count every 4.0uS. I am a bit confused on the math to get to 1uS interval?

I already built a personal delay() function by having my prescaler set to 64 and TCNT0 register set to 6 which gives an overflow every 250 count... But I do not see how to have the micro seconds interval.

Thank you all

M.
2  Using Arduino / Motors, Mechanics, and Power / Re: Stepper Identification on: October 03, 2013, 11:14:27 am
Thx,

I just checked the Resistance of both my pairs. Bn/Blk = 126 Ohm and my Yl/Or = 186 Ohm. With ohm law (12V) i get in the worst case that I will at least have 66 mA running in my Yl/Or pair... On the spec sheet it says that the rated current per phase is 0.19 A...

Maybe I am a bit confused to has why this is bad or not.

Thank you
M.
3  Using Arduino / Motors, Mechanics, and Power / Stepper Identification on: October 03, 2013, 10:25:17 am
Hello all,

I have the following stepper, 35L048B2U from portscap, in my possesion. My motor has 6wires (would suggest universal), but on the digikey page and on the manufacturer one it tells me Unipolar. I am a bit mixed up here. I also tried to see if two wires (the common) were connected together but with no avail.

Do I have a universal or unipolar stepper?

Thank you in advance
M.

P.S. I have added the link to the digikey page with all the datasheets.
http://www.digikey.ca/product-search/en?pv14=126&FV=ffec4e94%2Cfff4000f%2Cfff80056%2Cfffc0193&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25

Edit I changed the link so that it points to the exact motor
4  Using Arduino / Programming Questions / Re: Library within library on: September 23, 2013, 04:45:09 pm
Thanks for the answer!

Is it only within the arduino framework or it is a general programming principle?

M.
5  Using Arduino / Programming Questions / Library within library on: September 23, 2013, 04:18:37 pm
Hello everyone,

Today I tried to build a little library to manage many buttons. Within my button.cpp file I use a function(TIMER0_getTimeStamp) which comes from my home made Timer0 library. So in my button.h I include my timer0.h, and in my main since I do not need to explicitely use any of my timer0 functions I only include button.h.

I get an error message telling me that 'TIMER0_getTimeStamp' was not declared in this scope. After  playing a bit with the include statements I found that if I include timer0 in my main everything works, but why is that?

I thought it was possible to include an use a library within an other library without having to define it in the main file?

Here is my include statements

main file :
Code:
#include <button.h>
#include <utils.h>
#include <uart.h>

button.h :
Code:
#ifndef BUTTON_H_
#define BUTTON_H_

#define true 1
#define false 0

#include <avr/io.h>
#include <avr/interrupt.h>
#include <timer0.h>

button.cpp
Code:
#include <button.h>

If my question is not clear enough I can paste all my code, but since it does not seem to relate to the code per say I did not include it for sake of shortness.

Thanks you all
M.
6  Using Arduino / Programming Questions / Timer1 setting under servo library on: August 29, 2013, 05:07:31 pm
Hello everyone!

Today, for the hell of it, I was trying to program a pwm directly to my atmega328p in order to mimic the servo library shipped with the arduino IDE. Even tough I looked through servo.cpp, I could not find which mode of timer1 (pin 9 and 10) was used to generate the pwm.

Thank you in advance

M.
7  Using Arduino / Programming Questions / Delay function on: May 09, 2013, 01:06:28 pm
Hello everyone,

There is probably a post discussing this subject, but I did not find it. So my question : I want to do 1 and 10min delay, using the delay function. I was wondering is it possible to write delay(1*60*100); or it should be written has delay(60000);?

Thanks

M.
8  Using Arduino / General Electronics / Re: Zener voltage divider on: March 01, 2013, 05:00:07 pm
Yes a couple of time in the last 2days

My mind must have skipped the info.

Thx for the answer!

M.
9  Using Arduino / General Electronics / Zener voltage divider on: March 01, 2013, 04:49:59 pm
Hello,

I'm trying to build an external Aref from a Zener Diode voltage divider. In order to select te right resistor I want to know how much current will the Aref pin sink?

Thanks in advance

M.
10  Using Arduino / Programming Questions / Re: Inline println on: November 20, 2012, 04:06:06 pm
I have two questions on this part of the code :
1. Is this used to calculate the size of the array with the position in memory?
2. What is 'a' is some general form to use when defining a variable or a relation?

Code:

#define ARY_LEN(a) (sizeof(a)/sizeof(a[0]))


Thx!

M.
11  Using Arduino / Programming Questions / Re: Inline println on: November 20, 2012, 03:50:33 pm
Thank you everyone,

It was exactly the information I was looking for!

M.
12  Using Arduino / Programming Questions / Inline println on: November 20, 2012, 12:27:32 am
Hello,

I want to know if it is possible to print in array in the serial monitor in the form 0 0 0 0 0 0 for a 6 element array.

Currently I am using the following line of code. Combo_try[6] = {0,0,0,0,0,0}
Code:
Serial.println(combo_try[6]);

What I am getting is :
362
36
0þ0
0
0
0
...

Thanks you

M.
13  Using Arduino / Motors, Mechanics, and Power / Re: Continuous rotation Servo on: November 14, 2012, 02:02:13 pm
Thx Lefty,

I did not think I was buying a servo with extra features. I find these servo Ideal when you need to control the speed! But I guess you are right that without feedback it is impossible to start and stop the motor at exactly the same rotation on both side. I guess that with the addition of a Encoder I could get a response closer to a real servo with the addition of the 360deg rotation.

M.
14  Using Arduino / Motors, Mechanics, and Power / Continuous rotation Servo on: November 14, 2012, 12:21:38 pm
Hello,

I have a continuous rotation parallax servo. I'm trying to reproduce the functionality of a regular hobby servo. Basically I send à 1.6ms pulse for 1sec. and then try to return it to its original position by sending it a 1.4ms pulse for 1 sec. I observe a drift in the starting and ending position. It may be a completely normal situation, but I was not sure why exactly.

Thank you in advance

M.
15  Using Arduino / Programming Questions / Re: Simple servo + button + led Question on: November 14, 2012, 11:48:33 am
digitalRead() returns an int, not a boolean. This debounce code sucks.
I use a boolean, because I read in the doc that digitalRead() returns HIGH or LOW, so the boolean seemed fit.

Quote
It's really hard to tell, from these names, whether currentButton refers to a switch number, a pin number, or a switch state. Better variable names would be in order.
See the new code attach if it makes more sense.

Quote
How is your switch wired?
One leg to pin8 the other to a pull down resistor which is connected to ground.

Quote
After your sketch has been running for 32 seconds, what is going to happen? Look at the millis() documentation again. The function returns an unsigned long for a reason.
Thanks, for that hint went to check in the doc and it always return a unsigned long. Thinking back it may be one of the reason it failed.

Quote
does the same thing, and is guaranteed to work. But, count is a lousy name, since you aren't counting anything.
I changed my code to have the to variable subtract from each other. That also caused me some problem too. I also changed my variable name from count to time.

Quote
Why are you not using the Servo library? It makes dealing with the servo so much easier.
Because I like to program myself basic stuff in order to understand what is happening first. Once I understand what is going on I will either build my own libraries (for fun) or use the one provided.

With the few pointer you provided me the code is now working perfectly fine

Thank You
M.

Code:
nt switchPin = 8;
int ledPin = 13;
int servoPin = 3;

boolean lastButtonState = LOW;
boolean currentButtonState = LOW;
boolean ledOn = false;
boolean motorOn = false;

long time = 0;
long time_0 = 0;

void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
}

/*------------------------------------------------------------*/
boolean debounce(boolean lastState)
{
  boolean currentState = digitalRead(switchPin);
  if (lastState != currentState)
  {
    delay(5);
    currentState = digitalRead(switchPin);
  }
  return currentState;
}
/*------------------------------------------------------------*/

void loop()
{
  currentButtonState = debounce(lastButtonState);
  if (lastButtonState == LOW && currentButtonState == HIGH && motorOn == false)
  {
    ledOn = !ledOn;
    if (ledOn) {
      motorOn = !motorOn;
    }
  }
 
  lastButtonState = currentButtonState;
  digitalWrite(ledPin, ledOn);
 
  time = 0;
  time_0 = millis();
 
  if (motorOn) {
    motorOn = false;
    while(time - time_0 <= 1000) {
      digitalWrite(servoPin,HIGH);
      delayMicroseconds(1600);
      digitalWrite(servoPin,LOW);
      delay(20);
      time = millis();
    }
  }
  digitalWrite(servoPin,HIGH);
  delayMicroseconds(1500);
  digitalWrite(servoPin,LOW);
  delay(20);
}

Pages: [1] 2