Show Posts
Pages: 1 ... 100 101 [102] 103 104 ... 301
1516  Using Arduino / Programming Questions / Re: Millis Accuracy Again on: April 30, 2013, 07:55:53 pm
In Unix-land you have a multi-tasking OS. With Arduino you write your own tasking.

Nice to see you finally dumped the code-blocking delay that was screwing your results up.
How many times was that suggested in how many ways?

1517  Using Arduino / Programming Questions / Re: Accessing a "Wire" object from an interrupt routine == hang, need solution on: April 30, 2013, 08:30:44 am
Got, not used. Got surface mount by mistake and I'm bad enough soldering pins.

What I should have bought are the 74F299 in PDIP 20-pin, just over US$1 ea.
http://www.futurlec.com/74F/74F299.shtml

If you're going to use enough of something like in a product, a bit of code is no big deal.
1518  Using Arduino / Programming Questions / Re: Turning 6 inputs into a Binary Number on: April 30, 2013, 01:26:11 am
Little more detail?

Code:

for ( byte count = 0, count < 5, count++ )
{
  bitWrite(variable, count, digitalRead( pin[count] ));
} // end of for count

I would expect switch/button bouncing to make occasional bugs with this code if the switches/buttons are manual.
1519  Using Arduino / Programming Questions / Re: Writing data to file on: April 30, 2013, 01:16:55 am
You might leave some better clues so other members that don't know can learn from your solutions.

1520  Using Arduino / Programming Questions / Re: Writing data to file on: April 29, 2013, 08:56:19 pm
You can use the free Processing language on the PC with the Serial library to access the UNO (you may have to change an index to get the right COM port) and get data and do your file work on your PC.

www.processing.com

From the Arduino introduction on this site:
Quote
The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment.

Code for Processing and for the Arduino IDE are very similar.
 
1521  Using Arduino / Programming Questions / Re: Serial input prompt demo, no response to input & CR. on: April 29, 2013, 08:48:25 pm
They're supposed to do the same things that a typewriter does. Carriage return should take the line back to the left edge of the same line and new line is also referred to as line feed (the old crlf = carriage return, line feed) which you pull the lever to get on a typewriter.

\n works. You can embed it into string arrays and it works.
You don't need a special command to make a new line, the same code can print either simply by changing the data to be printed. That is the power available even with Serial Monitor. There is a lot more with a fully operational ANSI terminal.


 
1522  Using Arduino / Programming Questions / Re: Accessing a "Wire" object from an interrupt routine == hang, need solution on: April 29, 2013, 04:25:25 pm
I have bi-directional shift registers, but they're surface mount. The port extenders are superior anyway. I'd just wonder about price since a small AVR might cost less.

ATtiny2313A-PU, 2k flash, 128 bytes RAM, 18 I/O pins for 95 CENTS at Futurlec.
http://www.futurlec.com/Atmel/ATTINY2313A-PU.shtml

But... do we have core data for programming them?
1523  Using Arduino / Programming Questions / Re: Serial input prompt demo, no response to input & CR. on: April 29, 2013, 04:06:51 pm
You're right, it's \n that works. And \f doesn't.

Code:
void setup( void )
{
  Serial.begin( 9600 );
  Serial.print( "***\nHello Again\n\n12345\n" );
  delay( 2000 );
  Serial.print( "\nGoodbye\n" );
}

void loop( void )
{
}

The Serial Monitor source code should be in with the IDE... future project there.
1524  Using Arduino / Project Guidance / Re: Sine wave table on: April 29, 2013, 01:11:45 pm
Most vibration motors are regular motors with an unbalanced weight on the shaft. For those, frequency is a matter of motor speed only. Every time the motor turns is one shake. For those you would want motor and sensor to make a feedback control.


1525  Using Arduino / Programming Questions / Re: 5 LEDs blink 5 times in a minute at random times on: April 29, 2013, 01:05:45 pm
That is why I asked how strict the requirement is. If it is not strict then your code can be greatly simplified and not need to keep track of time at all except for the 1 second ON time. The sketch can be amazingly short.

