View previous topic :: View next topic |
Author |
Message |
emazzu630
Joined: 14 Aug 2018 Posts: 20 Location: Ouro Verde - SC
|
Contagem de 5 em 5 no display, de 1 em 1 na 74595 (SOLVED) |
Posted: Tue Dec 11, 2018 9:33 pm |
|
|
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
|
|
Posted: Wed Dec 12, 2018 3:27 am |
|
|
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
|
|
Posted: Wed Dec 12, 2018 7:44 am |
|
|
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
|
|
Posted: Wed Dec 12, 2018 12:01 pm |
|
|
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
|
|
Posted: Wed Dec 12, 2018 3:21 pm |
|
|
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
|
|
Posted: Wed Dec 12, 2018 3:32 pm |
|
|
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
|
|
|
|