Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ARDUINO UNO_ADC_4_DIGITOS
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Tue Jul 14, 2020 6:31 am    Post subject: Reply with quote

enniom wrote:
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


I will study but I do not know the STR2DIGITS instructions as I had commented companion of the forum and I will tell you later friend.
Thanks for the information.

Very Happy Very Happy
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1197
Location: SYDNEY

australia.gif
PostPosted: Tue Jul 14, 2020 6:37 am    Post subject: Reply with quote

Some of what I did with 7 segment display

I created an array in eeprom with the digit values.
This let me simply reference the binary display value

I also used serial to parallel 74HC595 drivers
this reduced the number of cpu ports

Below is some code to try to explain what I did

Note I am trying to find a clock I did with four 7 segment displays

You can also see in application note AN #196 me using eeprom this way

Regards Paul

Code:


'   so instead of this

  Data &B0110_1111                                         '0
   Data &B0000_0110                                         '1
   Data &B1010_1011                                         '2
   Data &B1000_1111                                         '3
   Data &B1100_0110                                         '4
   Data &B1100_1101                                         '5
   Data &B1110_1101                                         '6
   Data &B0000_0111                                         '7
   Data &B1110_1111                                         '8
   Data &B1100_1111  


  'I did this
 'Below $eeprom will store the values in eeprom saving flash space
'If they are the first to store in eeprom then

dim segs(10) as eram byte
'this will refer to the first 10 locations in eeram as the DIM statements
'allocate them in order
'so another
dim cats(10) as eram byte

'refers to bytes 11 onwards and so on

'so now to get the byte for the number 3 all I need to do is
'use segs(3)

$eeprom

 
   Data &B0000_0110                                         '1  segs(1)
   Data &B1010_1011                                         '2
   Data &B1000_1111                                         '3
   Data &B1100_0110                                         '4
   Data &B1100_1101                                         '5 segs(5)
   Data &B1110_1101                                         '6
   Data &B0000_0111                                         '7
   Data &B1110_1111                                         '8
   Data &B0110_1111                                         '9 segs(9)
   Data &B1100_1111                                         '0 segs(10)


$data
  'note check byte (data) values not tested

 


Last edited by Paulvk on Tue Jul 14, 2020 6:49 am; edited 1 time in total
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Tue Jul 14, 2020 6:48 am    Post subject: Reply with quote

EDC wrote:
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 Crying or Very sad

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


I already tested them with your timer Timer1 = 25536 and I agree with your calculation but it is the same fault as before.
It already works just change but you are very strange because it worked?



Code:

 Timer1 = 25536

 If Cnt < 4 Then
   Cnt = Cnt + 1
  Else
   Cnt = 1
 End If
 


These if the 4 digits work well.


Code:
Timer1 = 25536

 If Cnt < 5 Then
   Cnt = Cnt + 1
  Else
   Cnt = 1
 End If
 
Very Happy Very Happy
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 182
Location: Japan

japan.gif
PostPosted: Tue Jul 14, 2020 10:09 am    Post subject: Reply with quote

Why call [Presenta] in the main routine (Do-Loop) without enabling interrupts?
I think your fix just happens to be in sync and the display looks good.

Furthermore, when you look at the picture, it looks like there is a ghost in the next digit.
Back to top
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Thu Jul 16, 2020 7:10 pm    Post subject: Reply with quote

With my new update to 2.0.8.3 it works fine !!!
4 digits more brightness!

Code:
Incr Cnt : If Cnt > 4 Then Cnt = 1


Thank you all!!!

2.0.8.3
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Goto page Previous  1, 2, 3
Page 3 of 3

 
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