Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: LCD Library on: April 28, 2008, 10:32:11 am
mellis: great to hear.
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: LCD Library on: April 28, 2008, 06:21:08 am
Hi all,
I wrote the LCD4Bit library (it's really just a conversion of the existing 8-bit one).  
I haven't done any electronics work in the last year, sadly, and don't see myself having time to maintain the library in the near future.
As documented on the wiki, the source is in google code.  I'd be happy to make someone else an admin on that project so that they can maintain it and make future releases.

My main concerns would be:
 * backward compatibility (if a newbie has found or been given an old sketch, they should be able to download the library, wire up their arduino and have it just work) and
 * that the default download of the library be of a stable version.  There's no reason not to also release a beta version of the library and ask for testers.

function naming:

As in the code comment crimony pasted, I intentionally kept the mistake in the function name so that existing programs written against the 8-bit library could be made to work with the 4-bit library with minimal effort.

I'd be in favour of (as mem suggests) introducing a correctly named version of the function, and keeping the old named one too (and documenting it as legacy, and having it cause a deprecation warning, if that's possible).  This is my top concern - that we don't break existing sketches.  Arduino beginners have enough problems.  I have no idea of the number of people using the library.

With regard to choosing a good name, LCD.println() is indeed misleading as gradbert says, as it does not move the cursor to a new line afterward.  LCD.print() is already being used to allow printing of an individual character (but could be renamed to LCD.printChar()).  You could have LCD.printString() but I doubt that's consistent with anything else.  You might look to other arduino or processing libraries for a model.

You guys decide how to go forward, and I'll do my best to assist promptly.
3  Forum 2005-2010 (read only) / Bugs & Suggestions / temporary rss feed for forum available on: November 06, 2006, 04:44:56 pm
I made a temporary rss feed for this forum (based on the "latest 10 posts" page).

Temporary?  Well, I imagine it's simply a matter of turning on a preference in YaBB admin to have a feed provided by the forum software itself.  Particularly now that the forum has upgraded it's YaBB version.  Anyway, this was the quick workaround.  Hope others find it useful.

I've tested a little and already seen that the server has to reject requests sometimes due to high load.

Why are feeds a good idea for the forum?  The easier it is for people to passively monitor the forum, the more likely they are to do so and to contribute answers.

If you're using a feed reader, remember to make sure it doesn't check with a ridiculous frequency, as that puts an unnecessary load on the forum server.  You can normally adjust the check frequency per feed via that feed's properties.  Once or twice per hour sounds reasonable.  Really, we're not such a large readership that it should matter too much here if you check every 5 mins.  Hopefully has a decent cacheing strategy, and most of the load should be theirs.

This ok, admins?

4  Forum 2005-2010 (read only) / Syntax & Programs / Re:  control 8 digital outs at same time??? on: February 04, 2007, 08:31:42 am
Noah, here's a bit of the (tidied) output from the program above, to allow you to check quickly if it's what you want.

(4 solenoids, with periods of 2, 5, 8, 13)

1 1 1 1 TIME:  0.0  NEXT_TIME: 0.5,0.5,0.5,0.5
0 0 0 0 TIME:  0.5  NEXT_TIME: 2.0,5.0,8.0,13.0
0 0 0 0 TIME:  1.0  NEXT_TIME: 2.0,5.0,8.0,13.0
0 0 0 0 TIME:  1.5  NEXT_TIME: 2.0,5.0,8.0,13.0
1 0 0 0 TIME:  2.0  NEXT_TIME: 2.5,5.0,8.0,13.0
0 0 0 0 TIME:  2.5  NEXT_TIME: 4.0,5.0,8.0,13.0
0 0 0 0 TIME:  3.0  NEXT_TIME: 4.0,5.0,8.0,13.0
0 0 0 0 TIME:  3.5  NEXT_TIME: 4.0,5.0,8.0,13.0
1 0 0 0 TIME:  4.0  NEXT_TIME: 4.5,5.0,8.0,13.0
0 0 0 0 TIME:  4.5  NEXT_TIME: 6.0,5.0,8.0,13.0
0 1 0 0 TIME:  5.0  NEXT_TIME: 6.0,5.5,8.0,13.0
0 0 0 0 TIME:  5.5  NEXT_TIME: 6.0,10.0,8.0,13.0
1 0 0 0 TIME:  6.0  NEXT_TIME: 6.5,10.0,8.0,13.0
0 0 0 0 TIME:  6.5  NEXT_TIME: 8.0,10.0,8.0,13.0
0 0 0 0 TIME:  7.0  NEXT_TIME: 8.0,10.0,8.0,13.0
0 0 0 0 TIME:  7.5  NEXT_TIME: 8.0,10.0,8.0,13.0
1 0 1 0 TIME:  8.0  NEXT_TIME: 8.5,10.0,8.5,13.0
0 0 0 0 TIME:  8.5  NEXT_TIME: 10.0,10.0,16.0,13.0
5  Forum 2005-2010 (read only) / Syntax & Programs / Re:  control 8 digital outs at same time??? on: February 04, 2007, 08:04:31 am
Hi Noah.

Here's a quick draft at what I think you want to do.
Instead of writing pseudo-code in english, I wrote it in a real language (ruby).  You should be able to read it as though it were pseudocode, and we have the benefit of knowing I tested it and it works.  Your job is to grok it and see if it's what you want, steal ideas from it, or use it to help describe to us what you actually wanted, if it's not this.

On mac os x you should be able to run this program and view the output, to confirm the behaviour is what you want. on other platforms, you'll have to first install ruby.  Save the program as solenoids.rb and run ruby solenoids.rb at the command line. Use ctrl-c to stop the program.

#polyrhythmic solenoids pseudocode (actually, in ruby)

#constants -----
LOW = 0
HIGH = 1

SLEEP_PERIOD=0.5 #this should be lowest common denominator of all on_durations

#how long (in seconds) each switch should go high for (in your example all are 500ms)
$on_duration=[0.5, 0.5, 0.5, 0.5]

#periodicity (in seconds) with which each solenoid cycles
$period=[2, 5, 8, 13]

#program-maintained info -----
#calculated time at which each solenoid should next change state

#current state of each solenoid (as understood by the program)
$state = [LOW, LOW, LOW, LOW]

def update_switches(current_time)
  for i in 0...NUMBER_OF_SWITCHES do
    #if it is time to change this switch...
    if current_time >= $next_time[i]
      #change state and
      if $state[i]==LOW
        #TODO: change your solenoid HIGH here
        #set the next_time we should change this switch's state
        $next_time[i] = $next_time[i]+$on_duration[i]
        #TODO: change your solenoid LOW here
        #TODO: Decide if like me you want to subtract on_duration[i] from this...
        $next_time[i] = $next_time[i] + $period[i] - $on_duration[i]

#just for ruby version.  
def show_switches(current_time)
  for i in 0...NUMBER_OF_SWITCHES do
    print "%s " % $state[i]

  puts "PERIOD: %s  TIME: %.1f  NEXT_TIME: %s" % [$period.join(','), current_time, $next_time.join(",")]

#just for ruby version - emulate arduino delay(milli)
def delay(ms)

#main stuff here
current_time = 0

#this "while" represents your arduino loop()
while true do


  #show states e.g. on LEDs

  delay(SLEEP_PERIOD * 1000)

  current_time = current_time + SLEEP_PERIOD

Note that I've incorporated the time each solenoid spent in its HIGH state when calculating the next_time for a state transition.  This isn't what you asked for - you asked for 500ms on, 10s off, 500ms on, 10s off.  But this gives you a period of 10.5 seconds, instead of 10 seconds as I think you might have meant!  It's easily fixed if not.

Problem 1.
I've worked with floating point values.  You should NOT do this in arduino, but should move everything to be in integer values.  In doing this conversion you'll have to be careful in deciding what type of variable to use to store the "next time" array.  Be careful that the next_time[] values don't get too big for their storage type and wrap round to zero.
If you need to work in sub-second periods, decide what's a small enough interval; in your case perhaps 10ths of a second.  There are 10 x 60 x 60 x 24  tenths of a second in a day; make sure you can store a value that high, if you want it to run for one day, for example.  Just don't think about using floating point values.

Problem 2.
This current version will drift slightly over time, because I haven't used the arduino clock, rather just kept a rough counter (current_time) of what time has elapsed (and this doesn't take into consideration the time spent in the other parts of the loop).  In this version, your solenoids WILL stay quantized relative to each other, but their collective idea of 2 seconds might be 2.001 seconds, so they will be like the three hands on a slow-running wall-clock: half a revolution for the minute hand will be exactly a 24th of a revolution of the hour hand as expected, but it WON'T be exactly 30 minutes real time.

It's easy to fix this: Draw current_time in milliseconds from the arduino instead of maintaining it yourself.  At the start of the program, get the current time from the arduino and set this as the next_time for each solenoid.

For other readers, I hope it is obvious that this solution has nothing really to do with solenoids and can be used wherever.

hope this helps,
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: saving data to flash on: January 12, 2007, 12:17:20 am
Hi Don,
There is a little bit of EEPROM memory available where you can store stuff which won't be lost when you turn your device off.  (Just 512 bytes, but should be fine for the use you describe.)

See the following page on the playground for the growing documentation on this:

Here, quickly, are the relevant bits of code.
#include <avr/eeprom.h>

//location in eeprom to read/write to.  0-511.
unsigned int addr = 0;        

//To write...
byte val_to_store = 57;
eeprom_write_byte((unsigned char *) addr, val_to_store);

//To read back...
byte val_retrieved = eeprom_read_byte((unsigned char *) addr);

Values stored in this area will also survive the download of new programs to the arduino so long as you're using the standard arduino bootloader (which doesn't touch the eeprom, currently).

I'd prefer storing this kind of "high-score" information in the eeprom rather than in the flash, as you're never sure how much space you're going to have left, if any, in the flash.  Note that you get around 100,000 writes to the eeprom, which is better than to the flash (1/10th of that), but still a finite number capable of biting you...

Hope this solution fits.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Please help! on: November 06, 2006, 01:55:43 pm
What's the context for your program?  If it doesn't really have to be a c / c++ program, you'd probably have a lot more fun learning PD, processing or VVVV and using those for the communication than doing so in C.  You'd also find ready-made programs - has some starting points for interfacing in various languages.

Or do you just want a simple command-line tool for *nix environment?
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Please help! on: November 06, 2006, 01:50:16 pm
on which platform?  windows?  linux?



9  Forum 2005-2010 (read only) / Interfacing / Re: Linux Serial IO on: January 29, 2007, 07:32:03 am
to try to answer your original question, once you've set up the device with edk4971's stty line, I think you can simply do
echo -n "X"
where X is the single letter you want to send.  The -n switch suppresses the trailing new line.

I'm not sure what buffering will occur, however.

Sounds like you have already found a different way, with python.
10  Forum 2005-2010 (read only) / Interfacing / Re: Linux Serial IO on: January 13, 2007, 09:39:05 pm

I hope you don't mind, I copied this into the interfacing section of the Arduino wiki (playground), here:

It'd be interesting to know if the same command works on mac osx, too.
11  Forum 2005-2010 (read only) / Interfacing / Arduino-VVVV: toward a fully-featured node on: November 02, 2006, 03:19:34 pm
I've made a simple extension to mr benefit's arduino-vvvv work to allow the communication to handle multiple signals (in the case of my example arduino prog and vvvv patch, I treat all 6 arduino analog ins in vvvv).   Here's a write-up including links to the code.

I'd be interested in collaborating to make a more fully-featured vvvv node for the arduino.  Let's hear requests.  If you've already done it, let's hear that, too, please!

I'll have a look at the pure-data object and use that as a guide.  no MAX here smiley-sad

vvvv was very popular in impromptu demos at the fantastic arduino workshop I attended at the weekend.

12  Forum 2005-2010 (read only) / Interfacing / Re: Serial and Processing on: November 09, 2006, 12:41:16 pm
Have you had a look at this potentiometer + arduino + processing tutorial?

The framerate() function was renamed frameRate() recently.  Other than that the downloadable code should still work.
13  Forum 2005-2010 (read only) / Development / Re: Can I use object code from Arduino on other AV on: November 14, 2006, 10:53:09 pm
If your target is actually just a non-arduino board, rather than necessarily a non-arduino AVR, then I understand there's another approach to consider which doesn't involve any fuse-setting, bootloader installation, or need for other programming hardware.  It is perhaps the simplest approach, though it has its downsides.

You can buy atmega8 and atmega168 chips already made arduino-friendly with the bootloader on them, etc.
You can drop one of these chips into an arduino board, develop and program with the arduino IDE until you're happy, then take the chip out and pop it into your custom circuit.  (I think it should also be possible to program such a chip in-place in the custom circuit, by utilising the tx and rx connections of an arduino board with its atmega chip removed).

There's a drawback to this approach: because you'll have the arduino bootloader on the chip, there'll be the 5 second delay at power-up (or reset) while the bootloader pauses to allow any new program to be loaded.  It's up to you and your intended application as to whether or not this is acceptable in development and in production.  Also, you lose 1k of the program space to the bootloader.

Where to get atmega8 or atmega168 chips prepared for arduino:
* In europe,
* In the US the arduino community member "BigFun" has offered to supply atmega168 - perhaps he'll supply atmega8, too.  (See this forum posting).

Consider using the atmega168 chip instead of the atmega8 as it gives you 16k of program space instead of the atmega8's 8k, and only costs around 1 US dollar more.

While the main hardware page has a few key links on atmega8 standalone, there's definitely some missing documentation.  I've started to gather stuff on a new wiki page:

good luck!
14  Forum 2005-2010 (read only) / Development / Re: optimising for size on: November 22, 2006, 05:39:22 pm
Wolf Paulus mentions a small hack to save 450 bytes - remove the legacy serial code support in arduino/lib/targets/arduino/wiring.c

Arduino's standard library still supports some legacy serial code, which can be removed by editing arduino/lib/targets/arduino/wiring.c (Arduino Version 0006):
Start commenting out code at line 241, insert /* just before void beginSerial(long baud)
This will reduce the size of a deployable program and increase the available memory for custom code by 450 Bytes, which doesn't sound like much but is equivalent to 6.3%.

Not really so relevant for you guys working on pduino, but for us beginners reading this thread it's a nice tip.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Programmer is not responding on Serial Arduino on: November 25, 2006, 08:29:13 pm
How about a 10 second video -- the most basic ever -- on just compiling, resetting, and uploading, complete with expected led patterns?  One problem is that what works for us doesn't necessarily work for everyone else's boards.  Those who've taught classes are in a better position than I am to say what's the best cover-all approach to present.

THE todbot?  Thanks for the great learning material.
Pages: [1] 2 3 4