Show Posts
Pages: [1] 2 3 ... 23
1  Using Arduino / Project Guidance / Data logging in Linux on: April 30, 2012, 12:07:51 pm
I would like to make a data logger, using the analog inputs from an Arduino, which has serial-over-USB. I want to use a computer running Linux to retrieve the data from the serial connection serial and store it. I want to do it as fast as possible, but I can adjust the sample rate in the Arduino firmware to slow it down as far as needed. My question isn't about the Arduino part, but about the computer part. I know just enough bash and perl to be dangerous.

I need a way to grab the serial data from the Arduino and store it in a file. How do you do that? I know how to use the serial monitor in the Arduino program, but I don't know how to redirect that to a file. Can I just write a bash script like so?
Code:
cat /dev/ttyUSB0 >> mydatafile.txt

and this just keeps running until I kill it?

My hard drive is not infinitely big, so I also need a way to somehow "scroll" or  over-write the file when it gets to a certain size. I don't know what Linux utility lets you write to the end of a file and delete the first line, but there must be one. If not I guess I can write a perl script to do that constantly, but it might slow things down.

The other option would be to create multiple files and delete the old ones as hard drive space fills up. I guess I could do that with perl.

I hate to reinvent the wheel so insight is appreciated.
2  Using Arduino / Motors, Mechanics, and Power / Re: Help with AC motor from turntable on: April 23, 2012, 01:54:17 pm
OK. That grey square thing isn't immediately recognizable as a motor. It's just a grey square. What's under it? I'm guessing it's a 3-phase AC motor like a hard drive motor, but it might be a shaded-pole motor if there is some kind of speed control. Are there any gears under it?

If it's a shaded pole motor or brushed DC motor, you can slow it down by 'dimming it'. If it's an AC synchronous motor or 3-phase motor, you will have to change the driver electronics frequency.

What's that thing to the bottom left a bit? That DOES look like a motor, or transformer or solenoid.
3  Using Arduino / Motors, Mechanics, and Power / Re: Help with AC motor from turntable on: April 23, 2012, 01:00:45 pm
I can't see the mechanics well enough. What, in that picture, is the motor? I don't see a turntable just a bunch of boards and plastic.

Is it belt drive? Gear drive?

4  Using Arduino / Motors, Mechanics, and Power / Re: motor control on: April 12, 2012, 10:50:17 pm
I didn't say resolution...I said precision. Discussing the width of a pulse that can be measured is different than discussing the frequency of waveform that can be sampled/recovered.
5  Using Arduino / Motors, Mechanics, and Power / Re: SSR and Arduino on: April 10, 2012, 09:32:33 am
Many SSRs spec 3-30V. I have some 20A 240V SSRs that spec 3-30V input. I would look for a more-compatible SSR.
6  Using Arduino / Programming Questions / Re: Quick white space question on: April 10, 2012, 09:31:00 am
Wow, so in my case, the backslashes caused the pre-processor to remove the newlines, but the compiler would have ignored the newlines anyway.

I will have to keep this in mind next time I enter a C obfuscation contest.
7  Using Arduino / Motors, Mechanics, and Power / Re: motor control on: April 09, 2012, 09:46:49 pm
The '328 can run 16MHz, and the timers can run at CPU frequency. By definition this gives you 1/16th of a microsecond precision. 1/16 is .0625. If you could run at 20MHz, you could pull off .05us. Depending on speed requirements, you may be able to to get significantly more precision by oversampling.


I'm skeptical of the need for such precision. We are talking 15 bits of precision here; I doubt that any of the off-the-shelf RC signal generating hardware is that precise. If you aren't using off-the-shelf hardware, then why use RC servo protocol at all? It's an old and inefficient protocol; the only point in using it is for compatibility with existing hardware.
8  Using Arduino / General Electronics / Re: DSO Nano V2, digital oscilloscope on: April 09, 2012, 02:24:54 pm
If you go to youtube, you can find several videos on the DSO nano V.2 that compare it to 'real' scopes.

