Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Making A Meter with the 32 x 8 matrix display

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog
View previous topic :: View next topic  
Author Message
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Jun 09, 2013 12:52 pm    Post subject: Making A Meter with the 32 x 8 matrix display Reply with quote

I was looking at large volt and amp meters when I thought why not use one of the cheap 23 x 8 matrix displays. Looking at the display it is simple to use either the mega8L internal ADCs or an I2C ADC so starting with the code I already have for the clock I have removed most of the functions not wanted and kept those that drive the display. Still more to clean up but its working using a 1.5v cell for testing with ADC4.

In the picture below you can see the two pads next to the power connector these are PC4 (ADC4) (SDA) , PC5 (ADC5) (SCL) so if we solder to these we can use ADC4 & ADC5 or an I2C device

ADC4 is the rear pad next to the power connector ADC5 is next to it!



Regards Paul

Here is the code that proves the concept now to tidy it up.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Jun 11, 2013 12:14 pm    Post subject: Reply with quote

I have removed a lot of code not used for the meter there is still more to get rid of but now it is working as a volt meter up to 2.56 volts as I am using the internal 2.56 reference. I have put a decimal point between digits 1 & 2 .
There is 35% of flash used so a fair bit of space to implement more functions.

Note: The free version of Bascom can be used with this code!

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed Jun 12, 2013 1:42 pm    Post subject: Reply with quote

I have now cleaned up most of the code with some subs as yet not used but will be in the future. The eeprom data has been left and some of this will be changed to suit the meter also the numbers 1 t 0 have been moved to the far right this gives us space for plus or minus in front of the digits. I will now add brightness using one of the three buttons.


Regards Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jun 12, 2013 3:39 pm    Post subject: Reply with quote

Thanks Paul, very nice basis to get started.
_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Thu Jun 13, 2013 12:59 pm    Post subject: Reply with quote

Hello Mark

I hope to make it more than just a start I will be putting one into a power supply, one of three. Of the other two one will have two 4 digit panel meters (I have already mounted them in the front panel) the other a 128x64 LCD so another blog to come for this one with space for lots of functions as it will use a 40pin dip in ZIF socket so can use a 1284p if I want.

This one it will show volts 1.2-20, amps 0-22, temps of internals (heat sink etc), turn cooling fan on/off & rs232 port. Just have to see what fits into the 8K , infra-red remote might be nice.

So now for some more code I have cleaned up even more, put lots more comments to explain what the code is doing, added a brightness function the bottom button if held in cycles from max to min brightness so you just press and hold till you get what you want then let go.

So now we have a working meter with brightness control, decimal point and + sign.

Next I will add I2C buss with a 12bit ADC not using the AVRs ADC.

Code thus far.

Regards Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Jun 14, 2013 9:49 am    Post subject: Reply with quote

hi Paul,

yes, more is good Smile but sometimes one need just a simple starting point with the basic things working.

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Jun 17, 2013 11:34 am    Post subject: Reply with quote

Now the I2C buss.


This program is a test program searching for devices on the buss and displaying their addresses on the matrix as they are found, wait two seconds between each then get the temperature from a LM75 and display that, do this in a loop. Every time a device is added to the buss its address will be shown on the display.


Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Aug 11, 2013 10:09 am    Post subject: Reply with quote

I wanted to display positive , negative sign and decimal point on the display but also 4 digits but I only have 4 modules? I noticed we had 3 columns of unused leds so why not move the digits to the far right making the first 3 columns free then display them there. I have done just that now the EEPROM has the digits 1 to 9 & 0 at the far right and Sub Disply_num finds these in the string notes the position, removes them from the string then after getting the number pattern from the EEPROM adds them in to the front of the number giving us 4 digits and the special characters.

Below is the EEPROM data and the new sub.

Regards Paul

Code:








'--------------------------------
'--this gets the string (text value)
'--of a number finds a decimal point & negative sign & plus sign
'--removes it from the string then
'--displays it where it should be on the
'--display while it gets and displays the 4 digits
'--plus decimal point and or negative sign
'--to do this the numerical characters in EEPROM
'--have been moved 3 dot colums to the right to make
'--space for these special characters


