Show Posts
Pages: 1 ... 128 129 [130] 131 132 ... 300
1936  Using Arduino / Project Guidance / Re: bare bones and dirt cheap cnc on: March 06, 2013, 03:17:00 am
Poor repeatability means you try to cut a circle and it comes close but doesn't close.

I know someone else that's got lots of that potential. I told him that for fixed-depth cuts he'd be better off with a line-follower cutter.

1937  Using Arduino / Project Guidance / Re: Trouble aligning laser diodes on: March 06, 2013, 03:04:39 am
Adjustment screws should be 1/4 circle apart but they don't have to be vertical and horizontal wrt the stick they're in. Set them at 45 deg angles and if you have to have V and H then tilt the stick 45.

|
V
| <--- the stick
|
V <--- adjustment screws
|
|
V
|

And you'd need something spongy/springy opposite the adjustment screws for push-back.

Every time the distance between the stick and wall changes, you will be busy with a screwdriver.

1938  Using Arduino / Project Guidance / Re: Laser harp. on: March 06, 2013, 02:44:23 am
MIDI through a PC or chip?

I can't imagine running a wave table on an UNO but sort of hoping it's possible.


1939  Community / Bar Sport / Re: Youtube bar jokes series: on: March 06, 2013, 02:39:00 am
If you didn't like it, you wouldn't have watched. Hope you remember a few to use.

Some of them cracked me up, like the three guys whose sons were doing so well.
1940  Using Arduino / Sensors / Re: DS18B20 multiple sensors on: March 06, 2013, 02:35:12 am
I guess he would rather spend a pin and extra code than some wire.
That pin would feed the existing data wire with more current through a transistor.
If you've got 2-conductor wire, that will work without another wire and all those connects.
Or if you have a ground chassis (most any car or bike) you could get away with 1 wire.

1941  Using Arduino / Sensors / Re: Adequate temperature sensor for logging on: March 05, 2013, 05:45:00 pm
IMO the better temperature sensors give serial data rather than analog data.

But really anything consistent can be calibrated, even by table. 8-)

Some transistors have a nice amount of variation with temperature, there's even a temperature self-correcting circuit used to measure the one that varies with... probably used in those fancy chips that output serial data.

BTW, there's supposed to be a built-in temperature sensor in the UNO's 328P. That might do!

Also if you want something that doesn't need a PC running, there are cheap working SD card adapters you can log onto. Or, you have 1k EEPROM which can store 17 hours of 1 byte per minute data (0 to 255 or -128 to 127), the SD is really overkill for this.
1942  Using Arduino / Sensors / Re: Sensor measuring distance between another sensor on: March 05, 2013, 05:31:03 pm
Low frequency sound is better at getting around or through things than high frequency. It is also less directional.

If no substantial magnetic metal (iron, most steel, some exotic stuff) or moving conductors or current carrying conductors get in the way then you can tell distance by magnetic field strength.
It would be best to pre-calibrate that one by taking measures alongside a scale and trying different orientations of magnet and linear Hall sensor.

1943  Using Arduino / Sensors / Re: Measure nightsky with TSL237 on: March 05, 2013, 05:15:35 pm
So you have used interrupts and know to make variables used in interrupts as volatile?
And you know that time is kept in unsigned long variables?

How long can you aim at dark sky to get measurements? 3 seconds? 30 s? 300 s? 30 minutes?

Maybe the best way will be to count pulses and see how long that takes.
....
You understand, if I stop when pulse count is done I can know how many whole usecs (microseconds) it takes but I can't know the fraction of a usec after the last full usec. If it was 400001.7 usecs, I will miss the .7. That is an unavoidable (and small) source of error.
If I stop on a time count while also counting pulses then I can know the usecs and how many pulses but not the fraction. If 100 seconds takes 50.8 pulses, my 100 second read only sees 50.
....
Since pulses are so big compared to usecs there will be more possible error counting over a set time than counting a set number of pulses and seeing how long that took. I would rather have a fraction of a usec (really, Arduino is good to 4 usecs which is still very small) as error than a fraction of a much bigger pulse as error.
What decides the method for me is the way with the smaller error. In this case, it's pretty clear?


So big open to the forum just to be sure question --- can you read micros() in an interrupt?


1944  Using Arduino / Sensors / Re: Measure nightsky with TSL237 on: March 05, 2013, 03:48:19 pm
If you count pulses for 1800 or even 180 seconds and something bright doesn't intrude, you can get less error than if count 1 or 3 seconds. Can get... because there's always a way to can't anything.

