16F877A Timing Problems

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

16F877A Timing Problems

Post by Nasim Khaliqhey »

To whom it may concerns
dear sir or Madam
I have been using PIC16F877A for switching ON/ Off LEDs ,evry operation is working as my design there is a slight problem of delay timing
I use the calculation as flow for 16 bit .

65536-((7x16000000/(65536x4)) =65,1 I take just the first 2 digits also tried with the first 3 digits .
the result is the LED is ON constantly
looking forward for a solution
wr
Nasim

( Note) the calculations are done for 8Mhz and 16 Mhz the output voltage is stronger with 16 Mhz crystal

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: 16F877A Timing Problems

Post by Benj »

Hi Nasim,
the result is the LED is ON constantly
( Note) the calculations are done for 8Mhz and 16 Mhz the output voltage is stronger with 16 Mhz crystal
It sounds like the delay is significantly smaller than you're expecting. You are seeing the LED as constantly on but in actual fact it sounds like it's switching on and off at high speed. This is confirmed by the fact that changing the crystal frequency is changing the brightness of the LED.
65536-((7x16000000/(65536x4))
A calculation like this is not ideal as it will overflow your variables and won't give you the result you're looking for. Ideally if you can do the calculation before hand and simply plug in the value required to your program then it will reduce the work the program has to do.

Without seeing your program it's hard to know for sure where the problems may be.

Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: 16F877A Timing Problems

Post by Nasim Khaliqhey »

sign design for veriations.fcfx
(18.38 KiB) Downloaded 208 times
sign design for sending toPIC.hex
(45.26 KiB) Downloaded 194 times
Hi Ben here I send you two copies of I have been using Flowcode 6 .
and saved at a USB from there I can see the all operation over & over
unfortunately with Flowcode7 I can not see the LEDs operations
never mind that it will be found one or other way
kindly show me how to calculate the delay according to pre scalar or according 1/f
with regards
Nasim

Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: 16F877A Timing Problems

Post by Nasim Khaliqhey »

Nasim Khaliqhey wrote:sign design for veriations.fcfx

sign design for sending toPIC.hex

Hi Ben here I send you two copies of I have been using Flowcode 6 .
and saved at a USB from there I can see the all operation over & over
unfortunately with Flowcode7 I can not see the LEDs operations
never mind that it will be found one or other way
kindly show me how to calculate the delay according to pre scalar or according 1/f
with regards
Nasim
the topic is not belonging to my Report the PIC which is used is a PIC16F877A for shifting ON & Off LEDs
if I find the solution earlier I inform you thaks.

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: 16F877A Timing Problems

Post by Benj »

the topic is not belonging to my Report the PIC which is used is a PIC16F877A
I've created a new topic for you. Please be sure to post a new problem in a new forum topic to avoid confusion.

Bit confused, in your attached project file I don't see any of the code you mentioned. Just output icons and delays ranging from 563 seconds (9.38 Minutes) to 653 seconds (10.88 minutes).

You also have a variable counter which is not initialised. In the sim this will start from 0 but on the hardware this will have an unknown value. The variable is never used so probably not an issue.

Maybe it would help if you described what it is you're trying to do.

Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: 16F877A Timing Problems

Post by Nasim Khaliqhey »

thanks allot Ben
I did initialised the timer variable
but my delay calculations has been more then 100 % wrong
thamks

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: 16F877A Timing Problems

Post by Benj »

Hi Nasim,

If your delays are wrong then it suggests that something in your project setup is incorrect.

Are you using a crystal or other external oscillator source? If so what is the frequency? In your project you are specifying a crystal frequency of 19.6608MHz in the project options.

For your delays of 563 seconds (9.38 Minutes) approx how long is the delay lasting for?

Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: 16F877A Timing Problems

Post by Nasim Khaliqhey »

hi Ben
I will check all what I have been doing with the calculations
As I mentioned I made the Delay calculations regarding of using 16 MHz crystals & the caculation formulas been taken from micro lab
here must be a small personal mistake
I will start with finding the corrections hope fully soon
thanks for you help. & it is good to have you with
wr
Nasim
.

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: 16F877A Timing Problems

Post by Benj »

Hi Nasim,

For the delays you enter into Flowcode to be accurate you will simply have to click on the Build -> Project options Menu.

Set the clock speed to 16000000, you can type in the text field if it's not already available in the drop down list.

Click OK.

Delays will now be accurate, no need to calculate the number of instructions manually.

Nasim Khaliqhey
Posts: 90
Joined: Wed Oct 15, 2014 5:20 pm
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: 16F877A Timing Problems

Post by Nasim Khaliqhey »

thanks for very use full info dear Ben J I received a new password now I been able to read your post.
and I have done what you have asked me to do coming Monday I will put it in action you will receive
the info from me
sign design for veriations.fcfx
(18.37 KiB) Downloaded 283 times
with regards
Nasim

Post Reply