Sub Disply_num


Local X As Byte
Local Y As Byte
Local Z As Byte
Local Dpoint As Byte                                        'decimal point "."
Local Negtiv As Byte                                        'negative sign "-"
Local Plus As Byte                                          'the plus sign "+"


 Plus = Charpos(adcprn , "+")                               'find the plus sign location

 If Plus > 0 Then

  Delchar Adcprn , Plus                                     'get rid of plus sign

 End If

 Dpoint = Charpos(adcprn , ".")                             'find the decimal point location

 If Dpoint > 0 Then

  Delchar Adcprn , Dpoint                                   'get rid of decimal point

 End If

 Negtiv = Charpos(adcprn , "-")                             'find the negative sign location

 If Negtiv > 0 Then

  Delchar Adcprn , Negtiv                                   'get rid of negative sign

 End If

  Y = Len(adcprn)


  If Y > 4 Then Y = 4                                       'we can only display 4

For Z = 1 To Y

    Kar = Mid(adcprn , Z , 1)                               'get character one from the string

  Dignum = Z                                                'display it at digit Z

  Call Display_chr

  Dig(z) = Ana                                              'Ana contains the character from eeprom rotated
                                                            'ready to display
Next Z


'what we do here is combine a digit with the
'decimal point and or the negative sign

 If Plus > 0 Then                                           'put back plus sign


  Dig(plus).17 = 1
  Dig(plus).24 = 1
  Dig(plus).25 = 1
  Dig(plus).26 = 1
  Dig(plus).33 = 1


 End If



 If Dpoint > 0 Then                                         'put back decimal point

  Dig(dpoint).25 = 1
  Dig(dpoint).33 = 1

 End If

 If Negtiv > 0 Then                                         'put back negative sign

  Dig(negtiv).24 = 1
  Dig(negtiv).25 = 1
  Dig(negtiv).26 = 1

 End If



  Call Show_text

 Waitms 200

End Sub



'--------------------------------------
'--Here we stor text in eeprom to save on flash space

$eeprom                                                     'start of eeprom data