If you count pulses and see that a certain time has elapsed then you will be off by the fraction of the last pulse that didn't make it unless you exactly end the time period on a pulse start. So there you have the fraction error but that is divided by the number of pulses when you determine the average length of just 1 pulse (the inverse of frequency) so the more pulses, the better.

To do that, have an interrupt increment the pulse count and in loop() set up a timer the way it's done in BlinkWithoutDelay and when the interval is reached, copy pulse count and use that with the time interval you set up, do the math and you can have frequency. The longer the interval, the closer to precise you can be as long as something doesn't intrude on the patch of sky you're watching.

OTOH you can set up an interrupt to count some number of pulses and see how long that took, maybe completely in the IRQ. Then your loop() code just watches for the IRQ to update the how-long-it-took variable and report that. You will have pulses and time. 

Why not a library?
You keep wondering what library to use. You keep wondering if the library you use is the problem. That's because you don't know what they do and it is a problem trying to troubleshoot with such an unknown.

In this case what the library does is not difficult and you will doubtless benefit from learning. Just take your time, identify what it is your don't know and learn those pieces as you put it together.

1945  Using Arduino / Sensors / Re: DS18B20 multiple sensors on: March 05, 2013, 12:58:03 pm
So there's conditions where one way makes more sense than another. Dat's noice.
1946  Using Arduino / Sensors / Re: Measure nightsky with TSL237 on: March 05, 2013, 12:53:49 pm
I wouldn't use a library. I'd save micros() in an unsigned long, count 10,000 pulses and save the micros() right then.
Annnnnd I think you can get micros() in an interrupt though it's stopped. If not then you'll pick up a couple micros setting a flag in the interrupt, leaving the interrupt and catching the flag in loop(). With a tight loop() you'll have micros() very quickly.

Errors --- you can measure Arduino inaccuracy and compensate. Deal with that after you get the rest working. It amounts to changing time microseconds

frequency = pulses / time

If the time is a 62845 microseconds then multiply pulses by 1 million then divide by 62845 to get Hz = cycles(pulses) per second.

10000 pulses / 62845 usecs = 10000 pulses / ( 62845 seconds / 1000000 ) = 10000 pulses x 1000000 / 62845 seconds (doing it with integers and the least loss requires 64-bit long long int) = 159121 Hz.
 
When you do math for science, keep the units (pulses, seconds, ergs) in the math because at the end if your units don't make sense then your math didn't either. (this is where you remember your science teachers saying the same thing)

1947  Using Arduino / Sensors / Re: DS18B20 multiple sensors on: March 05, 2013, 07:50:45 am
The microcontroller must assure that sufficient power is available by enabling what Dallas calls a "strong pullup". 

I dunno about PIC but with AVR I can make a pin pullup by setting it INPUT HIGH. If I'm not using that same pin to read data for a while, I can switch it to OUTPUT and give the line 5V. If I want to, I can switch the same pin to INPUT again. With the ability to switch modes in less than a usec, why do I need an extra pin? I can throw an extra resistor, even 1k on the pin and it won't affect the current from low-tolerance pullup in the AVR (20k-50k, does PIC have built-in pullup resistors?) much but limit the OUTPUT HIGH current lots.
   
1948  Using Arduino / Programming Questions / Re: Why does this program only work when I use a Serial.* statement in it? on: March 05, 2013, 07:38:14 am

The example code is not the best it could be.

int ledpin = 13;  //  there are less than 256 pins, use a byte instead, save a byte in RAM
This I get.
int pinArray[ 8 ]; // because a habit is a habit
This?  Not so much unless you mean it as an example of what NOT to do?

Exactly. It is the same mistake multiplied 8 times in 1 line most often out of the habit of typing i-n-t.

 
1949  Using Arduino / Sensors / Re: Measure nightsky with TSL237 on: March 05, 2013, 07:12:01 am
You can count the time length of a number of pulses, the more you count the more the per-pulse average will ... average out.

You can count how many pulses in a measure of time and lose a fraction of a pulse. The longer the time the less the lost fraction means.

pulses/time or time/pulses, both are ratios is all. Get one, you have the other.

 
1950  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 04, 2013, 04:37:14 am
Why not a stepper?
Pages: 1 ... 128 129 [130] 131 132 ... 300