Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Troubleshooting / arduino power concern on: January 19, 2009, 12:52:27 am
Hey all. I'm using an Arduino Diecimila and powering it via 4AA batteries to the VIN pin. I know that this is not ideal, but it seems to work. It has been working well this way, so far. Does the VIN pin go through the 7805? Can I expect reliable results this way, or have I just been getting lucky?

Also, I would also like to have the option of plugging the arduino in, via the barrel power jack. What happens if the arduino is receiving power from both the barrel jack and the VIN pin? Will it simply ignore the batteries, will the batteries continue to drain, or will my arduino burst into a cataclysmic  fireball?

Thanks,
Tim

2  Forum 2005-2010 (read only) / Troubleshooting / arduino sleep on: January 19, 2009, 12:59:55 am
I'm trying to get my arduino Diecimila to go to sleep using the code from the playground: http://www.arduino.cc/playground/Learning/ArduinoSleepCode

According to the serial output, the device claims to be going to sleep, yet it doesn't behave as though it's sleeping. Maybe I'm misunderstanding the concept of SLEEP_MODE_PWR_DOWN mode, but I expected the arduino to behave as though there was no power attached - ie. the power led turns off, and any external functions cease.

This is not the case however. The serial output says "Timer: Entering Sleep mode" but the arduino still draws around 9mA of current, the power LED remains on, and any additional components (such as LEDs) remain on. The 9mA draw is average when I manually turn off LEDs prior to sleeping the device.

Is there something that has fundamentally changed about sleeping the arduino since that article was published?

Thanks in advance,
Tim
3  Forum 2005-2010 (read only) / Troubleshooting / Re: printf on: September 19, 2007, 09:49:33 am
printf doesn't print to the serial port, it just prints to the "display" (of which, there is none on arduino).

If you want the power of printf, try using the sprintf function and then sending the result via Serial.print().

Hope that helps.
Tim
4  Forum 2005-2010 (read only) / Troubleshooting / Re: Stepper Motor control 'delay()' problem on: September 11, 2007, 05:27:11 am
Does this help? Blink Without delay()

5  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: MacBook - Arduino USB - Itunes on: January 26, 2009, 11:11:18 pm
What does your iPhone do when you try to connect it? Does the iPhone realize it's connected at all?

A friend of mine just had this problem recently, where his computer and iPhone seemed to completely ignore one another when connected. This is how I fixed it for him.. (your mileage may vary)

Get a mac uninstaller program like "AppZapper" (change preferences to allow "safe" applications to be deleted) and essentially uninstall iTunes and everything with it. AppZapper will find and delete the configuration files.

I went an extra step and deleted the iTunes Library files as well. I left he actual media in place, just deleted the library files.

Anyways, then go download and reinstall iTunes.

It worked for me.
Tim
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Liquid Crystal Library on: September 14, 2007, 10:33:32 am
Open LiquidCrystal.cpp and modify the following lines:

Code:
extern void pinMode(int, int);
extern void digitalWrite(int, int);
extern int digitalRead(int);

to

Code:
extern void pinMode(uint8_t, uint8_t);
extern void digitalWrite(uint8_t, uint8_t);
extern int digitalRead(uint8_t);

I just tried it, and it worked for me.
7  Forum 2005-2010 (read only) / Interfacing / Re: Arduino - C# on: January 26, 2009, 01:41:21 pm
Basically, it looks like you guys were right on the money (Thank you ever so much) I added a delay in the C# code before sending the data and it worked. I just never had to do anything like that when using PySerial in the past... but it worked.

There is still one teensy tiny little problem I can't wrap my head around, however.

I changed the sleep mode to SLEEP_MODE_IDLE so that the arduino could be awakened by serial data... however, when the arduino is awakened by serial data it reads it perfectly,

However, if it is not awakened (already awake) then it misses the first byte from the C# program. This is consistent behavior. Can you see any reason for this in the code? I'm seeing cross eyed at this point...

Thanks again for all your help thus far.

