EEPROM Question

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

EEPROM Question

Post by George_B »

Hi, that's my first post here so excuse me for any mistake and for my poor English as well.

I am working on a project using a MCU PIC 16f628A to control two dosing pumps.

Using the Flowcode 4 software i have programmed the PIC micro controller.

The problem i am facing is regarding the EEPROM as i mentioned on the title of the topic.

I write a variable to the EEPROM , then i turn the power off and then again on but the variable i get in the same adress is not the same with the saved variable. I guess that the EEPROM doesn't save the variable properly and that is the reason that i ask your help.

Is there anything that i should do to face that issue ?

Thanks in advance !
George

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: EEPROM Question

Post by petesmart »

Hi George,

I seem to recall have an issue with location zero on the EEprom... try using another location..... location one or two for example

see how you go

all the best

Pete
sorry about that Chief!

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Hi Pete, you gave me an answer that i am looking for three days now.

Thank you very much for your answer!!!!!

PROBLEM SOLVED: ADDRESS 0 of EEPROM is not recommended for use.

Regards
George

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM Question

Post by Enamul »

Hi,
I seem to recall have an issue with location zero on the EEprom... try using another location.....
Are you saying that in some PIC we might have problem in using 0th address of EEPROM? Because in my one project I have used 16f876 I have seen this kind of problem not with all PIC but with some PIC (may be hardware problem I thought)..

I was using 0th location as an indicator for writing some data in EEPROM but if we turn off-on power and try to read the location which we have already written...we don't get that bcz it seems to me now 0 th address goes wrong which tells PIC nothing written.

Is that a PIC IC issue or FC issue?

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: EEPROM Question

Post by petesmart »

Hi,

I believe its a pic issue... Benj from MM put me onto it some time ago, and i did follow up on the Microchip website, which confirmed it.

It does not impact all PIC variants, just a few I believe...as a rule now I dont use location zero, just in case.

all the best

Pete
sorry about that Chief!

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM Question

Post by Enamul »

Hi Pete,

Thanks for the info :)

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: EEPROM Question

Post by petesmart »

No problem, glad i could help.

this link maybe useful... follow the thread down to the middle of the posts.... BenJ provides some explaination

http://www.matrixmultimedia.com/mmforum ... n+0#p30258

cheers

Pete
sorry about that Chief!

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM Question

Post by Enamul »

Hi,

I wish I would have noticed this in the early Jan '12. We had a tough time with 100 s of 16f876 ICs...Work fine couple times..then don't work..re-write works few times..then same problem...

Few ICs don't work at all..

Thanks goes to you and Ben the Boss :)

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Hi, another issue that i have is about the stepper motor speed in flowcode.

How is it possible to program to have variable speeds during the motor's operation ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM Question

Post by Benj »

Hi George,

You vary the stepper motor speed by varying the time period between calling the step functions.

Using a delay you can simply edit the length of the delay.

Using a timer interrupt you can vary the timer period register.

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Thanks very much for your reply!

To be honest i didn't get the way that i have to develop the flowchart to achieve that you just explained. Is there any example of this kind of program in flowcode?

Basically, i am trying to control a stepper motor driver (using pulse and direction signals). I can control the motor properly but i don't know how to adjust the speed of the pulses in order to have the motor running faster.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM Question

Post by Benj »

Hello,

Here is quick demo using delays.
3. Stepper Speed Control.fcf
(6 KiB) Downloaded 392 times

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Hi Ben and thanks again!

I did something similar to your design.. the only "problem" is that the pulses are not very fast as i want to be and therefore the speed of the motor is still low..

In your example above, what is the frequency of the pulses if we suppose that the ADC is 0 ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM Question

Post by Benj »

Hello,

In my example I added a delay of 50 to the ADC sample so the maximum speed would be 1/50ms or 20hz.

You could change this delay to say 1 to give you a max speed of 1000hz or even change the delay to us instead of ms which would give you much higher frequency ranges.

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Thank you very much i appreciate your help !

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Hi again!! I managed to run and control the stepper motor properly after i tried several examples of coding..

Another think that i want to ask, is it possible to interface the DS1307 to PIC 16F877A using Flowcode? Do i have to use any component from Comms Menu in flowcode?

I am trying to make a digital clock ( actually i did it ) but i want to restore the data (hour,minutes,day) after the power goes off.
Regards
George

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM Question

Post by Benj »

Hello George,

The DS1307 device needs a I2C interface connection so you should be able to use the I2C component in Flowcode to communicate with the device.

Here is an article on the device.
http://www.matrixmultimedia.com/mmforum ... 307#p35668

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: EEPROM Question

Post by Enamul »

Hi,
Here is a clock program using ECIO-40 but you can change that to any PIC with enough memory. To have clock running in the absence of power, you need to connect a 3.3V battery in Vbat pin of DS1307 IC. In the example program, you need to put time and date in the FIRST_TIME macro which keep record in EEPROM and next time when powers up..you don't need to think about time it will keep maintain real time.

Edit: For ECIO-40P
RB0/SDA
RB1/SCK

Hope this will help :)
Attachments
ECIO_CLOCK_v1.fcf
(42.91 KiB) Downloaded 287 times
Enamul
University of Nottingham
enamul4mm@gmail.com

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Hi all!

I am facing an issue regarding a Timer program that i am currently working on.

I am using an interrupt (TMR0) in order to count seconds and so on..

The problem with my timer is that it is not quite accurate as it should be. The timer runs faster that the internet clock.

Is there anything that i have to look at in order to solve this problem?

Attachment = (F low C ode V ersion 5)
Clock_Using_Interrupt.fcf
(10.5 KiB) Downloaded 262 times
Thanks in advance
George

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: EEPROM Question

Post by George_B »

Any idea please?

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: EEPROM Question

Post by dazz »

Hi george
First off can you follow the link in my sig to enable access to the v5 forums as it make it easier to find questions if they are in the correct forums

If you do a forum search for timer theres a spread sheet somewhere that martin posted, which will help you get the correct times, also add an led and make a 1 second flasher as once thats right you know your clock settings are on the correct track

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Post Reply