Data 0 , 0 , 0 , 62 , 81 , 73 , 69 , 62                     ' 0
Data 0 , 0 , 0 , 0 , 66 , 127 , 64 , 0                      ' 1
Data 0 , 0 , 0 , 98 , 81 , 73 , 73 , 70                     ' 2
Data 0 , 0 , 0 , 34 , 73 , 73 , 73 , 54                     ' 3
Data 0 , 0 , 0 , 24 , 20 , 18 , 127 , 16                    ' 4
Data 0 , 0 , 0 , 47 , 73 , 73 , 73 , 49                     ' 5
Data 0 , 0 , 0 , 60 , 74 , 73 , 73 , 48                     ' 6
Data 0 , 0 , 0 , 1 , 113 , 9 , 5 , 3                        ' 7
Data 0 , 0 , 0 , 54 , 73 , 73 , 73 , 54                     ' 8
Data 0 , 0 , 0 , 6 , 73 , 73 , 41 , 30                      ' 9
Data 7 , 5 , 7 , 0 , 60 , 66 , 66 , 66                      ' : DEG C
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' ;
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' <
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' =
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' >
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' ?
Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0                          ' @
Data 0 , 126 , 17 , 17 , 17 , 126 , 0 , 0                   ' A
Data 0 , 127 , 73 , 73 , 73 , 54 , 0 , 0                    ' B
Data 0 , 62 , 65 , 65 , 65 , 34 , 0 , 0                     ' C
Data 0 , 127 , 65 , 65 , 65 , 62 , 0 , 0                    ' D
Data 0 , 127 , 73 , 73 , 73 , 65 , 0 , 0                    ' E
Data 0 , 127 , 9 , 9 , 9 , 1 , 0 , 0                        ' F
Data 0 , 62 , 65 , 73 , 73 , 122 , 0 , 0                    ' G
Data 0 , 127 , 8 , 8 , 8 , 127 , 0 , 0                      ' H
Data 0 , 0 , 65 , 127 , 65 , 0 , 0 , 0                      ' I
Data 0 , 48 , 64 , 64 , 64 , 63 , 0 , 0                     ' J
Data 0 , 127 , 8 , 20 , 34 , 65 , 0 , 0                     ' K
Data 0 , 127 , 64 , 64 , 64 , 64 , 0 , 0                    ' L
Data 0 , 127 , 2 , 4 , 2 , 127 , 0 , 0                      ' M
Data 0 , 127 , 2 , 4 , 8 , 127 , 0 , 0                      ' N
Data 0 , 62 , 65 , 65 , 65 , 62 , 0 , 0                     ' O
Data 0 , 127 , 9 , 9 , 9 , 6 , 0 , 0                        ' P
Data 0 , 62 , 65 , 81 , 33 , 94 , 0 , 0                     ' Q
Data 0 , 127 , 9 , 9 , 25 , 102 , 0 , 0                     ' R
Data 0 , 38 , 73 , 73 , 73 , 50 , 0 , 0                     ' S
Data 0 , 1 , 1 , 127 , 1 , 1 , 0 , 0                        ' T
Data 0 , 63 , 64 , 64 , 64 , 63 , 0 , 0                     ' U
Data 0 , 31 , 32 , 64 , 32 , 31 , 0 , 0                     ' V
Data 0 , 63 , 64 , 60 , 64 , 63 , 0 , 0                     ' W
Data 0 , 99 , 20 , 8 , 20 , 99 , 0 , 0                      ' X
Data 0 , 7 , 8 , 112 , 8 , 7 , 0 , 0                        ' Y
'data 0 , 113 , 73 , 69 , 67 , 0 , 0 , 0                    ' Z
'Data 7 , 5 , 7 , 0 , 60 , 66 , 66 , 66                      ' !

'-------------prompts

Data "S" , "U" , "N" , "M" , "O" , "N" , "T" , "U" , "E" , "W" , "E" , "D"
Data "T" , "H" , "R" , "F" , "R" , "I" , "S" , "A" , "T"
Data "T" , "I" , "M" , "E" , "D" , "A" , "T" , "E" , "T" , "E" , "M" , "P"
Data "2"
Data "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9",
Data "A" , "L" , "A" , "M" , "D" , "A" , "Y"                ', "M" , "A" , "L" , "A" , "M"
'Data "A" , "L" , "A" , "M"
Data &H23                                                   'this is the register E control byte
                                                             '&H23 is the default with alarm off
                                                             '&HA3 is alarm on this is the
                                                             'eram variable Ereg


Data 2368 , 2386 , 2428                                     'default values for brightness

'Data 0 , 0 , 0 , 0 , 0 , 0                                  'default alarm values

$data    
 
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Aug 12, 2013 1:36 pm    Post subject: Reply with quote

Now some more characters for use with numbers in the 3 columns.
We have plus, minus, divides, decimal point, comma, exclamation mark and single quotation mark.
This makes for formatting numbers so that they may be more easily read.

Regards Paul

Code:




'--------------------------------
'--this gets the string (text value)
'--of a number finds a decimal point & negative sign & plus sign
'--removes it from the string then
'--displays it where it should be on the
'--display while it gets and displays the 4 digits
'--plus decimal point and or negative sign
'--to do this the numerical characters in EEPROM
'--have been moved 3 dot colums to the right to make
'--space for these special characters


Sub Disply_num

Local W As Byte
Local X As Byte
Local Y As Byte
Local Z As Byte
Local Dpoint As Byte                                        'decimal point "."
Local Negtiv As Byte                                        'negative sign "-"
Local Plus As Byte                                          'the plus sign "+"
Local Divid As Byte
Local Hfn As Byte
Local Ecl As Byte

'--Notice that a LOCAL variable is not initialized.
'--It will contain a value that will depend on the value of the FRAME data.
'--So you can not assume the variable is 0. If you like it to be 0,
'--you need to assign it.

