Show Posts
Pages: 1 ... 420 421 [422] 423 424 ... 586
6316  Using Arduino / Programming Questions / Re: Help with delays on: July 19, 2011, 05:42:40 am
Quote
could the resistance of it be affecting the delays?
No.

Quote
I am using 2 LEDs on a separate microcontroller and using a transistor to turn the microcontroller on and off...
Whoa, that's a bit out of left field. Does this have anything to do with the above sketch? Is that sketch running on the processor that's controlled by the transistor?

______
Rob

6317  Using Arduino / Programming Questions / Re: Question regarding timer1/counter on: July 19, 2011, 05:25:36 am
Here's my version of a delay line.

Code:
// will produce invalid results for the first DELAY_IN_US micro seconds
// as defined produces an image of PORTB:2 on PORTC:6, delayed by 56uS
// Note that if you organise the hardware so the in and out bits are on different
// ports but the same bit location you don't have to do any bit shifting

#define DELAY_IN_US    56
#define INPORT         PINB
#define OUTPORT        PORTC
#define MYPORT_IN_BIT  2 
#define MYPORT_OUT_BIT 6 

byte buffer [DELAY_IN_US];
byte *ptr = buffer;
// define something to compare the pointers against assuming it's faster to compare two
// pointers than a pointer against a literal
byte *end_ptr = buffer + sizeof(buffer) + 1; 

void  one_mhz_interrupt_func () {

    *ptr++ = (INPORT >> MYPORT_IN_BIT) & 1;         // isolate the input bit   
   
    // by definition the next byte in the buffer is DELAY_IN_US uS old so the pointer now points
    // either to that byte or it's off the end of the buffer
                               
    if (ptr == end_ptr) ptr = buffer; // reset pointer to start of the buffer if necessary
   
    // note that if you have nothing else connected to the port you don't have to fool around with
    // bits here either, but this assumes there are other things on OUTPORT
    OUTPORT |= (*ptr) << MYPORT_OUT_BIT;   
   
}

In a nutshell every uS you read the IO port and put that value in the buffer, then take the oldest value out and write it to the IO port. The same +-.5uS jitter will apply as David's routine, however I think this is about as fast as you can get so you could possibly make the interrupt frequency faster to reduce the jitter.

Caveat: Off the top of my head, should work but I may have missed something.

______
Rob
6318  Using Arduino / Programming Questions / Re: Question regarding timer1/counter on: July 19, 2011, 01:01:13 am
David's "delay line" ring buffer will work and that is the way I would do it, you can't get much simpler, much better that starting timers etc.

But for future reference you can provide an external clock to the timers on the T0 and T1 pins.

______
Rob
6319  Using Arduino / Installation & Troubleshooting / Re: Resistance of an Arduino Pin on: July 18, 2011, 09:08:55 pm
40 is the value in the "Maximum" table, but you should never use components at their max level.

30 would be OK, but rating things at half (or is that twice) the rated levels is a good safety margin that doesn't stress a component.

______
Rob
6320  Using Arduino / Programming Questions / Re: Help with delays on: July 18, 2011, 08:29:58 pm
I can see nothing really wrong with the code, so it's probably the resistor retrolefty mentioned.

You are saving the millis() value for no reason, I assume this is a start at a version that doesn't use delay().

Also you aren't debouncing the button, but in this program that won't matter.

RE the LED, if you control through a transistor in the normal way that will invert the signal, that is how things work. But for a single LED you don't need a transistor, just a current-limiting resistor.

______
Rob
6321  Using Arduino / Networking, Protocols, and Devices / Re: RFD21733 2.4Gz Transceiver on: July 18, 2011, 08:11:03 pm
Hi katapulp, I can't help with these modules but they look good. Xbee is the default "standard" for this sort of thing but they are so large and these modules are only 15x15mm, albeit with a shorter range than Xbee.

Anyway I'm interested in how you go with them.

______
Rob
6322  General Category / General Discussion / Re: I've heard of Arduino on: July 18, 2011, 07:58:56 pm
I wouldn't over think it too much, for $20 you can buy an Arduino, another 20 for some parts, then start playing.

Another option is a starter kit, there are a few around, like this http://toysdownunder.com/arduino-starter-kit.html.

Here's a review of some

http://aaroneiche.com/2009/06/29/arduino-starter-rundown/

Cupla years old now I think but still useful.

______
Rob
6323  Using Arduino / Project Guidance / Re: Arduino controlled lab variable power suply on: July 18, 2011, 07:31:07 pm
Surely using a modern variable regulator and a DAC or digital pot would be easier, that's a heck of a complex circuit for what is essentially a simple problem.

______
Rob
6324  Using Arduino / Installation & Troubleshooting / Re: Resistance of an Arduino Pin on: July 18, 2011, 07:21:34 pm
Quote
can the Arduino be used directly as a relay without other hardware?
To a point. The max current you should draw from an Arduino pin is about 20mA, if the thing you want to actuate only needs that much then go for it. If it needs more then you should use a transistor or other amplifying device.

______
Rob
 
6325  Using Arduino / Programming Questions / Re: Time accurate multi threading using Interrupts on: July 18, 2011, 09:26:45 am
That's the sort of trouble you can get into.

That code looks pretty good to me, I'd probably get rid of the

while(millis()-sync_top<10) {

block as i don't see any reason to only test for serial chars every N mS.

Bear in mind that the serial reception is already interrupt driven.

EDIT: Just noticed, the two variables (acc and delta_acc) used in the ISR should be declared with "volatile"

______
Rob
6326  Using Arduino / Programming Questions / Re: Time accurate multi threading using Interrupts on: July 18, 2011, 08:38:24 am
It's normally bad form to nest interrupts and a good way to get into trouble. Apart from that I don't seen any reason to, you have working code now  (which we haven't seen) that handles the time-critical DAC stuff and the serial receiving is easily handled by the main loop I would think.

If that's all there is to it I see no reason for a second interrupt, and certainly not a nested one.

______
Rob
6327  Using Arduino / Storage / Re: Problems with parallel sram on: July 18, 2011, 08:13:36 am
The voltage shouldn't die like that, what are you using for a power supply?

______
Rob
6328  Using Arduino / Storage / Re: Problems with parallel sram on: July 18, 2011, 06:14:38 am
Did you look at the code I think is wrong?

You also need to find out where 5v turns into 4.36v. Measure at the source, if it's good there then work down the line until it goes bad.

If it's bad at the source unplug the ram and see if things change. Do you have 5v with no ram? If so then the ram chip may be at fault. If it doesn't change then the PSU is at fault.

Do you only get this voltage when running your sketch? If you run a blank sketch does it still show 4.36v?

______
Rob
6329  Using Arduino / Storage / Re: Problems with parallel sram on: July 18, 2011, 02:56:02 am
Yep I just looked at the data sheet, it seems that it's OK to even leave CE low permanently. I still prefer to keep such things together in one function, but that's as much a style issue as anything. Meaning that a function called writeByte() should do everything involved in writing a byte. On a larger program someone may call writeByte() directly one day and wonder why it didn't work.

Admittedly if speed is an issue the current code will be faster and this is a very small program, it's easy to see what's happening as the CE code is just a few  lines above.

______
Rob
6330  Using Arduino / Project Guidance / Re: Is My Project Feasible? on: July 17, 2011, 07:48:06 pm
I'd do what RC said. Make a small board with one input SR and one output SR, thus 8 IOs. Organize the board so the data in and data out pins on the SRs come in from one side and go out on the other. When you have that working make more boards and start daisy-chaining them.

Eventually you will need 64 boards, if you do it like this they are all connected in series and you don't have to worry about driving 64 clock and data lines but it will be slow(ish). But if it's just for people to press a button and see a LED then that's OK.

______
Rob
Pages: 1 ... 420 421 [422] 423 424 ... 586