Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino Memory Limit on: February 03, 2008, 01:10:59 pm
If you're using the stack also to store return addresses, etc., then what you're describing is very much possible. On my Motorola 68HCS12 this is precisely what happens, and it mostly goes back to 0 only to reset and freeze.

If you're not using it to store return addresses, really they should just be overwriting each other -- which isn't good, but shouldn't cause it to crash. Of course, if you get to the point where you're starting to address negative memory locations, THEN you're going to have a problem (in all honesty, they should be treated unsigned if I remember correctly, so you'll just be accessing memory that's not really there).

EDIT: But I just realized that's not the OP smiley-cry

So, OP, what exactly are you doing that could cause you to run out of memory? That's quite a bit of processing to do on a RISC microcontroller.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Disable Interrupts on: December 18, 2007, 01:23:46 am
Thanks a bunch; I can't say I noticed any major problem with the timing while interrupts were enabled today but I figured I should prepare for a worst-case scenario. I'm used to coding realtime systems and while it isn't likely that an interrupt will occur in the middle of this pulse, it is definitely possible.

Do you think my reasoning is justified here? Or do you see a better way of handling PWM that I am missing? The problem I was facing is that I have 4 analog values coming in which need to be fed serially to a controlling computer. I also have 4 servos hooked up which need to have their signals periodically refreshed. I have determined that I can have all of the analog values interleaved and the signals for the PWM pulsed all at the same time using the code above. Originally I was doing it one servo at a time, then one sensor at a time, then serial. Unfortunately the delay was far too much to maintain accuracy, especially when the sensor values tend to be compared against each other.

So far this has worked well for me, so I think I'll leave interrupts disabled. A lost packet isn't a big deal if it were to ever occur, I can handle that. An incorrect value from a sensor or to a servo, however, could be disasterous.

Thanks for the help,
-- Matt
3  Forum 2005-2010 (read only) / Syntax & Programs / Disable Interrupts on: December 17, 2007, 05:22:32 am
Hi there,

I'm working on controlling several PWM devices and I need to be sure that my widths are accurate to within about hundred milliseconds. Originally I was using this code, which worked OK:

Code:
digitalWrite(pin1, HIGH);
delayMicroseconds(pulse);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
delayMicroseconds(pulse);
digitalWrite(pin2, LOW);
// etc...

However we have since discovered that this is just too long of a delay as all of the pulses add up together. I'm fully aware that delayMicroseconds() disables interrupts, but our new plan involves something along these lines:

Code:
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
delayMicroseconds(pulse);
digitalWrite(pin1, LOW);
delayMicroseconds(difference);
digitalWrite(pin2, LOW);

This way we only have to spend some time sorting the timings beforehand. Problem is that these delays are no longer atomic. I am worried that if serial data or something similar comes in at the point in between the two delays, the pulse widths will be extended beyond where they should be.

My hope is that there is a way to disable interrupts so that I can wrap the entire pulse code. I'm not concerned with losing serial data; our protocol has a mechanism to recover from this; however I am concerned if the devices are not operating as they should be. In theory, disabling interrupts should fix this problem.

Any ideas?

Thanks,
-- Matt
4  Forum 2005-2010 (read only) / Interfacing / Re: Multiple Infrared Sensors on: February 03, 2008, 04:10:48 am
We actually found the problem while working on something else,

The problem is that device has some really severe drops in resistance periodically (not sure what causes this, but I imagine it's somehow related to how it's taking samples). This causes a sudden drop on the Vcc line. For this device it's ok, because it's expecting it, but the other two devices are not, causing a sudden change in the signal.

We put a 10uF capacitor across from Vcc to ground on each of the three sensors (literally right next to them, as we found out placing them away from the sensors doesn't seem to help as much) and the fluctuation went away. Combine that with a 4.7uF capacitor from signal to ground and taking 100 samples and then averaging the results, we have managed to get an extremely stable signal.

Thanks for all the help. I knew it had to be something stupid.
-- Matt
5  Forum 2005-2010 (read only) / Interfacing / Re: Multiple Infrared Sensors on: February 02, 2008, 01:20:02 pm
Okay, I got the datasheet. Here it is:

http://info.hobbyengineering.com/specs/SHARP-GP2Y0A02YK.pdf

Please let me know if you see anything; I don't. Today I'll be trying what you said with a resistor as well as some other suggestions I got.

Thanks,
-- Matt
6  Forum 2005-2010 (read only) / Interfacing / Re: Multiple Infrared Sensors on: February 01, 2008, 01:53:15 am
Unfortunately I don't have access to it until Friday evening (Eastern) so I'll post then (all locked up and stuff; don't need anyone jacking our PC/104 that's attached to it >< ). I'll pick up the datasheets then and post when I can smiley

Thanks,
-- Matt
7  Forum 2005-2010 (read only) / Interfacing / Multiple Infrared Sensors on: January 31, 2008, 01:48:19 am
Hi all,

We're having some trouble hooking up some infrared sensors to our Arduino (Diecmela, actually the Boarduino footprint found at ladyada.net ).

We have three infrared sensors hooked up to the A0, A1, and A2 pins. We are adjusting the AREF pin to be set to 3V.

We are noticing that when the infrared sensor goes out of range (that is, goes to a very low voltage), the signal becomes unstable and the results we get from analogRead() are very irratic. When in range (the voltage is higher), the signal becomes stable again. We have hooked these up to an oscilloscope to verify this problem and see a very irratic signal. However, when we hook up the sensor to a power supply and hook the signal directly to the scope, we see a perfectly stable signal even when out of range.

We came across a little phenomenon while testing this -- we had removed the sensors from A1 and A2 and began playing with just A0. We noticed that the A1 and A2 pins got pulled up to the voltage level of the A0 pin! Surely this isn't anything I haven't heard of before; I just hooked up a pull-down resistor to each and the A1 and A2 pins went to zero and everything was as expected again.

... so is this the problem we're having? We're sampling from each of the sensors at an interval of around 100ms, so could these signals be interfering?

If so, what's the solution? Just a pull-down resistor on each pin? I had tried that but the signal still seemed a bit unstable, but perhaps the 49K resistors I was using was a bit too much; perhaps 10K would work better?

Any advice would be greatly appreciated.

Regards,
-- Matt

P.S. I can post my code, but I don't think this has anything to do with it. It seems more of an electrical problem to me.
8  Forum 2005-2010 (read only) / Interfacing / Re: 5v Output working at 10v?? PROBLEM! on: January 31, 2008, 02:46:46 am
Are you sure you're referencing your ground properly? It would appear you're not, and I'm fairly certain your Arduino would have blown up by now if it were truly operating at that voltage.
Pages: [1]