Syntax error with the EEPROM command

I am using a 28X1 and need to store a byte variable in location 0 of the EEPROM. I get a "Syntax Error" on the line EEPROM 0, b6
My code is as follows:
Code:
     'Variables
Symbol RXIN =W0
Symbol DLYin=W2
Symbol Dly = b6
      'Pins
Symbol RX_IN= Input0
 	let dirsc = %11111110
 	Pause 10000
   Main:
	readadc10 0,DLYIN
	If DLYIN=0 then goto Main1
	DLY=DLYIN/15 MIN 30 MAX 100
	[B]EEPROM 0, b6[/B]
   Main1:
	pulsin 0,1,RXIN
	read 0, b6
 

BCJKiwi

Senior Member
the syntax includes ( ) around the data;
i.e. EEPROM 0, (b6)

But should you be using the scratchpad instead?

EEPROM has limited write cycles, scratchpad is RAM = unlimited write cycles (& faster)
 
I still get a Syntax Error message with the parenthesis
EEPROM 0, (b6)
I am not familiar with tha scratch pad. Will the data be erased when the power is turned off?
I need to be able to read the data after the Picaxe is turned off and powered on again.
 

BCJKiwi

Senior Member
Yes scratchpad will get lost on a power cycle.

It looks like the eeprom command will not handle b6 - it's expecting numbers only (or text enclosed in " "s).
So the write command will be required instead.

EEPROM;
"Information:
This is not an instruction, but a method of pre-loading the microcontrollers data
memory. The command does not affect program length."


Read and write manipulate the data stored in eeprom during regular program activity.
 

westaust55

Moderator
Your are using the EEPROM command incorrectly.

EEPROM is a compile time directive that only occurs when you run the Program Editor and download the program to the PICAXE.


variable b6 is never know at compile/run time so it will give the syntax error.


Within the running program you need to use the WRITE and READ commands

I see that you are using the READ comamnd already at the bottom off your code.
Just change the EEPROM to WRITE and all should be well

EDIT:

I concur with BCJKiwi wrt use of scratchpad vs EEPROM.
While Scratchpad RAM does not retain the values when the power is off, EEPROM has in round terms 100,000 write cycles. It is best for applications which write once (or few times) and read many times applications.
If you are writing once per second then, within about 30 hours the EEPROM/PICAXE may have problems in the future with EEPROM memory failure.
 
Last edited:

Dippy

Moderator
Yes, as WA says. You only use the EEPROM command at download time to 'preload' the EEPROM with data to be used in your code e.g. some default values at startup or preloaded messages for LCD.

If you looked in the Manual uner "eeprom/ data" command it says:

"Function:
Preload EEPROM data memory. If no EEPROM command is used the values are
automatically cleared to the value 0. The keywords DATA and EEPROM have
identical functions and either can be used.
Information:
This is not an instruction, but a method of pre-loading the microcontrollers data
memory. The command does not affect program length."


Note the use of the word preload.

Look in the Basic Manual under READ and WRITE as said. Always worth a look.

You could use scratchpad or just poke the byte somewhere.

To reduce EEPROM wear you could cycle the writes throughout the EEPROM (a bit like SD cards do I believe), or have a bit of capacitance on the power and have a supply fail detect, so for most times you POKE or Scratchpad the byte and when a power fail is detected it sticks the value in EEPROM. This could even be done with clever use of interrupt. The latter is a bit more fiddly and requires an extra couple of components but is better than a failed EEPROM.
 
Last edited:
The data will be written occasionally and read all the time. The attached schematic shows the 5K pot (R3) and jumper (J6). I will adjust the pot to get the desired value of b6 and then remove the jumper so the value of W2 will be 0 and no writing will take place. But I need the value of b6 to be available after cycling the power.
I changed the code as follows and it compiles without errors, I need to test it on the circuit to see if b6 is available after cycling the power.
THANK YOU FOR THE HELP
Code:
Main:
	readadc10 0,DLYIN
	If W2=0 then goto Main1
	b6=W2/15 MIN 30 MAX 100
	Write 0, b6
Main1:
	pulsin 0,1,RXIN
	Read 0, b6
 

Attachments

BeanieBots

Moderator
The diode you have in between 5v and the 28X1 Vcc pin is likely to cause you some problems.

First off, not sure how accurate/repeatable you need the ADC value to be, but as you are using ReadADC10 I take it you want better than 8 bit.
The diode volt drop will effect your readings because the 28X1 uses the power rail as its reference voltage. The diode volt drop will depend on both temperature and what the PICAXE is doing at any given time.
When the programming cable is plugged in and the serin line is high, the +12v is current limited by the 22k. The excess current will be conducted by the internal clamp diode. Normally, this current would be drained into Vcc, however, your diode will prevent this by blocking it. The result will be an increase in the supply voltage to the 28X1.
OK, so you have a zener clamping serin. What is it's voltage? How sharp is its knee point?
No decoupling for 28X1 (or any of the others). Asking for trouble, especially with that diode in place.