Dpoint = 0
Negtiv = 0
Plus = 0
Divid = 0
Hfn = 0
Ecl = 0


  Y = Len(adcprn)


  If Y > 4 Then Y = 5                                       'we can only display 4

  Z = 1

  Do

    W = 0

    Kar = Mid(adcprn , Z , 1)                               'get one character from the string

    X = Asc(kar)


'--here we see if its a special character for the 3 columns
    Select Case X

      Case 32                                               'space

      Kar = Chr(64)                                         'is blank in EEPROM

      Case 33                                               '"!"

       W = 1

       Ecl = Z

      Case 43                                               ' "+"

       W = 1

      ' Y = Y + 1                                            'add one to Y as we will remove this character

       Plus = Z

      Case 39                                               ' "'"

       W = 1

      ' Y = Y + 1                                            'add one to Y as we will remove this character

       Hfn = Z

      Case 45                                               ' "-"

       W = 1

       'Y = Y + 1                                            'add one to Y as we will remove this character

       Negtiv = Z

      Case 46                                               ' "."

       W = 1

       'Y = Y + 1                                            'add one to Y as we will remove this character

       Dpoint = Z

      Case 47                                               ' "/"

       W = 1

       'Y = Y + 1                                            'add one to Y as we will remove this character

       Divid = Z

    End Select


    If W = 1 Then                                           'special character was found

     Delchar Adcprn , Z                                     'remove character

  '   Z = Z - 1

     Else

      Dignum = Z                                            'display it at digit Z

      Call Display_chr

      Dig(z) = Ana

      Incr Z                                                'Ana contains the character from eeprom rotated

    End If
                                                            'ready to display
Loop Until Z = Y


'what we do here is combine a digit with the
'decimal point and or the negative sign

 If Plus > 0 Then                                           'put back plus sign


  Dig(plus).17 = 1
  Dig(plus).24 = 1
  Dig(plus).25 = 1
  Dig(plus).26 = 1
  Dig(plus).33 = 1


 End If



 If Dpoint > 0 Then                                         'put back decimal point

  Dig(dpoint).25 = 1
  Dig(dpoint).33 = 1

 End If

 If Negtiv > 0 Then                                         'put back negative sign

  Dig(negtiv).24 = 1
  Dig(negtiv).25 = 1
  Dig(negtiv).26 = 1

 End If

 If Hfn > 0 Then                                            'put back single quotation mark

  Dig(hfn).1 = 1
  Dig(hfn).9 = 1


 End If

 If Divid > 0 Then                                          'put back division sign

  Dig(divid).32 = 1
  Dig(divid).25 = 1
  Dig(divid).18 = 1

 End If

  If Ecl > 0 Then                                           'put back exclamation mark

  Dig(ecl).1 = 1
  Dig(ecl).9 = 1
  Dig(ecl).17 = 1
  Dig(ecl).25 = 1
  Dig(ecl).33 = 1
  Dig(ecl).49 = 1

 End If


 ' Call Show_text

 'Waitms 200

End Sub
 
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Aug 13, 2013 1:11 pm    Post subject: Reply with quote

I have added more checks to the code now if the string ends up less than 4 characters it gets padded out to 4 so that the unused displays are blanked I use character 64 "@" which is all 0s in EEPROM this means you can chose the character you want by replacing the one in EEPROM

Note even thought I am using a module with a M328 on it the code is only at 6580 so will still work on a standard display I will put up the full code to date when I tidy up a bit

Regards Paul

Code:





'--------------------------------
'--this gets the string (text value)
'--of a number finds a decimal point & negative sign & plus sign
'--removes it from the string then
'--displays it where it should be on the
'--display while it gets and displays the 4 digits
'--plus decimal point and or negative sign
'--to do this the numerical characters in EEPROM
'--have been moved 3 dot colums to the right to make
'--space for these special characters


Sub Disply_num

