I finally ran out of memory

Yes, I finally did it. I overflowed memory and upset the compiler really bad. I was working on the code to read the PING sensor and I can’t even add a couple of variables and a 5 or 6 lines of code to read the sensor.

Hmmm, this must be a clue that it’s time to upgrade to a Pro and convert my code over. I could comment out all the serout lines and such I have for debugging, but I have an idea for being able to turn those on and off remotely via bluetooth at some point. But, since I have no more space for program code, that won’t happen with the Basic ATOM either.

Other than the serout lines, there really isn’t anything else I can remove to get back some code space. :frowning:

8-Dale

Does this mean the Ping code will take a little longer? :frowning:

:frowning: Sorry and :slight_smile: Glad to hear this.

Sorry to hear that ran out of room. I know that when I was using the Atom I did this a couple of times. This was mostly due to debug code. But once you convert your code over, I think you will be happy with the Pro.

Happy to hear that your computer is back up and running!!! :smiley:.

Yes, unfortunately, it probably does. Well, unless I can find some code that I can remove to make room for new code.

I have a Creep behavior that I really isn’t necessary. I just wanted to see if I could get it to work. :smiley: I’ll take a look and see what doesn’t really need to be there. :slight_smile:

It will be at least a few weeks before I can afford to upgrade to an Atom PRO. Other things have priority right now, like getting a PIC programmer and/or a different microcontroller (not Atom PRO).

8-Dale

Somehow, I knew you would say something like that. :slight_smile:

I knew this was going to happen sooner or later. I don’t doubt I would be happy with the PRO, but I would also like to move to a microcontroller that has Open Source tools available, such as ARM or AVR.

Thanks! I even have my Creative X-Fi sound card working. :slight_smile: Now I have to get all 5 speakers working so I get surround sound again. Actually, I think two came unplugged and just the center speaker does not work.

8-Dale

I do like working with the AVR chips as well. Earlier I was playing around with Atmega16 and Atmega32 chips. I am set up win an STK500 and JTAG, which makes things work very well.

At some point I will probably switch back and maybe get a board like:bdmicro.com/mavric-ib/ I much prefer programming in C or C++.

But for right now I am enjoying working with the Atom Pro as it is fun being able to share ideas and code with forum members and the Pro does give you reasonable access to some of the hardware such as the timers and interrupts, etc.

Lucky guy!

The thing that bugs me about running out of memory is it doesn’t seem like I should be now. I removed all the Creep code and commented out all my serout commands.

Now I go from 4806 bytes free down to 193 bytes free and a crash when I uncomment these lines:

[code]PING_Detected var bit ’ 1 = Detected, 0 = Nothing detected
PING_Distance var long ’ PING object detection distance
PING_Echo var long ’ PING echo duration

PULSOUT PING, 5
PULSIN PING, 1, PING_Echo
PING_Distance = PING_Echo ** 2251[/code]

I’m not sure about how large the values returned I can get, so I declared the PING variables as longs. Still, it doesn’t seem like this little bit of code should take that much space, but I could be wrong.

8-Dale

i think it goes by the size of the varible (it puts aside enough memory for the maximum possible size u desinate for the varible) or something to that effect

i have the basic atom, and i had it for months with non-stop programming
and it still has lots of memory left, but im thinking of getting atom pro, cause its cabable of more things

If I look at the documentation for the Ping sensor up on parralax.com the ping can happen from 115microseconds to 18.5ms (18500 microseconds).

So it looks like the value should only go up to 18500. Also looking at the pulsin command it looks like by default it will only go up to 65535.

I have never used the ** command, but I know that it is supposed to return the upper 32 bits from the multiply. Looking at the sample code for the sensor my guess is that on the BS2 these are 16 bit operations, as it talks about it being like the multiply of the value divided by 65536.

As to why these instructions take almost 4000 bytes???

That code doesn’t seem to work. Could it be because I am using an atom pro?

Spacejunk

Looking at the differences between an Atom and the Atom Pro, I see that the PULSEOUT parameters are different. On the Atom it is number of microseconds. On the Atom Pro it is the number of .5 microseconds and it is supposed to have a minimum value of 8. (Version 8.0 ide)

So maybe try changing the 5 to a 10.

I don’t have one of these so I can not try it out. But you might need to initialize the state of the PING line to either high or low?
LOW PING

You can see the sensors data sheet at:
parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf

It still isn’t working. :confused: I tried using low ping before the pulsout command.

I don’t claim that this new code of mine actually works. It may not even be correct for reading the PING. I have a Basic ATOM, not a PRO. :smiley:

8-Dale

The atom and atom pro shouldn’t be that much different. Have you tested this code?

I have not been able to test the code since I keep running out of memory on my Basic ATOM.

The Basic ATOM and PRO are much more different than you might think. The PRO has much higher resolution on timing and the servo command.

8-Dale

I did change the timing res but I am still having trouble. Hope you fix your memory problem. :slight_smile: Thanks.

I have been thinking about diffrent way of doing this. I may us an SX prosser to read the sonar if I spend lots more time than I already have. This could mean more things to go wrong :confused: . Anyway, I hope I can get this working.

I was just thinking how we both have good solid code for reading various kinds of sensors. Although I need to convert my code for use on the Atom PRO, we could create a library file of sensor code we’ve written that has been tested and debugged that is solid and works.

I am going to do this with the code I have written for the Basic Atom and then convert it and do it for the Atom PRO when I get one also.

We could send these library files of sensor code to Beth where she could add them as downloads here. This would create a good code base for others to start out with. Creating code from scratch and researching how to use a device is a good exercise and learning experience that I gain extra satisfaction from once things work, but others may not share my enthusiasm in this. :slight_smile:

I like reusable modules because they allow me to concentrate on the larger application of creating the robot’s software rather than having to reinvent the wheel all the time when I know others have already been there and done it before me. I have to admit though, I rarely use a module as is and almost always end up modifying it in some way. I have based all my sensor code on what others have done before me and very little of the original code could be recognized now. :slight_smile: I base my code for the PING sensor on what I found on the Parallax site written for the BS2.

8-Dale

Good idea! :smiley: Maybe it will help with my Ping problem. :frowning: