Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Accuracy of PIC chips

Status
Not open for further replies.

varkunus

New Member
Heya there, how accurate will a pic chip be, and how much will it loose a day? Minutes? Seconds? As some of you know I am making a clock for a pic. Now when I use the wait command, it will only allow a maximum of 65 seconds before I have to loop that command. But with pause I dont get the same syntax error alert. Now time is really tight since my electronics teacher leaves at the end of term so quick replies will be appreciated.
Furthermore could someone tell me how to loop using BASIC programming. I think its like b1 or something. But I also read that you can only loop a maximum of 5 times? But I might not need to if you guys give me the go ahead with using the pause function. Cheers guys"

Richard
 
Heya there, how accurate will a pic chip be, and how much will it loose a day? Minutes? Seconds? As some of you know I am making a clock for a pic.
If you use a 3.2768MHz crystal for the PIC, +/-second/day is not a problem.
If you use a 32.768KHz watch crystal on Timer1 osc, again +/-1 sec/day


It is possible to use the most popular range of crystals to give accurate times.

Now when I use the wait command, it will only allow a maximum of 65 seconds before I have to loop that command.
Which loop are you using.?

But with pause I dont get the same syntax error alert.
No idea what this means.?

Now time is really tight since my electronics teacher leaves at the end of term so quick replies will be appreciated.

Furthermore could someone tell me how to loop using BASIC programming.
Which version of Basic would that be.?

I think its like b1 or something. But I also read that you can only loop a maximum of 5 times? But I might not need to if you guys give me the go ahead with using the pause function. Cheers guys"

Richard

hi,
If you want useful answers, you must give us a more accurate description of the problem...:)
 
Last edited:
sorry im a programming noob guys. I am using PICAXE programming editor, I am doing it as a flowchart but can convert to basic coding. Also the PIC chips themselves are 4mhz.

And I do need to do a loop function. Could someone tell me how to loop. So say I use the wait command, and do it for 60 seconds. But then need to loop that to do 11 hours. I will have to work out how many loops I need, but could someone tell me the command to do it, or the flow chart icon? Cheers guys, if i can get this done by tomoz (final but one lesson) ill be overjoyed!
 
sorry im a programming noob guys. I am using PICAXE programming editor, I am doing it as a flowchart but can convert to basic coding. Also the PIC chips themselves are 4mhz.

And I do need to do a loop function. Could someone tell me how to loop. So say I use the wait command, and do it for 60 seconds. But then need to loop that to do 11 hours. I will have to work out how many loops I need, but could someone tell me the command to do it, or the flow chart icon? Cheers guys, if i can get this done by tomoz (final but one lesson) ill be overjoyed!

hi,
As its a college question, you should solve it yourself.

Give you a hint, consider putting a loop inside a loop.?

for x1 = ....

for x2 = ...
nextx2...

next x1...

:)
 
yes i have solved most of it my self. But my teacher has cancer so has had to leave unexpectidly and we have suppy teachers after that. So I really dont have time to do it. But could some give me the command on how to loop please, cause otherwise I really am stuffed. Could some please give me an example of the syntax needed to loop. And why cant i just do loop 60 seconds? Or if i do will I have to loop 60, then make one loop an hour. Then the next looped 11 times for 11 hours. Please guys Im running out of time, I really need you to help me out
 
yes i have solved most of it my self. But my teacher has cancer so has had to leave unexpectidly and we have suppy teachers after that. So I really dont have time to do it. But could some give me the command on how to loop please, cause otherwise I really am stuffed. Could some please give me an example of the syntax needed to loop. And why cant i just do loop 60 seconds? Or if i do will I have to loop 60, then make one loop an hour. Then the next looped 11 times for 11 hours. Please guys Im running out of time, I really need you to help me out

hi,
Post the program code you have written so far, I'll have a look.:)
 
main:
label_6: high 0
high 1
pause 60000
low 0
pause 46740000
low 1
pause 39600000
goto label_6