1526  Using Arduino / Programming Questions / Re: Accessing a "Wire" object from an interrupt routine == hang, need solution on: April 29, 2013, 12:58:49 pm
Thanks for the suggestion, the port manipulation stuff looks interesting.  For this particular project, we're fixed on I2C and an Uno board (executive decision from above).  We're going to have several of these port expanders, both for more I/O and to reduce the wiring required, so unfortunately wiring direct to the Arduino isn't possible.  Our device will have a lot of modular hardware, many inputs and many outputs, and with I2C we only need to run 2 wires to each module.  We will be instructing hardware to do things, and receiving interrupts when events happen.  We have to detect the event and then control the hardware accordingly.  It worked great wired directly to a Mega 256, so now we're moving to the Uno to reduce per-unit costs.  It looks good on paper anyway..  smiley-cool 

To reduce per-unit cost you should use a stand-alone AVR chip (like a 328 or 1284) possibly running on internal oscillator. The external oscillator on the UNO uses 2 pins that would let you have 8 bits on one port, but I see that you don't need that.

Port expanders? I hope they're as cheap as shift registers ;^) or actually are shift registers, 2 or 3 for a buck. The kind I get are SPI bus which is 4 wires but 2 MB/sec fast (AVR running 16MHz). It's possible to write a line of those over 10,000x a second. There are bi-directional shift registers but for code simplicity I would go with daisy-chained shift register outputs on the one hardware SPI bus and perhaps inputs daisy-chained on soft-SPI.

1527  Using Arduino / Programming Questions / Re: Serial input prompt demo, no response to input & CR. on: April 29, 2013, 12:32:14 pm
It should work with Serial Monitor too. You just have to set up Serial Monitor. I like Hyperterminal because it sends every character immediately, but it's more of a pain to set up and start than Serial Monitor.
 
You have another option. You can download and use Processing (the free PC language that Arduino IDE is based on) to make a PC side. What you can have it do is almost anything. Text, graphics, read/write to hard drive, the works is open to Processing. And Processing code is -very much- like Arduino code.
http://www.processing.org/

1528  Using Arduino / Project Guidance / Re: Sine wave table on: April 29, 2013, 12:21:40 pm

How does the motor operate?

Sine wave is one-axis of circular movement. Physical things often make the wave movement between force and inertia, not through constant control.

If you must control then it will be the same table regardless of frequency. If you must have the table, it can be an int array giving 4-place precision fast and tight.
I understand that frequency is speed of the motor and therefor will have an effect on period length (I know that 100 HZ is 100 cycles/second), I am just new to coding and am not proficient with sine mathematics. Could anyone link me to example code on how I can even get started?

If the motor goes around and around, it makes the sine in the circular movement. If it vibrates like a reed or string, it very likely does the same. Many-many physical processes generate the movement in the way they work, regard the motor as a physical process.

So. How does the motor work? Is there a web page to find it?




1529  Using Arduino / Programming Questions / Re: 5 LEDs blink 5 times in a minute at random times on: April 29, 2013, 12:15:03 pm
5 leds 5 times each or 5 leds 1 time each or 5 leds 5 times total.....?
Is that strict or 'about' 5 per minute?

If you use a byte array to keep the pin numbers then you can select a pin by array index. That should open many ideas to you.

You could keep a variable with index and each time through loop() deal with the indexed led then change the index for next time through loop(). That way you can have one short code for all leds and switch one at a time by whatever method you choose to control the times, possibly just if a random exceeds a limit then change the limit until it looks like you want.

The standard random function is not really random. You give it a seed and it will generate a sequence of 'random' numbers always the same for that seed. So every so often which should allow for many 'randoms', give it a new seed based on something as undetermined as possible or even just from a list of seeds if only the look matters.
1530  Using Arduino / Programming Questions / Re: Accessing a "Wire" object from an interrupt routine == hang, need solution on: April 29, 2013, 11:53:09 am
I'm using an IO Expander chip, this gives me 8 digital inputs.  When any pin changes level, I get an interrupt.  The states don't latch, so at that instant I need to capture the state of all of the pins.

If you can get all 8 inputs on the same AVR Port then you can read them all at once with a Port Read. With a MEGA you have clear ports by default. With an UNO... not so easy if possible at all, better to use 2 Ports of 4 bits each.

Look up Port Manipulation on this site.
Pages: 1 ... 100 101 [102] 103 104 ... 301