PICAXE program help

Hi everyone. Newbie here :)

I'm currently studying A2 Electronics, and my teacher is trying to think of ideas for projects. Today he got me to see whether we could use the EPROM memory on a PICAXE-18A for a project. I discovered that it was too impractical, but am wondering if anyone could point out an easier way :)

The idea was as follows :-

To feed in 4 bits serially to the PIC and WRITE this value to an address in the EPROM. Then READ that address and OUTPUT it when necessary.

The problem I found was that the WRITE command needs the user to specify the value to be stored - either a Variable from A-H, or a number from 0 to 255.

As the user will not know what the value of the 4-bit serial input will be, we didnt think the WRITE command would work, and instead it would need an EPIC flowchart considering all possible values. Even only using 2 bits, it would be huge.

So my question is whether anyone can think of a way to write the flowchart more easily, or whether it really is too much for an A2 project.

Btw, we're running the PIC Logicator software on XP Professional on a school database and as stated above, it's a PICAXE-18A.

Many thanks.

Ben
 

BeanieBots

Moderator
Welcome to the forum.
I think you've answered your own question.

The problem I found was that the WRITE command needs the user to specify the value to be stored - either a Variable from A-H, or a number from 0 to 255.
If WRITE can use a variable (which it can) then simply make that variable hold the data you want to save. It REALLY IS that simple.

I don't use logicator myself so can't help with the specifics.
 
Hmm. I think that's the problem. It's NOT as simple as wished. I'm not sure how Logicator accomodates for this option.

I have double Electronics tomorrow morning and will enquire further and report back in the afternoon, but I have a feeling that Logicator will be stubborn :|

But ta anyways :)

Ben
 

hippy

Ex-Staff (retired)
You only have one four-bit number to store so that can be be held in a single variable and placed in any single Eeprom location; WRITE to location Zero is good enough. When you want that number back again you use a READ of location Zero to get it back into a variable.

The challenge then is to build up the four-bit number one bit at a time into a variable which can be used with the WRITE block.

That isn't quite so hard as you may be imagining. First, think of how you'd read in one bit, store that and read it back. Then think about how you might store two ( or more ) bits in a single variable.

Logicator will do what you want, it's really a matter of working out what you need to do then how you need to do it. The key ingredient is "Binary Arithmatic".
 
OK that's sounding more feasible.

I forgot to mention that the information would then be outputted in parallel.
Don't know how much difference that would make??

So the fact that the incoming 4 bit number is unknown won't make a difference?
I just store the input in a variable, then depending on the value of that info, I WRITE to a predetermined address?

Ben
 

BeanieBots

Moderator
That's pretty much it.
What the value is doesn't matter. You just store (write) it to EEPROM.
You only need one location, so that can be a fixed location.

Outputting is also simple. Just get the value back from EPPROM (read) and present it to an output port with something like "let pins = ...."
 

westaust55

Moderator
If you only have 4 bits of data being input for each value without any leading zero bits then you cannot use the usual SERIN type commands.

Realise that you are using Logicator whereas most here (including myself) use the BASIC programming language through the Programming Editor, but you might look at the SHIFTIN command on page 189 of PICAXE manual 2 (currently Rev 6.9) for some guidance on how to serial receive data with two wires as a data and clock line.

Example there is for 8 bits with notes about greater numbers of bits but can equally be used for 4-bit values

EDIT:
ultimately all is determined by what the source of the input is and whether it is only 4 bits of data or if it is just the low nybble (4-bits) of a byte.
EF needs to give more details on what the input source is.
 
Last edited:

Technical

Technical Support
Staff member
A 4 bit number is just part of an 8 bit number (byte).

So in Logicator you can probably just
'serin' to serially receive the byte into a variable
'write' the var to memory
then later
'read' the value into a var
'out' the value onto the output pins
 
Top