ROBOTC.net forums
http://robotc.net/forums/

Can ROBOTC handle a database?
http://robotc.net/forums/viewtopic.php?f=1&t=3957
Page 1 of 1

Author:  horeg [ Wed Jan 04, 2012 5:56 pm ]
Post subject:  Can ROBOTC handle a database?

Hello all,

I am new both in ROBOTC and Mindstorms, can you please let me know if ROBOTC is able to hande a database? I didn't find much relevant info about this in the ROBOTC manual.

Thanks a million in advance,
Horeg

Author:  MHTS [ Wed Jan 04, 2012 6:03 pm ]
Post subject:  Re: Can ROBOTC handle a database?

horeg wrote:
Hello all,

I am new both in ROBOTC and Mindstorms, can you please let me know if ROBOTC is able to hande a database? I didn't find much relevant info about this in the ROBOTC manual.

Thanks a million in advance,
Horeg

What do you mean by "handle a database"?

Author:  horeg [ Wed Jan 04, 2012 6:11 pm ]
Post subject:  Re: Can ROBOTC handle a database?

Something like for instance I can store data in an external file and then load it into the running software as needed? In other words, I would like to construct a robot that can store a large amount of data in an external file (database) and then recall fragments of data from this background storage.

Author:  MHTS [ Wed Jan 04, 2012 6:15 pm ]
Post subject:  Re: Can ROBOTC handle a database?

RobotC does support file I/O. The simplest way to do it is to store the file in .csv format (comma separated fields in a text file). You can then transfer the file to a Windows PC and have Excel to open it or you can create the CSV file on a Windows PC, transfer it to the NXT and have RobotC open and read the data.

Author:  horeg [ Wed Jan 04, 2012 6:21 pm ]
Post subject:  Re: Can ROBOTC handle a database?

MHTS wrote:
RobotC does support file I/O. The simplest way to do it is to store the file in .csv format (comma separated fields in a text file). You can then transfer the file to a Windows PC and have Excel to open it or you can create the CSV file on a Windows PC, transfer it to the NXT and have RobotC open and read the data.


Perfect, thanks a lot!

Author:  miki [ Wed Jun 20, 2012 2:27 am ]
Post subject:  Re: Can ROBOTC handle a database?

horeg wrote:
... ROBOTC is able to hande a database?

Hi horeg,

If you plan to create a database-like program in NXT, with intensive write cycles, you should know that the NXT's main processor (Atmel AT91SAM7S256) is rated at 10,000 write cycles: http://www.keil.com/dd/docs/datashts/atmel/at91sam7s256_ds.pdf
;-)

Author:  mightor [ Wed Jun 20, 2012 2:34 am ]
Post subject:  Re: Can ROBOTC handle a database?

If you're a very good programmer, you could use some kind of tiered approach with a WiFi sensor and a database server with a front-end on a Linux or Windows box. The NXT does transactions over WiFi to the DB server.

How big is the amount of data you're planning to store? 10K? 100K? As far as I know, files need to be contiguous, that is, not fragmented. The bigger the files, the harder it will be to satisfy this requirement. That is also why you need to specify the size of the file you wish to write to when you create it.

Regards,
Xander

Author:  Spiked3 [ Wed Jun 20, 2012 3:49 am ]
Post subject:  Re: Can ROBOTC handle a database?

The short answer: yes, as many have pointed out. The longer answer: probably not.

If you intend you write a database on the NXT, the lack of pointers is going to slow you down to a stop almost completely. If you take the approach of using wifi, as Xander suggested (and I would as well if you're brave) you will find the technology in its early stages, and you will probably have to discover, diagnose, work around as much with the communications protocol as you would the database protocol. With a ton of patience, you probably can do it, and you will be the first and only so far.

If (more and likely it sounds like) you are just looking for data storage, as opposed to a database, then the file IO is ok for small amounts of data, or large amounts only if you want to access it sequentially in entirety each time, or append only when writing. There are no read/write at offset type functions that I am aware of, and are critical to accessing 'records'.

I hate to be the pessimist, but I am also the realist. If you have a particular plan for data in mind, run it by us here. maybe someone will have some ideas.

Author:  horeg [ Tue Jan 22, 2013 11:15 am ]
Post subject:  Re: Can ROBOTC handle a database?

Hello guys,

Thank you very much for your answers and I apologize for being back so late. My robot project was on hold for a year but I am now about to get a fresh start. This will be really a fresh one as I have only limited experience in programming, some experience with C back in 1997 and Basic 3.14 back in 1986. I want to try to write a sw that can learn. I have a kind of (psychological-logical) theoretical model for that that I would like now to implement into a sw. I believe in learning by doing so my model is far from being complete. For first I think I will try to connect visual and tactile information with each other so that the robot would herself make the abstractions by continuously grouping and regrouping the acquired information. This grouping and regrouping must take place in an external database/data storage as the memory of the brick will be very probably too small for this. But I was not sure if RobotC is able to handle such a database or I should look for some other SW.

Author:  amcerbu [ Tue Jan 22, 2013 3:17 pm ]
Post subject:  Re: Can ROBOTC handle a database?

You'll be happy to know that the RobotC folks added official support for pointers. There're still some bugs (dereferencing a pointer that's not set to an initialized variable's location crashes the NXT), and there's no dynamic memory access, but you can do a lot more now.

Author:  mightor [ Tue Jan 22, 2013 3:35 pm ]
Post subject:  Re: Can ROBOTC handle a database?

amcerbu,

I actually ported a pretty crude alloc/free thing the other night to ROBOTC. It seems to work :) Still quite rough around the edges, though, so it'll need some more work.

= Xander

Author:  amcerbu [ Tue Jan 22, 2013 6:46 pm ]
Post subject:  Re: Can ROBOTC handle a database?

mightor wrote:
amcerbu,

I actually ported a pretty crude alloc/free thing the other night to ROBOTC. It seems to work :) Still quite rough around the edges, though, so it'll need some more work.

= Xander

Awesome! Is it a workaround (I've heard people mention using a large array and dividing it into sections to simulate allocation), or an actual RobotC hack?

Out of curiosity, what happens when you don't free allocated blocks of memory? :D

Author:  mattallen37 [ Tue Jan 22, 2013 9:44 pm ]
Post subject:  Re: Can ROBOTC handle a database?

If you don't free memory, then you run the risk of running out of memory. In that case, you won't be able to allocate any more.

Author:  mightor [ Wed Jan 23, 2013 1:32 am ]
Post subject:  Re: Can ROBOTC handle a database?

Quote:
Awesome! Is it a workaround (I've heard people mention using a large array and dividing it into sections to simulate allocation), or an actual RobotC hack?

Yeah, it uses a large heap of memory and allocates the request amount and marks it as used. When it is freed, it will try to reuse that chunk if possible.
Quote:
Out of curiosity, what happens when you don't free allocated blocks of memory?

You get a NULL pointer back, just like the real thing and if you don't check for that, you'll probably crash your brick, just like the real thing!
Quote:
If you don't free memory, then you run the risk of running out of memory. In that case, you won't be able to allocate any more.

That is the case with all finite resources, is it not?

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/