CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Contagem de 5 em 5 no display, de 1 em 1 na 74595 (SOLVED)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
emazzu630



Joined: 14 Aug 2018
Posts: 20
Location: Ouro Verde - SC

View user's profile Send private message

Contagem de 5 em 5 no display, de 1 em 1 na 74595 (SOLVED)
PostPosted: Tue Dec 11, 2018 9:33 pm     Reply with quote

Já procurei na internet, mas não encontrei nada dessa natureza. Tenho o programa montado contando de 5 em 5 no display e no 74HC595. Preciso dividir por 5 para contar de 1 em 1 no 74HC595. No display precisa continuar contando de 5 em 5.

-------------------------------------

I've searched the internet, but I have not found anything of this nature. I have the program set counting by 5 in the display and in the 74HC595. I need to divide by 5 to count from 1 in 1 on the 74HC595. The display needs to continue counting by 5.


Last edited by emazzu630 on Wed Dec 12, 2018 1:17 pm; edited 2 times in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 3:27 am     Reply with quote

Not quite clear what you want to do, but if you have a count called 'count' say:
Code:

    int8 remainder, over5;
    //count called 'count' say
   
    over5=count/5;
    remainder=count % 5;



Will give 'over5', being count/5, and 'remainder' being the remainder from
division by 5.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 7:44 am     Reply with quote

Show us your code and a diagram of your circuit.
Tell us what works and what does not.

Mike
emazzu630



Joined: 14 Aug 2018
Posts: 20
Location: Ouro Verde - SC

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 12:01 pm     Reply with quote

https://drive.google.com/file/d/1ji3VW3v5CzUglW-NBfw5eFBTMFy7T5IT/view?usp=sharing
https://www.4shared.com/photo/RD_aEzT3da/simulao.html

Na imagem acima o display conta de 5 em 5. Nos leds aparece o numero "15" em binário e no display também o numero "15". Eu preciso descobrir uma forma de ir fazendo a divisão por "5" para que no display fique "15" e em binário "3", mas isso nesse ritmo para qualquer numero que contar.

----------------------------------

In the picture above the display counts by 5 in 5. In the leds the number "15" in binary appears and in the display also the number "15". I need to figure out a way to go by dividing by "5" so that the display is "15" and binary "3", but this at this rate for any number that counts.


Code:


unsigned int16 pulsa=0;

/////////////////////////////////////////////////////////////////
   
while(!input(up_5)||!input(dw_5)) {   //while 7 segmentos
   if (!input(up_5))
   var+=c;
   else
   var-=c;
   int_to_seg(var);
   
   d++;
   if(!input(up_5)||!input(dw_5)){
   if(d>9) c=5;}
   delay_ms(delay);
   if(delay>=200)
   delay-=20;
   }
   return var;

/////////////////////////////////////////////////////////////////
   
while(!input(up_5)||!input(dw_5)) {    //while 74hc595 binário
   if (!input(up_5))
   var+=e;
   else
   var-=e;
   int_to_led(var);
   
   f++;
   if(!input(up_5)||!input(dw_5)){
   if(f>9) e=1;}
   delay_ms(delay);
   if(delay>=200)
   delay-=20;
   }
   return var;
}

void main() {

while (true){
   pulsa=ajuste(pulsa);
   }
}



O codigo acima está funcionando, mas ele só assume a contagem de 5 em 5, no display e nos leds. Eu preciso que ele assuma a contagem de 1 em 1 nos leds em binario.


Last edited by emazzu630 on Wed Dec 12, 2018 8:41 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 3:21 pm     Reply with quote

OK, maybe I'm reading this wrong , but if 1 press=5, 2 presses=10, ...,5=25, then

simply count 'presses' ,multiply by 5 save as a variable '5counts', and send this '5counts' data to the display.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 3:32 pm     Reply with quote

You want the LEDs to show the display value, divided by 5.
Make the changes shown in bold below:
Quote:

while(!input(up_5)||!input(dw_5)) { //while 74hc595 binário
if (!input(up_5))
var+=e;
else
var-=e;

// int_to_led(var);
int_to_led(var/5); // *** Divide var by 5 ***

f++;
if(!input(up_5)||!input(dw_5)){
if(f>9) e=1;}
delay_ms(delay);
if(delay>=200)
delay-=20;
}
return var;
}
emazzu630



Joined: 14 Aug 2018
Posts: 20
Location: Ouro Verde - SC

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 8:30 pm     Reply with quote

https://drive.google.com/file/d/1bDN7wKL6PqIe5Ip0WewfyfiaK4-7TvCQ/view?usp=sharing
https://drive.google.com/file/d/1wOFQ4_-Ry9jN532YUkag9-YDeCaqXi6H/view?usp=sharing
https://drive.google.com/file/d/1PRmwnyqxZYOLeISd0qMkBnw44PlsfnZ5/view?usp=sharing

Obrigado aos membros do fórum que se preocuparam em resolver a discussão. A solução apresentada pelo "PCM programmer" foi testada e funcionou. Nas imagens acima podemos ver o resultado

------------------------------------------------------------

Thanks to forum members who have been concerned to resolve the discussion. The solution presented by "PCM programmer" was tested and worked. In the images above we can see the result.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group