Show Posts
Pages: 1 2 [3] 4 5 ... 81
31  Using Arduino / Programming Questions / Re: Button not being read during loop consistently on: June 21, 2011, 01:34:59 pm
Code:
void loop()
{

  reading = digitalRead(inPin);

  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    [...]
  }
  previous = reading;

The problem is with the line previous=reading. You should only set previous inside the if statement, otherwise depending on the switch  bounces the condition of the if might never be true for the switch state and the time together. Try:

Code:
void loop()
{

  reading = digitalRead(inPin);

  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
     count++;

    // ... and remember when the last button press was
    time = millis();
    previous = reading;
  }

Korman
32  Using Arduino / LEDs and Multiplexing / Re: 16x16 RGB matrix pwmmed - is it doable? on: June 21, 2011, 01:24:15 pm
Back to numbers: You want a refresh frequency of 25 frames * 8 lines * 8 levels of intensity = 1600 timeslots per second.
Now you have 4 displays * 8 columns * 3 LED colours = 96 bits to send out every 1/1600th of a second.

If you use one long daisy chain with 12 74HC595 registers providing 8 output each, you will have 1/(1600 * 96)th of a second to send the bit, or 6.5 µs (104 clock cycles at 16MHz). If you can't make it, the refresh rate won't be sustainable.

Now if instead of using only one data bit for the output, imagine you use 6 pins on your Arduino on the same i/o register (eg pins 8 to 13 which are all controlled by the PB register) and attach a daisy chain of 2 74HC595 registers to each pin. You then can write the data for all 6 pins with one single assembly instruction and you need to toggle the clock pin only once to process 6 bits. You will have 625 clock cycles to write all 96 bits, which is a lot easier.

Another line to investigate is to use the hardware shiftout register using pins 11 and 13 as clock. This also reduces the work of the processor and might give you enough time to do other stuff meanwhile.

The more I see those number, the more the whole project seems feasible with the Arduino. You will just have to be careful with the programming, but that's part of the fun, isn't it?

Korman
33  Using Arduino / LEDs and Multiplexing / Re: 16x16 RGB matrix pwmmed - is it doable? on: June 21, 2011, 09:25:25 am
Depending on how many i/o ports on your Arduino you have free, you can also work in parallel. With multiple days chains in parallel, specially if they're attached to the same Arduino I/O register, you cut the bitrate by the number of chains. And you won't be able to use digitalWrite(), but that was out of the question anyway at those speeds. For a few dollars, you get an Atmel168 you can dedicate to drive 2 of your blocks.

About the RAM, a random regular SRAM with 32x8 kbit costs $2 or so. You should be able to fit one write cycle into all the reads. You'll end up creating a simple bus manager. Small dual-ported video ram might be hard to come by these days.

In the end, you have many options and it mostly depends on what else your Arduino is going to do and what kind of hardware you intend to build.

Korman
34  Topics / Education and Teaching / Re: What are some unconventional ways to start teaching? on: June 21, 2011, 08:23:48 am
There's also a lot of teaching out in the industry. They call it training.

One gets into this when the boss comes around and tells you: "This is Rajeesh, he's on your team now, show him the ropes." More often than not, you can count yourself lucky if you don't need to start with the 3 R.
Another popular one is the boss sending you a half finished power point presentation attached to a calendar entry in the very near future (between 20 minutes and 2 weeks) and tells you: "15 technicians form the customer a coming over to to learn enough about the system to do the acceptance tests. You have 5 days to make sure they know enough to sign off the system and operate it afterwards."

Unions? Degrees? You must be kidding.


Korman
35  Using Arduino / LEDs and Multiplexing / Re: 16x16 RGB matrix pwmmed - is it doable? on: June 21, 2011, 07:42:31 am
You're going to need a little more planning than this. First, forget the TLC5940, you can't use it with this display. Your display is a matrix of 8*8 RGB LED, with 8 anode rows and 3*8 cathode columns (one for each colour). The TLC5940 and similar are designed to drive 16 individual single colour leds or 5+1/3 RGB led. It handles the PWM for you fro one LED, but it can't deal with a matrix.

If you want a ready made IC able to drive a LED matrix, you would need to look for something like the MAX6952, although this one can only drive 5 columns so you would need 4+1/5 per display to get all colours. It allows you 15 levels of brightness which it regulates via the current through the LED. I guess there will be some models for 8*8 matrices available, but I never bothered to look for them.

If you want to regulate the colour intensity via PWM, here are a few little back of the envelope calculations to evaluate the available time.

Lets say the desired LED refresh rate for your display is 25 times per second.
You have 8 rows and 24 columns for your 8*8 display. The maximum brightness will be 1/8 of the LED constantly running.
You need to load the shift register at minimum 8*25 =200 times per seconds and you need to output 200*24 = 4800 bits towards
the shift register.
If you want to add 8 levels of brightness, you will need be able to split the timeslot of each LED into 8 parts. That means you have to refresh each LED 200 times per second thus you're going to need to output 4800*8 = 38400 bits per second. For 16 levels it'll be twice as much, 76800 bits per second.
In the first case, you have 26 µs or 416 clock ticks on a 16MHz Arduino between each bit. With 16 colours, it'll be half the time. This will be tough, but not impossible.
And finally, to make it all worse, the human perception reacts logarithmically to intensity, not linearly. So if you go from 1 timeslot to 2, the LED will be appear 100% brighter, from 2 timeslots to 3 only 50% brighter and 7 timeslots to 8 just 14% brighter.

Now if you move to 4 displays, you have two options: More rows or more columns. No matter what way you go, your available time will diminish and your bit rates explode. The only way to keep this under control is to have per matrix one controller to work on the matrices in parallel.

A completely different option is to use some kind of dual ported video ram to refresh the LED. A few kB are amply enough for this application. That's what it was basically invented for and the Arduino would only need to write into the right places the data with no real time constraints. An simple approach is to increment the address counter for each tick which pushes row shift register and each bit of the byte will drive one column. If you want PWM on the colours, write for each byte 8 or 16 versions with the right PWM phase. The circuit for the refresh can be completely independent of the Arduino then. That's what the first home computers in the 80'ies were doing.

I hope, I gave you some ideas how to proceed.

Korman
36  Using Arduino / Programming Questions / Re: Atmega Assembler on: June 16, 2011, 01:53:26 pm
I think atmega is an example of [...]

Don't think, be certain. Read it all in the data-sheet, that's why Atmel publishes it. Anything else is just messing around, which you shouldn't do if you take your work seriously.

Korman
37  Using Arduino / Programming Questions / Re: Atmega Assembler on: June 16, 2011, 08:53:03 am
I simply want to understand how interrupt works for an university project. And the C code must do exactly what it does: a stupid thing to understand how interrupt works.

Oh, why didn't you say so in the first place? In this case, take a look at the datasheet of the ATmega328 by Atmel, more specifically chapters 6.7, 11 and 12. You'll find there working sample code how to things in C and in Assembly, C being first. Most things are explained there, for the rest look into the Arduino boot-loader source or avr-dump output of your program.

Doing this would have prevented that you waste your and our time with a wild goose chase.

Korman
38  Using Arduino / General Electronics / Re: Power on/off with momentary button on: June 16, 2011, 04:53:11 am
Something like this? The circuit is here.
Here you have a version that uses a debouncer and a flip-flop and some nice explanation how it works.

If you want to look for more on Google, search for push-button power circuit

Korman
39  Using Arduino / Programming Questions / Re: Atmega Assembler on: June 16, 2011, 04:30:52 am
Might one ask, what you expect to gain by writing it in assembler? If it's just because digitalWrite() is slow, do direct port manipulations in C, this is just as fast as writing it in assembler. In most cases, the code produced by the compiler is as good or better than what all but the most experiences assembler programmers produce. You just need to make sure you define your variables of the proper type (like int8_t instead of int for small values) to give the compiler a chance to optimise it.

And if you really have a small piece of code where you have an improved version in assembly, use the C inline assembler. For any real world project this is a far more sensible approach.

Korman
40  Using Arduino / Project Guidance / Re: watch winder....first post! on: June 16, 2011, 04:23:02 am
Is this one of the boxes to move automatic watches to keep them running? If so, this is a fairly easy project to start with. The biggest question is how you plan to move the watches. If 180 degree movements forth and back would be sufficient, the easiest way would be to get a hobby RC servo. Then you will need no additional hardware besides the Arduino and the servo. Use the Servo library included in the Arduino package.

If you really need a 360 degree movement, you will need some kind of motor (any will do) and a circuit to drive it. Motorshields offer this ready to use, but you can do it on your own. If you use a DC motor, you can do it with a transistor  because it runs in only one direction, you won't even need a full H-bridge. Look for the solenoid or motor tutorial on how to do this.

The internal clock is precise enough to be used reliably as a watch, but for not moving things for a day, it's good enough. I would use the Time library, but you can do it also with millis(). Just make sure you do your timestamp manipulations correctly to prevent problems when the timer overflows and wraps around every other month.

For the additional gimmicks, those can be added as the project progresses. For the Arduino itself, any will do. Best take the Arduino Uno, Duemilanove or any compatible you like.

Korman
41  Using Arduino / Project Guidance / Re: Feasability: Replace Older Motorcycle Dash with LCD? on: June 16, 2011, 01:41:25 am
About your design: Numeric rpm is really bad user interface and annoying. For rpm go with a bar or gauge at the side of the display, that's far easier to parse while riding.

Korman
42  Using Arduino / Project Guidance / Re: Feasability: Replace Older Motorcycle Dash with LCD? on: June 16, 2011, 12:18:43 am
For your needs, I would suggest either the Pro Mini together with a FTDI USB-Breakout cable or FTDI USB Breakout board or the Arduino Nano. Those have the smallest form factor and don't have any connectors soldered on. Those are best for use on your motorbike. To use the Pro Mini with the breakout board, just solder pins to the serial and you're ready to go. My development kit with the Pro Mini looks like this:



About the starter kits, I would forgo those, as you have a very clear project in mind. Just get the parts you need, a breadboard and your usual collection of resistors, LED buttons etc. But I guess, you have those anyway. In this project, as written above, the real challenge is the electrical part to get stable and clean power and the enclosure.

Korman
43  Using Arduino / Project Guidance / Re: Feasability: Replace Older Motorcycle Dash with LCD? on: June 15, 2011, 06:46:35 am
I can't really help you with the inputs, you best have a look at them with an oscilloscope. Give the age, I would guess that you're getting some kind of pulses relative to the speed or rpm, but on;y testing will tell. If this is the case, you can build this with an Arduino quite easily, that won't be the big challenge.

In my opinion, what will turn out to be a problem is the environment. First, I would put the Arduino in the same enclose that the display. Mounting it somewhere else will only add cabling to your solution and potential entries for water. If the Arduino itself is too big and you don't want to make a custom board with the Arduino included, get an Arduino Mini Pro.

The next challenge will be vibration. I guess, forget the pin contacts, they will work loose. Soldering is the way to go, which brings us back to the Mini Pro.

Then your enclose: It's going to be exposes to rain, cold, heat, sun, vibrations and water from the garden hose if you ever wash your bike. The enclose needs to be sealed. I haven't seen yet any commercial enclosures made for the Arduino which can withstand in such an environment. You should primarily look for an enclose to work in that environment and see if you can fit an Arduino with the display inside. My best guess would be the junk-yard to see if you find an old motorcycle speedometer to cannibalise.

About the display itself, make sure you find one that withstands the vibrations and the sun and also is still readable in bright sunlight from behind your back and at night.

And last, you should check whether your bike is still street-legal with the new display. Here in Germany, you need to have at least a certified odometer and speedometer otherwise you'll fail the yearly inspection.

Korman
44  Topics / Interactive Art / Re: Can Arduino do this ArtWork? on: June 10, 2011, 08:50:11 am
Argl, this really pisses me off. People cross-posting in multiple boards just to waste everyone's time. That's about the quickest way to use up any good will from others.

Korman
45  Topics / Interactive Art / Re: Can Arduino do this ArtWork? on: June 10, 2011, 04:19:01 am
Can Arduino do this ArtWork?
[...]
Basically, i am doing a media wall with 1000 points of stepper motors.

Well it depends on your requirements and on how you organise your steppers, but if it's just to bridge the gap between the motor drivers and the computer, the Arduino should be powerful enough and even have enough RAM.

Those 1000 stepper motors need to driven electrically somehow. Do you have some plan how you want to do that? What's your budget? If you get the stepper motors for $1 you might need to spend another $1 or more per motor to drive them. Custom boards to drive the motors should start to make sense at this scale. Or do you plan to address them as a matrix? The programming of the Arduino depends mostly how the hardware is solved and the hardware will determine the costs.

By the way, the installations shown might work with cheaper DC-motors. For the second one, attach small propellers to it and you just need to control the direction. In the first example, if the flower gears are driven with a rubber wheel, you can also get away with just running the motor more or less the appropriate time. Those motors usually cost less than what steppers cost.

Korman
Pages: 1 2 [3] 4 5 ... 81