Table of data and dynamic hex command

rs2845

Senior Member
Hello all,

It's unnatural for everything to be 'plain sailing' for my endeavours. Got a question about inserting bytes of data.

Basically I'm building an alarm system.. The part in question is my control panel. I need to store 64 character labels for 16 zones and 40 individual devices (telling me about its exact location). How would I go about setting out these labels in my picaxe 40x2 program? A table? EEPROM? Can someone guide me..?! As you can see it's late and i'll have no hair left if I read any more data sheets.

I do have two 24LC512 external EEPROM chips. I don't mind starting small by using the picaxe EEPROM and expanding later. I can't figure out how to set out the data let alone use an EEPROM!! All about learning though..



Data sheet for my display: http://www.stone-hmi.com/en/UploadFiles/231.pdf
 

westaust55

Moderator
To use the 24LC512 or similar 24LC series EEPROMs you need to communicate using the i2c commands.


You do not say which PICAXE chip you are using.

In addition to the commands such as hi2csetup, hi2cin and hi2cout
have a look at the PICAXE i2c tutorial here:http://www.picaxe.com/docs/axe110_i2c.pdf
the tutorial does use the older commands such as i2cslave, i2cwrite and i2cread but should be easy to translate.

Since your labels are up to 64 characters per line that fits in well with the larger EEPROMs where an internal page length is 64 bytes.
You will need a program/routine to accept and to write the labels for the zones to the EEPROM and a second program/routine to read them back for operational/alarm purposes.

If you seek help with actual program coding, It would help if you:
1. indicate how or when it is intended the data is save to EEPROM,
2. clearly indicate what part of the overall project you want help with
3. Post whT ever code you have already developed as that will/may give folks a better ideal on what exactly you are trying to do/achieve.

you mention getting data into/out of EEPROM but give a link to your display module - what is the connection here in terms of desired help.
 
Last edited:

tony_g

Senior Member
You do not say which PICAXE chip you are using.
4th line down i believe westy, 40x2, have you started indulging in the christmas "spirit" already LOL....oh wait should that be "holiday spirit" now with all the P.C and offend no one correctness? merry christmas.
 

westaust55

Moderator
4th line down i believe westy, 40x2, have you started indulging in the Christmas "spirit" already LOL.... merry Christmas.
If only that were the case . . . .


Is that 64x16x40 = 40960 bytes of storage ?

EEPROM is 256 bytes, and a table is 256 bytes also.
I suspect that it is 64 * (16 + 40) = 3,584 bytes.
In which case even a 24LC256 with 32 kbytes capacity will well and truly cover the requirements.

With a 64 byte "message"/"label" size allowed for once the message/label number is know, just multiply by 64 to get the EEPROM starting address and then read in the next 64 bytes (or until a terminator character is found)
 

nick12ab

Senior Member
Basically I'm building an alarm system.. The part in question is my control panel. I need to store 64 character labels for 16 zones and 40 individual devices (telling me about its exact location).
Others have suggested that you want 40 devices per zone and also that you want a total of 16 zones and 40 individual zones that all need labels. Which do you want? Do you also need an extra byte per individual devvice to indicate what zone it is in? (You could actually use a byte per two devices as there are only 16 zones)

And what about 64 character labels? 64 labels of 1 character of which 56 would be used for 16 zones and 40 individual devices and 8 for what? Or labels of 64 characters long and each device and each zone gets their own label?

Finally don't forget that you can connect 8 of these EEPROMs straight to the PICAXE just by setting the address pins (A0 A1 A2) on each EEPROM to a different pattern of highs and lows - so in order of A0 A1 A2 the first EEPROM will be 0 0 0, the second will be 1 0 0, the third will be 0 1 0, the fourth will be 1 1 0 and so on.

If only that were the case . . . .
It is the case!
How would I go about setting out these labels in my picaxe 40x2 program?
 

westaust55

Moderator
It is the case!
Nick, might I respectfully suggest that you stop trying to be a smart alec!
tony_g had already pointed out what I had missed - it does not need a nickpicker to remind me.
I only pick up your technical/math errors but you seem hell bent on picking up every typo, omission, etc I ever make.

Only yesterday you had another "shot" at me with the remark:
No one would have realized that he had done this if it wasn't for this incredibly useful post!
when I made a valid comment after giving the OP information and the OP then changed tack.

You have no idea what has happened to my eyesight in recent weeks, and due to another ailment while several lots of scans taken to track down cause and on medication will not be partaking of alcoholic drinks for at least another week.

For the rest of the readers on this forum,
may you all have a Merry Christmas and a Happy New Year
 
Last edited:

rs2845

Senior Member
Hello all,

Can't be arguing now near Christmas!

The 16 zones are for the entire system and all labels should only be 32 chars sorry. Each device will have a specific location, and will be assigned to a zone which is a little more generic to the area. So for example if a manual callpoint was in the garage near the entrance. The zone would be "garage" and the device label would be "near entrance"

I'm also going to half the devices to 15.
So that's (16*32)+(15*32)= 992 bytes

Each device (now only 15) should have a 32 character long label. Each zone should have a 32 character long label. For each device label I'm going to need to write what zone number (1-16) it is assigned to. So I'm guessing I need 32 additional bytes free? New total is 1024. I think I've just filled two 24LC512's to the top!

I originally thought that each 24LC512 had 524288 bytes available for use.

The panel won't store which device is assigned to what zone. Unless i have spare space.. My initial plans were that the device would "hold" the assigned zone number, so the panel read the devices for this. But it makes sense to store in the panel...

With regards to how/when the text should be stored and called back to/from the EEPROM:

Basically- once the labels get stored into the EEPROM (perhaps during an initialisation process at powerup) that should be it.

I'm hoping I can one day create a small PC application I can connect to the panel to download into the EEPROM. I'm not even going to try do this yet!

Then when the panel receives some sort of "alarm command" from a specific device (most likely the loop card will store a numeric status value from each device which the panel will compare with, 0 or 1) the corresponding activated device and zone label (so for example zone 4, device 7 on the system) will be inserted into the hex command my LCD display needs to show the activated device.

Does this make sense? It's a little difficult to explain.


The code I tried last night is clearly wrong as it did nothing- hence me not posting it. I was using table and not EEPROM.
 
Last edited:

westaust55

Moderator
with the EEPROMs where the number is in the format 24LCxxx, the xxx is the number of kbits.
so 512 kbits ==> 512 / 8 ==> 64 kbytes.

one 24LC256 with 32 kbytes of storage space will more than suffice.

Due to the nature of "paging" with EEPROMs if you attempt to cross a page boundary when reading/writing multiple bytes of data with a single Hi2cIN or Hi2cOUT command you will in fact wrap around to the first byte in the page.

If your labels/messages are exactly divisible into 64, eg 64, 32, 16 or 8 then there will not be a problem.

With a 24LC256 or 24LC512 you could quite easily stay with your 64 character label strings and have one message per page.

If your code assigns a number say 0 to 15 for zones and 16 onwards for the device/location descriptions then as mentioned before to access / read descriptions multiply the zone/device number by 16 to get the EEPROM address to start reading from. You can use a null ($00) character to indicate the end of a label/description so you know when to stop reading data back.
Alternatively make the first byte in each EEPROM page equal the length of the descriptive string.

If these labels are going to be defined once only and not changed again (or very rarely) as is likely the case for a one off project then a separate PICAXE program could be used to write the data to the EEPROM.
Otherwise it will need to be built into the main program.
 
Last edited:

nick12ab

Senior Member
Nick, might I respectfully suggest that you stop trying to be a smart alec!
You said "If only that were the case . . . ." when he told you where it said that it was a 40X2 which sounds to me like you are saying that what he said was not the case, not that you were agreeing with him.

If you thought that it didn't say that because of your eyesight, then there's no need to have a shout because I pointed it out for you in greater detail.
 