If you are nervous about reverse polarity, then fit a low current in-line fuse and put a 1N4001 ACROSS the supply.
 

BeanieBots

Moderator
Yep, I should of spotted the BAT85. (ie. enhanced download circuit).
It was the non-conventional way of showing a 0v ABOVE the components that threw me.
So, no zener clamping then. ALL the excess serin current goes..... where?
(see my original post for the answer to that).
 

Dippy

Moderator
Quickly Marmite, take the diode out before BB crowbars his internal fuse.

PS. I don't suppose you're the first person to put a diode there :)
 
Thank you for the input, by now it must be obvious that I am a beginner. A further explanation of my purpose and design is in order. The circuit will be powered from a radio control receiver (J2) the power is from a 3 cell LiPo connected to an electronic speed control which in turn provides 5V to the receiver and 11.1V (nominal) to the motor. There is little or no chance of reverse voltage (I'll use polarized connectors) so I removed the diode (D2).
Your comment "No decoupling for 28X1 (or any of the others)" is another concern. If I need to add a capacitor(s) I don't know where or what capacity.
 

Attachments

Dippy

Moderator
Decoupling caps for PICAXE are usually a capacitor or two as physicaly close to the V+/Gnd connections as possible. This is commonly doen with logic chips and other old favourites such as the old 555 where its switching could put a bit of noise on the line. I shudder to say crowbar.

It reduces nasties in the power tracks to the PICAXE. And you effectively insert this capaciive 'filter' at the last moment i.e. right next to pins.

Coincidentally just about where you C1 drawn.

Every person has their 'favourite' capacitor and it is always better than anyone else's. Pretty sad really...

On circuits which may be a bit noisy I tend to use 2 caps; a tantalum (e.g. 4u7/10V) and a ceramic (e.g. 47nF). Right slap bang next to the IC power pins. Values can be smaller. On average non noisy circuits a 100nF or 220nF polyester would do enough.
 

BeanieBots

Moderator
Dippy has pretty much covered the decoupling cap bit.
(my favourite is 100nF ceramic;))
Have you measured the voltage comming from the BEC in your ESC?
Most of the ones I've seen are 6v, in which case you might need to consider using a low dropout 5v regulator.

As an avid RC'r myself, can I ask what you're building?
 
I am using a 25A speed controller from Great Planes. The manufacturer says that the output to the RX is 5V. I meassured it and fluctuates from 4.8 to 5.1V.
The airplane is a scratch built Kadet Seniorita. I reduced the plans to 78% and built it as light as I could. The sole purpose is to carry the circuit and a lot of lights. Actually it will have a total of 34 LED. Four of the lights will be inside the transparent platic spinner and 6 SMD LED in the propeller. To power the lights in the spinner and propeller I made a special backplate and scavenged soft brushes from an RC car motor. The drag produced by the brushes causes an increase of 1.2 Amps on the current to the motor but it is well within the capability of the motor/controller/battery.
I intend to fly it at an event for electric powered planes. One of the days of the event they fly until very late hours with lighted airplanes.
If you are interested I could post some photos.
Thank you again for your advise from you and Dippy.
 
Last edited:

BeanieBots

Moderator
"Scratch built", good for you!
Lights in the prop! I've seen it done in helicopter blades by including batteries etc within the blade itself. What size prop? Won't it compromise the performance, or worse, structure? Have you considered inductive power for the prop LEDs?
 
BeaniBots,
Performance is not a problem. The total weight is 33 oz. therefore the wing loading is very low. The propeller is an APC 10x7E but I will change to a 10x5E and test again. So far it had 3 flights with the brushes but no circuit. The airframe is holding fine. I'm using a Futaba 7 channel FAAST (2.4GH) and so far no glitches from the Picaxe (tested on the ground today after I removed the diode:eek:)
And yes, scratch built, I am an old man and don't believe in ARFs
More news as they develop.
 
Last edited:

BeanieBots

Moderator
Please do a video once done.
As I get older, I've moved away from scratch build and have recently committed the ultimate sin and gone RTF:eek:

2.4Ghz FAAST will be virtually immune to noise in both directions. Severe noise will reduce range but should not cause any glitching. IMHO it is an absolute god-send for the RC world. No more peg boards or worry of downs caused by channel conflict. The shorter aerials make life much easier too, both in the model and on the ground. Be careful indoors though. Wireless routers and micro-wave ovens cause a 3m dead area around them:eek:
 
Top