thanks alot. It says syntax error when I play run so i need to learn how to loop say 60 seconds to make 11 hours, and how to loop it to make 13 hours. Is there a maximum number of loops you can do?

I mean if someone could give me an example of how to loop by actually posting some syntax, then I would be almost there, especially if there isnt a maxiumum number of loops. And ericgibbs thanks so much, seems your the only one to have taken and interest. I am so close yet so far, and time is running out
 
Last edited:
Read the Picaxe manual 2, page 63, defining Pause. Maximum pause is 65535. Do your loops as logical loops within loops...like seconds, minutes, hours. Do...loop or For...next. Makes life easier and it works. And add "remarks" to your program lines, it helps you troubleshooting...and us, if you ask for help here...and your instructor, if (s)he wants to evaluate what you've done.

Heck read all the Picaxe manuals. :)

Ken
 
yes but my teacher has taught me to do it using flow charts. Please will someone just give me the command to loop I AM RUNNING OUT OF TIME.

hsersetup
Syntax:
HSERSETUP OFF
HSERSETUP baud, mode
- Baud is a variable/constant which specifies the baud rate:
B300_X where X =
B600_X 4 for 4MHz
B1200_X 8 for 8 MHZ
B2400_X 16 for 16MHz
B4800_X 20 for 20MHZ
B9600_X 32 for 32MHx
B19200_X 40 for 40 MHz
B38400_X
B57600_X
B115200_X
- Mode is a variable/constant whose bits specify special functions:
bit0 - background receive serial data to the scratchpad
bit1 - invert serial output data (default is true)
Function:
Configure the hardware serial port for serial operation.
Information:
The hsersetup command is used to configure the fixed hardware serial port of the
microcontroller. It configures two pins to be dedicated to hserin and hserout.
The baud rate is configured by the baud value. For convenience a number of
predefined values are predefined (e.g. B9600_4 for baud rate of 9600,n,8,1 at
4MHz operation)
Hardware serial input can be configured in two ways:
1) via hserin command only (mode bit0 = 0)
2) automatic in the background (mode bit0 = 1)
In automatic mode the hardware serial input is fully automated. Serial data
received by the hardware pin is saved into the scratchpad memory area as soon as
it is received. Upon the hsersetup command the serial pointer (hserptr) is reset to
0. When a byte is received it is saved to this scratchpad address, the hserptr
variable is incremented

Thats what I get get for page 63. PLease will someone just help me, I really dont have the time to muck around my whole GCSE is in jepody. Why wont someone just help out under these non typical circumstances!
 
guys help, you are really my lifeline, just atleast tell me the command on how to loop a certain part of the program

is it something like that?

main: for b3 = 0 to 99 ‘ start a for...next loop
gosub lstep ‘ call left step sub-procedure
next b3 ‘ next loop
for b3 = 0 to 99 ‘ start a for...next loop
gosub rstep ‘ call left step sub-procedure
next b3 ‘ next loop
 
Last edited:
some people really dont understand how desperate I am, once my teacher leaves. THATS IT. I will get no more help at all,

main:
label_3D: high 0
high 1
for b3 = 0 to 779
wait 60 First wait
low 0
low 1
for b3 = 0 to 659
wait 60
goto label_3D

Will this work, in that it will loop the first wait 60 780 times, and then go onto the next loop after pin 0 and 1 are low?
 
Code:
main:
label_6: high 0
high 1
pause 60000
low 0
pause 46740000
low 1
pause 39600000
goto label_6

Hi,
Example:

'if the pause is in 1 sec intervals
'then this will give 60 * 60 secs = 3600secs = 1 hour
for x = 0 to 59
pause 60' secs
next x

'this will give 3600 * 24 = 86400 secs = 1 day
for x = 0 to 23
pause 3600' secs
next x

These are called For Next Loops

Can you follow this OK.?

EDIT:
If you dont understand, tell me exactly what you are trying to do with these timing loops.
 
Last edited:
Code:
'if the pause is in 1 sec intervals
'then this will give 60 * 60 secs = 3600secs = 1 hour
for x = 0 to 59
pause 60' secs
next x