eclectic

Moderator
You've missed the point again Nick.

Westy was answering the question
"have you started indulging in the Christmas "spirit" already LOL.... "

Please Nick, try and understand the more subtle aspects.

e
 

rs2845

Senior Member
Aaanyway.

Thankyou so much for the info on EEPROM. I'm going to find some examples and see how I get on. I think I should be 'okay' with that.

Now on the second point- if I am using EEPROM. How can I "pull in" a device and zone label to send to my display?

Baring in mind- each character of text has to be in hex format.

Could you suggest a small example? Perhaps based on a picaxe EEPROM space? The overall hex string that needs to be sent to the display is:

$AA $54 $00 $A0 $00 $A0 $first letter $second letter.... $CC $33 $C3 $3C

Will I use a variable? Can't figure it out.
 

nick12ab

Senior Member
Now on the second point- if I am using EEPROM. How can I "pull in" a device and zone label to send to my display?
The hi2cin command.

Baring in mind- each character of text has to be in hex format.
Why and how is it going to be in hex format?

Westy was answering the question
"have you started indulging in the Christmas "spirit" already LOL.... "
Well now it makes sense.

Even so, the quote contained an on-topic statement first then an off-topic one second so it's fair to assume that he was referring to the first part.
 

rs2845

Senior Member
Just reading that now. It doesn't look too difficult. He says.

Well, my display (see datasheet in first post) requires the text to be in hex format, not ASCII.

Can the picaxe convert ASCII to hex? Or should I write the text to the EEPROM in hex?

I'm guessing once I use the hi2c command, I'll store the text to a variable (such as b0?) and then insert that into the overall hex command?

So AA 54 00 A0 00 A0 **b0** CC 33 C3 3C
 

nick12ab

Senior Member
Well, my display (see datasheet in first post) requires the text to be in hex format, not ASCII.

Can the picaxe convert ASCII to hex? Or should I write the text to the EEPROM in hex?
ASCII, decimal, hex and binary are just different formats that a binary number can be displayed in. The data is always sent to the display in binary.

I don't think that the datasheet is very clear (see command set) but first try the '8x8 lattice ASCII character' command (whatever that means, sounds like each character occupies 7x7 pixels + 1 to the right and below for spacing) with an ASCII string to see what happens then try the other text commands.
 

westaust55

Moderator
if I am using EEPROM. How can I "pull in" a device and zone label to send to my display?
To initially set up to access an external EEPROM such as the 24LC512, you use the Hi2cSETUP command.
This sets up the two i2c comms port pins on the PICAXE, defines the EEPROM slave address to be accessed, the speed and the width of the addressing (byte or word)

Then you use the Hi2cIN command to read in data or the Hi2cOUt command to send/write data to the EEPROM.
These command allow you to define the EEPROM chip memory location/address for writing/reading the first of one or more bytes of data
followed by one or more byte variables to each hold a data value, character ASCII code, etc.

Well, my display (see datasheet in first post) requires the text to be in hex format, not ASCII.
Can the picaxe convert ASCII to hex? Or should I write the text to the EEPROM in hex?
There are modes that allow you to send ASCII character string. The 8x8 lattice as mentioned by nick12ab means an 8x8 pixel matrix area but the actual characters may be 5 pixels wide x 7 pixels high which is a common standard.

I'm guessing once I use the hi2c command, I'll store the text to a variable (such as b0?) and then insert that into the overall hex command?
Commands such as SEROUT can take a character string in quote marks such as "Hello World" which can be sent to displays etc.
However be aware that a byte variable can only store the data equating to a single character. In this way you can have
b0 = $55 or b0 = 857 which is the same as b0 = "U"
You need to have a PICAXE command with several byte variables in sequence to send characters for a string but as the number of variables are limited,
it can be better to read the characters either singly or a few at a time from EEPROM, send those to the display and in a loop return for more characters until sending the message data is completed.
 
Last edited:
Top