View previous topic :: View next topic |
Author |
Message |
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Sun Jul 12, 2020 3:13 am Post subject: |
|
|
Now I understand all the pure logic, friend. I am going to test your program and I will tell you tomorrow because it is already very nights.
Good night!!
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Sun Jul 12, 2020 4:01 am Post subject: |
|
|
I was able to understand the method you want to achieve.
It's a programming mistake.
Code: |
Dim W As Word
Dim W1 As Word
Dim W2 As Word
Dim W3 As Word
Dim W4 As Word
W = 1234
W1 = W / 1000 'W1 = 1
W2 = W Mod 1000 'W2 = 234
W2 = W2 / 100 'W2 = 2
W3 = W Mod 100 'W3 = 34
W3 = W3 / 10 'W3 = 3
W4 = W Mod 10 'W4 = 4
Print W1
Print W2
Print W3
Print W4
Print
End
|
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Sun Jul 12, 2020 7:12 pm Post subject: |
|
|
Hi!! O_Family!!
Now if I already understand all of them, it is pure logic and mathematics.
All three simulator of yours works fine now I am going to test external card. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Jul 13, 2020 9:57 am Post subject: |
|
|
also have a look at STR2DIGITS function. _________________ Mark |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Jul 13, 2020 1:11 pm Post subject: |
|
|
Hello, Mark
I overlooked this wonderful function.
Recent additions?
I'll add it to my manual now! |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Jul 13, 2020 1:42 pm Post subject: |
|
|
i think it exist some time. since version 2.0.5.0 _________________ Mark |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Mon Jul 13, 2020 7:39 pm Post subject: |
|
|
Hello everyone the World !!
I already learned them very well mathematically and logically and the simulator works very well.
[img][/img]
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Mon Jul 13, 2020 7:58 pm Post subject: |
|
|
At the time of connecting with the digits it works and gives values 0-1023 but there are some digits are weak and others are not, why is it? My card is fine.
DIGITO___1 _Low_Led
DIGITO___0 _High_Led___OK!!
DIGITO___2_ Low_Led
DIGITO___3_High_Led___OK!!
[img][/img] |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jul 14, 2020 12:27 am Post subject: |
|
|
Isn't this a program? There are no other ways?
1234
4
3
2
1
Code: | Dim W1 As Word
Dim W2 As Word
Dim W3 As Word
Dim W4 As Word
Dim Wx As Word
Dim Wy As Word
Const W = 1234
Do
Print "W= " ; W
W1 = W Mod 10
Print "W1= " ; W1
Wx = W / 10
Print "Wx= " ; Wx
W2 = Wx Mod 10
Print "W2= " ; W2
Wy = Wx / 10
Print "Wy= " ; Wy
W3 = Wy Mod 10
Print "W3= " ; W3
W4 = Wy / 10
Print "W4= " ; W4
Loop
End
|
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jul 14, 2020 12:30 am Post subject: |
|
|
Are you ok or wrong?
Code: | $regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack=40
$swstack=16
$framesize=32
Ddrb = 255
Portb = 0
Q1 Alias Portb.0
Q2 Alias Portb.1
Q3 Alias Portb.2
Q4 Alias Portb.3
Ddrd = 255
Portd = 0
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Timer1 = Timer , Prescale = 256
On Timer1 Presenta
Enable Timer1
Timer1 = 62500
Dim W As Word
Dim W1 As Word
Dim W2 As Word
Dim W3 As Word
Dim W4 As Word
Dim Wx As Word
Dim Wy As Word
Dim Cnt As Word
Do
W = Getadc(0)
W = W
If W > 9999 Then
W = 1023
End If
Gosub Separa
Gosub Presenta
Loop
End
Separa:
W1 = W Mod 10
Wx = W / 10
W2 = Wx Mod 10
Wy = Wx / 10
W3 = Wy Mod 10
W4 = Wy / 10
Presenta:
Timer1 = 62500
If Cnt < 4 Then
Incr Cnt
Else
Cnt = 1
End If
If Cnt = 1 Then
Q1 = 0 : Q2 = 0 : Q3 = 0 : Q4 = 1
Portd = Lookup(w4 , Tabla)
End If
If Cnt = 2 Then
Q1 = 0 : Q2 = 0 : Q3 = 1 : Q4 = 0
Portd = Lookup(w3 , Tabla)
End If
If Cnt = 3 Then
Q1 = 0 : Q2 = 1 : Q3 = 0 : Q4 = 0
Portd = Lookup(w2 , Tabla)
End If
If Cnt = 4 Then
Q1 = 1 : Q2 = 0 : Q3 = 0 : Q4 = 0
Portd = Lookup(w1 , Tabla)
End If
Return
Tabla:
Data 63
Data 6
Data 91
Data 79
Data 102
Data 109
Data 124
Data 7
Data 127
Data 103 |
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Tue Jul 14, 2020 1:56 am Post subject: |
|
|
When LEDs are dynamically lit (pulse lit) (duty lit), if the display time for each digit is not constant, the light and shade will appear for each digit.
Normally, a periodic interrupt is used to light each digit sequentially with a pulse for a certain period.
Earlier, I told you that if you turn on the light while doing the calculation in the main routine like you, there will be a problem with the processing time, but that is the result.
In addition, when using dynamic lighting, it is necessary to turn off the common signal for each digit, change the segment data, and turn on the common signal.
This blanking period prevents the ghost phenomenon that affects the display of adjacent digits. |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Tue Jul 14, 2020 3:55 am Post subject: |
|
|
An alternative to STR2DIGITS.
Code: | $sim
Dim I As Byte , W As Word , Digit As Byte
Dim St_w As String * 6
Dim Wd(5) As Byte At St_w Overlay
W = 12034
St_w = Str(w)
For I = 1 To 5
Digit = Wd(i) - 48
Print Digit
Next
End |
E |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jul 14, 2020 6:25 am Post subject: |
|
|
O-Family wrote: | When LEDs are dynamically lit (pulse lit) (duty lit), if the display time for each digit is not constant, the light and shade will appear for each digit.
Normally, a periodic interrupt is used to light each digit sequentially with a pulse for a certain period.
Earlier, I told you that if you turn on the light while doing the calculation in the main routine like you, there will be a problem with the processing time, but that is the result.
In addition, when using dynamic lighting, it is necessary to turn off the common signal for each digit, change the segment data, and turn on the common signal.
This blanking period prevents the ghost phenomenon that affects the display of adjacent digits. |
Thanks Friend O_Family.
I was reading the calculation of the timer, all of them are fine, for me I lack many to study this topic, I am going to study in your tutorial with time and calm.
I already found the flaws you were the program but it works very well since you turn on the 4 digits and I am very happy.
Anyway I already learned the Mod and Lookup instructions how it works ok.
The 4 digits already works very well.
Code: | If Cnt < 5 Then
Cnt = Cnt + 1
Else
Cnt = 1
End If |
|
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Tue Jul 14, 2020 6:29 am Post subject: |
|
|
For 7SEG LED displays multiplexing you should have 50Hz for each display so for four of them you should calc 4x50Hz=200Hz.
Now look for your speed -> 16MHz/256=62500Hz Now 16bit Timer1 65536-62500=3036. So 62500Hz/3036=20Hz ONLY
For 200Hz you should use Prescaler = 2 and Timer1 = 25536
Second thing. Instead this code:
Code: | Presenta:
Timer1 = 62500
If Cnt < 4 Then
Incr Cnt
Else
Cnt = 1
End If
If Cnt = 1 Then
Q1 = 0 : Q2 = 0 : Q3 = 0 : Q4 = 1
Portd = Lookup(w4 , Tabla)
End If
If Cnt = 2 Then
Q1 = 0 : Q2 = 0 : Q3 = 1 : Q4 = 0
Portd = Lookup(w3 , Tabla)
End If
If Cnt = 3 Then
Q1 = 0 : Q2 = 1 : Q3 = 0 : Q4 = 0
Portd = Lookup(w2 , Tabla)
End If
If Cnt = 4 Then
Q1 = 1 : Q2 = 0 : Q3 = 0 : Q4 = 0
Portd = Lookup(w1 , Tabla)
End If
Return
|
Use something like this:
Code: |
Presenta:
Timer1 = 25536 'remember Prescale = 2
Incr Cnt : If Cnt > 4 Then Cnt = 1
Select Case Cnt
Case 1
Q1 = 0
Portd = Lookup(w4 , Tabla)
Q4 = 1
Case 2
Q4 = 0
Portd = Lookup(w3 , Tabla)
Q3 = 1
Case 3
Q3 = 0
Portd = Lookup(w2 , Tabla)
Q2 = 1
Case 4
Q2 = 0
Portd = Lookup(w1 , Tabla)
Q1 = 1
End Select
Return |
Last edited by EDC on Tue Jul 14, 2020 6:36 am; edited 1 time in total |
|
Back to top |
|
|
|