Saving data into 08M2 internal memory

JAM1959

Member
Hello. I am fairly new to Picaxe. Need help to understand saving data into 08M2 internal memory. Have been using attached code. Want to record movement of my racing cars rear suspension using two pots connected to a 08M2.Only need to record movement for one lap lasting about 2 minutes and 30 seconds. Is this possible. Or can someone advise. Thanks in advance. Going racing next weekend 16 October.
 

Attachments

papaof2

Senior Member
My first guess is that the suspension will be moving multiple times each second, so you will need storage for 150 seconds times X movements per second bytes/words of data.
Did you check how much memory the 08M2 has and whether program and data share the same memory space?
 

JAM1959

Member
Thanks for reply. I am more stuck on how to write code which will store data in internal memory. Once car is back in pits i would then like to download and read data in Picaxe Editor. Is that possible.
 

AllyCat

Senior Member
Hi,

Yes it's certainly possible in principle. BTW: It's better to post small code sections in-line (between [code ] [/code] tags); it saves having to download and clutter up my Hard Drive with programs that I'll never need again (and most members won't bother to look). ;)
Code:
main:
    for b0 = 0 to 250 step 2
        readadc10 c.1,w1
        write b0, word w1
        pause 50
    next b0
    goto main1
main1:
    for b0 = 0 to 250 step 2
        read b0,word w1
        pause 100
    next b0
What you have written looks OK, except that the goto1 / main1: is unnecessary; instead you'd probably want a "Pause" until you are ready to Read/Download the Data (or use two separate programs to Write and Read). PAUSE 60000 will give a minute's wait, which could be extended by using several, e.g. inside a FOR .. NEXT loop. But it's probably better to wait for a User Button-Press, or a {DISCONNECT} and a SERRXD from (then SERTXD loop to) the PE Terminal.

However, most of the PICaxes have only 256 bytes of (Data) EEPROM, that's only 128 Words, or less than one Word per second for 2.5 minutes (so the PAUSE 50 would need to be about PAUSE 1250. Firstly, I wouldn't use Words (of which 6 bits are "wasted" if using READADC10), just use READADC and you can store almost two values per second. The 08M2 only has around 100 bytes of spare RAM so hardly worth bothering with (although you might use 64 of them to store the "extra" 2 bits from the READADC10), and you'd need to keep the PICaxe powered up until Read (by a PEEK or @bptr). Other M2s have up to 500 bytes of spare RAM and the X2s up to over 1000 (including Scratchpad).

But you probably "need" much more memory. The simple (and quite economical) solution is to use an external serial EEPROM such as a 24LC16 or (better) a 24LC256, etc.. Only another 8-pin chip and the 2-wire I2C bus is easy to wire up and use in a program. :)

Cheers, Alan.
 
Last edited:

AllyCat

Senior Member
Hi,

Or you/we really ought to give the AXE110P a mention. It even has a socket for a 24LC... , but there's not much time until 16th. :(

Cheers, Alan.
 

PhilHornby

Senior Member
That's a module that I blissfully unaware of - looks like a contender :)

Is there a download link for its default 'firmware' somewhere? - I couldn't spot one.
 

AllyCat

Senior Member
Hi,

There's an AXE110P "Wizard" in PE5 and PE6 > PICAXE > Wizards > which are different, but both appear to create (then Copy) a "Mission" program. Never used it myself, but it looks like quite a good model for programming or using other (PICaxe) Data Logger systems as well.

Cheers, Alan.
 

JAM1959

Member
Hi,

Yes it's certainly possible in principle. BTW: It's better to post small code sections in-line (between [code ] [/code] tags); it saves having to download and clutter up my Hard Drive with programs that I'll never need again (and most members won't bother to look). ;)

What you have written looks OK, except that the goto1 / main1: is unnecessary; instead you'd probably want a "Pause" until you are ready to Read/Download the Data (or use two separate programs to Write and Read). PAUSE 60000 will give a minute's wait, which could be extended by using several, e.g. inside a FOR .. NEXT loop. But it's probably better to wait for a User Button-Press, or a {DISCONNECT} and a SERRXD from (then SERTXD loop to) the PE Terminal.

However, most of the PICaxes have only 256 bytes of (Data) EEPROM, that's only 128 Words, or less than one Word per second for 2.5 minutes (so the PAUSE 50 would need to be about PAUSE 1250. Firstly, I wouldn't use Words (of which 6 bits are "wasted" if using READADC10), just use READADC and you can store almost two values per second. The 08M2 only has around 100 bytes of spare RAM so hardly worth bothering with (although you might use 64 of them to store the "extra" 2 bits from the READADC10), and you'd need to keep the PICaxe powered up until Read (by a PEEK or @bptr). Other M2s have up to 500 bytes of spare RAM and the X2s up to over 1000 (including Scratchpad).

