Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

problem with aritmatic

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
kiki

Bascom Member



Joined: 06 Dec 2013
Posts: 21

blank.gif
PostPosted: Sun Jan 05, 2014 8:16 am    Post subject: problem with aritmatic Reply with quote

hi all..i need your help..

Waktu:
Start Timer1
Set Portb.4 'this pin use for active dinamo
Pul = Pul + 6 ''here the problem..if interrupt we switch 2 time then "pul" is 12 so i want 6+6=2,how to create that
If Pul > 9 Then 'one time i switch the interrupt "pul"=6 and "det"=0 and timer is 60 inthe same time
Pul = 0 'two time i switch the interrupt,"rat"=1 and "pul"=2 and "det"=0 and timer is 120 inthe same time
Rat = Rat + 1 'example:timer is countdown until "pul"=2 and "det"=5 so if we switch the interrupt then "pul" and "det"
must be add 60 so"pul"=8 and "det"=5

End If

Return

====================================================================================================
$regfile = "attiny2313.dat"
$crystal = 4000000
$sim

Dim A As Byte
Dim Det As Byte
Dim Pul As Byte
Dim Rat As Byte
Config Pind.4 = Input

Config Portd.1 = Output
Config Portb = Output

Config Timer1 = Timer , Prescale = 8
Config Int1 = Low Level
Enable Interrupts
Enable Timer1

Enable Int1 ,
On Int1 Waktu
On Ovf1 Nilai

Stop Timer1
Tcnt1 = 65386


Do

Portb = Lookup(det , Seg) 'for 7 segment
Waitus 1
Portd = &B1111111 'for 7 segment katoda
Waitus 500

Portb = Lookup(pul , Seg) 'for 7 segment
Waitus 1
If Pul = 0 Then Portd = &B1111111 'for 7 segment katoda
If Pul > 0 Then Portd = &B1111101
Waitus 500

Portb = Lookup(rat , Seg) 'for 7 segment
Waitus 1
If Rat = 0 Then Portd = &B1111111 'for 7 segment katoda
If Rat > 0 Then Portd = &B1111011
Waitus 500
Loop Until Portb..4 = 0

End
Waktu:
Start Timer1
Set Portb.4 'this pin use for active dinamo
Pul = Pul + 6 ''here the problem..if interrupt we switch 2 time then "pul" is 12 so i want 6+6=2,how to create that
If Pul > 9 Then 'one time i switch the interrupt "pul"=6 and "det"=0 and timer is 60 inthe same time
Pul = 0 'two time i switch the interrupt,"rat"=1 and "pul"=2 and "det"=0 and timer is 120 inthe same time
Rat = Rat + 1 'example:timer is countdown until "pul"=2 and "det"=5 so if we switch the interrupt then "pul" and "det"
must be add 60 so"pul"=8 and "det"=5

End If

Return

Nilai:
Incr A

If A = 150 Then Decr Det
If Det = 255 Then Det = 9
If Det = 0 Then Decr Pul
If Pul = 255 Then Pul = 0
If Pul = 0 Then Decr Rat
If Rat = 255 Then Rat = 0

If Det = 0 And Pul = 0 And Rat = 0 Then
Portd = &B1111111
Stop Timer1
Reset Portd.4


Return


Seg: 'nilai 7 segment common katoda
Data &B00111111 , &B00000101 , &B01011011 , &B01001111
Data &B01100101 , &B01101110 , &B01111100 , &B00000111
Data &B01111111 , &B01100111

very need your help please...thanks :D

(BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.6 )
Back to top
View user's profile
Deanus

Bascom Member



Joined: 26 May 2006
Posts: 188
Location: Adelaide

australia.gif
PostPosted: Tue Jan 07, 2014 6:39 am    Post subject: Reply with quote

Hi Kiki,


Quote:
Pul = Pul + 6 ''here the problem..if interrupt we switch 2 time then "pul" is 12 so i want 6+6=2,how to create that


This code is doing the correct thing, if you want the answer 2 then the code MUST be Pul = Pul + 1, then two times on the switch will be 2!

6+6 cannot = 2

Due to the fact this post has been sitting here a while and unanswered, I don't think we can help you on this one, the logic requirements see all wrong
unless you explain what you want one step at a time.

Regards from a baffled

Deanus[/quote]
Back to top
View user's profile
kiki

Bascom Member



Joined: 06 Dec 2013
Posts: 21

blank.gif
PostPosted: Fri Jan 10, 2014 8:54 am    Post subject: Reply with quote

ok , i see...thanks for your information. Very Happy
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum