Show Posts
Pages: 1 ... 57 58 [59] 60 61 ... 105
871  Using Arduino / Programming Questions / Servo control on: March 14, 2012, 02:44:32 pm
I posted this in the Storage section a few days ago because at the time I was trying to figure out if what I wanted to do would work with an SD Card.  The answer was yes.  So now I'm moving on to the actual programming aspect of the same thing.  The idea is as follows:

I have two servos that will function as a pan and tilt system.  I'm going to cue them with music.  I have several cue points during the audio piece where I need the servos to do something.  Taking a page from a similar broadcast system, I thought I could have a single text file with commands listed in it like so:
angle_pan   speed_pan   angle_tilt   speed_tilt   pause
       90           2           90            2       5
       45           4           90            0       2
      135           4           90            0       5
Which I would read in as:
- move the pan servo to 90 degrees with speed = 2, move the tilt servo to 90 degrees with speed = 2, wait for 5 seconds.
- after 5 seconds, move the pan servo to 45 degrees with speed = 4, leave the tilt servo at 90 degrees, wait for 2 seconds.
- after 2 seconds, move the pan servo to 135 degrees with speed = 4, leave the tilt servo at 90 degrees, wait 5 seconds.
Etc., etc.  (speed will be somewhere between 2 (fast) and 10 (slow))

The controller's code will then open the SD card, and read the file in bit by bit as it needs to and move the servos as needed.

I choose this method primarily because then I don't have to do anything with the actual code on the controller, just the text file that's on the SD card.  The controller simply reads it in as needed.  When I need to change what the servos do, I simply update the SD card with a new file (for a different piece of music), and off I go.

My question is, is this the best way of doing this.  Will I have to content with a lot of lag between the time it takes for the data to be read from the SD card each time?  I don't plan on reading the whole thing in at the beginning of the program, it will be too big to fit in memory.  So I'll constantly be reading from the card and pass instructions to the servos.

Does anyone have suggestions on how to improve this system, or even come up with a different design perhaps?  I suppose I can always add a DataFlash chip on the controller board.  The controller then reads the whole file from SD card into memory for faster access.  I don't know if that would really make much of a difference though.

Ideas/suggestions anyone?
872  Using Arduino / LEDs and Multiplexing / Re: ws2801 with higher voltage leds on: March 14, 2012, 03:28:57 am
Can anyone shed some light on how to use higher voltage leds (or more leds chained together) than the ws2801 is normally spec'd for?

There is a schematic and description of this on page 10 of the datasheet here but I'm not sure how to calculate the value of the two resistors (RB and RXFB).