But you probably "need" much more memory. The simple (and quite economical) solution is to use an external serial EEPROM such as a 24LC16 or (better) a 24LC256, etc.. Only another 8-pin chip and the 2-wire I2C bus is easy to wire up and use in a program. :)

Cheers, Alan.
Thanks Alan for taking the time to answer. And u have answered all my concerns. I do have a 28x2 Picaxe but would have to solder up a circuit on a board. Later i can order a complete board, at the moment time is the problem. The data loggers u can buy are out of my price bracket because of our exchange rate in South Africa. Will try your suggestions and see what results i get. Thank your again. Appreciated.
 

mikeyBoo

Senior Member
The link Phil gave to Dataq is spot on. I used Dataq for years in a heavy industrial environment & it can be used to record & measure just about anything (albeit we used the high-end Dataq stuff).

The advantage to their Windaq software is that you can record at very high speeds on multiple channels & then compress or expand time to view pretty much any detail you’re looking for. The data can be scaled into any real-world units (e.g. psi, rpm, etc.).

This type of stuff is used by NASCAR-type crews to hone in on details you couldn’t see using “normal” recorders.

However, in heavy industrial environments there is a tremendous amount of noise (magnetic, etc.) so you must use isolators (e.g. Analog Devices 3B/5B modules). The high-end Dataq stuff has built-in isolators.

I am not sure if race cars have a lot of electrical noise, but I suspect they do.
You would need a laptop & a DI-1100 to get started.
Dataq allows free download of their playback software (but you have to buy the acquisition hardware)
https://www.dataq.com/products/windaq/

I designed a board that lets a Picaxe hook up to a 5B rack or Saleae. If anyone is interested I can post it as a small project. Keep in mind that Picaxe is great for controlling all manner of small projects, but it’s really not appropriate for high-speed data acquisition.

Note that Dataq publishes their data-storage format so it would be possible to write a Python/Tcl etc. app to send Picaxe data directly into a Windaq chart (I haven’t needed to do that but it might be useful).
 

AllyCat

Senior Member
Hi,
... record movement of my racing cars rear suspension using two pots connected to a 08M2.
Are these conventional "rotary" pots with some form of mechanical linkage arm, or something else?

I'd be concerned about their longer-term reliability, and of course two channels will demand twice as much memory space (or half the sampling rate). Therefore, I'd definitely reduce the data "width" to one byte (or less), at least until you can get a serial EEPROM. They're quite a "standard" component, so you should be able to find one of a satisfactory size/availability/price in SA. There are other similar part numbers and manufacturers, you just need to ensure that it uses the I2C (two-wire) Bus and not SPI (3 or 4 data/control wires).

The potentiometer linkage may have a relevance to the data width, for example a swing arm might use less than a half or a quarter of the full pot track. That could make one or two of the data bits redundant (unchanging) or capable of being "inferred" (even if a rollover from 1 back to 0 of a High bit occurs), e.g. by adding a constant. Thus, even a READADC10 value might be recordable within a single byte, or could be compressed into a byte by dividing by 2 or 4 (or a scaling multiplier such as * 64 / 96 or ** 43690 , etc.). Note also that the "WORD" operator is not available within all PICaxe instructions (particularly memory-related), so it can be better to organise the data management in bytes, from the start of programming.

If the ADC values are a full 10 bits (and all useful), then I'd divide them by 4 to store bytes into EEPROM, having stripped off the two Low bits (using // 4 first) to store into RAM (which won't be a catastrophic loss if the supply does get interrupted). Then four pairs of two bits can be merged into (and recovered from) a single byte by simple logical operations. Therefore, 256 bytes of EEPROM (Data) with 64 btes in RAM (08M2) or 1024 bytes of RAM (Scratchpad) with 256 bytes of EEPROM (28X2), etc. could be stored.

Cheers, Alan.
 

AllyCat

Senior Member
Hi,

Yes, I was assuming a two-stage process where first the two low bits are stripped off (into another register variable by using // ) for subsequent processing, and then the original Word is scaled down by division by 4 (e.g. W1 = W1 / 4) to give the byte to be stored.

More efficiently, the Word (say W1) could be multiplied by 64 to put the High (8) bits into B3 (to be stored with a single byte WRITE or POKE, etc.), leaving the two Low bits in the "top" of B2, to be (for example) combined with 3 other pairs of bits to store in a "compact" (single byte) form elsewhere in RAM or EEPROM.

Cheers, Alan.
 
Top