Basically, it's a cool single-channel DSO that works up to 50kHz.
9  Using Arduino / Motors, Mechanics, and Power / Re: Arduino synchronous rectification PWM? on: March 29, 2012, 01:43:14 pm
Setting up timers is very easy. Each timer can hook up to a certain 2 pins.

For each timer, there are 4 registers (basically you can consider them byte variables) you need to worry about--2 control registers for the timer, and an compare register for each pin. All you have to do is write the correct configuration to the config registers, and  you get PWM flowing on the pins connected to that timer. The two output compare registers are for each of the 2 PWM pins connected to that timer. You just write whatever duty cycle you want to those registers.

You need 4 pins, so you need 2 timers. You can probably use Timer0 and Timer2. Those are what I use when I need to drive a unipolar stepper. You pseudo code would look like this
Code:
void setup(){

//setup timer 0 for 7.8kHz PWM
TCCR0A = 0b00011011   //config register A for timer0: see table in datasheet for what to write
TCCR0B = 0b00000011   //config register B: see table in datasheet
//now you have PWM on pins 6 and 5.

//setup timer 2 for 7.8kHz PWM
TCCR2A = 0b00011011   //config register A for timer2: see table in datasheet
TCCR2B = 0b00000011   //config register B: see table in datasheet
//now you have PWM on pins 11 and 3.
}

void loop(){
//set motor 1 to 1/2 power:
OCR0A = 128;  //pin 6
OCR0B = 129;  //pin 5

//set motor 2 to full power:
OCR2A = 254;  //pin 11
OCR2B = 255;  //pin 3
}

If it helps you think clearly, you can do do this at the top of your program

Code:
#define OCR0A pin6
#define OCR0B pin5
#define OCR2A pin11
#define OCR2B pin3

Then your loop looks more like this:

Code:
void loop(){
//set motor 1 to 1/2 power:
pin6 = 128; 
pin5 = 129; 

//set motor 2 to full power:
pin11 = 254; 
pin3 = 255; 
}


10  Using Arduino / Motors, Mechanics, and Power / Re: Arduino synchronous rectification PWM? on: March 28, 2012, 04:35:52 pm
This is actually very doable. All you have to do is set up PWM on 2 pins, using the same timer, both in "phase correct" mode. Set your PWM timer's frequency so that one timer period is equal to the delay you need to prevent shoot-through. Then, whatever duty cycle you are "commanding" the system to output (say 128) you just set the lower pin duty cycle to 128 and the upper pin duty cycle to 129. The upper pin will switch before the lower one, by a time equal to 1/F_timer, on every PWM cycle.
11  Using Arduino / Motors, Mechanics, and Power / Re: Outpur pin maximum current on: March 24, 2012, 02:27:37 pm
yes that's what I meant.
12  Using Arduino / Programming Questions / Re: Quick white space question on: March 24, 2012, 02:26:39 pm
I mean besides those things. I mean specifically the backslashes.

It compiled with the backslashes and gave correct output. I guess backslashes are just ignored inside array declarations?
13  Using Arduino / Motors, Mechanics, and Power / Re: Unipolar motor -- am I crazy? [now with code/schematic] on: March 23, 2012, 05:00:15 pm
Your code seems convoluted, but it might work.

Your schematic should work fine. I'm using a driver board built with TIP110; pictured below...it works fine.

If you use the correct pins, you can create a sinewave/microstep drive.

14  Using Arduino / Programming Questions / Re: Quick white space question on: March 23, 2012, 02:45:05 pm
Ok. So what exactly happens if you do this:
Code:
byte contstant_table [32] { 1,2, 3, 4, 5, 6, 7, 8, 9, 10, \
11,12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
27, 28, 29, 30, 31, 32}

I did this because my brain was still in perl-mode and I thought I needed the \'s. This compiled, but I have no idea what it did.
15  Using Arduino / Motors, Mechanics, and Power / Re: Outpur pin maximum current on: March 22, 2012, 04:46:17 pm
This is a good question--can you parallel pins to get more current capacity? For a low-cost implementation, I can see the utility. If you aren't using the other pins, why not use them etc.

I know that if you run a pin configured as an output into a pin configured as an input, and you set the output pin high, I think you can toast something, but I have never tried it.
Pages: [1] 2 3 ... 23