Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Software Serial .print() bug on: July 19, 2007, 10:11:14 am
It appears that .print(0,DEC) doesn't print anything. The same thing happens for .print(0,HEX);

serial.print("x:"); serial.print(0,HEX); serial.print(":");

results in x:: for output
2  Forum 2005-2010 (read only) / Development / Re: Bug in SoftwareSerial ... solution on: July 19, 2007, 07:09:07 pm
Thanks! I found the source and patched it.
3  Forum 2005-2010 (read only) / Development / Re: Bug in SoftwareSerial ... solution on: July 19, 2007, 04:21:34 pm
Ok. Probably a dumb noob question but where did you find the srouce for SoftwareSerial? Are the sources for other libs available too?
4  Forum 2005-2010 (read only) / Development / Re: Better ways of interfacing Servos on: July 19, 2007, 05:30:01 pm
Quote
Thanks for your hints, Mellis.

After some hours of diggin' in datasheets and webpages i finally came up with a solution that works:
(hope it's of any interest)

Quote
/* ServoPWM
 * ---------------
 *
 * Comments
 *
 * (copyright notice) 2007 by Moe
 * <http://youraddress.here>
 * <mailto:you@youraddress.here>
 *
 */

int val = 0;

void setup(void) {
  pinMode(9,OUTPUT);  // Servo Pin
  Serial.begin(9600);

  TCCR1A = 0x00;      // sets timer control bits to PWM Phase and Frequency Correct mode
  TCCR1B = 0x12;      // sets timer control bits to Prescaler N = 8
  ICR1 = 0x0FA0;      // Upper Timer Limit = 4000 (in hex) equals 4ms => 1/5 of servo frequency

}

void loop(void) {
  val = analogRead(0);      // read potentiometer
  val = (val * 1.76) + 600; // convert potentiometer reading to value in microseconds (my servo responds to signals in the 600us - 2400us range)
  analogWrite(9,val);       // pulse servo
  Serial.println(val);      // output servo value

}

what it does:

- it initializes the PWM timer so its frequency is 4ms - 1/5 of the servo's frequency of 20ms
  (as all of the servo's signals fall in between the 0.5ms - 2.5ms range).
- analogWrite now takes values from 0 to 4000 (for us = 0.001ms)

EDIT:

it currently only works on pins 9 and 10 as Timer1 only drives these two.

best regards,
Moe

Very interesting code. Thanks.

One question though. I thought that you were only supposed to give the servo pulse every 20 - 30ms. If i'm reading the code correctly, it will just give one pulse right after another.

I probably just need to go read up on timers...
5  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Potentiometer + RC Servo motor on: July 19, 2007, 07:52:44 pm
I know this is an old thread but I just wanted to point out that not all servos will be able to handle 500 to 2500ms.

Start with 1000-2000ms and gradually increase the range. If the servo buzzes at the low or high limit, that's as far as it wants to go. A servo trying to move past it's limit will draw quite a bit (relatively) of current and can even damage the servo gears.

- Jon
6  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Using the ATMega168 chip externally from Ardui on: July 19, 2007, 10:20:20 am
Quote
I'm new to microcontrollers, and have been using the Arduino for a couple of weeks now. I would like to develop my projects using the Arduino IDE, and board, then remove the programmed chip and place it into a circuit board/breadboard.

I think I've got most of this figured out, but I want to keep my component count low. So how do you run the chip without an external clock? I tried the ATMega datasheet, but I'm afraid I don't know enough about AVR programming to make sense of it. I think I have to set some fuses for this, but I haven't a clue on how to do that.

My projects are mostly LED based, (no motors, solenoids, etc..)

Any advice and sample code would be greatly appreciated!  smiley

When I ordered my Arduino from Modern Device, I ordered it with an extra 168 with the bootloader already installed. I took this chip and put it on a breadboard with a 16mhz xtal and it's working fine. There aren't that many connections to configure to allow it to be programmed like a regular arduino board.

Sparkfun.com has a pretty decent tutorial section that shows how to do most of this work.

http://www.sparkfun.com/commerce/present.php?p=BEE-2-Code
Pages: [1]