'this will give 3600 * 24 = 86400 secs = 1 day
for x = 0 to 23
pause 3600' secs
next x

hi,
I have downloaded and installed PICAXE.
The PAUSE interval is in millisec.
So:

'then this will give 60 * 60000 millisecs = 3600secs = 1 hour
for x = 0 to 59
pause 60000' == secs
next x

'then this will give 1440 * 60000 millisecs = 86400 secs = 1 day
for x = 0 to 1440
pause 60000' secs
next x

A quick look thru of the PICAXE manual should explain all you need to know for these timing loops,, examples are in the manual.
 
Last edited:
well i can use wait function to make it easier.

So if i want to loop it 13 hours i make that 780 loops. Could you write the exact syntax of how to do this? And thanks for all your help so far.
main:
label_3D: high 0
high 1
for b3 = 0 to 779
wait 60 First wait
low 0
low 1
for b3 = 0 to 659
wait 60
goto label_3D

from the manual i thought this was the way to do loops with the b3 command. Like i said im a complete noob at programming and PICs are only part of my project. Please just to do it for me, no time

Basically could you tell me the exact commands on how to loop a 60 second WAIT for 11 hours, and 13 hours. And then i should bhe done and can crack on with the rest of my circuit
 
Last edited:
well i can use wait function to make it easier.

So if i want to loop it 13 hours i make that 780 loops. Could you write the exact syntax of how to do this? And thanks for all your help so far.

main:
label_3D: high 0
high 1
for b3 = 0 to 779
wait 60 First wait
low 0
low 1
for b3 = 0 to 659
wait 60
goto label_3D

from the manual i thought this was the way to do loops with the b3 command. Like i said im a complete noob at programming and PICs are only part of my project. Please just to do it for me, no time

Basically could you tell me the exact commands on how to loop a 60 second WAIT for 11 hours, and 13 hours. And then i should bhe done and can crack on with the rest of my circuit

hi,
You have already done it OK..:)

b3 is just a variable.

Code:
main:
label_3D: 
high 0 ' set output 0 low
high 1 'set output 1 high
for b3 = 0 to 779 ' 13 hours
wait 60 '   First wait
low 0
low 1

for b3 = 0 to 659 ' 11 hours
wait 60 ' Second wait
goto label_3D
 
Last edited:
well i can use wait function to make it easier.

So if i want to loop it 13 hours i make that 780 loops. Could you write the exact syntax of how to do this? And thanks for all your help so far.
main:
label_3D: high 0
high 1
for b3 = 0 to 779
wait 60 First wait
low 0
low 1
for b3 = 0 to 659
wait 60
goto label_3D

from the manual i thought this was the way to do loops with the b3 command. Like i said im a complete noob at programming and PICs are only part of my project. Please just to do it for me, no time

Basically could you tell me the exact commands on how to loop a 60 second WAIT for 11 hours, and 13 hours. And then i should bhe done and can crack on with the rest of my circuit

Google "BASIC pic"

https://www.mikroe.com/en/books/picbasicbook/04.htm#intro

the wait command that you want i guess its called "delay_ms(#...)" in BASIC and the page shows 3 types of loops along with other nice info.
But befor putting a long delay you may want to read up about the delay_ms routine to see how much it can handle.
Im not fluent in BASIC.

Good Luck.
 
hi flex,
The OP is using PICAXE Basic.:)
 
main:
label_10: for b3 = 0 to 4
high 0
wait 1
low 0
goto label_10
i have just tried doing this program on the actually pic prototype board.. And it just stays high, the light (pin 0) wont go off. SO it obviously isnt working, i need to only loop it a certain amount of times
 
YES this works main:
label_10: high 0
for b0 = 1 to 5
wait 1
next b0
low 0
wait 10
goto label_10

Now if i want to do another loop do i just use b1? e.g the number after the b is just another loop. Such as loop a, or loop b
 
Status
Not open for further replies.

Latest threads

Back
Top