There is no 'RXFB' in a high voltage application, only constant current as it acts as the feedback loop for the WS2801.  In high voltage applications, there is no feedback loop (it's grounded.)

That same page has the formula needed to calculate RL, as well as what VCE and RB are.  You should know what VDD is (in that example it's 24V), and you should know what your VLED is ...
873  Using Arduino / Project Guidance / Re: Help identify possible part ... on: March 14, 2012, 03:09:44 am
874  Using Arduino / Storage / Re: Questions about interfacing with SD card on: March 11, 2012, 05:16:49 pm
So if a large portion is read into the buffer, how does it know when to go back and read more?  Or is that what I need to control?
When you read(), as with, the character is removed from the buffer. When the buffer is empty, a read() causes another buffer-full of data to be fetched. This, of course, is time-consuming.
So it might actually be worth trying to figure out when to time those reads?  If I know the MCU is going to be idling for 5 seconds between instructions, maybe trigger a read then?  Pondering ...

Any suggestions on the other part?
875  Using Arduino / Storage / Re: Questions about interfacing with SD card on: March 11, 2012, 03:55:09 pm
Behind the scenes, a larger portion of the file is read into a buffer. It it that buffer that accesses, not the SD card itself. No, you can't change that behavior.
Well that's fine, I don't plan on changing it either.  So if a large portion is read into the buffer, how does it know when to go back and read more?  Or is that what I need to control?

So, why bother? This value, if needed, can be inferred from the record number.
Because I'm used to doing that for MySQL tables. smiley  Each record has an index number, so I can read only the record that has that specific index number (or record within a specific range.)  Whether I will be reading things sequentially, or jumping back and forth, won't matter as long as there's an index number.  But, if it's not needed here since I will be reading sequentially at all times, then I won't bother adding that unnecessary data.

You don't need to. Open the file once. Close the file once. Read the file in a while loop that executes until the whole file has been read.
Sounds easy, perhaps easier said than done.  There will be other stuff going on of course, such as controlling the actual servos and also communicating via Ethernet (though this is still being debated and may not make it into the final project, or at least not the first iteration.)

Anything from none at all to complete migraines. Depends on whether you test the code as you go, or try to write it all first, then test.

Now, I just thought of something else, is there a way to make the SD card show up as a mass storage device when the unit is plugged into a computer's USB port?  Let's me explain the controller board here.  It has an AVR (with Arduino bootloader), an RTC w/ battery, FTDI IC, SPI breakout, and the card reader (with hex converter).  A pluggable stack above it will have the servo connections which simply tie into the Arduino pins below.  Same principle as any Arduino shield.

The FTDI USB connection is to download new sketches (because I just don't like using SPI for that every time, personal choice.)  So I'm curious if the SD card can then shows up as a mass storage device on the computer when a USB cable is plugged in.  This will save me from having to remove it each time I want to download a new instructions file to it.
876  Using Arduino / Storage / Questions about interfacing with SD card on: March 11, 2012, 03:04:37 pm
On a project I'm currently doing R&D work on, I'll be incorporating an SD card for reading of external data.  What I'd like to do is store instructions, specifically in_idx, angle_pan, speed_pan, angle_tilt, speed_tilt, and a timestamp index.  Imagine an Excel file with all the data in it.  in_idx is simply the instruction index.

My question is, is it possible to "stream" this data.  In other words, rather than having the MCU open the file and read the whole thing in memory to execute, is it possible to read-as-needed?  What I'm thinking is, let's say the first few instruction look like this:

in_idx  angle_pan   speed_pan   angle_tilt   speed_tilt   timestamp
     0         90           2           90            2           5
     1         45           4           90            0           2
     2        135           4           90            0           5

This tells me from the first instruction, that both pan and tilt servos need to go to their 90 degree position at speed = 2.  The '5' timestamps at the end means nothing happens for 5 seconds after that, so the MCU knows not to come back for another instruction for 5 seconds.  (The board will have an RTC on it for accurate timings and syncing with other units nearby.)

After those 5 seconds have elapsed, it reads the next set which is 45, 4, 90, 2, 2: move the pan servo to 45 degrees at speed = 4, keep the tilt servo at 90, and wait 2 seconds before getting the next instruction.

After 2 seconds, read the next instruction which tells the pan servo to go to 135 degrees at speed = 4, keep the tilt servo at 90, and wait 5 seconds for the next instruction.

I suppose I can open/close the file each time, but I'm more concerned about delays in doing that.  Basically I want a system I can time accurately to music.  I can tear the audio apart and get exact timings for it.  I want to be able to feed the timing data (modified of course) into a table and onto the SD card for the MCU to then read from.

What caveats do I need to look out for?  What potential problems and/or headaches will I encounter here?  I know I need to figure out how long to wait before expecting the servo to be where I sent it to and feeding it another instruction (otherwise it will never reach its intended target angle.)

Honestly, I don't know if this is the best way of doing this process, so I am open for suggestions here.  The reason I want to incorporate an SD card for this is two fold,
a) I suspect the data will be rather large to fit it all in 32K of memory (actually, I know it won't fit.)
b) Using an SD card means I can set all the instructions in Excel, and export it as a comma delimited file and onto the SD card from my computer, then just pop the card onto the board.

877  Using Arduino / Networking, Protocols, and Devices / Re: W5100 Probleme ethernet on: March 11, 2012, 02:33:58 pm
I said that on my shield he had not the MAC @ Stickers but apparently a new shield on there is no predefined MAC @.

I just bought a brand new, genuine Arduino Ethernet Shield R3, and it most definitely has a sticker with the MAC address on it.
878  Using Arduino / Project Guidance / Re: Help identify possible part ... on: March 11, 2012, 01:51:06 pm
Here's another one, this time on the Ethernet Shield R3.  There's a reset supervisor on it, IC1, which is labeled as 'CAT811TTBI-CT3'.  I'm assuming that's simply an STM811, push-pull, active low IC?  Can anyone verify this please?

And what voltage should it be?  They come in varying voltages: 2.59-2.66V, 2.89-2.96V, 3.04-3.11V, 4.31-4.45V, and 4.56-4.7V.  Since it's ascertaining the 5V line, am I correct that it's a 4.56 - 4.7V one?
879  Using Arduino / Project Guidance / Re: Help identify possible part ... on: March 11, 2012, 03:56:09 am
Danke.  I didn't think of looking a the gate properties.
880  Using Arduino / Project Guidance / Help identify possible part ... on: March 11, 2012, 02:33:09 am
Does anyone here have a SparkFun MicroSD Shield?  Can you tell me what the hex converter IC on it is?  The Eagle files don't give me any information other than to say it's a hex converter.  Is that any run of the mill converter?  Any particular part number?

For reference, this is the product:
881  Using Arduino / Installation & Troubleshooting / Re: Board Not Working on: March 08, 2012, 09:50:20 pm
What schematic did you use?  What parts?  How are we supposed to figure out what's wrong when you don't provide the information?  That's like driving to your car mechanic, handing over the keys, and say 'fix it' ...
882  Using Arduino / LEDs and Multiplexing / Re: A class for blinking LEDs on: March 08, 2012, 05:51:37 pm
I run both 0023 and 1.0 side by side, and just last night started working on a project that will be written entirely in 1.0, or at least, that's the hope.  Everything else has been done in 0023 and I have no plans on "upgrading" them to be 1.0 compliant.
883  Using Arduino / Networking, Protocols, and Devices / Re: Non-blocking Server on: March 08, 2012, 04:19:56 pm
And I just noticed, there are several other servo libraries in the playground, many of which use timers to control the servos.  I think I may have to start experimenting with them, see what works best.  A lot of them are for large quantities of servos, 8 up to 32 or more.  I only need TWO. smiley
884  Using Arduino / Networking, Protocols, and Devices / Re: Non-blocking Server on: March 08, 2012, 03:24:29 pm
Hrm, came across this:

Is something like that what you're talking about doughboy?
885  Using Arduino / Networking, Protocols, and Devices / Re: Non-blocking Server on: March 08, 2012, 03:18:48 pm
The only thing I can think of is you need to make your servoSweep function be interrupt driven if it is that critical.
or use one of the many timer libraries based on "polling".
you need to make the ethernet server routine "yield" to the servoSweep routine so it can execute.

Well yes, I do understand that part.  It's how to implement it that I don't know.  I'm strictly going by all the library examples online.

I do need to be able to move the servo (or at least send it the instruction to move) regardless of what else might be going on inside the main loop.  Ultimately the whole ethernet call/respose section will be pulled out of the main loop and stuck into it's own function.  And it will simply become another function call just like the servoSweep() one.  However, there will be more functions added in the long run, and even without using a single delay(), they will all eat time time ticks that will cause the servo itself to become jittery since it's own instructions are now slowed down because of other stuff running at the same time.
Pages: 1 ... 57 58 [59] 60 61 ... 105