Local V As Byte
Local W As Byte
Local X As Byte
Local Y As Byte
Local Z As Byte
Local Dpoint As Byte                                        'decimal point "."
Local Negtiv As Byte                                        'negative sign "-"
Local Plus As Byte                                          'the plus sign "+"
Local Divid As Byte
Local Hfn As Byte
Local Ecl As Byte

'--Notice that a LOCAL variable is not initialized.
'--It will contain a value that will depend on the value of the FRAME data.
'--So you can not assume the variable is 0. If you like it to be 0,
'--you need to assign it.

Dpoint = 0
Negtiv = 0
Plus = 0
Divid = 0
Hfn = 0
Ecl = 0
X = 0



  Z = 1

  Do

    W = 0

    Kar = Mid(adcprn , Z , 1)                               'get one character from the string

    X = Asc(kar)


'--here we see if its a special character for the 3 columns
    Select Case X

      Case 32                                               'space

      Kar = Chr(64)                                         'is blank in EEPROM

      Case 33                                               '"!"

       W = 1

       Ecl = Z

      Case 43                                               ' "+"

       W = 1


       Plus = Z

      Case 39                                               ' "'"

       W = 1


       Hfn = Z

      Case 45                                               ' "-"

       W = 1


       Negtiv = Z

      Case 46                                               ' "."

       W = 1


       Dpoint = Z

      Case 47                                               ' "/"

       W = 1


       Divid = Z

    End Select


    If W = 1 Then                                           'special character was found

     Delchar Adcprn , Z                                     'remove character

     Y = Len(adcprn)                                        'how long is the string

        If Y < 4 Then                                       'need to blank some digits

         For X = Y To 4

          Adcprn = Adcprn + Chr(64)                         'add blanks to end of string to get to 4
                                                             'Note I have used @ as my location for a blank
         Next X

        End If

     Else

      Dignum = Z                                            'display it at digit Z

      Call Display_chr

      Dig(z) = Ana

      Incr Z                                                'Ana contains the character from eeprom rotated

    End If
                                                            'ready to display
Loop Until Z = 5


'what we do here is combine a digit with the
'decimal point and or the negative sign

 If Plus > 0 Then                                           'put back plus sign


  Dig(plus).17 = 1
  Dig(plus).24 = 1
  Dig(plus).25 = 1
  Dig(plus).26 = 1
  Dig(plus).33 = 1


 End If



 If Dpoint > 0 Then                                         'put back decimal point

  Dig(dpoint).25 = 1
  Dig(dpoint).33 = 1

 End If

 If Negtiv > 0 Then                                         'put back negative sign

  Dig(negtiv).24 = 1
  Dig(negtiv).25 = 1
  Dig(negtiv).26 = 1

 End If

 If Hfn > 0 Then                                            'put back single quotation mark

  Dig(hfn).1 = 1
  Dig(hfn).9 = 1


 End If

 If Divid > 0 Then                                          'put back division sign

  Dig(divid).32 = 1
  Dig(divid).25 = 1
  Dig(divid).18 = 1

 End If

  If Ecl > 0 Then                                           'put back exclamation mark

  Dig(ecl).1 = 1
  Dig(ecl).9 = 1
  Dig(ecl).17 = 1
  Dig(ecl).25 = 1
  Dig(ecl).33 = 1
  Dig(ecl).49 = 1

 End If

 Z = Y - X


End Sub
 
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Sep 08, 2013 12:52 pm    Post subject: Reply with quote

Now I wanted to be able to display words of more than 4 letters on the display so a message could be displayed and the only way to do this is to scroll the display to the left with the code below 20 characters can be displayed it is demonstrated by showing from letter "A" to the letter "T" in the code below if the code for the ADC , scan I2C buss and the infra-red is removed it fits into the 8K of the normal display.

the Sub Scrolllr does this in HT1632.inc

There is code for measuring current using a ACS713 0 t 20 amps sensor with noise reduction by taking multiple samples and shifting the binary value right Note this is not the same as just dividing the addition of all the samples buy how many taken to get an average. This is necessary as the ACS current sensors have a 20mv noise present on their outputs.

Regards Paul
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog 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