[EDIT]
Please allow me to pose this question in addition to the weirdness above.

My project uses a light dependent resistor in a voltage divider to act sort of like a night light. When the ambient light in the room is too high, the arduino goes to sleep.

So it seems to me that to ensure the arduino is ready to receive updates via serial, I have one of two options: use SLEEP_MODE_IDLE so that serial data awakens the arduino, or attach a physical button that the user must depress before sending the serial data (to pull the ldrPin low and make sure the arduino is awake)

Now, the device would only need to receive updates every couple of months or so... and using SLEEP_MODE_IDLE yields some weird results... for example, when the arduino is supposed to be asleep it keeps repeating over serial "going to sleep" - even though if it were truly sleeping it wouldn't be looping anymore... also, using SLEEP_MODE_IDLE it doesn't seem as though it always wakes up as it's supposed to... So my question is, how bad of design practice do you think it would be for me to have a button on the device that must be pressed before you can send serial data?

I swear, working on this project has been like a lot of smoke and mirrors, a lot of things didn't seem to work the way I originally thought they would! hah.

Thanks again
Tim
8  Forum 2005-2010 (read only) / Interfacing / Arduino - C# on: January 26, 2009, 11:53:23 am
Hey all.

I spent the weekend trying to get a simple C# program to send data via serial to my Arduino Diecimila. I'm just trying to send a very simple stream of 12 bytes - however my timing seems to be off. Most of the time, it misses all the data, and sometimes it catches the last couple.

The code worked fine when that's all it did, but when I included the code into the rest of my work it suddenly stopped working.

I can't, for the life of me, understand why. The rest of the code in the loop() section only activates when ldrPin (2) changes state... So I don't see how I could possibly miss so much data. I even included 5 "dummy" bytes in hopes of giving the arduino a chance to catch up.

If anybody would mind taking a look at this code, I would greatly appreciate it.

http://pastebin.com/m405d7d44 - arduino code
http://pastebin.com/m13775e0a - C# code

Thanks in advance.
Tim
9  Forum 2005-2010 (read only) / Interfacing / Re: PySerial on: February 12, 2009, 12:21:51 am
Looks like you just need to install the pywin32 package for python:

http://sourceforge.net/projects/pywin32/

10  Forum 2005-2010 (read only) / Interfacing / Re: RTC to 4Bit LCD on: January 26, 2009, 11:03:30 pm
I've never used the LCD library that you're using, but I have been working with the Ds1307 code for the last couple of days.

Try casting the bytes to int before printing them:

 Serial.print(int(minute), DEC);
 Serial.print(":");
 
I didn't get compile errors from this, but I did find that Serial.print() would print unreadable characters without the cast to int...

Might help.
Tim
11  Forum 2005-2010 (read only) / Interfacing / Re: Serial Graphic LCD 84x48 SGD-A on: September 11, 2007, 05:36:51 am
It does function as a noop, but a useful one. It prevents buffer overflows like:

char a[3] = {65, 67, 64};
print(a);

so it allows me to print strings that may not have been input as string literals.

Thanks again for the help Horace.
Tim
12  Forum 2005-2010 (read only) / Interfacing / Re: Serial Graphic LCD 84x48 SGD-A on: September 09, 2007, 04:11:39 am
[EDIT] I was totally unaware that we had access to the entire standard C library from arduino. That is awesome. The code now works perfectly. I added a strcat to append a null terminator to printed text. This is to prevent buffer overflows.

Code:
void print(char string[]) {
  strcat(string, "\0");
  Serial.print('S', BYTE);
  Serial.print(strlen(string), BYTE);
  Serial.print(string);
}

[/EDIT]

I got it working. When I was passing char[] to the print() function it was being passed as a pointer, so sizeof() returned 1, apparently causing all sorts of chaos. I tried to find an elegant solution, but a friend of mine who is comfortable with C suggested that I use null-terminated strings, or pass the length as a parameter, so I created an overloaded function like so:

Code:
void print(char string[], int length) {
  Serial.print('S', BYTE);
  Serial.print(length, BYTE);
  Serial.print(string);
}

void print(char string[]) {
  Serial.print('S', BYTE);
  Serial.print(strlen(string), BYTE);
  Serial.print(string);
}

int strlen(char str[]) {
  int i;
  for(i=0; i<=255; i++) {
    if(str[i]=='\0') {
      return(i);
    }
  }
}

It can be used as either print("Junk", 4); or print("Junk\0");

If anyone has a better solution, please let me know. Otherwise, it works.

Thanks for your help Horace.
Tim
13  Forum 2005-2010 (read only) / Interfacing / Re: Serial Graphic LCD 84x48 SGD-A on: September 08, 2007, 09:58:54 pm
I wish that were true. I've actually tried:

Serial.print(4,BYTE);
Serial.print('4', BYTE);
Serial.print(4, DEC);
Serial.print('4', DEC);
Serial.print(4);

etc. Sending BYTE is actually worse because it won't even send the entire string, ie.
Serial.print('S', BYTE);
Serial.print(7, BYTE);
Serial.print("Testing");

may only display "Te" to the screen.
14  Forum 2005-2010 (read only) / Interfacing / Re: Serial Graphic LCD 84x48 SGD-A on: September 08, 2007, 10:00:16 am
I wanted to be thorough, and troubleshoot this at the lowest possible level, so I used this code snippet:

Code:
void setup() {
  beginSerial(9600);
  
  // this part works
  Serial.print('P', BYTE);  // move cursor
  Serial.print(20);         // x=20
  Serial.print(20);         // y=20
  
  // this part works
  Serial.print('S', BYTE);  // begin string
  Serial.print(4);          // length of string
  Serial.print('T', BYTE);  
  Serial.print('E', BYTE);
  Serial.print('S', BYTE);
  Serial.print('T', BYTE);
  
  // this part is displayed onscreen instead of moving the cursor
  Serial.print('P', BYTE);  // move cursor
  Serial.print(40);         // x=40
  Serial.print(40);         // y=40
  
  // this part works
  Serial.print('S', BYTE);  // begin string
  Serial.print(4);          // length of string
  Serial.print('T', BYTE);  
  Serial.print('E', BYTE);
  Serial.print('S', BYTE);
  Serial.print('T', BYTE);
}

The end result looks something like, "          TESTP4040S4TEST" on the LCD display. As you can see, the first "move cursor" operation worked fine, but once I issue any text commands, the LCD never recovers.

Any help would be greatly appreciated.
15  Forum 2005-2010 (read only) / Interfacing / Serial Graphic LCD 84x48 SGD-A on: September 08, 2007, 09:57:09 am
Hey all, I'm trying to interface my Arduino with the Serial Graphic LCD 84x48 SGD-A from Sparkfun.

The following is a snippet of code including some of the functions that I'm using to communicate with the display:

Code:
void setup() {
  beginSerial(9600);
  
  print("Let's test this.");
  delay(1000);
  sleep();
  delay(1000);
  wake();
  delay(1000);
  printf("That worked nicely!");
}

void loop() {
}

void print(char string[]) {
  Serial.print('S', BYTE);
  Serial.print(sizeof(string));
  Serial.print(string);
}

void ping() {
  Serial.print('X', BYTE);
}

void wake() {
  char result = 'Z';
  do {
    ping();
    //delay(100);
    if(Serial.available() > 0) {
      result = Serial.read();
    }
  } while(result != 'X');
}

void sleep() {
  Serial.print('Z', BYTE);
}

The problem is that once I print() none of my other functions will work. Instead they print their "control characters" to the LCD display. It's as if I'm "stuck" in "string" mode. To be thorough, I also tried looping through a null terminated string and sending the BYTES individually, (and replacing sizeof()) but  no matter what I do, I'm stuck in text mode after writing to the display. Any suggestions?

Thanks,
Tim
Pages: [1] 2 3 4